list.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 pagination = {
  77. data: [],
  78. current_page: 1,
  79. total: 1,
  80. last_page: 1,
  81. };
  82. const state = reactive({
  83. currentTab: 0,
  84. showApply: false,
  85. pagination: {
  86. data: [],
  87. current_page: 1,
  88. total: 1,
  89. last_page: 1,
  90. },
  91. loadStatus: '',
  92. });
  93. const tabMaps = [
  94. {
  95. name: '全部',
  96. value: 'all',
  97. },
  98. {
  99. name: '申请中',
  100. value: 'nooper',
  101. },
  102. {
  103. name: '处理中',
  104. value: 'ing',
  105. },
  106. {
  107. name: '已完成',
  108. value: 'completed',
  109. },
  110. {
  111. name: '已拒绝',
  112. value: 'refuse',
  113. },
  114. ];
  115. // 切换选项卡
  116. function onTabsChange(e) {
  117. state.pagination = pagination
  118. state.currentTab = e.index;
  119. getOrderList();
  120. }
  121. // 获取售后列表
  122. async function getOrderList(page = 1, list_rows = 5) {
  123. state.loadStatus = 'loading';
  124. let res = await sheep.$api.order.aftersale.list({
  125. type: tabMaps[state.currentTab].value,
  126. list_rows,
  127. page,
  128. });
  129. if (res.error === 0) {
  130. let orderList = _.concat(state.pagination.data, res.data.data);
  131. state.pagination = {
  132. ...res.data,
  133. data: orderList,
  134. };
  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 { error } = await sheep.$api.order.aftersale.cancel(orderId);
  149. if (error === 0) {
  150. state.pagination = pagination
  151. getOrderList();
  152. }
  153. }
  154. },
  155. });
  156. }
  157. function onDelete(orderId) {
  158. uni.showModal({
  159. title: '提示',
  160. content: '确定要删除吗?',
  161. success: async function (res) {
  162. if (res.confirm) {
  163. const { error } = await sheep.$api.order.aftersale.delete(orderId);
  164. if (error === 0) {
  165. state.pagination = pagination
  166. getOrderList();
  167. }
  168. }
  169. },
  170. });
  171. }
  172. onLoad(async (options) => {
  173. if (options.type) {
  174. state.currentTab = options.type;
  175. }
  176. getOrderList();
  177. });
  178. // 加载更多
  179. function loadmore() {
  180. if (state.loadStatus !== 'noMore') {
  181. getOrderList(state.pagination.current_page + 1);
  182. }
  183. }
  184. // 上拉加载更多
  185. onReachBottom(() => {
  186. loadmore();
  187. });
  188. </script>
  189. <style lang="scss" scoped>
  190. .list-box {
  191. background-color: #fff;
  192. .order-head {
  193. padding: 0 25rpx;
  194. height: 77rpx;
  195. }
  196. .apply-box {
  197. height: 82rpx;
  198. .title {
  199. font-size: 24rpx;
  200. }
  201. .value {
  202. font-size: 22rpx;
  203. color: $dark-6;
  204. }
  205. }
  206. .tool-btn-box {
  207. height: 100rpx;
  208. .tool-btn {
  209. width: 160rpx;
  210. height: 60rpx;
  211. background: #f6f6f6;
  212. border-radius: 30rpx;
  213. font-size: 26rpx;
  214. font-weight: 400;
  215. }
  216. }
  217. }
  218. </style>