Jelajahi Sumber

fix(group-buy): 处理拼团分享门店绑定错误码

- 新增团购绑定关系业务错误码常量,分享进入团详情时识别并提示客户暂无关联门店

- 请求层放行自定义业务码,由页面按业务场景自行处理,避免全局 toast 和 reject 截断流程

- 团详情成功返回 hdId 时同步本地门店绑定信息,修正计算属性赋值冲突
shizhongqi 4 hari lalu
induk
melakukan
fa9471f877

+ 4 - 0
mallApp/src/constant/errCode.js

@@ -0,0 +1,4 @@
+/** 与后端 common/components/errCode.php 对应的业务错误码 */
+
+// 拼团:客户在当前门店暂无绑定关系
+export const GROUP_BUY_HD_NOT_BOUND = 6001

+ 20 - 1
mallApp/src/pages/groupBuy/detail.vue

@@ -120,6 +120,7 @@ import {
   createGroup,
   joinGroup
 } from '@/api/group-buy'
+import { GROUP_BUY_HD_NOT_BOUND } from '@/constant/errCode'
 
 export default {
   name: 'GroupBuyDetail',
@@ -210,7 +211,16 @@ export default {
           uni.hideLoading()
           if (this.groupBuyId) {
             const res = results[0]
+            if (res.code === GROUP_BUY_HD_NOT_BOUND) {
+              this.handleHdNotBound(res)
+              return
+            }
             if (res.code === 1 && res.data) {
+              // TODO: 临时处理,后续需要增加判断登录(或注册情况)
+              if (res.data.hdId) {
+                uni.setStorageSync('hdId', res.data.hdId)
+                this.option.hdId = res.data.hdId
+              }
               this.applyGroupDetail(res.data)
               // 分享进入时若无 goodsId,用团上的商品再拉落地信息补全详情图
               if (!this.goodsId && res.data.goodsId) {
@@ -225,7 +235,9 @@ export default {
             }
           } else {
             const res = results[0]
-            if (res.code === 1 && res.data) this.applyLanding(res.data, false)
+            if (res.code === 1 && res.data) {
+              this.applyLanding(res.data, false)
+            }
           }
         })
         .catch(() => {
@@ -236,6 +248,13 @@ export default {
           this.setupShare()
         })
     },
+    /**
+     * 处理"客户暂无关联此店"业务码(GROUP_BUY_HD_NOT_BOUND)
+     * TODO: 具体引导登录/绑定关系的产品交互待定,目前仅做识别与占位
+     */
+    handleHdNotBound(res) {
+      this.$msg(res.msg || '客户暂无关联此店')
+    },
     /** 应用落地页数据;keepOpenGroup=true 时保留分享带来的团信息 */
     applyLanding(data, keepOpenGroup) {
       if (!data) return

+ 5 - 3
mallApp/src/plugins/luch-request_0.0.7/request.js

@@ -184,9 +184,8 @@ class Request {
 					resolve(response.data)
 					return
 				}
+
 				if (statusCode === 200) { // 成功
-			
-					
 					if (response.data.code === 1) {
 						resolve(response.data)
 					} else {
@@ -206,6 +205,10 @@ class Request {
 							// this.handleAuthExpired(currentPages)
 							// -1 仅作为业务失败返回,不触发自动登出
 							resolve(response.data)
+						} else if (response.data.code && response.data.code >= 1000) {
+							// 自定义业务码(见 common/components/errCode.php 号段规划)
+							// 不弹全局 toast、不 reject,交给页面自行判断 code 处理
+							resolve(response.data)
 						} else if (response.data.code == 2) {
 							this.handleAuthExpired(currentPages)
 						} else {
@@ -287,4 +290,3 @@ class Request {
 	}
 }
 export default new Request()
-