抖音平台小程序

index.vue 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="page-wrap" :style="{ 'padding-top': `${pageContentTop}px;` }">
  3. <!-- S 今天 剧集列表 -->
  4. <view class="list-wrap">
  5. <view class="tag">今天</view>
  6. <view v-for="video in videoListToday" :key="video.album_id" class="item-wrap">
  7. <view class="lt-wrap">
  8. <view class="img-wrap"
  9. ><u-lazy-load
  10. class="img"
  11. :image="video.cover_url"
  12. img-mode="scaleToFill"
  13. height="227rpx"
  14. border-radius="20"
  15. /></view>
  16. </view>
  17. <view class="rt-wrap">
  18. <view class="title">{{ video.title }}</view>
  19. <view class="info">
  20. <view>{{ video.seq_num }}集全</view>
  21. <view class="line"> | </view>
  22. <view>观看至<text class="num">{{ video.seq }}</text>集</view>
  23. </view>
  24. <view class="btn" @click="onClickVideo(video)">继续观看</view>
  25. </view>
  26. </view>
  27. <!-- 空数据 -->
  28. <view v-if="!videoListToday.length" class="empty-wrap">
  29. <u-empty
  30. text="暂无"
  31. mode="history"
  32. icon-size="0"
  33. />
  34. </view>
  35. </view>
  36. <!-- E 今天 剧集列表 -->
  37. <!-- S 更早 剧集列表 -->
  38. <view class="list-wrap">
  39. <view class="tag">更早</view>
  40. <view v-for="video in videoListLast" :key="video.album_id" class="item-wrap">
  41. <view class="lt-wrap">
  42. <view class="img-wrap"
  43. ><u-lazy-load
  44. class="img"
  45. :image="video.cover_url"
  46. img-mode="scaleToFill"
  47. height="227rpx"
  48. border-radius="20"
  49. /></view>
  50. </view>
  51. <view class="rt-wrap">
  52. <view class="title">{{ video.title }}</view>
  53. <view class="info">
  54. <view>{{ video.seq_num }}集全</view>
  55. <view class="line"> | </view>
  56. <view>观看至<text class="num">{{ video.seq }}</text>集</view>
  57. </view>
  58. <view class="btn" @click="onClickVideo(video)">继续观看</view>
  59. </view>
  60. </view>
  61. <!-- 空数据 -->
  62. <view v-if="!videoListLast.length" class="empty-wrap">
  63. <u-empty
  64. text="暂无"
  65. mode="history"
  66. icon-size="0"
  67. />
  68. </view>
  69. </view>
  70. <!-- E 更早 剧集列表 -->
  71. </view>
  72. </template>
  73. <script>
  74. const app = getApp();
  75. export default {
  76. components: {},
  77. data() {
  78. return {
  79. appName: app.globalData.$appInfo.appName,
  80. pageContentTop: app.globalData.pageContentTop,
  81. videoListToday: [],
  82. videoListLast: [],
  83. filter: {
  84. hasNext: true,
  85. page: 1,
  86. page_size: 12,
  87. source: 2, // 1追剧 2浏览历史 3收藏
  88. },
  89. };
  90. },
  91. onLoad() {
  92. // this.handleGetVideoList();
  93. },
  94. onShow() {
  95. this.filter.hasNext = true;
  96. this.filter.page = 1;
  97. this.videoListToday = [];
  98. this.videoListLast = [];
  99. this.handleGetVideoList();
  100. },
  101. onPullDownRefresh() {
  102. this.filter.hasNext = true;
  103. this.filter.page = 1;
  104. this.videoListToday = [];
  105. this.videoListLast = [];
  106. this.handleGetVideoList();
  107. },
  108. onReachBottom() {
  109. this.handleGetVideoList();
  110. },
  111. methods: {
  112. // 获取短剧列表
  113. async handleGetVideoList() {
  114. const { hasNext, page, page_size, source } = this.filter;
  115. if (!hasNext) return false;
  116. try {
  117. const url = this.$api.video_likeList;
  118. const params = {
  119. source,
  120. page,
  121. page_size,
  122. };
  123. const { data: res = {} } = await this.$get(url, params);
  124. console.log('res => ', res)
  125. uni.stopPullDownRefresh()
  126. if (res && res.errno == 0) {
  127. this.videoListToday = [...res.rst.data.today];
  128. if (!res.rst.data.last.length) {
  129. // 更新"是否有下一页"状态
  130. this.filter.hasNext = false;
  131. } else {
  132. this.filter.hasNext = true;
  133. this.filter.page++;
  134. this.videoListLast = [...this.videoListLast, ...res.rst.data.last];
  135. }
  136. } else {
  137. uni.showToast({ title: res.err || "操作失败", icon: "none" });
  138. }
  139. } catch (error) {
  140. console.log('error => ', error)
  141. } finally {
  142. }
  143. },
  144. // 监听点击“短剧详情”
  145. onClickVideo({ album_id, episode_id, seq }) {
  146. uni.navigateTo({
  147. url: `/pages/subPackages/videoPlayer/index?album_id=${album_id}&episode_id=${episode_id}&seq=${seq}`,
  148. });
  149. },
  150. },
  151. };
  152. </script>
  153. <style lang="scss" scoped>
  154. .page-wrap {
  155. min-height: 100vh;
  156. background: url(https://dou-smallapp.oss-cn-beijing.aliyuncs.com/static/bg-01.png)
  157. #ffffff no-repeat;
  158. background-size: 750rpx 524rpx;
  159. background-color: #f9f9f9;
  160. .list-wrap {
  161. padding: 20rpx;
  162. background-color: #f9f9f9;
  163. .tag {
  164. font-weight: 600;
  165. font-size: 30rpx;
  166. color: #333333;
  167. line-height: 42rpx;
  168. font-style: normal;
  169. margin-bottom: 20rpx;
  170. }
  171. .item-wrap {
  172. background-color: #fff;
  173. margin-bottom: 20rpx;
  174. padding: 20rpx;
  175. display: flex;
  176. align-items: flex-start;
  177. border-radius: 10rpx;
  178. .lt-wrap {
  179. .img-wrap {
  180. width: 172rpx;
  181. height: 227rpx;
  182. border-radius: 20rpx;
  183. .img {
  184. width: 100%;
  185. height: 100%;
  186. vertical-align: middle; // 解决图片下边框缝隙问题
  187. }
  188. }
  189. }
  190. .rt-wrap {
  191. flex: 1;
  192. min-height: 227rpx;
  193. margin-left: 24rpx;
  194. .title {
  195. min-height: 86rpx;
  196. font-weight: 400;
  197. font-size: 28rpx;
  198. color: #000000;
  199. line-height: 40rpx;
  200. text-align: left;
  201. font-style: normal;
  202. word-break: break-all;
  203. }
  204. .info {
  205. display: flex;
  206. align-items: center;
  207. margin-top: 20rpx;
  208. font-weight: 400;
  209. font-size: 24rpx;
  210. color: #999999;
  211. line-height: 34rpx;
  212. font-style: normal;
  213. .line {
  214. margin: 0 18rpx;
  215. color: #e3e3e3;
  216. }
  217. .num {
  218. color: #ff5757;
  219. }
  220. }
  221. .btn {
  222. margin-top: 24rpx;
  223. width: 180rpx;
  224. height: 60rpx;
  225. background: linear-gradient(263deg, #ff7070 0%, #ff5037 100%);
  226. border-radius: 34rpx;
  227. display: flex;
  228. align-items: center;
  229. justify-content: center;
  230. font-weight: 500;
  231. font-size: 28rpx;
  232. color: #ffffff;
  233. font-style: normal;
  234. }
  235. }
  236. }
  237. }
  238. }
  239. </style>