videoList.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 in videoList" @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() {
  86. uni.navigateTo({
  87. url: '/pagesGood/'(this.videoType == 1 ? ('liveDetail?liveId=' + item.liveId) :
  88. ('videoDetail?videoId=' + item.videoId))
  89. });
  90. }
  91. },
  92. }
  93. </script>
  94. <style lang="less" scoped>
  95. page {
  96. width: 100%;
  97. height: 100%;
  98. }
  99. .container {
  100. width: 100%;
  101. height: 100%;
  102. .search-box {
  103. width: 100%;
  104. height: 58px;
  105. box-sizing: border-box;
  106. padding: 2px 12px 1px 12px;
  107. }
  108. .video-box {
  109. width: 100%;
  110. height: calc(100% - 58px) !important;
  111. overflow-y: auto;
  112. .video-col {
  113. float: left;
  114. background: #FFFFFF;
  115. box-shadow: 0px 3px 6px 0px rgba(0, 0, 0, 0.15);
  116. border-radius: 5px;
  117. width: calc(50% - 18px);
  118. margin-top: 4px;
  119. margin-bottom: 6px;
  120. padding-bottom: 10px;
  121. position: relative;
  122. .video-img {
  123. width: 100%;
  124. height: 170px;
  125. object-fit: cover;
  126. float: left;
  127. }
  128. .video-title {
  129. width: 100%;
  130. height: 18px;
  131. box-sizing: border-box;
  132. padding-left: 8px;
  133. float: left;
  134. font-size: 15px;
  135. font-family: PingFang SC;
  136. color: #333333;
  137. line-height: 18px;
  138. overflow: hidden;
  139. white-space: nowrap;
  140. text-overflow: ellipsis;
  141. margin: 6px 0 2px 0;
  142. }
  143. .video-date {
  144. width: 100%;
  145. box-sizing: border-box;
  146. padding-left: 8px;
  147. height: 16px;
  148. float: left;
  149. font-size: 12px;
  150. font-family: PingFang SC;
  151. color: #52A63A;
  152. line-height: 16px;
  153. overflow: hidden;
  154. white-space: nowrap;
  155. text-overflow: ellipsis;
  156. }
  157. .video-mask {
  158. width: 100%;
  159. height: 100%;
  160. position: absolute;
  161. background-color: rgba(0, 0, 0, 0.3);
  162. border-radius: 5px;
  163. .video-mask-horn {
  164. width: 0;
  165. height: 0;
  166. border-bottom: 4px solid #52A63A;
  167. border-right: 4px solid transparent;
  168. position: absolute;
  169. right: -4px;
  170. top: 8px;
  171. }
  172. .video-mask-text {
  173. position: absolute;
  174. right: -4px;
  175. top: 12px;
  176. width: 52px;
  177. height: 18px;
  178. border-radius: 9px 0 0 9px;
  179. background: #52A63A;
  180. line-height: 18px;
  181. font-size: 10px;
  182. font-family: PingFang SC;
  183. color: #FFFFFF;
  184. text-align: center;
  185. }
  186. }
  187. }
  188. .video-col:nth-child(odd) {
  189. margin-left: 15px;
  190. margin-right: 3px;
  191. }
  192. .video-col:nth-child(even) {
  193. margin-left: 3px;
  194. margin-right: 15px;
  195. }
  196. }
  197. }
  198. </style>