list.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <!-- 售后列表 -->
  2. <template>
  3. <s-layout title="售后列表">
  4. <!-- tab -->
  5. <su-sticky bgColor="#fff">
  6. <su-tabs
  7. :list="tabMaps"
  8. :scrollable="false"
  9. @change="onTabsChange"
  10. :current="state.currentTab"
  11. />
  12. </su-sticky>
  13. <s-empty v-if="state.pagination.total === 0" icon="/static/data-empty.png" text="暂无数据" />
  14. <!-- 列表 -->
  15. <view v-if="state.pagination.total > 0">
  16. <view
  17. class="list-box ss-m-y-20"
  18. v-for="order in state.pagination.list"
  19. :key="order.id"
  20. @tap="sheep.$router.go('/pages/order/aftersale/detail', { id: order.id })"
  21. >
  22. <view class="order-head ss-flex ss-col-center ss-row-between">
  23. <text class="no">服务单号:{{ order.no }}</text>
  24. <text class="state">{{ formatAfterSaleStatus(order) }}</text>
  25. </view>
  26. <s-goods-item
  27. :img="order.picUrl"
  28. :title="order.spuName"
  29. :skuText="order.properties.map((property) => property.valueName).join(' ')"
  30. :price="order.refundPrice"
  31. />
  32. <view class="apply-box ss-flex ss-col-center ss-row-between border-bottom ss-p-x-20">
  33. <view class="ss-flex ss-col-center">
  34. <view class="title ss-m-r-20">{{ order.way === 10 ? '仅退款' : '退款退货' }}</view>
  35. <view class="value">{{ formatAfterSaleStatusDescription(order) }}</view>
  36. </view>
  37. <text class="_icon-forward"></text>
  38. </view>
  39. <view class="tool-btn-box ss-flex ss-col-center ss-row-right ss-p-r-20">
  40. <view>
  41. <button
  42. class="ss-reset-button tool-btn"
  43. @tap.stop="onApply(order.id)"
  44. v-if="order?.buttons.includes('cancel')"
  45. >
  46. 取消申请
  47. </button>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <uni-load-more
  53. v-if="state.pagination.total > 0"
  54. :status="state.loadStatus"
  55. :content-text="{
  56. contentdown: '上拉加载更多',
  57. }"
  58. @tap="loadMore"
  59. />
  60. </s-layout>
  61. </template>
  62. <script setup>
  63. import sheep from '@/sheep';
  64. import { onLoad, onReachBottom } from '@dcloudio/uni-app';
  65. import { reactive } from 'vue';
  66. import { concat } from 'lodash-es';
  67. import {
  68. formatAfterSaleStatus,
  69. formatAfterSaleStatusDescription,
  70. handleAfterSaleButtons,
  71. } from '@/sheep/hooks/useGoods';
  72. import AfterSaleApi from '@/sheep/api/trade/afterSale';
  73. import { resetPagination } from '@/sheep/helper/utils';
  74. const state = reactive({
  75. currentTab: 0,
  76. showApply: false,
  77. pagination: {
  78. list: [],
  79. total: 0,
  80. pageNo: 1,
  81. pageSize: 10,
  82. },
  83. loadStatus: '',
  84. });
  85. const tabMaps = [
  86. {
  87. name: '全部',
  88. value: [],
  89. },
  90. {
  91. name: '申请中',
  92. value: [10],
  93. },
  94. {
  95. name: '处理中',
  96. value: [20, 30, 40],
  97. },
  98. {
  99. name: '已完成',
  100. value: [50],
  101. },
  102. {
  103. name: '已拒绝',
  104. value: [61, 62, 63],
  105. },
  106. ];
  107. // 切换选项卡
  108. function onTabsChange(e) {
  109. resetPagination(state.pagination);
  110. state.currentTab = e.index;
  111. getOrderList();
  112. }
  113. // 获取售后列表
  114. async function getOrderList() {
  115. state.loadStatus = 'loading';
  116. let { data, code } = await AfterSaleApi.getAfterSalePage({
  117. pageNo: state.pagination.pageNo,
  118. pageSize: state.pagination.pageSize,
  119. statuses: tabMaps[state.currentTab].value.join(','),
  120. });
  121. if (code !== 0) {
  122. return;
  123. }
  124. data.list.forEach((order) => handleAfterSaleButtons(order));
  125. state.pagination.list = concat(state.pagination.list, data.list);
  126. state.pagination.total = data.total;
  127. state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
  128. }
  129. function onApply(orderId) {
  130. uni.showModal({
  131. title: '提示',
  132. content: '确定要取消此申请吗?',
  133. success: async function (res) {
  134. if (!res.confirm) {
  135. return;
  136. }
  137. const { code } = await AfterSaleApi.cancelAfterSale(orderId);
  138. if (code === 0) {
  139. resetPagination(state.pagination);
  140. await getOrderList();
  141. }
  142. },
  143. });
  144. }
  145. onLoad(async (options) => {
  146. if (options.type) {
  147. state.currentTab = options.type;
  148. }
  149. await getOrderList();
  150. });
  151. // 加载更多
  152. function loadMore() {
  153. if (state.loadStatus === 'noMore') {
  154. return;
  155. }
  156. state.pagination.pageNo++;
  157. getOrderList();
  158. }
  159. // 上拉加载更多
  160. onReachBottom(() => {
  161. loadMore();
  162. });
  163. </script>
  164. <style lang="scss" scoped>
  165. .list-box {
  166. background-color: #fff;
  167. .order-head {
  168. padding: 0 25rpx;
  169. height: 77rpx;
  170. }
  171. .apply-box {
  172. height: 82rpx;
  173. .title {
  174. font-size: 24rpx;
  175. }
  176. .value {
  177. font-size: 22rpx;
  178. color: $dark-6;
  179. }
  180. }
  181. .tool-btn-box {
  182. height: 100rpx;
  183. .tool-btn {
  184. width: 160rpx;
  185. height: 60rpx;
  186. background: #f6f6f6;
  187. border-radius: 30rpx;
  188. font-size: 26rpx;
  189. font-weight: 400;
  190. }
  191. }
  192. }
  193. </style>