From 8810c218b31e4b281e7ec11d1077f7131cc50938 Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Thu, 22 Jan 2026 15:02:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E9=A4=90=E9=A1=B5=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/api/request.js | 4 ++-- pages/product/index.vue | 35 +++++++++++++++++++++++------------ stores/carts-websocket.js | 18 ++++++++++++------ utils/share.js | 5 +++-- 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/common/api/request.js b/common/api/request.js index c6a2e1b..8e7f50f 100644 --- a/common/api/request.js +++ b/common/api/request.js @@ -52,7 +52,7 @@ export default async (params) => { //获取成功 if (res.code == 200) { uni.hideLoading(); - uni.hideToast(); + // uni.hideToast(); resolve(res.data ? res.data : true); } else { switch (res.code) { @@ -135,7 +135,7 @@ export default async (params) => { // 不管成功还是失败都会执行 setTimeout((res) => { uni.hideLoading(); - uni.hideToast(); + // uni.hideToast(); }, 10000); }, }); diff --git a/pages/product/index.vue b/pages/product/index.vue index 1daec79..02219c9 100644 --- a/pages/product/index.vue +++ b/pages/product/index.vue @@ -817,11 +817,7 @@ - // 分步取值 + 每层兜底,避免某一环不存在导致 undefined - const shopExtendShopTable = uni.cache.get('shopTable') || {}; // 兜底空对象 - const shopExtendMap = shopExtendShopTable.shopExtendMap || {}; // 兜底空对象 - // 最终声明:即使 shopinfo_bg 不存在,也兜底为空字符串/默认值 - const shopExtend = ref(shopExtendMap.shopinfo_bg || ''); + const shopExtend = ref(''); /** * 通用数据合集 end @@ -1765,8 +1761,11 @@ if (Message.operate_type == 'init') { // cartStore.limitTimeDiscount = Message.time_dis_info; cartInit(Message.data) - - uni.hideLoading(); + try { + uni.hideLoading(); + } catch (error) { + //TODO handle the exception + } isLoading.value = false; if (!socketInitFinished) { @@ -2509,11 +2508,16 @@ if (e.type) { orderType.value = e.type; } + await handleMixinOnLoad({ ...e, shopId: e.shopId || uni.cache.get('shopId') }) - const userInfo = userStore.userInfo + + if(userStore.shopUserInfo.shopExtendList){ + shopExtend.value=userStore.shopUserInfo.shopExtendList.find(v=>v.autoKey=='shopinfo_bg')||'' + } + // //获取用户信息 // const userInfo = await APIshopUserInfo({ // shopId: uni.cache.get('shopId') @@ -2523,11 +2527,13 @@ // shopId: uni.cache.get('shopId') // }); Object.assign(shopInfo, userStore.shopInfo); - - - if (userInfo && typeof userInfo === 'object') { - shopUserInfo.value = userInfo + if (e.type == 'beforehand') { + uni.cache.set("tableCode", userStore.shopUserInfo.id); + options.initMessage.table_code = userStore.shopUserInfo.id } + options.initMessage.shop_id = userStore.shopInfo.id + shopUserInfo.value = userStore.shopUserInfo + await productqueryProduct(); const extraInitPar = {} @@ -2539,6 +2545,11 @@ const time_dis_info = await getLimitDiscount() options.initMessage.time_dis_info = time_dis_info + + console.log('options.initMessage', { + ...options.initMessage, + ...extraInitPar, + }) useSocket.connect({ ...options.initMessage, ...extraInitPar, diff --git a/stores/carts-websocket.js b/stores/carts-websocket.js index c79e699..95c6fc2 100644 --- a/stores/carts-websocket.js +++ b/stores/carts-websocket.js @@ -90,11 +90,13 @@ export const useWebSocket = defineStore('socketTask', () => { let onMessage = () => { } - function setOnMessage(onMessageBallBack){ - onMessage=onMessageBallBack + + function setOnMessage(onMessageBallBack) { + onMessage = onMessageBallBack } - function chnageInitMessage(data){ - initMessage=data + + function chnageInitMessage(data) { + initMessage = data } // 连接 WebSocket const connect = async (connectMsg, onMessageBallBack) => { @@ -127,6 +129,8 @@ export const useWebSocket = defineStore('socketTask', () => { url: uni.conf.baseUrlwws + '?' + Date.now(), success: (res) => { console.log('连接成功'); + console.log('connectMsg', connectMsg); + console.log('initMessage', initMessage); isConnected.value = true; // 监听初始化成功在开启心跳 startHeartbeat(); @@ -233,7 +237,7 @@ export const useWebSocket = defineStore('socketTask', () => { // 发送消息 const sendMessage = (data) => { - if(!data){ + if (!data) { return } if (isConnected.value && data) { @@ -369,6 +373,8 @@ export const useWebSocket = defineStore('socketTask', () => { initNetworkListener, connect, allowReconnect, - socketTask,setOnMessage,chnageInitMessage + socketTask, + setOnMessage, + chnageInitMessage }; }) \ No newline at end of file diff --git a/utils/share.js b/utils/share.js index ac6518a..e49905d 100644 --- a/utils/share.js +++ b/utils/share.js @@ -46,10 +46,11 @@ export function bindInvite(args) { if (!inviteCode || inviteCode === null || inviteCode === undefined) { return; } - + + const shopUserInfo=uni.cache.get('shopUserInfo') // 邀请码有效,调用自动绑定邀请人接口,传递绑定所需参数 autoBindInviteUser({ - id: shopUserId, + id: shopUserInfo.id, shopId, inviteCode });