|
@@ -580,6 +580,8 @@ export default {
|
|
|
deliveryPolicyList: [],
|
|
deliveryPolicyList: [],
|
|
|
validAddress: false,
|
|
validAddress: false,
|
|
|
hbData: [],
|
|
hbData: [],
|
|
|
|
|
+ /** 已发起过可用红包请求的门店 id,避免 onShow/getInfo/currentInfo 各打一次 */
|
|
|
|
|
+ hbDataRequestedShopId: null,
|
|
|
selectedHbId: null,
|
|
selectedHbId: null,
|
|
|
selectedHb: null,
|
|
selectedHb: null,
|
|
|
limitExceedProductId: "",
|
|
limitExceedProductId: "",
|
|
@@ -624,10 +626,6 @@ export default {
|
|
|
this.loadShopInfo();
|
|
this.loadShopInfo();
|
|
|
this.loadSelectedAddress();
|
|
this.loadSelectedAddress();
|
|
|
// 附加费在 loadPsMethods 中与配送方式一并批量返回
|
|
// 附加费在 loadPsMethods 中与配送方式一并批量返回
|
|
|
- // 商品金额变化后刷新红包可用性(对齐 affirmGhs onShow)
|
|
|
|
|
- if (this.shopInfo && this.shopInfo.id) {
|
|
|
|
|
- this.getHbData();
|
|
|
|
|
- }
|
|
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
|
/** 商品总价变化时,剔除红包并批量刷新附加费缓存(不随购买方式切换重复请求) */
|
|
/** 商品总价变化时,剔除红包并批量刷新附加费缓存(不随购买方式切换重复请求) */
|
|
@@ -1308,6 +1306,8 @@ export default {
|
|
|
if (cached && typeof cached === "object") {
|
|
if (cached && typeof cached === "object") {
|
|
|
this.mergePickupShopInfo(cached);
|
|
this.mergePickupShopInfo(cached);
|
|
|
}
|
|
}
|
|
|
|
|
+ // 缓存已有门店 id 时立即拉红包;getInfo/currentInfo 稍后若 id 相同会被拦住
|
|
|
|
|
+ this.getHbData();
|
|
|
|
|
|
|
|
getInfo({ hdId }).then((res) => {
|
|
getInfo({ hdId }).then((res) => {
|
|
|
if (res.code == 1 && res.data) {
|
|
if (res.code == 1 && res.data) {
|
|
@@ -2340,15 +2340,29 @@ export default {
|
|
|
}
|
|
}
|
|
|
return String(item.id) === String(this.limitExceedProductId);
|
|
return String(item.id) === String(this.limitExceedProductId);
|
|
|
},
|
|
},
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 拉取当前门店可用红包列表。
|
|
|
|
|
+ * 同一 shopId 只请求一次:进页时缓存/getInfo/currentInfo 都可能拿到门店信息,
|
|
|
|
|
+ * 若不拦截会连打三次 /hb/available-hb;失败时清标记以便重试。
|
|
|
|
|
+ */
|
|
|
getHbData() {
|
|
getHbData() {
|
|
|
if (!this.shopInfo || !this.shopInfo.id) {
|
|
if (!this.shopInfo || !this.shopInfo.id) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- getAvailableHb({ shopId: this.shopInfo.id }).then((res) => {
|
|
|
|
|
|
|
+ const shopId = this.shopInfo.id;
|
|
|
|
|
+ if (this.hbDataRequestedShopId === shopId) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.hbDataRequestedShopId = shopId;
|
|
|
|
|
+ getAvailableHb({ shopId }).then((res) => {
|
|
|
if (res.code == 1) {
|
|
if (res.code == 1) {
|
|
|
this.hbData = res.data || [];
|
|
this.hbData = res.data || [];
|
|
|
this.syncSelectedHbAfterPriceChange();
|
|
this.syncSelectedHbAfterPriceChange();
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
+ this.hbDataRequestedShopId = null;
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ this.hbDataRequestedShopId = null;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|