list.vue 4.7 KB

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