videoList.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  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. uni.navigateTo({
  122. url: '/pagesGood/liveDetail?liveId=' + item.liveId + '&roomId=' + item.roomId + '&videoType=' + this.videoType
  123. });
  124. } else {
  125. uni.navigateTo({
  126. url: '/pagesGood/liveDetail?&videoId=' + item.videoId + '&videoType=' + this.videoType
  127. });
  128. }
  129. return;
  130. if(this.videoType == 1){
  131. var that=this;
  132. if(item.liveStatus==2){
  133. this.$refs.uTips.show({
  134. title: '未开始',
  135. type: 'warning',
  136. })
  137. wx.requestSubscribeMessage({
  138. tmplIds: ['y0X1cZfbEMg7HdTGN_bW8v7TKeI3M0CHSVTY1zStIXM'],
  139. success(res) {
  140. if(res.y0X1cZfbEMg7HdTGN_bW8v7TKeI3M0CHSVTY1zStIXM=="accept"){
  141. var post_data={liveId:item.liveId,mid:uni.getStorageSync("userData").userId}
  142. post_data.isDelete=0;
  143. NET.request(API.subscribeLive, post_data, 'POST').then(res => {
  144. //this.goodsList = res.data
  145. }).catch(res => {
  146. })
  147. }else{
  148. console.log('444', res);
  149. }
  150. //console.log('1111', res);
  151. },
  152. fail(res) {
  153. console.log('2222', res);
  154. }
  155. })
  156. return false;
  157. }
  158. if(uni.getStorageSync("firstTimeLiveUser")==""){
  159. uni.setStorage({
  160. key: 'firstTimeLiveUser',
  161. data: 1
  162. })
  163. uni.navigateTo({
  164. url: '/pagesGood/' + (that.videoType == 1 ? ('liveDetail?liveId=' + item.liveId + '&roomId=' + item.roomId) :
  165. ('videoDetail?videoId=' + item.videoId))
  166. });
  167. }else{
  168. // wx.getSetting({
  169. // success(res) {
  170. // /*if (!res.authSetting['scope.camera']){
  171. // that.show_qx=false;
  172. // }else*/
  173. // if (!res.authSetting['scope.record']){
  174. // that.show_qx=false;
  175. // }else{
  176. uni.navigateTo({
  177. url: '/pagesGood/' + (that.videoType == 1 ? ('liveDetail?liveId=' + item.liveId + '&roomId=' + item.roomId) :
  178. ('videoDetail?videoId=' + item.videoId))
  179. });
  180. // }
  181. // }
  182. // })
  183. }
  184. }else{
  185. // uni.navigateTo({
  186. // url: '/pagesGood/' + (this.videoType == 1 ? ('liveDetail?liveId=' + item.liveId + '&roomId=' + item.roomId) :
  187. // ('videoDetail?videoId=' + item.videoId))
  188. // });
  189. uni.navigateTo({
  190. url: '/pagesGood/liveDetail?videoId=' + item.videoId + '&videoType=' + this.videoType
  191. });
  192. }
  193. }
  194. },
  195. }
  196. </script>
  197. <style lang="less" scoped>
  198. page {
  199. width: 100%;
  200. height: 100%;
  201. }
  202. .container {
  203. width: 100%;
  204. height: 100%;
  205. .search-box {
  206. width: 100%;
  207. height: 58px;
  208. box-sizing: border-box;
  209. padding: 2px 8px 1px 8px;
  210. }
  211. .video-box {
  212. width: 100%;
  213. height: calc(100% - 58px) !important;
  214. overflow-y: auto;
  215. .video-col {
  216. float: left;
  217. background: #FFFFFF;
  218. box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.15);
  219. border-radius: 5px;
  220. width: calc(50% - 18px);
  221. margin-top: 4px;
  222. margin-bottom: 6px;
  223. padding-bottom: 10px;
  224. position: relative;
  225. .video-img {
  226. width: 100%;
  227. height: 170px;
  228. object-fit: cover;
  229. float: left;
  230. }
  231. .video-title {
  232. width: 100%;
  233. height: 18px;
  234. box-sizing: border-box;
  235. padding-left: 8px;
  236. float: left;
  237. font-size: 15px;
  238. font-family: PingFang SC;
  239. color: #333333;
  240. line-height: 18px;
  241. overflow: hidden;
  242. white-space: nowrap;
  243. text-overflow: ellipsis;
  244. margin: 6px 0 2px 0;
  245. }
  246. .video-date {
  247. width: 100%;
  248. box-sizing: border-box;
  249. padding-left: 8px;
  250. height: 16px;
  251. float: left;
  252. font-size: 12px;
  253. font-family: PingFang SC;
  254. color: #52A63A;
  255. line-height: 16px;
  256. overflow: hidden;
  257. white-space: nowrap;
  258. text-overflow: ellipsis;
  259. }
  260. .video-mask {
  261. width: 100%;
  262. height: 100%;
  263. position: absolute;
  264. background-color: rgba(0, 0, 0, 0.3);
  265. border-radius: 5px;
  266. .video-mask-horn {
  267. width: 0;
  268. height: 0;
  269. border-bottom: 4px solid #52A63A;
  270. border-right: 4px solid transparent;
  271. position: absolute;
  272. right: -4px;
  273. top: 8px;
  274. }
  275. .video-mask-text {
  276. position: absolute;
  277. right: -4px;
  278. top: 12px;
  279. width: 52px;
  280. height: 18px;
  281. border-radius: 9px 0 0 9px;
  282. background: #52A63A;
  283. line-height: 18px;
  284. font-size: 10px;
  285. font-family: PingFang SC;
  286. color: #FFFFFF;
  287. text-align: center;
  288. }
  289. }
  290. }
  291. .video-col:nth-child(odd) {
  292. margin-left: 16px;
  293. margin-right: 2px;
  294. }
  295. .video-col:nth-child(even) {
  296. margin-left: 2px;
  297. margin-right: 16px;
  298. }
  299. }
  300. }
  301. .uni-popup-dialog {
  302. width: 80vw;
  303. border-radius: 15px;
  304. background-color: #fff;
  305. position: fixed;
  306. margin-left: 10vw;
  307. top: 34vh;
  308. z-index: 11;
  309. }
  310. .uni-dialog-title {
  311. /* #ifndef APP-NVUE */
  312. display: flex;
  313. /* #endif */
  314. flex-direction: row;
  315. justify-content: center;
  316. padding-top: 15px;
  317. padding-bottom: 5px;
  318. }
  319. .uni-dialog-title-text {
  320. font-size: 16px;
  321. font-weight: 500;
  322. }
  323. .uni-dialog-content {
  324. /* #ifndef APP-NVUE */
  325. display: flex;
  326. /* #endif */
  327. flex-direction: row;
  328. justify-content: center;
  329. align-items: center;
  330. padding: 5px 15px 15px 15px;
  331. text-align: center;
  332. }
  333. .uni-dialog-content-text {
  334. font-size: 14px;
  335. color: #6e6e6e;
  336. }
  337. .uni-dialog-button-group {
  338. /* #ifndef APP-NVUE */
  339. display: flex;
  340. /* #endif */
  341. flex-direction: row;
  342. border-top-color: #f5f5f5;
  343. border-top-style: solid;
  344. border-top-width: 1px;
  345. }
  346. .uni-dialog-button {
  347. /* #ifndef APP-NVUE */
  348. display: flex;
  349. /* #endif */
  350. background: rgba(0, 0, 0, 0);
  351. border: none;
  352. flex: 1;
  353. flex-direction: row;
  354. justify-content: center;
  355. align-items: center;
  356. height: 45px;
  357. }
  358. .uni-border-left {
  359. border-left-color: #f0f0f0;
  360. border-left-style: solid;
  361. border-left-width: 0px;
  362. }
  363. .uni-dialog-button-text {
  364. font-size: 14px;
  365. }
  366. .uni-button-color {
  367. color: #007aff;
  368. }
  369. .uni-dialog-input {
  370. flex: 1;
  371. font-size: 14px;
  372. }
  373. .uni-popup__success {
  374. color: #4cd964;
  375. }
  376. .uni-popup__warn {
  377. color: #f0ad4e;
  378. }
  379. .uni-popup__error {
  380. color: #dd524d;
  381. }
  382. .uni-popup__info {
  383. color: #909399;
  384. }
  385. .qx_bg{
  386. width: 100vw;
  387. height: 100vh;
  388. background: rgba(0, 0, 0, 0.25);
  389. position: fixed;
  390. top: 0px;
  391. left: 0px;
  392. z-index: 10;
  393. }
  394. </style>