shish 2 ماه پیش
والد
کامیت
54d1846a5d
2فایلهای تغییر یافته به همراه29 افزوده شده و 10 حذف شده
  1. 16 10
      hdApp/src/admin/home/workbench.vue
  2. 13 0
      hdApp/src/utils/pendingGhsInvite.js

+ 16 - 10
hdApp/src/admin/home/workbench.vue

@@ -158,11 +158,10 @@
 
             <block v-else>
 
-              <block v-if="hasPendingGhsInvite">
+              <block v-if="showPendingInvite">
                 <view class="location-empty-box">
-                  <view class="location-empty-title">您有未完成的批发店邀请</view>
-                  <view class="location-empty-subtitle">请先完成绑定后再采购</view>
-                  <button class="location-empty-btn" @click="goPendingInviteGhs()">去购买</button>
+                  <view class="location-empty-title">您有待绑定的邀请批发店,点击继续</view>
+                  <button class="location-empty-btn" @click="goPendingInviteGhs()">点击继续</button>
                 </view>
               </block>
               <block v-else-if="hasRequestApi == 0">
@@ -243,7 +242,7 @@
   import { hasNotice } from "@/api/admin";
   import { APIHOST } from "@/config";
   import permision from "@/utils/wa-permission_1.1/permission.js";
-  import { hasPendingInvite, getGhsProductQueryFromPending, buildGhsInviteSharePayload } from "@/utils/pendingGhsInvite";
+  import { refreshPendingInviteState, getGhsProductQueryFromPending, buildGhsInviteSharePayload } from "@/utils/pendingGhsInvite";
   export default {
     name: "workbench",
     mixins: [autoUpdateMixins],
@@ -266,7 +265,8 @@
         shopInfo:[],
         showBoughtTooltip: false, // 是否显示买花记录提示
         supplierSearchTime: 0, // 查找附近批发店时间
-        hasRequestApi:0
+        hasRequestApi:0,
+        showPendingInvite: false
       };
     },
     computed: {
@@ -275,9 +275,6 @@
         if (!this.supplierSearchTime) return false;
         const twoDays = 2 * 24 * 60 * 60 * 1000;
         return (Date.now() - this.supplierSearchTime) < twoDays;
-      },
-      hasPendingGhsInvite() {
-        return hasPendingInvite()
       }
     },
     watch: {
@@ -285,6 +282,7 @@
       loginInfo(newVal) {
         if(!this.$util.isEmpty(newVal.admin) && newVal.admin.currentShopId > 0){
           this.handleLoginStyle()
+          this.refreshPendingInviteUI()
         }
       }
     },
@@ -303,6 +301,7 @@
       
         this.supplierSearchTime = uni.getStorageSync('supplier_search_time') || 0;
 
+        this.refreshPendingInviteUI()
         this.init();
     
         // 判断是否登录
@@ -332,6 +331,9 @@
           this.pageTo({ url: '/pagesPurchase/ghsProduct', query: query })
         }
       },
+      refreshPendingInviteUI() {
+        this.showPendingInvite = refreshPendingInviteState(this.supplierList || [])
+      },
       onChooseAvatar(e){
         if(this.loginInfo && this.loginInfo.staff && this.loginInfo.staff.founder != 2){
           this.$msg('门店LOGO请老板修改')
@@ -411,7 +413,10 @@
         // #endif
       },
       init () {
-        this.getGHSList()
+        this.refreshPendingInviteUI()
+        this.getGHSList().then(() => {
+          this.refreshPendingInviteUI()
+        })
   
         // #ifdef MP-WEIXIN
         this.isMini = 1
@@ -550,6 +555,7 @@
           this.supplierList = res.data.list
           this.ad = res.data.ad ? res.data.ad : []
           this.hasRequestApi = 1
+          this.refreshPendingInviteUI()
         })
       },
       toRemindCustom(){

+ 13 - 0
hdApp/src/utils/pendingGhsInvite.js

@@ -183,6 +183,19 @@ export function tryBindPendingInvite() {
 	}).catch(() => false)
 }
 
+export function refreshPendingInviteState(supplierList) {
+	restorePendingInviteFromLegacy()
+	const pending = getPendingInvite()
+	if (pending && pending.ghsShopId && supplierList && supplierList.length) {
+		const bound = supplierList.some(item => Number(item.shopId) === Number(pending.ghsShopId))
+		if (bound) {
+			clearPendingInvite()
+			return false
+		}
+	}
+	return hasPendingInvite()
+}
+
 export function navigateAfterLogin(vm, option) {
 	const pending = getPendingInvite()
 	if (!pending || !pending.ghsShopId) {