抖音平台小程序

movie.vue 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="page-wrap" :style="{ 'padding-top': `${pageContentTop}px;` }">
  3. <!-- S 搜索 -->
  4. <view class="search-wrap" @click="onClickSearch">
  5. <image class="icon" src="/static/imgs/icon-ss.png" />
  6. <text class="tips">请输入剧集名称</text>
  7. </view>
  8. <!-- E 搜索 -->
  9. <!-- S 轮播图 banner -->
  10. <view class="swiper-wrap">
  11. <u-swiper
  12. :border-radius="16"
  13. :list="swiperList"
  14. mode="none"
  15. bg-color="transparent"
  16. height="220"
  17. img-mode="aspectFit"
  18. />
  19. </view>
  20. <!-- E 轮播图 banner -->
  21. <!-- S 剧集广场 -->
  22. <view class="video-wrap">
  23. <view class="header-wrap">
  24. <image class="icon" src="/static/imgs/icon-jjgc.png" />
  25. <text class="title">剧集广场</text>
  26. </view>
  27. <view class="list-wrap">
  28. <view class="item-wrap" v-for="video in videoList" :key="video.album_id" @click="onClickVideo(video)">
  29. <view class="img-wrap"
  30. ><u-lazy-load
  31. class="img"
  32. :image="video.cover_url"
  33. img-mode="scaleToFill"
  34. height="280rpx"
  35. border-radius="20"
  36. /></view>
  37. <view class="item-name">{{ video.title }}</view>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- E 剧集广场 -->
  42. </view>
  43. </template>
  44. <script>
  45. const app = getApp();
  46. export default {
  47. components: {},
  48. data() {
  49. return {
  50. appName: app.globalData.$appInfo.appName,
  51. pageContentTop: app.globalData.pageContentTop,
  52. swiperList: [
  53. "https://dou-smallapp.oss-cn-beijing.aliyuncs.com/static/banner-01.jpg",
  54. ],
  55. videoList: [],
  56. filter: {
  57. hasNext: true,
  58. page: 1,
  59. page_size: 12,
  60. keyword: "",
  61. },
  62. };
  63. },
  64. onLoad() {
  65. app.handleSetNavTitle();
  66. },
  67. onShow() {
  68. this.filter.hasNext = true;
  69. this.filter.page = 1;
  70. this.videoList = [];
  71. this.handleGetVideoList();
  72. },
  73. onPullDownRefresh() {
  74. this.filter.hasNext = true;
  75. this.filter.page = 1;
  76. this.videoList = [];
  77. this.handleGetVideoList();
  78. },
  79. onReachBottom() {
  80. this.handleGetVideoList();
  81. },
  82. methods: {
  83. // 获取短剧列表
  84. async handleGetVideoList() {
  85. const { hasNext, page, page_size, keyword } = this.filter;
  86. if (!hasNext) return false;
  87. try {
  88. const url = this.$api.video_albumList;
  89. const params = {
  90. keyword,
  91. page,
  92. page_size,
  93. };
  94. const { data: res = {} } = await this.$get(url, params);
  95. uni.stopPullDownRefresh()
  96. if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
  97. if (!res.rst.data.length) {
  98. // 更新"是否有下一页"状态
  99. this.filter.hasNext = false;
  100. } else {
  101. this.filter.hasNext = true;
  102. this.filter.page++;
  103. this.videoList = [...this.videoList, ...res.rst.data];
  104. }
  105. } else {
  106. uni.showToast({ title: res.err || "操作失败", icon: "none" });
  107. }
  108. } catch (error) {
  109. } finally {
  110. }
  111. },
  112. // 监听点击“搜索”
  113. onClickSearch() {
  114. uni.navigateTo({
  115. url: "/pages/subPackages/search/index",
  116. });
  117. },
  118. // 监听点击“短剧详情”
  119. onClickVideo({ album_id, episode_id, seq }) {
  120. uni.navigateTo({
  121. url: `/pages/subPackages/videoPlayer/index?album_id=${album_id}&episode_id=${episode_id}&seq=${seq}`,
  122. });
  123. },
  124. },
  125. };
  126. </script>
  127. <style lang="scss" scoped>
  128. .page-wrap {
  129. min-height: 100vh;
  130. padding: 0 30rpx;
  131. background: url(https://dou-smallapp.oss-cn-beijing.aliyuncs.com/static/bg-01.png)
  132. #ffffff no-repeat;
  133. background-size: 750rpx 524rpx;
  134. .search-wrap {
  135. display: flex;
  136. align-items: center;
  137. width: 690rpx;
  138. height: 68rpx;
  139. margin-top: 8rpx;
  140. padding: 0 22rpx;
  141. background: #ffffff;
  142. border-radius: 34rpx;
  143. .icon {
  144. width: 32rpx;
  145. height: 32rpx;
  146. }
  147. .tips {
  148. margin-left: 12rpx;
  149. font-weight: 400;
  150. font-size: 28rpx;
  151. color: #999999;
  152. line-height: 40rpx;
  153. text-align: right;
  154. font-style: normal;
  155. }
  156. }
  157. .swiper-wrap {
  158. margin-top: 26rpx;
  159. }
  160. .video-wrap {
  161. margin-top: 40rpx;
  162. .header-wrap {
  163. display: flex;
  164. align-items: center;
  165. .icon {
  166. width: 38rpx;
  167. height: 38rpx;
  168. }
  169. .title {
  170. margin-left: 10rpx;
  171. font-weight: 600;
  172. font-size: 34rpx;
  173. color: #000000;
  174. line-height: 48rpx;
  175. font-style: normal;
  176. }
  177. }
  178. .list-wrap {
  179. display: flex;
  180. flex-wrap: wrap;
  181. justify-content: flex-start;
  182. margin-top: 50rpx;
  183. .item-wrap {
  184. display: flex;
  185. flex-direction: column;
  186. align-items: center;
  187. flex: 0 1 33.33%;
  188. // width: 212rpx;
  189. margin-bottom: 40rpx;
  190. // margin-right: 40rpx;
  191. // &:nth-of-type(3n) {
  192. // margin-right: 0;
  193. // }
  194. .img-wrap {
  195. width: 212rpx;
  196. height: 280rpx;
  197. .img {
  198. width: 100%;
  199. height: 100%;
  200. vertical-align: middle; // 解决图片下边框缝隙问题
  201. }
  202. }
  203. .item-name {
  204. margin-top: 28rpx;
  205. width: 100%;
  206. font-weight: 400;
  207. font-size: 28rpx;
  208. color: #000000;
  209. line-height: 40rpx;
  210. font-style: normal;
  211. word-break: break-all;
  212. overflow: hidden;
  213. -webkit-line-clamp: 1;
  214. text-overflow: ellipsis;
  215. display: -webkit-box;
  216. -webkit-box-orient: vertical;
  217. text-align: center;
  218. }
  219. }
  220. }
  221. }
  222. }
  223. </style>