videoList.vue 9.4 KB

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