videoList.vue 8.0 KB

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