From 62c9994444adfe82f7424042be5054976355394f Mon Sep 17 00:00:00 2001 From: Waiting Date: Thu, 16 May 2024 13:07:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=9F=E4=BA=A7=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E6=8A=98=E6=89=A3=E4=BB=B7=E6=98=BE=E7=A4=BA=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/sku-dialog.vue | 2 +- src/pages/mall/index.vue | 6 +++--- src/pages/mall/subs/goods/detail.vue | 8 ++++---- src/pages/mall/subs/search/index.vue | 4 ++-- src/pages/mall/subs/shoppingcart/index.vue | 4 ++-- src/store/modules/user/index.ts | 12 ++++++++++++ src/store/modules/user/types.ts | 1 + 7 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/components/sku-dialog.vue b/src/components/sku-dialog.vue index f53b33b..3eb7241 100644 --- a/src/components/sku-dialog.vue +++ b/src/components/sku-dialog.vue @@ -85,7 +85,7 @@ const show = async (goodsId: string, fn: Function) => { callback = fn; goodsDetailBean.value = await getGoodsDetail(goodsId); - goodsDetailBean.value.consumePrice = Number((goodsDetailBean.value?.price * ((userInfo?.value?.levelEntity?.discount || 100) / 100)).toFixed(2)); + goodsDetailBean.value.consumePrice = Number((goodsDetailBean.value?.price * userInfo?.value.userDiscount).toFixed(2)); if((goodsDetailBean.value?.stocks?.length || 0) <= 0) { showToast('暂无库存'); diff --git a/src/pages/mall/index.vue b/src/pages/mall/index.vue index 18c4d67..28eac68 100644 --- a/src/pages/mall/index.vue +++ b/src/pages/mall/index.vue @@ -22,8 +22,8 @@ @click.stop='goPath(`/pages/mall/subs/goods/detail?goodsId=${item.goodsId}`)'> {{ item.goodsName || '未知' }} - ¥{{ (item.price * ((userInfo.levelEntity?.discount || 100) / 100)).toFixed(2) }} - ¥{{ (item.price * userInfo.userDiscount).toFixed(2) }} + ¥{{ item.price }} @@ -55,7 +55,7 @@ import useShoppingCartStore from '@/store/modules/shoppingcart'; import { useUserStore } from '@/store'; const userStore = useUserStore(); -const { userInfo, companyConfigInfo } = storeToRefs(userStore); +const { userInfo,companyConfigInfo } = storeToRefs(userStore); const shoppingCartStore = useShoppingCartStore(); const { totalCount } = storeToRefs(shoppingCartStore); diff --git a/src/pages/mall/subs/goods/detail.vue b/src/pages/mall/subs/goods/detail.vue index 65f1ec1..b9030b1 100644 --- a/src/pages/mall/subs/goods/detail.vue +++ b/src/pages/mall/subs/goods/detail.vue @@ -15,8 +15,8 @@ - ¥{{ ((goodsBean?.price || 0) * ((userInfo.levelEntity?.discount || 100) / 100)).toFixed(2) }} - ¥{{ goodsBean?.price || 0 }} @@ -56,8 +56,8 @@ {{ item.goodsName || '未知' }} - {{ (item.price * ((userInfo.levelEntity?.discount || 100) / 100)).toFixed(2) }} - {{ (item.price * userInfo.userDiscount).toFixed(2) }} + {{ item.price }} diff --git a/src/pages/mall/subs/search/index.vue b/src/pages/mall/subs/search/index.vue index fa4a1b0..89375cb 100644 --- a/src/pages/mall/subs/search/index.vue +++ b/src/pages/mall/subs/search/index.vue @@ -13,8 +13,8 @@ @click.stop='goPath(`/pages/mall/subs/goods/detail?goodsId=${item.goodsId}`)'> {{ item.goodsName || '未知' }} - ¥{{ (item.price * ((userInfo.levelEntity?.discount || 100)/100)).toFixed(2) }} - ¥{{ (item.price * userInfo.userDiscount).toFixed(2) }} + ¥{{ item.price }} diff --git a/src/pages/mall/subs/shoppingcart/index.vue b/src/pages/mall/subs/shoppingcart/index.vue index d837c49..461012d 100644 --- a/src/pages/mall/subs/shoppingcart/index.vue +++ b/src/pages/mall/subs/shoppingcart/index.vue @@ -25,8 +25,8 @@ - ¥{{ (item?.price * ((userInfo.levelEntity?.discount || 100) / 100)).toFixed(2) }} - ¥{{ item?.price }} diff --git a/src/store/modules/user/index.ts b/src/store/modules/user/index.ts index b6e5058..4bbec6f 100644 --- a/src/store/modules/user/index.ts +++ b/src/store/modules/user/index.ts @@ -50,12 +50,24 @@ const useUserStore = defineStore('user', { // getUserInfo(state: UserBean): UserBean { // return { state }; // } + + getUserDiscount(): number { + if(this.userInfo.levelEntity.discount > 0 && this.userInfo.levelEntity.discount < 10) { + return this.userInfo.levelEntity.discount / 10; + } else if(this.userInfo.levelEntity.discount >= 10 && this.userInfo.levelEntity.discount <= 100) { + return this.userInfo.levelEntity.discount / 100; + } + return 1; + }, + }, actions: { // 设置用户的信息 async setUserInfo(partial: Partial) { this.userInfo = partial as UserBean; + this.userInfo.levelEntity.discount = 79; + this.userInfo.userDiscount = this.getUserDiscount; await setCompanyId(this.userInfo.companyId); await this.fetchTerminal(); await this.fetchCompanyInfo(); diff --git a/src/store/modules/user/types.ts b/src/store/modules/user/types.ts index 75e999b..84e5197 100644 --- a/src/store/modules/user/types.ts +++ b/src/store/modules/user/types.ts @@ -50,6 +50,7 @@ export interface UserBean { updateTime: string; useCouponsPrice: number; wirelinedTelephone: string; + userDiscount:number } export type providerType =