Ver Fonte

fix(api): 扩展响应拦截器的错误码处理范围

在httpResponse拦截器中添加对1001和1002错误码的处理
在订单页面添加错误对话框并更新错误提示文案
ylong há 1 semana atrás
pai
commit
fbc9353f4e
2 ficheiros alterados com 12 adições e 4 exclusões
  1. 2 1
      api/config.js
  2. 10 3
      pages-mine/pages/order-page.vue

+ 2 - 1
api/config.js

@@ -53,9 +53,10 @@ export const httpRequest = (config) => {
 
 // 此处配置响应拦截器
 export const httpResponse = (res) => {
+  console.log(res, "res");
   return new Promise(function (resolve, reject) {
     if (res.statusCode == 200) {
-      if (res.data.code !== 200) {
+      if (res.data.code !== 200 && res.data.code !== 1001 && res.data.code !== 1002) {
         uni.showToast({
           icon: "none",
           title: res.data.msg || "服务器异常,请联系客服",

+ 10 - 3
pages-mine/pages/order-page.vue

@@ -19,11 +19,14 @@
             @click="handleReportSelect" cancelText="取消" :mask-close-able="false" :safe-area-inset-bottom="true" />
 
         <common-dialog ref="reviewDialog" title="温馨提示" @confirm="confirmReview">
-            <text>对审结果有疑问,申请复审?</text>
+            <text>对审结果有疑问,申请复审?</text>
         </common-dialog>
         <common-dialog ref="processDialog" title="温馨提示" @confirm="handleSuccess">
             <text>{{ reviewMsg }}</text>
         </common-dialog>
+        <common-dialog ref="errorDialog" title="温馨提示" :showCancel="false">
+            <text>{{ errorMsg }}</text>
+        </common-dialog>
     </view>
 </template>
 
@@ -70,7 +73,8 @@ export default {
             pageSize: 10,
             hasMore: true,
             params: {},
-            reviewMsg: ""
+            reviewMsg: "",
+            errorMsg: ""
         }
     },
     onLoad(options) {
@@ -106,8 +110,11 @@ export default {
                 if (res.code == 200) {
                     this.reviewMsg = res.data || '申请复审成功'
                     this.$refs.processDialog.openPopup()
+                } else if (res.code == 1001 || res.code == 1002) {
+                    this.$refs.errorDialog.openPopup()
+                    this.errorMsg = res.msg || '您的订单已下架或出库,无法为您提供复审服务,给您带来的不便深感抱歉'
                 } else {
-                    this.reviewMsg = res.data || '申请复审失败'
+                    this.errorMsg = res.data || '申请复审失败'
                 }
             })
         },