list.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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"></su-tabs>
  7. </su-sticky>
  8. <s-empty v-if="state.pagination.total === 0" icon="/static/data-empty.png" text="暂无数据">
  9. </s-empty>
  10. <!-- 列表 -->
  11. <view v-if="state.pagination.total > 0">
  12. <view class="list-box ss-m-y-20" v-for="order in state.pagination.data" :key="order.id"
  13. @tap="sheep.$router.go('/pages/order/aftersale/detail', { id: order.id })">
  14. <view class="order-head ss-flex ss-col-center ss-row-between">
  15. <text class="no">服务单号:{{ order.no }}</text>
  16. <text class="state">{{ status[order.status] }}</text>
  17. </view>
  18. <s-goods-item :img="order.picUrl" :title="order.spuName"
  19. :skuText="order.properties.reduce((a,b)=>a+b.valueName+' ','')" :price="order.refundPrice/100"
  20. :num="order.count"></s-goods-item>
  21. <view class="apply-box ss-flex ss-col-center ss-row-between border-bottom ss-p-x-20">
  22. <view class="ss-flex ss-col-center">
  23. <!-- 此处需修改 -->
  24. <view class="title ss-m-r-20">{{ status2[order.way] }}</view>
  25. <!-- <view class="value">{{ order.aftersale_status_desc }}</view> -->
  26. <view class="value">{{ order.applyReason }}</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. <view>
  32. <button class="ss-reset-button tool-btn" @tap.stop="onApply(order.id)"
  33. v-if="order.btns.includes('cancel')">取消申请</button>
  34. </view>
  35. <view>
  36. <button class="ss-reset-button tool-btn" @tap.stop="onDelete(order.id)"
  37. v-if="order.btns.includes('delete')">删除</button>
  38. </view>
  39. </view> -->
  40. </view>
  41. </view>
  42. <uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{
  43. contentdown: '上拉加载更多',
  44. }" @tap="loadmore" />
  45. </s-layout>
  46. </template>
  47. <script setup>
  48. import sheep from '@/sheep';
  49. import {
  50. onLoad,
  51. onReachBottom
  52. } from '@dcloudio/uni-app';
  53. import {
  54. computed,
  55. reactive
  56. } from 'vue';
  57. import _ from 'lodash';
  58. const pagination = {
  59. data: [],
  60. current_page: 1,
  61. total: 1,
  62. last_page: 1,
  63. };
  64. const state = reactive({
  65. currentTab: 0,
  66. showApply: false,
  67. pagination: {
  68. data: [],
  69. current_page: 1,
  70. total: 1,
  71. last_page: 1,
  72. },
  73. loadStatus: '',
  74. });
  75. // 字典需要登录 尚未接入 先用固定值代替
  76. const status = {
  77. 10: '申请售后',
  78. 20: '商品待退货',
  79. 30: '商家待收货',
  80. 40: '等待退款',
  81. 50: '退款成功',
  82. 61: '买家取消',
  83. 62: '商家拒绝',
  84. 63: '商家拒收货'
  85. }
  86. const status2 = {
  87. 10: '仅退款',
  88. 20: '退货退款'
  89. }
  90. const tabMaps = [{
  91. name: '全部',
  92. value: 'all',
  93. },
  94. // {
  95. // name: '申请中',
  96. // value: 'nooper',
  97. // },
  98. // {
  99. // name: '处理中',
  100. // value: 'ing',
  101. // },
  102. // {
  103. // name: '已完成',
  104. // value: 'completed',
  105. // },
  106. // {
  107. // name: '已拒绝',
  108. // value: 'refuse',
  109. // },
  110. ];
  111. // 切换选项卡
  112. function onTabsChange(e) {
  113. state.pagination = pagination
  114. state.currentTab = e.index;
  115. getOrderList();
  116. }
  117. // 获取售后列表
  118. async function getOrderList(page = 1, list_rows = 5) {
  119. pagination.current_page = page;
  120. state.loadStatus = 'loading';
  121. let res = await sheep.$api.order.aftersale.list({
  122. // type: tabMaps[state.currentTab].value,
  123. pageSize: list_rows,
  124. pageNo: page,
  125. });
  126. console.log(res, '未处理前售后列表数据')
  127. if (res.code === 0) {
  128. let orderList = _.concat(state.pagination.data, res.data.list);
  129. state.pagination = {
  130. total: res.data.total,
  131. ...res.data,
  132. data: orderList,
  133. };
  134. console.log(state.pagination, '售后订单数据')
  135. // if (state.pagination.current_page < state.pagination.last_page) {
  136. state.loadStatus = 'more';
  137. // } else {
  138. // state.loadStatus = 'noMore';
  139. // }
  140. }
  141. }
  142. function onApply(orderId) {
  143. uni.showModal({
  144. title: '提示',
  145. content: '确定要取消此申请吗?',
  146. success: async function(res) {
  147. if (res.confirm) {
  148. const {
  149. error
  150. } = await sheep.$api.order.aftersale.cancel(orderId);
  151. if (error === 0) {
  152. state.pagination = pagination
  153. getOrderList();
  154. }
  155. }
  156. },
  157. });
  158. }
  159. function onDelete(orderId) {
  160. uni.showModal({
  161. title: '提示',
  162. content: '确定要删除吗?',
  163. success: async function(res) {
  164. if (res.confirm) {
  165. const {
  166. error
  167. } = await sheep.$api.order.aftersale.delete(orderId);
  168. if (error === 0) {
  169. state.pagination = pagination
  170. getOrderList();
  171. }
  172. }
  173. },
  174. });
  175. }
  176. onLoad(async (options) => {
  177. if (options.type) {
  178. state.currentTab = options.type;
  179. }
  180. getOrderList();
  181. });
  182. // 加载更多
  183. function loadmore() {
  184. // if (state.loadStatus !== 'noMore') {
  185. getOrderList(pagination.current_page + 1);
  186. // }
  187. }
  188. // 上拉加载更多
  189. onReachBottom(() => {
  190. loadmore();
  191. });
  192. </script>
  193. <style lang="scss" scoped>
  194. .list-box {
  195. background-color: #fff;
  196. .order-head {
  197. padding: 0 25rpx;
  198. height: 77rpx;
  199. }
  200. .apply-box {
  201. height: 82rpx;
  202. .title {
  203. font-size: 24rpx;
  204. }
  205. .value {
  206. font-size: 22rpx;
  207. color: $dark-6;
  208. }
  209. }
  210. .tool-btn-box {
  211. height: 100rpx;
  212. .tool-btn {
  213. width: 160rpx;
  214. height: 60rpx;
  215. background: #f6f6f6;
  216. border-radius: 30rpx;
  217. font-size: 26rpx;
  218. font-weight: 400;
  219. }
  220. }
  221. }
  222. </style>