order.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <!-- 我的拼团订单列表 -->
  2. <template>
  3. <s-layout title="我的拼团">
  4. <su-sticky bgColor="#fff">
  5. <su-tabs
  6. :list="tabMaps"
  7. :scrollable="false"
  8. @change="onTabsChange"
  9. :current="state.currentTab"
  10. ></su-tabs>
  11. </su-sticky>
  12. <s-empty v-if="state.pagination.total === 0" icon="/static/goods-empty.png" />
  13. <view v-if="state.pagination.total > 0">
  14. <view
  15. class="order-list-card-box bg-white ss-r-10 ss-m-t-14 ss-m-20"
  16. v-for="record in state.pagination.list"
  17. :key="record.id"
  18. >
  19. <view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20">
  20. <view class="order-no">拼团编号:{{ record.id }}</view>
  21. <view class="ss-font-26" :class="formatOrderColor(record)">
  22. {{ tabMaps.find((item) => item.value === record.status).name }}
  23. </view>
  24. </view>
  25. <view class="border-bottom">
  26. <s-goods-item
  27. :img="record.picUrl"
  28. :title="record.spuName"
  29. :price="record.combinationPrice"
  30. >
  31. <template #groupon>
  32. <view class="ss-flex">
  33. <view class="sales-title"> {{ record.userSize }} 人团 </view>
  34. </view>
  35. </template>
  36. </s-goods-item>
  37. </view>
  38. <view class="order-card-footer ss-flex ss-row-right ss-p-x-20">
  39. <button
  40. class="detail-btn ss-reset-button"
  41. @tap="sheep.$router.go('/pages/order/detail', { id: record.orderId })"
  42. >
  43. 订单详情
  44. </button>
  45. <button
  46. class="tool-btn ss-reset-button"
  47. :class="{ 'ui-BG-Main-Gradient': record.status === 0 }"
  48. @tap="sheep.$router.go('/pages/activity/groupon/detail', { id: record.id })"
  49. >
  50. {{ record.status === 0 ? '邀请拼团' : '拼团详情' }}
  51. </button>
  52. </view>
  53. </view>
  54. </view>
  55. <uni-load-more
  56. v-if="state.pagination.total > 0"
  57. :status="state.loadStatus"
  58. :content-text="{
  59. contentdown: '上拉加载更多',
  60. }"
  61. @tap="loadMore"
  62. />
  63. </s-layout>
  64. </template>
  65. <script setup>
  66. import { reactive } from 'vue';
  67. import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
  68. import sheep from '@/sheep';
  69. import _ from 'lodash';
  70. import {formatOrderColor} from "@/sheep/hooks/useGoods";
  71. import { resetPagination } from '@/sheep/util';
  72. import CombinationApi from '@/sheep/api/promotion/combination';
  73. // 数据
  74. const state = reactive({
  75. currentTab: 0,
  76. pagination: {
  77. list: [],
  78. total: 0,
  79. pageNo: 1,
  80. pageSize: 5,
  81. },
  82. loadStatus: '',
  83. deleteOrderId: 0,
  84. });
  85. const tabMaps = [
  86. {
  87. name: '全部',
  88. },
  89. {
  90. name: '进行中',
  91. value: 0,
  92. },
  93. {
  94. name: '拼团成功',
  95. value: 1,
  96. },
  97. {
  98. name: '拼团失败',
  99. value: 2,
  100. },
  101. ];
  102. // 切换选项卡
  103. function onTabsChange(e) {
  104. resetPagination(state.pagination);
  105. state.currentTab = e.index;
  106. getGrouponList();
  107. }
  108. // 获取订单列表
  109. async function getGrouponList() {
  110. state.loadStatus = 'loading';
  111. const { code, data } = await CombinationApi.getCombinationRecordPage({
  112. pageNo: state.pagination.pageNo,
  113. pageSize: state.pagination.pageSize,
  114. status: tabMaps[state.currentTab].value,
  115. });
  116. if (code !== 0) {
  117. return;
  118. }
  119. state.pagination.list = _.concat(state.pagination.list, data.list)
  120. state.pagination.total = data.total;
  121. state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
  122. }
  123. onLoad((options) => {
  124. if (options.type) {
  125. state.currentTab = options.type;
  126. }
  127. getGrouponList();
  128. });
  129. // 加载更多
  130. function loadMore() {
  131. if (state.loadStatus === 'noMore') {
  132. return;
  133. }
  134. state.pagination.pageNo++;
  135. getGrouponList();
  136. }
  137. // 上拉加载更多
  138. onReachBottom(() => {
  139. loadMore();
  140. });
  141. //下拉刷新
  142. onPullDownRefresh(() => {
  143. getGrouponList();
  144. setTimeout(function () {
  145. uni.stopPullDownRefresh();
  146. }, 800);
  147. });
  148. </script>
  149. <style lang="scss" scoped>
  150. .swiper-box {
  151. flex: 1;
  152. .swiper-item {
  153. height: 100%;
  154. width: 100%;
  155. }
  156. }
  157. .order-list-card-box {
  158. .order-card-header {
  159. height: 80rpx;
  160. .order-no {
  161. font-size: 26rpx;
  162. font-weight: 500;
  163. }
  164. }
  165. .order-card-footer {
  166. height: 100rpx;
  167. .detail-btn {
  168. width: 210rpx;
  169. height: 66rpx;
  170. border: 2rpx solid #dfdfdf;
  171. border-radius: 33rpx;
  172. font-size: 26rpx;
  173. font-weight: 400;
  174. color: #999999;
  175. margin-right: 20rpx;
  176. }
  177. .tool-btn {
  178. width: 210rpx;
  179. height: 66rpx;
  180. border-radius: 33rpx;
  181. font-size: 26rpx;
  182. font-weight: 400;
  183. margin-right: 20rpx;
  184. background: #f6f6f6;
  185. }
  186. .invite-btn {
  187. width: 210rpx;
  188. height: 66rpx;
  189. background: linear-gradient(90deg, #fe832a, #ff6600);
  190. box-shadow: 0px 8rpx 6rpx 0px rgba(255, 104, 4, 0.22);
  191. border-radius: 33rpx;
  192. color: #fff;
  193. font-size: 26rpx;
  194. font-weight: 500;
  195. }
  196. }
  197. }
  198. .sales-title {
  199. height: 32rpx;
  200. background: rgba(#ffe0e2, 0.29);
  201. border-radius: 16rpx;
  202. font-size: 24rpx;
  203. font-weight: 400;
  204. padding: 6rpx 20rpx;
  205. color: #f7979c;
  206. }
  207. .num-title {
  208. font-size: 24rpx;
  209. font-weight: 400;
  210. color: #999999;
  211. }
  212. .warning-color {
  213. color: #faad14;
  214. }
  215. .danger-color {
  216. color: #ff3000;
  217. }
  218. .success-color {
  219. color: #52c41a;
  220. }
  221. </style>