From c56ea0dd732e737b7ea7b4ff8ca6898a8879b7fd Mon Sep 17 00:00:00 2001 From: Waiting Date: Mon, 3 Jun 2024 22:59:17 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 10 +++++----- src/pages/home/index.vue | 4 ++-- src/pages/mall/subs/order/order-confirm.vue | 16 ++++++++++------ src/store/modules/shoppingcart/index.ts | 13 ++++++++++--- src/store/modules/user/index.ts | 11 +++++++++-- src/utils/auth/index.ts | 4 +++- 6 files changed, 39 insertions(+), 19 deletions(-) diff --git a/src/App.vue b/src/App.vue index 4bd9a17..ec7e94e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -51,11 +51,11 @@ export default { else { //生产环境 if(import.meta.env.VITE_APP_BASE_API.includes('api.lakeapp')) { - setCompanyId('1150930317231112193'); - setRegisterStoreId('1150930317436633090'); + // setCompanyId('1150930317231112193'); + // setRegisterStoreId('1150930317436633090'); - // setCompanyId('1471673498334113794'); - // setRegisterStoreId('1471673498413805570'); + setCompanyId('1471673498334113794'); + setRegisterStoreId('1471673498413805570'); } //测试 else { @@ -109,7 +109,7 @@ export default { } //原先商品团购 - if(options?.query.couponsId) { + if(options?.path?.includes('ticketsBuy/ticketsBuy') && options?.query.couponsId) { setTimeout(() => { uni.reLaunch({ url: 'pages/common/groupbuy/index?id=' + options?.query.couponsId diff --git a/src/pages/home/index.vue b/src/pages/home/index.vue index b0cd86a..33301c2 100644 --- a/src/pages/home/index.vue +++ b/src/pages/home/index.vue @@ -72,7 +72,7 @@ import CompanyDialog from '@/components/company-dialog.vue'; import { getCompanyList } from '@/api/company'; import { useUserStore } from '@/store'; import { assetsUrl, defaultAvatar, defaultImage } from '@/utils/assets'; -import { getCompanyId, getOpenId, goPath, isLogin } from '@/utils'; +import { getOpenId, goPath, isLogin } from '@/utils'; import { storeToRefs } from 'pinia'; import { UserBean } from '@/store/modules/user/types'; @@ -196,7 +196,7 @@ const fetchCompanyList = (fn: any = undefined) => { } else { let index = companyList.value.findIndex((res: { id: string }) => res.id === getApp().globalData?.companyId); //未在当前公司下注册 - if(index < 0) { + if(index < 0 && !getApp()?.globalData?.storeId) { goPath('/pages/common/register/index'); return; } diff --git a/src/pages/mall/subs/order/order-confirm.vue b/src/pages/mall/subs/order/order-confirm.vue index 76997d2..183f20b 100644 --- a/src/pages/mall/subs/order/order-confirm.vue +++ b/src/pages/mall/subs/order/order-confirm.vue @@ -49,7 +49,8 @@ - {{ item.checkedStock.colorName||'均色' }},{{ item.checkedStock.sizeName||'均码' }} x{{ item.checkedStock.count }} + {{ item.checkedStock.colorName || '均色' }},{{ item.checkedStock.sizeName || '均码' }} + x{{ item.checkedStock.count }} ¥{{ item.price }} @@ -160,16 +161,16 @@ const buildSqbParams = computed(() => { client_sn: orderBean.value?.id || '', return_url: '/pages/common/payresult/index', total_amount: Number(((totalPrice.value || 0) * 100).toFixed(2)), - terminal_sn: terminalInfo.value.terminalSn, - subject: orderBean?.value?.orderGoods[0].name||'未知', + terminal_sn: terminalInfo.value?.terminalSn, + subject: orderBean?.value?.orderGoods[0].name || '未知', subject_img: orderBean?.value?.orderGoods[0].images || '', - merchant_name: terminalInfo.value.companyName, + merchant_name: terminalInfo.value?.companyName, notify_url: 'https://www.baidu.com' }, true); return { ...params, - sign: hexMD5(parseParameter(params) + '&key=' + terminalInfo.value.terminalKey).toUpperCase() + sign: hexMD5(parseParameter(params) + '&key=' + terminalInfo.value?.terminalKey).toUpperCase() }; }); @@ -202,7 +203,10 @@ const navigateTo = (e: any) => { }; const createOrder = async () => { - + if(!terminalInfo.value) { + showToast('当前店铺未配置收款渠道,请联系商家'); + return; + } //邮寄 if(tabIndex.value == 1 && !deliveryAddress.value.addrid) { showToast('请选择收货地址'); diff --git a/src/store/modules/shoppingcart/index.ts b/src/store/modules/shoppingcart/index.ts index 4432854..dc1bcdf 100644 --- a/src/store/modules/shoppingcart/index.ts +++ b/src/store/modules/shoppingcart/index.ts @@ -12,11 +12,11 @@ const useShoppingCartStore = defineStore('shoppingCart', { key: 'shoppingCartState', storage: { setItem(key, value) { - uni.setStorageSync(key, value || []); // [!code warning] + uni.setStorageSync(key, value); // [!code warning] uni.setStorageSync(`shoppingCart_${getCompanyId()}`, JSON.parse(value).shoppingCartList); }, getItem(key) { - return uni.getStorageSync(uni.getStorageSync(`shoppingCart_${getCompanyId()}`)) || []; // [!code warning] + return uni.getStorageSync(uni.getStorageSync(`shoppingCart_${getCompanyId()}`)) || ''; } }, // 部分持久化状态的点符号路径数组,[]意味着没有状态被持久化(默认为undefined,持久化整个状态) @@ -33,12 +33,19 @@ const useShoppingCartStore = defineStore('shoppingCart', { }, getSameGoodsIndex: (state) => (goodsId: string, colorId: string, sizeId: string) => { - return state.shoppingCartList?.findIndex(res => res.id === goodsId && res.checkedStock.colorId === colorId && res.checkedStock.sizeId === sizeId); + if(Array.isArray(state.shoppingCartList)) { + return state.shoppingCartList?.findIndex(res => res.id === goodsId && res.checkedStock.colorId === colorId && res.checkedStock.sizeId === sizeId); + } else { + return -1; + } } }, actions: { save(partial: Partial) { + if(!Array.isArray(this.shoppingCartList)) { + this.shoppingCartList = []; + } this.shoppingCartList.push(partial as GoodsBean); }, diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index 835f013..60ccede 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -93,10 +93,17 @@ const useUserStore = defineStore('user', { // referrerUserId: getReferrerUserId() }); getApp().globalData?.logger.info('login result: ', res); + console.log('login result: ', res); + console.log('login result: ', res.token); + console.log('login result: ', res.sessionKey); setToken(res.token); setSessionKey(res.sessionKey); setOpenId(res.maOpenId); - await this.setUserInfo(res.user); + if(res.user){ + await this.setUserInfo(res.user); + }else { + this.setUserInfo(res.userInfo) + } // } resolve(res); } else { @@ -152,7 +159,7 @@ const useUserStore = defineStore('user', { } else { await clearToken(); } - await this.fetchTerminal(); + this.fetchTerminal(); this.fetchCompanyInfo(); }, diff --git a/src/utils/auth/index.ts b/src/utils/auth/index.ts index 0d7c0e4..7ac7c3c 100644 --- a/src/utils/auth/index.ts +++ b/src/utils/auth/index.ts @@ -41,7 +41,9 @@ function getCompanyId() { function setCompanyId(companyId: string) { uni.setStorageSync(CompanyIdKey, companyId); - getApp().globalData!.companyId = companyId; + if(getApp()?.globalData) { + getApp().globalData!.companyId = companyId; + } } function getReferrerUserId() {