videoList.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. <k-scroll-view @onPullDown="handlePullDown" @onPullUp="handleLoadMore" class="video-box">
  8. <view class="video-col" v-for="(item, index) in videoList" :key="index" @click="goToVideoDetail(item)">
  9. <cover-image class="video-img" :src="videoType == 1 ? item.imgUrl : item.coverUrl"></cover-image>
  10. <view class="video-title">{{videoType == 1 ? item.liveName : item.videoName}}</view>
  11. <view class="video-date" v-if="videoType == 1">直播时间:{{item.liveStartTime}}-{{item.liveEndTime}}</view>
  12. <view class="video-mask" v-if="videoType == 1 && item.liveStatus == 2">
  13. <view class="video-mask-horn"></view>
  14. <view class="video-mask-text">未开播</view>
  15. </view>
  16. </view>
  17. </k-scroll-view>
  18. <u-top-tips ref="uTips"></u-top-tips>
  19. </view>
  20. </template>
  21. <script>
  22. const NET = require('@/utils/request')
  23. const API = require('@/config/api')
  24. export default {
  25. data() {
  26. return {
  27. videoType: 1,
  28. pageIndex: 1,
  29. isOver: false,
  30. videoName: '',
  31. videoList: [],
  32. }
  33. },
  34. onLoad(options) {
  35. this.videoType = options.videoType
  36. if (this.videoType == 2) {
  37. uni.setNavigationBarTitle({
  38. title: '短视频'
  39. });
  40. }
  41. this.getVideoList()
  42. },
  43. methods: {
  44. // 搜索直播
  45. search(data) {
  46. this.videoName = data.value
  47. this.videoList = []
  48. this.pageIndex = 1
  49. this.getVideoList()
  50. },
  51. // 下拉刷新
  52. handlePullDown(stopLoad) {
  53. this.pageIndex = 1
  54. this.videoList = []
  55. this.getVideoList(stopLoad)
  56. stopLoad ? stopLoad() : '';
  57. },
  58. // 懒加载
  59. handleLoadMore(stopLoad) {
  60. if (!this.isOver) {
  61. this.pageIndex++
  62. this.getVideoList()
  63. } else {
  64. stopLoad ? stopLoad({
  65. isEnd: true
  66. }) : '';
  67. }
  68. },
  69. // 获取直播列表
  70. getVideoList(stopLoad) {
  71. NET.request((this.videoType == 1 ? API.getLiveTelecastList : API.getShortVideo) + '/' + this.pageIndex + '/10', {
  72. liveName: this.videoName,
  73. videoName: this.videoName,
  74. }, 'GET').then(res => {
  75. this.isOver = res.data.list.length != 10
  76. this.videoList = this.videoList.concat(res.data.list)
  77. }).catch(res => {
  78. this.$refs.uTips.show({
  79. title: '获取直播列表失败',
  80. type: 'warning',
  81. })
  82. })
  83. },
  84. // 跳转直播详情
  85. goToVideoDetail(item) {
  86. if (this.videoType != 1) {
  87. uni.setStorage({
  88. key: 'videoUrl',
  89. data: item.mediaUrl
  90. })
  91. }
  92. uni.navigateTo({
  93. url: '/pagesGood/'(this.videoType == 1 ? ('liveDetail?liveId=' + item.liveId) :
  94. ('videoDetail?videoId=' + item.videoId))
  95. });
  96. }
  97. },
  98. }
  99. </script>
  100. <style lang="less" scoped>
  101. page {
  102. width: 100%;
  103. height: 100%;
  104. }
  105. .container {
  106. width: 100%;
  107. height: 100%;
  108. .search-box {
  109. width: 100%;
  110. height: 58px;
  111. box-sizing: border-box;
  112. padding: 2px 12px 1px 12px;
  113. }
  114. .video-box {
  115. width: 100%;
  116. height: calc(100% - 58px) !important;
  117. overflow-y: auto;
  118. .video-col {
  119. float: left;
  120. background: #FFFFFF;
  121. box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.15);
  122. border-radius: 5px;
  123. width: calc(50% - 18px);
  124. margin-top: 4px;
  125. margin-bottom: 6px;
  126. padding-bottom: 10px;
  127. position: relative;
  128. .video-img {
  129. width: 100%;
  130. height: 170px;
  131. object-fit: cover;
  132. float: left;
  133. }
  134. .video-title {
  135. width: 100%;
  136. height: 18px;
  137. box-sizing: border-box;
  138. padding-left: 8px;
  139. float: left;
  140. font-size: 15px;
  141. font-family: PingFang SC;
  142. color: #333333;
  143. line-height: 18px;
  144. overflow: hidden;
  145. white-space: nowrap;
  146. text-overflow: ellipsis;
  147. margin: 6px 0 2px 0;
  148. }
  149. .video-date {
  150. width: 100%;
  151. box-sizing: border-box;
  152. padding-left: 8px;
  153. height: 16px;
  154. float: left;
  155. font-size: 12px;
  156. font-family: PingFang SC;
  157. color: #52A63A;
  158. line-height: 16px;
  159. overflow: hidden;
  160. white-space: nowrap;
  161. text-overflow: ellipsis;
  162. }
  163. .video-mask {
  164. width: 100%;
  165. height: 100%;
  166. position: absolute;
  167. background-color: rgba(0, 0, 0, 0.3);
  168. border-radius: 5px;
  169. .video-mask-horn {
  170. width: 0;
  171. height: 0;
  172. border-bottom: 4px solid #52A63A;
  173. border-right: 4px solid transparent;
  174. position: absolute;
  175. right: -4px;
  176. top: 8px;
  177. }
  178. .video-mask-text {
  179. position: absolute;
  180. right: -4px;
  181. top: 12px;
  182. width: 52px;
  183. height: 18px;
  184. border-radius: 9px 0 0 9px;
  185. background: #52A63A;
  186. line-height: 18px;
  187. font-size: 10px;
  188. font-family: PingFang SC;
  189. color: #FFFFFF;
  190. text-align: center;
  191. }
  192. }
  193. }
  194. .video-col:nth-child(odd) {
  195. margin-left: 15px;
  196. margin-right: 3px;
  197. }
  198. .video-col:nth-child(even) {
  199. margin-left: 3px;
  200. margin-right: 15px;
  201. }
  202. }
  203. }
  204. </style>