list.vue 5.5 KB

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