Răsfoiți Sursa

零售端-未登录用户进店不显示店名

ouyang 12 ore în urmă
părinte
comite
22cc30f8a1
1 a modificat fișierele cu 8 adăugiri și 1 ștergeri
  1. 8 1
      mallApp/src/pages/home/index.vue

+ 8 - 1
mallApp/src/pages/home/index.vue

@@ -432,7 +432,7 @@ export default {
       })
       this.cartBadgeCount = count
     },
-    /** 拉取当前用户 custom.id,仅用于分享追加 inviterCustomId */
+    /** 拉取当前用户 custom.id,仅用于分享追加 inviterCustomId;游客也拉 shop/info 供顶栏店名 */
     syncMyCustomId() {
       const hdId = Number(this.hdId) || Number(uni.getStorageSync('hdId')) || 0
       const applyShopRes = (shopRes) => {
@@ -455,11 +455,18 @@ export default {
         return Promise.resolve()
       }
       uni.setStorageSync('account', account)
+      // 缓存店与当前 account 不一致时清空,避免顶栏短暂显示上一店名
+      const cached = uni.getStorageSync('currentShop')
+      if (!cached || String(cached.id) !== String(account)) {
+        this.shopInfo = null
+      }
       return getHdInfo().then((res) => {
         if (res.code == 1 && res.data.hd && res.data.hd.id) {
           uni.setStorageSync('hdId', res.data.hd.id)
           return getInfo({ hdId: res.data.hd.id }).then(applyShopRes)
         }
+        // 游客无 hd:直接用 account 拉门店信息,保证顶栏 merchantName 有值
+        return getInfo({}).then(applyShopRes)
       })
     },
     /** 在分享 path 后追加 inviterCustomId */