list.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <!-- 拼团活动列表 -->
  2. <template>
  3. <s-layout navbar="inner" :bgStyle="{ color: '#FE832A' }">
  4. <view class="page-bg" :style="[{ marginTop: '-' + Number(statusBarHeight + 88) + 'rpx' }]" />
  5. <view class="list-content">
  6. <!-- 参团会员统计 -->
  7. <view class="content-header ss-flex-col ss-col-center ss-row-center">
  8. <view class="content-header-title ss-flex ss-row-center">
  9. <view
  10. v-for="(item, index) in state.summaryData.avatars"
  11. :key="index"
  12. class="picture"
  13. :style="index === 6 ? 'position: relative' : 'position: static'"
  14. >
  15. <span class="avatar" :style="`background-image: url(${item})`" />
  16. <span v-if="index === 6 && state.summaryData.avatars.length > 3" class="mengceng">
  17. <i>···</i>
  18. </span>
  19. </view>
  20. <text class="pic_count">{{ state.summaryData.userCount || 0 }}人参与</text>
  21. </view>
  22. </view>
  23. <scroll-view
  24. class="scroll-box"
  25. :style="{ height: pageHeight + 'rpx' }"
  26. scroll-y="true"
  27. :scroll-with-animation="false"
  28. :enable-back-to-top="true"
  29. >
  30. <view class="goods-box ss-m-b-20" v-for="item in state.pagination.list" :key="item.id">
  31. <s-goods-column
  32. class=""
  33. size="lg"
  34. :data="item"
  35. :grouponTag="true"
  36. @click="sheep.$router.go('/pages/goods/groupon', { id: item.id })"
  37. >
  38. <template v-slot:cart>
  39. <button class="ss-reset-button cart-btn">去拼团</button>
  40. </template>
  41. </s-goods-column>
  42. </view>
  43. <uni-load-more
  44. v-if="state.pagination.total > 0"
  45. :status="state.loadStatus"
  46. :content-text="{
  47. contentdown: '上拉加载更多',
  48. }"
  49. @tap="loadMore"
  50. />
  51. </scroll-view>
  52. </view>
  53. </s-layout>
  54. </template>
  55. <script setup>
  56. import { reactive } from 'vue';
  57. import { onLoad, onReachBottom } from '@dcloudio/uni-app';
  58. import sheep from '@/sheep';
  59. import CombinationApi from '@/sheep/api/promotion/combination';
  60. const { safeAreaInsets, safeArea } = sheep.$platform.device;
  61. const sysNavBar = sheep.$platform.navbar;
  62. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  63. const pageHeight =
  64. (safeArea.height + safeAreaInsets.bottom) * 2 + statusBarHeight - sysNavBar - 350;
  65. const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-header.png');
  66. const state = reactive({
  67. pagination: {
  68. list: [],
  69. total: 0,
  70. pageNo: 1,
  71. pageSize: 10,
  72. },
  73. loadStatus: '',
  74. summaryData: {},
  75. });
  76. // 加载统计数据
  77. const getSummary = async () => {
  78. const { data } = await CombinationApi.getCombinationRecordSummary();
  79. state.summaryData = data;
  80. };
  81. // 加载活动列表
  82. async function getList() {
  83. state.loadStatus = 'loading';
  84. const { data } = await CombinationApi.getCombinationActivityPage({
  85. pageNo: state.pagination.pageNo,
  86. pageSize: state.pagination.pageSize,
  87. });
  88. data.list.forEach((activity) => {
  89. state.pagination.list.push({ ...activity, price: activity.combinationPrice });
  90. });
  91. state.pagination.total = data.total;
  92. state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
  93. }
  94. // 加载更多
  95. function loadMore() {
  96. if (state.loadStatus === 'noMore') {
  97. return;
  98. }
  99. state.pagination.pageNo++;
  100. getList();
  101. }
  102. // 上拉加载更多
  103. onReachBottom(() => loadMore());
  104. // 页面初始化
  105. onLoad(() => {
  106. getSummary();
  107. getList();
  108. });
  109. </script>
  110. <style lang="scss" scoped>
  111. .page-bg {
  112. width: 100%;
  113. height: 458rpx;
  114. margin-top: -88rpx;
  115. background: v-bind(headerBg) no-repeat;
  116. background-size: 100% 100%;
  117. }
  118. .list-content {
  119. position: relative;
  120. z-index: 3;
  121. margin: -190rpx 20rpx 0 20rpx;
  122. background: #fff;
  123. border-radius: 20rpx 20rpx 0 0;
  124. .content-header {
  125. width: 100%;
  126. border-radius: 20rpx 20rpx 0 0;
  127. height: 100rpx;
  128. background: linear-gradient(180deg, #fff4f7, #ffe4d1);
  129. .content-header-title {
  130. width: 100%;
  131. font-size: 30rpx;
  132. font-weight: 500;
  133. color: #ff2923;
  134. line-height: 30rpx;
  135. position: relative;
  136. .more {
  137. position: absolute;
  138. right: 30rpx;
  139. top: 0;
  140. font-size: 24rpx;
  141. font-weight: 400;
  142. color: #999999;
  143. line-height: 30rpx;
  144. }
  145. .picture {
  146. display: inline-table;
  147. }
  148. .avatar {
  149. width: 38rpx;
  150. height: 38rpx;
  151. display: inline-table;
  152. vertical-align: middle;
  153. -webkit-user-select: none;
  154. -moz-user-select: none;
  155. -ms-user-select: none;
  156. user-select: none;
  157. border-radius: 50%;
  158. background-repeat: no-repeat;
  159. background-size: cover;
  160. background-position: 0 0;
  161. margin-right: -10rpx;
  162. box-shadow: 0 0 0 1px #fe832a;
  163. }
  164. .pic_count {
  165. margin-left: 30rpx;
  166. font-size: 22rpx;
  167. font-weight: 500;
  168. width: auto;
  169. height: auto;
  170. background: linear-gradient(90deg, #ff6600 0%, #fe832a 100%);
  171. color: #ffffff;
  172. border-radius: 19rpx;
  173. padding: 4rpx 14rpx;
  174. }
  175. .mengceng {
  176. width: 40rpx;
  177. height: 40rpx;
  178. line-height: 36rpx;
  179. background: rgba(51, 51, 51, 0.6);
  180. text-align: center;
  181. border-radius: 50%;
  182. opacity: 1;
  183. position: absolute;
  184. left: -2rpx;
  185. color: #fff;
  186. top: 2rpx;
  187. i {
  188. font-style: normal;
  189. font-size: 20rpx;
  190. }
  191. }
  192. }
  193. }
  194. .scroll-box {
  195. height: 900rpx;
  196. .goods-box {
  197. position: relative;
  198. .cart-btn {
  199. position: absolute;
  200. bottom: 10rpx;
  201. right: 20rpx;
  202. z-index: 11;
  203. height: 50rpx;
  204. line-height: 50rpx;
  205. padding: 0 20rpx;
  206. border-radius: 25rpx;
  207. font-size: 24rpx;
  208. color: #fff;
  209. background: linear-gradient(90deg, #ff6600 0%, #fe832a 100%);
  210. }
  211. }
  212. }
  213. }
  214. </style>