فهرست منبع

团购分享不能带 hdId。hdId 是"用户-花艺师"专属绑定关系(后端校验 hd.userId 需等于当前登录用户)

shizhongqi 1 هفته پیش
والد
کامیت
1be9a381a9
3فایلهای تغییر یافته به همراه19 افزوده شده و 6 حذف شده
  1. 1 1
      mallApp/src/config.js
  2. 2 2
      mallApp/src/ext.json
  3. 16 3
      mallApp/src/pages/groupBuy/detail.vue

+ 1 - 1
mallApp/src/config.js

@@ -1,4 +1,4 @@
 export const ProjectName = 'mall'
 export const ProjectName = 'mall'
 export const CURRENT_ENV = 'dev'
 export const CURRENT_ENV = 'dev'
-export const APIHOST = 'http://api.shop.theflorist.cn'
+export const APIHOST = 'https://api.shop.theflorist.cn'
 export const WSSHOST = 'wss://chat.shop.huaml.com'
 export const WSSHOST = 'wss://chat.shop.huaml.com'

+ 2 - 2
mallApp/src/ext.json

@@ -4,9 +4,9 @@
   "directCommit": false,
   "directCommit": false,
   "ext": {
   "ext": {
     "account": 0,
     "account": 0,
-    "apiHost": "http://api.shop.theflorist.cn",
+    "apiHost": "https://api.shop.theflorist.cn",
     "socketApiHost": "api.shop.theflorist.cn",
     "socketApiHost": "api.shop.theflorist.cn",
-    "imgHost": "http://img.theflorist.cn",
+    "imgHost": "https://img.theflorist.cn",
     "name":"中花卉"
     "name":"中花卉"
   }
   }
 }
 }

+ 16 - 3
mallApp/src/pages/groupBuy/detail.vue

@@ -171,6 +171,12 @@ export default {
     this.option = option || {}
     this.option = option || {}
     this.goodsId = Number(option.goodsId || 0)
     this.goodsId = Number(option.goodsId || 0)
     this.groupBuyId = Number(option.id || option.groupBuyId || 0)
     this.groupBuyId = Number(option.id || option.groupBuyId || 0)
+    // 分享链接需带 account,进入页时同步到本地存储(与商品详情页一致,shopId 作 account 兜底)
+    const account = Number(option.account || option.shopId || 0)
+    if (account > 0) {
+      uni.setStorageSync('account', account)
+      this.option.account = account
+    }
     this.init()
     this.init()
   },
   },
   onUnload() {
   onUnload() {
@@ -399,21 +405,28 @@ export default {
       this.$msg('海报生成功能即将上线')
       this.$msg('海报生成功能即将上线')
       this.showShareMenu = false
       this.showShareMenu = false
     },
     },
+    /**
+     * 组装分享参数,path 必须携带 account 以便好友进入对应店铺
+     * 注意:不能带 hdId。hdId 是"用户-花艺师"专属绑定关系(后端校验 hd.userId 需等于当前登录用户),
+     * 分享给其他好友后,好友的 userId 与 hdId 绑定的 userId 不一致,会被后端清空门店信息(mainId=0),
+     * 进而报"无效门店",因此分享链接只保留 account,不透传 hdId
+     */
     buildSharePayload() {
     buildSharePayload() {
       const remain = this.openGroup
       const remain = this.openGroup
         ? Number(this.openGroup.remainNum)
         ? Number(this.openGroup.remainNum)
         : Math.max(0, (this.goods.groupSize || 3) - 1)
         : Math.max(0, (this.goods.groupSize || 3) - 1)
       const title = remain > 0 ? `还差${remain}人成团` : (this.goods.name || '一起来拼团')
       const title = remain > 0 ? `还差${remain}人成团` : (this.goods.name || '一起来拼团')
       const imageUrl = this.goods.coverUrl || this.goods.cover || ''
       const imageUrl = this.goods.coverUrl || this.goods.cover || ''
+      const account = this.account || uni.getStorageSync('account') || ''
       let path = ''
       let path = ''
       if (this.shareGroupId) {
       if (this.shareGroupId) {
-        path = `pages/groupBuy/detail?id=${this.shareGroupId}&account=${this.account}`
+        path = `pages/groupBuy/detail?id=${this.shareGroupId}&account=${account}`
       } else {
       } else {
-        path = `pages/groupBuy/detail?goodsId=${this.goods.goodsId || this.goodsId}&account=${this.account}`
+        path = `pages/groupBuy/detail?goodsId=${this.goods.goodsId || this.goodsId}&account=${account}`
       }
       }
-      if (this.hdId) path += `&hdId=${this.hdId}`
       return { title, path, imageUrl }
       return { title, path, imageUrl }
     },
     },
+    /** 初始化 H5/小程序分享数据,pagePath 与 onShareAppMessage 保持一致 */
     setupShare() {
     setupShare() {
       const payload = this.buildSharePayload()
       const payload = this.buildSharePayload()
       this.shareData = payload
       this.shareData = payload