list.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <s-layout navbar="inner" :bgStyle="{ color: '#FE832A' }">
  3. <view
  4. class="page-bg"
  5. :style="[{ marginTop: '-' + Number(statusBarHeight + 88) + 'rpx' }]"
  6. ></view>
  7. <view class="list-content">
  8. <view class="content-header ss-flex-col ss-col-center ss-row-center">
  9. <view class="content-header-title ss-m-b-22 ss-flex ss-row-center">
  10. <view>{{ state.activityInfo.title }}</view>
  11. <!-- <view class="more">更多</view> -->
  12. </view>
  13. <view class="content-header-box ss-flex ss-row-center">
  14. <view class="countdown-box ss-flex" v-if="endTime?.ms > 0 && state.activityInfo">
  15. <view class="countdown-title ss-m-r-12">{{$t('activity.seckill.list.toend')}}</view>
  16. <view class="ss-flex countdown-time">
  17. <view class="ss-flex countdown-h">{{ endTime.h }}</view>
  18. <view class="ss-m-x-4">:</view>
  19. <view class="countdown-num ss-flex ss-row-center">{{ endTime.m }}</view>
  20. <view class="ss-m-x-4">:</view>
  21. <view class="countdown-num ss-flex ss-row-center">{{ endTime.s }}</view>
  22. </view>
  23. </view>
  24. <view class="" v-if="endTime?.ms < 0 && state.activityInfo"> {{$t('activity.seckill.list.ended')}} </view>
  25. </view>
  26. </view>
  27. <scroll-view
  28. class="scroll-box"
  29. :style="{ height: pageHeight + 'rpx' }"
  30. scroll-y="true"
  31. :scroll-with-animation="false"
  32. :enable-back-to-top="true"
  33. >
  34. <view class="goods-box ss-m-b-20" v-for="item in state.pagination.data" :key="item.id">
  35. <s-goods-column
  36. class=""
  37. size="lg"
  38. :data="item"
  39. :grouponTag="true"
  40. @click="
  41. sheep.$router.go('/pages/goods/groupon', {
  42. id: item.id,
  43. activity_id: state.activityId,
  44. })
  45. "
  46. >
  47. <template v-slot:cart>
  48. <button class="ss-reset-button cart-btn">{{$t('activity.seckill.list.togroup')}}</button>
  49. </template>
  50. </s-goods-column>
  51. </view>
  52. <uni-load-more
  53. v-if="state.pagination.total > 0"
  54. :status="state.loadStatus"
  55. :content-text="{
  56. contentdown: $t('activity.index.uploadMore'),
  57. }"
  58. @tap="loadmore"
  59. />
  60. </scroll-view>
  61. </view>
  62. </s-layout>
  63. </template>
  64. <script setup>
  65. import { reactive, computed } from 'vue';
  66. import { onLoad, onReachBottom } from '@dcloudio/uni-app';
  67. import sheep from '@/sheep';
  68. import _ from 'lodash';
  69. import { useDurationTime } from '@/sheep/hooks/useGoods';
  70. const { screenHeight, safeAreaInsets, screenWidth, safeArea } = sheep.$platform.device;
  71. const sys_navBar = sheep.$platform.navbar;
  72. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  73. const pageHeight =
  74. (safeArea.height + safeAreaInsets.bottom) * 2 + statusBarHeight - sys_navBar - 350;
  75. const headerBg = sheep.$url.css('/assets/addons/shopro/uniapp/goods/groupon-header.png');
  76. const state = reactive({
  77. activityId: 0,
  78. pagination: {
  79. data: [],
  80. current_page: 1,
  81. total: 1,
  82. last_page: 1,
  83. },
  84. loadStatus: '',
  85. activityInfo: {},
  86. });
  87. // 倒计时
  88. const endTime = computed(() => {
  89. if (state.activityInfo.end_time) {
  90. return useDurationTime(state.activityInfo.end_time);
  91. }
  92. });
  93. async function getList(activityId, page = 1, list_rows = 4) {
  94. state.loadStatus = 'loading';
  95. const res = await sheep.$api.goods.activityList({
  96. list_rows,
  97. activity_id: activityId,
  98. page,
  99. });
  100. if (res.code === 1) {
  101. let couponList = _.concat(state.pagination.data, res.data.data);
  102. state.pagination = {
  103. ...res.data,
  104. data: couponList,
  105. };
  106. if (state.pagination.current_page < state.pagination.last_page) {
  107. state.loadStatus = 'more';
  108. } else {
  109. state.loadStatus = 'noMore';
  110. }
  111. }
  112. }
  113. async function getActivity(id) {}
  114. // 加载更多
  115. function loadmore() {
  116. if (state.loadStatus !== 'noMore') {
  117. getList(state.activityId, state.pagination.current_page + 1);
  118. }
  119. }
  120. // 上拉加载更多
  121. onReachBottom(() => {
  122. loadmore();
  123. });
  124. onLoad(async (options) => {
  125. if (!options.id) {
  126. state.activityInfo = null;
  127. return;
  128. }
  129. state.activityId = options.id;
  130. getList(state.activityId);
  131. const { code, data } = await sheep.$api.activity.activity(options.id);
  132. if (code === 1) {
  133. state.activityInfo = data;
  134. } else {
  135. state.activityInfo = null;
  136. }
  137. });
  138. </script>
  139. <style lang="scss" scoped>
  140. .page-bg {
  141. width: 100%;
  142. height: 458rpx;
  143. margin-top: -88rpx;
  144. background: v-bind(headerBg) no-repeat;
  145. background-size: 100% 100%;
  146. }
  147. .list-content {
  148. position: relative;
  149. z-index: 3;
  150. margin: -190rpx 20rpx 0 20rpx;
  151. background: #fff;
  152. border-radius: 20rpx 20rpx 0 0;
  153. .content-header {
  154. width: 100%;
  155. border-radius: 20rpx 20rpx 0 0;
  156. height: 150rpx;
  157. background: linear-gradient(180deg, #fff4f7, #ffe4d1);
  158. .content-header-title {
  159. width: 100%;
  160. font-size: 30rpx;
  161. font-weight: 500;
  162. color: #ff2923;
  163. line-height: 30rpx;
  164. position: relative;
  165. .more {
  166. position: absolute;
  167. right: 30rpx;
  168. top: 0;
  169. font-size: 24rpx;
  170. font-weight: 400;
  171. color: #999999;
  172. line-height: 30rpx;
  173. }
  174. }
  175. .content-header-box {
  176. width: 678rpx;
  177. height: 64rpx;
  178. background: rgba($color: #fff, $alpha: 0.66);
  179. border-radius: 32px;
  180. .num {
  181. font-size: 24rpx;
  182. font-family: OPPOSANS;
  183. font-weight: 500;
  184. color: #f51c11;
  185. line-height: 30rpx;
  186. }
  187. .title {
  188. font-size: 24rpx;
  189. font-weight: 400;
  190. font-family: OPPOSANS;
  191. color: #333;
  192. line-height: 30rpx;
  193. }
  194. .countdown-title {
  195. font-size: 28rpx;
  196. font-weight: 500;
  197. color: #333333;
  198. line-height: 28rpx;
  199. }
  200. .countdown-time {
  201. font-size: 28rpx;
  202. color: rgba(#ed3c30, 0.23);
  203. .countdown-h {
  204. font-size: 24rpx;
  205. font-family: OPPOSANS;
  206. font-weight: 500;
  207. color: #ffffff;
  208. padding: 0 4rpx;
  209. height: 40rpx;
  210. background: rgba(#ed3c30, 0.23);
  211. border-radius: 6rpx;
  212. }
  213. .countdown-num {
  214. font-size: 24rpx;
  215. font-family: OPPOSANS;
  216. font-weight: 500;
  217. color: #ffffff;
  218. width: 40rpx;
  219. height: 40rpx;
  220. background: rgba(#ed3c30, 0.23);
  221. border-radius: 6rpx;
  222. }
  223. }
  224. }
  225. }
  226. .scroll-box {
  227. height: 900rpx;
  228. .goods-box {
  229. position: relative;
  230. .cart-btn {
  231. position: absolute;
  232. bottom: 10rpx;
  233. right: 20rpx;
  234. z-index: 11;
  235. height: 50rpx;
  236. line-height: 50rpx;
  237. padding: 0 20rpx;
  238. border-radius: 25rpx;
  239. font-size: 24rpx;
  240. color: #fff;
  241. background: linear-gradient(90deg, #ff6600 0%, #fe832a 100%);
  242. }
  243. }
  244. }
  245. }
  246. </style>