videoList.vue 4.6 KB

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