videoList.vue 4.4 KB

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