Browse Source

【功能优化】提交售后信息后直接返回到订单详情

Xiao_123 9 months ago
parent
commit
52f69a3705
2 changed files with 32 additions and 21 deletions
  1. 9 12
      pages/order/aftersale/apply.vue
  2. 23 9
      pages/order/detail.vue

+ 9 - 12
pages/order/aftersale/apply.vue

@@ -42,7 +42,7 @@
         </view>
       </view>
       <!-- 申请原因 -->
-      <view class="refund-item ss-flex ss-col-center ss-row-between" @tap="handleShowModal">
+      <view class="refund-item ss-flex ss-col-center ss-row-between" @tap="state.showModal = true">
         <text class="item-title">申请原因</text>
         <view class="ss-flex refund-cause ss-col-center">
           <text class="ss-m-r-20" v-if="formData.applyReason">{{ formData.applyReason }}</text>
@@ -171,7 +171,7 @@
       uni.showToast({
         title: '申请成功',
       });
-      sheep.$router.go('/pages/order/aftersale/list');
+      sheep.$router.redirect('/pages/order/aftersale/list');
     }
   }
 
@@ -179,19 +179,14 @@
   function onRefundChange(e) {
     formData.way = e.detail.value;
     // 清理理由
-    state.reasonList = formData.way === '10' ? state.config.afterSaleRefundReasons || [] : state.config.afterSaleReturnReasons || [];
+    state.reasonList =
+      formData.way === '10'
+        ? state.config.afterSaleRefundReasons || []
+        : state.config.afterSaleReturnReasons || [];
     formData.applyReason = '';
     state.currentValue = '';
   }
 
-  function handleShowModal () {
-    if (!formData.way) {
-      sheep.$helper.toast('请先选择售后类型');
-      return;
-    }
-    state.showModal = true
-  }
-
   // 选择申请原因
   function onChange(e) {
     state.currentValue = e.detail.value;
@@ -218,11 +213,13 @@
       return;
     }
     state.order = data;
-    state.item = data.items.find((item) => parseInt(item.id) === state.itemId) || {};
+    state.item = data.items.find((item) => item.id === state.itemId) || {};
+
     // 设置选项
     if (state.order.status === 10) {
       state.wayList.splice(1, 1);
     }
+
     // 读取配置
     state.config = (await TradeConfigApi.getTradeConfig()).data;
   });

+ 23 - 9
pages/order/detail.vue

@@ -260,7 +260,7 @@
 
 <script setup>
   import sheep from '@/sheep';
-  import { onLoad } from '@dcloudio/uni-app';
+  import { onLoad, onShow } from '@dcloudio/uni-app';
   import { reactive, ref } from 'vue';
   import { isEmpty } from 'lodash-es';
   import {
@@ -309,7 +309,7 @@
     uni.showModal({
       title: '提示',
       content: '确定要取消订单吗?',
-      success: async function(res) {
+      success: async function (res) {
         if (!res.confirm) {
           return;
         }
@@ -345,11 +345,20 @@
       return;
     }
 
-    // 正常的确认收货流程
-    const { code } = await OrderApi.receiveOrder(orderId);
-    if (code === 0) {
-      await getOrderDetail(orderId);
-    }
+    uni.showModal({
+      title: '提示',
+      content: '确认收货吗?',
+      success: async function (res) {
+        if (!res.confirm) {
+          return;
+        }
+        // 正常的确认收货流程
+        const { code } = await OrderApi.receiveOrder(orderId);
+        if (code === 0) {
+          await getOrderDetail(orderId);
+        }
+      },
+    });
   }
 
   // #ifdef MP-WEIXIN
@@ -420,6 +429,11 @@
     }
   }
 
+  onShow(async () => {
+    //onShow中获取订单列表,保证跳转后页面为最新状态
+    await getOrderDetail(state.orderInfo.id);
+  })
+
   onLoad(async (options) => {
     let id = 0;
     if (options.id) {
@@ -430,7 +444,7 @@
     if (state.comeinType === 'wechat') {
       state.merchantTradeNo = options.merchant_trade_no;
     }
-    await getOrderDetail(id);
+    state.orderInfo.id = id
   });
 </script>
 
@@ -455,7 +469,7 @@
     color: rgba(#fff, 0.9);
     width: 100%;
     background: v-bind(headerBg) no-repeat,
-    linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
+      linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
     background-size: 750rpx 100%;
     box-sizing: border-box;