list.vue 5.4 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. <!-- TODO 功能缺失:填写退货信息 -->
  41. <view>
  42. <button
  43. class="ss-reset-button tool-btn"
  44. @tap.stop="onApply(order.id)"
  45. v-if="order?.buttons.includes('cancel')"
  46. >取消申请</button
  47. >
  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 _ 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/util';
  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. // TODO 芋艿:优化点,增加筛选
  86. const tabMaps = [
  87. {
  88. name: '全部',
  89. value: 'all',
  90. },
  91. // {
  92. // name: '申请中',
  93. // value: 'nooper',
  94. // },
  95. // {
  96. // name: '处理中',
  97. // value: 'ing',
  98. // },
  99. // {
  100. // name: '已完成',
  101. // value: 'completed',
  102. // },
  103. // {
  104. // name: '已拒绝',
  105. // value: 'refuse',
  106. // },
  107. ];
  108. // 切换选项卡
  109. function onTabsChange(e) {
  110. resetPagination(state.pagination);
  111. state.currentTab = e.index;
  112. getOrderList();
  113. }
  114. // 获取售后列表
  115. async function getOrderList() {
  116. state.loadStatus = 'loading';
  117. let { data, code } = await AfterSaleApi.getAfterSalePage({
  118. // type: tabMaps[state.currentTab].value,
  119. pageNo: state.pagination.pageNo,
  120. pageSize: state.pagination.pageSize,
  121. });
  122. if (code !== 0) {
  123. return;
  124. }
  125. data.list.forEach((order) => handleAfterSaleButtons(order));
  126. state.pagination.list = _.concat(state.pagination.list, data.list);
  127. state.pagination.total = data.total;
  128. state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
  129. }
  130. function onApply(orderId) {
  131. uni.showModal({
  132. title: '提示',
  133. content: '确定要取消此申请吗?',
  134. success: async function (res) {
  135. if (!res.confirm) {
  136. return;
  137. }
  138. const { code } = await AfterSaleApi.cancelAfterSale(orderId);
  139. if (code === 0) {
  140. resetPagination(state.pagination);
  141. await getOrderList();
  142. }
  143. },
  144. });
  145. }
  146. onLoad(async (options) => {
  147. if (options.type) {
  148. state.currentTab = options.type;
  149. }
  150. await getOrderList();
  151. });
  152. // 加载更多
  153. function loadMore() {
  154. if (state.loadStatus === 'noMore') {
  155. return;
  156. }
  157. state.pagination.pageNo++;
  158. getOrderList();
  159. }
  160. // 上拉加载更多
  161. onReachBottom(() => {
  162. loadMore();
  163. });
  164. </script>
  165. <style lang="scss" scoped>
  166. .list-box {
  167. background-color: #fff;
  168. .order-head {
  169. padding: 0 25rpx;
  170. height: 77rpx;
  171. }
  172. .apply-box {
  173. height: 82rpx;
  174. .title {
  175. font-size: 24rpx;
  176. }
  177. .value {
  178. font-size: 22rpx;
  179. color: $dark-6;
  180. }
  181. }
  182. .tool-btn-box {
  183. height: 100rpx;
  184. .tool-btn {
  185. width: 160rpx;
  186. height: 60rpx;
  187. background: #f6f6f6;
  188. border-radius: 30rpx;
  189. font-size: 26rpx;
  190. font-weight: 400;
  191. }
  192. }
  193. }
  194. </style>