videoList.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. <template>
  2. <view class="container">
  3. <view class="search-box">
  4. <uni-search-bar ref="searchBar" radius="5" placeholder="搜索" clearButton="auto" cancelButton="none" bgColor="#F8F8F8"
  5. @confirm="search" class="search-bar" />
  6. </view>
  7. <scroll-view class="video-box" scroll-y="true" @scrolltolower="handleLoadMore()">
  8. <view style="padding-top: 20px;background-color: #FFFFFF;" v-if="!videoList.length">
  9. <u-divider color="#909399" border-color="#909399">没有更多了</u-divider>
  10. </view>
  11. <view class="video-col" v-for="(item, index) in videoList" :key="index" @click="goToVideoDetail(item)">
  12. <image class="video-img" :src="videoType == 1 ? item.imgUrl : item.coverUrl" mode="aspectFill"></image>
  13. <view class="video-title">{{videoType == 1 ? item.liveName : item.videoName}}</view>
  14. <view class="video-date" v-if="videoType == 1">直播时间:{{item.liveStartTime}}-{{item.liveEndTime}}</view>
  15. <view class="video-mask" v-if="videoType == 1 && item.liveStatus == 2">
  16. <view class="video-mask-horn"></view>
  17. <view class="video-mask-text">未开播</view>
  18. </view>
  19. </view>
  20. </scroll-view>
  21. <u-top-tips ref="uTips"></u-top-tips>
  22. <view class="uni-popup-dialog" :hidden="show_qx">
  23. <view class="uni-dialog-title">
  24. <text class="uni-dialog-title-text">提示</text>
  25. </view>
  26. <view class="uni-dialog-content">
  27. <text class="uni-dialog-content-text">请在设置中开启摄像头权限和麦克风权限</text>
  28. </view>
  29. <view class="uni-dialog-button-group">
  30. <button class="uni-dialog-button uni-border-left" open-type="openSetting" @click="closeSetting">
  31. 设置权限
  32. </button>
  33. </view>
  34. </view>
  35. <view class="qx_bg" :hidden="show_qx">
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. const NET = require('@/utils/request')
  41. const API = require('@/config/api')
  42. export default {
  43. data() {
  44. return {
  45. show_qx:true,
  46. videoType: 1,
  47. pageIndex: 1,
  48. isOver: false,
  49. videoName: '',
  50. videoList: [],
  51. }
  52. },
  53. onLoad(options) {
  54. this.videoType = options.videoType
  55. if (this.videoType == 2) {
  56. uni.setNavigationBarTitle({
  57. title: '短视频'
  58. });
  59. }
  60. this.getVideoList()
  61. },
  62. onPullDownRefresh() {
  63. this.pageIndex = 1
  64. this.videoList = []
  65. this.getVideoList('refresh')
  66. },
  67. methods: {
  68. closeSetting:function(){
  69. this.show_qx=true;
  70. },
  71. // 搜索直播
  72. search(data) {
  73. this.videoName = data.value
  74. this.videoList = []
  75. this.pageIndex = 1
  76. this.getVideoList()
  77. },
  78. // 懒加载
  79. handleLoadMore() {
  80. if (!this.isOver) {
  81. this.pageIndex++
  82. this.getVideoList()
  83. }
  84. },
  85. // 获取直播列表
  86. getVideoList(type) {
  87. NET.request((this.videoType == 1 ? API.getLiveTelecastList : API.getShortVideo) + '/' + this.pageIndex + '/10', {
  88. liveName: this.videoName,
  89. videoName: this.videoName,
  90. }, 'GET').then(res => {
  91. if (type == 'refresh') {
  92. uni.stopPullDownRefresh();
  93. }
  94. this.isOver = res.data.list.length != 10
  95. this.videoList = this.videoList.concat(res.data.list)
  96. }).catch(res => {
  97. this.$refs.uTips.show({
  98. title: '获取直播列表失败',
  99. type: 'warning',
  100. })
  101. })
  102. },
  103. // 跳转直播详情
  104. goToVideoDetail(item) {
  105. if (this.videoType != 1) {
  106. uni.setStorage({
  107. key: 'videoUrl',
  108. data: item.mediaUrl
  109. })
  110. }else{
  111. uni.setStorage({
  112. key: 'liveImgUrl',
  113. data: item.imgUrl
  114. })
  115. uni.setStorage({
  116. key: 'liveName',
  117. data: item.liveName
  118. })
  119. }
  120. if(this.videoType == 1){
  121. var that=this;
  122. if(uni.getStorageSync("firstTimeLiveUser")==""){
  123. uni.setStorage({
  124. key: 'firstTimeLiveUser',
  125. data: 1
  126. })
  127. uni.navigateTo({
  128. url: '/pagesGood/' + (that.videoType == 1 ? ('liveDetail?liveId=' + item.liveId + '&roomId=' + item.roomId) :
  129. ('videoDetail?videoId=' + item.videoId))
  130. });
  131. }else{
  132. wx.getSetting({
  133. success(res) {
  134. if (!res.authSetting['scope.camera']){
  135. that.show_qx=false;
  136. }else if (!res.authSetting['scope.record']){
  137. that.show_qx=false;
  138. }else{
  139. uni.navigateTo({
  140. url: '/pagesGood/' + (that.videoType == 1 ? ('liveDetail?liveId=' + item.liveId + '&roomId=' + item.roomId) :
  141. ('videoDetail?videoId=' + item.videoId))
  142. });
  143. }
  144. }
  145. })
  146. }
  147. }else{
  148. uni.navigateTo({
  149. url: '/pagesGood/' + (this.videoType == 1 ? ('liveDetail?liveId=' + item.liveId + '&roomId=' + item.roomId) :
  150. ('videoDetail?videoId=' + item.videoId))
  151. });
  152. }
  153. }
  154. },
  155. }
  156. </script>
  157. <style lang="less" scoped>
  158. page {
  159. width: 100%;
  160. height: 100%;
  161. }
  162. .container {
  163. width: 100%;
  164. height: 100%;
  165. .search-box {
  166. width: 100%;
  167. height: 58px;
  168. box-sizing: border-box;
  169. padding: 2px 8px 1px 8px;
  170. }
  171. .video-box {
  172. width: 100%;
  173. height: calc(100% - 58px) !important;
  174. overflow-y: auto;
  175. .video-col {
  176. float: left;
  177. background: #FFFFFF;
  178. box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.15);
  179. border-radius: 5px;
  180. width: calc(50% - 18px);
  181. margin-top: 4px;
  182. margin-bottom: 6px;
  183. padding-bottom: 10px;
  184. position: relative;
  185. .video-img {
  186. width: 100%;
  187. height: 170px;
  188. object-fit: cover;
  189. float: left;
  190. }
  191. .video-title {
  192. width: 100%;
  193. height: 18px;
  194. box-sizing: border-box;
  195. padding-left: 8px;
  196. float: left;
  197. font-size: 15px;
  198. font-family: PingFang SC;
  199. color: #333333;
  200. line-height: 18px;
  201. overflow: hidden;
  202. white-space: nowrap;
  203. text-overflow: ellipsis;
  204. margin: 6px 0 2px 0;
  205. }
  206. .video-date {
  207. width: 100%;
  208. box-sizing: border-box;
  209. padding-left: 8px;
  210. height: 16px;
  211. float: left;
  212. font-size: 12px;
  213. font-family: PingFang SC;
  214. color: #52A63A;
  215. line-height: 16px;
  216. overflow: hidden;
  217. white-space: nowrap;
  218. text-overflow: ellipsis;
  219. }
  220. .video-mask {
  221. width: 100%;
  222. height: 100%;
  223. position: absolute;
  224. background-color: rgba(0, 0, 0, 0.3);
  225. border-radius: 5px;
  226. .video-mask-horn {
  227. width: 0;
  228. height: 0;
  229. border-bottom: 4px solid #52A63A;
  230. border-right: 4px solid transparent;
  231. position: absolute;
  232. right: -4px;
  233. top: 8px;
  234. }
  235. .video-mask-text {
  236. position: absolute;
  237. right: -4px;
  238. top: 12px;
  239. width: 52px;
  240. height: 18px;
  241. border-radius: 9px 0 0 9px;
  242. background: #52A63A;
  243. line-height: 18px;
  244. font-size: 10px;
  245. font-family: PingFang SC;
  246. color: #FFFFFF;
  247. text-align: center;
  248. }
  249. }
  250. }
  251. .video-col:nth-child(odd) {
  252. margin-left: 16px;
  253. margin-right: 2px;
  254. }
  255. .video-col:nth-child(even) {
  256. margin-left: 2px;
  257. margin-right: 16px;
  258. }
  259. }
  260. }
  261. .uni-popup-dialog {
  262. width: 80vw;
  263. border-radius: 15px;
  264. background-color: #fff;
  265. position: fixed;
  266. margin-left: 10vw;
  267. top: 34vh;
  268. z-index: 11;
  269. }
  270. .uni-dialog-title {
  271. /* #ifndef APP-NVUE */
  272. display: flex;
  273. /* #endif */
  274. flex-direction: row;
  275. justify-content: center;
  276. padding-top: 15px;
  277. padding-bottom: 5px;
  278. }
  279. .uni-dialog-title-text {
  280. font-size: 16px;
  281. font-weight: 500;
  282. }
  283. .uni-dialog-content {
  284. /* #ifndef APP-NVUE */
  285. display: flex;
  286. /* #endif */
  287. flex-direction: row;
  288. justify-content: center;
  289. align-items: center;
  290. padding: 5px 15px 15px 15px;
  291. text-align: center;
  292. }
  293. .uni-dialog-content-text {
  294. font-size: 14px;
  295. color: #6e6e6e;
  296. }
  297. .uni-dialog-button-group {
  298. /* #ifndef APP-NVUE */
  299. display: flex;
  300. /* #endif */
  301. flex-direction: row;
  302. border-top-color: #f5f5f5;
  303. border-top-style: solid;
  304. border-top-width: 1px;
  305. }
  306. .uni-dialog-button {
  307. /* #ifndef APP-NVUE */
  308. display: flex;
  309. /* #endif */
  310. background: rgba(0, 0, 0, 0);
  311. border: none;
  312. flex: 1;
  313. flex-direction: row;
  314. justify-content: center;
  315. align-items: center;
  316. height: 45px;
  317. }
  318. .uni-border-left {
  319. border-left-color: #f0f0f0;
  320. border-left-style: solid;
  321. border-left-width: 0px;
  322. }
  323. .uni-dialog-button-text {
  324. font-size: 14px;
  325. }
  326. .uni-button-color {
  327. color: #007aff;
  328. }
  329. .uni-dialog-input {
  330. flex: 1;
  331. font-size: 14px;
  332. }
  333. .uni-popup__success {
  334. color: #4cd964;
  335. }
  336. .uni-popup__warn {
  337. color: #f0ad4e;
  338. }
  339. .uni-popup__error {
  340. color: #dd524d;
  341. }
  342. .uni-popup__info {
  343. color: #909399;
  344. }
  345. .qx_bg{
  346. width: 100vw;
  347. height: 100vh;
  348. background: rgba(0, 0, 0, 0.25);
  349. position: fixed;
  350. top: 0px;
  351. left: 0px;
  352. z-index: 10;
  353. }
  354. </style>