新增商品其他售价逻辑

修复下单重复创建订单问题
This commit is contained in:
Waiting 2024-05-16 15:38:34 +08:00
parent 62c9994444
commit f547216c2b
8 changed files with 52 additions and 17 deletions

View File

@ -26,6 +26,7 @@ export interface GoodsBean {
name: string; name: string;
price: number; price: number;
send_num: number; send_num: number;
priceExt: number;
price_ext: number; price_ext: number;
payPrice: number; payPrice: number;
profile: string; profile: string;

View File

@ -85,6 +85,7 @@ const show = async (goodsId: string, fn: Function) => {
callback = fn; callback = fn;
goodsDetailBean.value = await getGoodsDetail(goodsId); goodsDetailBean.value = await getGoodsDetail(goodsId);
goodsDetailBean.value.price = userStore.getRealGoodsPrice(goodsDetailBean.value?.price,goodsDetailBean.value?.priceExt)
goodsDetailBean.value.consumePrice = Number((goodsDetailBean.value?.price * userInfo?.value.userDiscount).toFixed(2)); goodsDetailBean.value.consumePrice = Number((goodsDetailBean.value?.price * userInfo?.value.userDiscount).toFixed(2));
if((goodsDetailBean.value?.stocks?.length || 0) <= 0) { if((goodsDetailBean.value?.stocks?.length || 0) <= 0) {

View File

@ -24,7 +24,8 @@
<text class='goods-name'>{{ item.goodsName || '未知' }}</text> <text class='goods-name'>{{ item.goodsName || '未知' }}</text>
<text class='goods-price'>¥{{ (item.price * userInfo.userDiscount).toFixed(2) }} <text class='goods-price'>¥{{ (item.price * userInfo.userDiscount).toFixed(2) }}
<text v-if='userInfo.userDiscount>0&&userInfo.userDiscount<1' <text v-if='userInfo.userDiscount>0&&userInfo.userDiscount<1'
style='text-decoration: line-through;color: #999999;font-size: 25rpx'>¥{{ item.price }} style='text-decoration: line-through;color: #999999;font-size: 25rpx'>
¥{{ item.price }}
</text> </text>
</text> </text>
<image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart(item)' /> <image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart(item)' />
@ -46,6 +47,7 @@
</template> </template>
<script setup lang='ts'> <script setup lang='ts'>
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
import SkuDialog from '@/components/sku-dialog.vue'; import SkuDialog from '@/components/sku-dialog.vue';
import { assetsUrl, defaultImage } from '@/utils/assets'; import { assetsUrl, defaultImage } from '@/utils/assets';
import { goLogin, goPath, isLogin, showToast } from '@/utils'; import { goLogin, goPath, isLogin, showToast } from '@/utils';
@ -55,7 +57,7 @@ import useShoppingCartStore from '@/store/modules/shoppingcart';
import { useUserStore } from '@/store'; import { useUserStore } from '@/store';
const userStore = useUserStore(); const userStore = useUserStore();
const { userInfo,companyConfigInfo } = storeToRefs(userStore); const { userInfo, companyConfigInfo } = storeToRefs(userStore);
const shoppingCartStore = useShoppingCartStore(); const shoppingCartStore = useShoppingCartStore();
const { totalCount } = storeToRefs(shoppingCartStore); const { totalCount } = storeToRefs(shoppingCartStore);
@ -84,6 +86,19 @@ onLoad(() => {
fetchCategoryList(); fetchCategoryList();
}); });
onShareAppMessage((e) => {
return {
title: 'VIP顾客中心',
path: '/pages/mall/index'
};
});
onShareTimeline((e) => {
return {
title: 'VIP顾客中心',
path: '/pages/mall/index'
};
});
const fetchCategoryList = async () => { const fetchCategoryList = async () => {
if(companyConfigInfo.value.mallopen == 1) { if(companyConfigInfo.value.mallopen == 1) {
const list = await getCategoryList(); const list = await getCategoryList();
@ -131,6 +146,10 @@ const fetchGoodsList = async (refresh: boolean = true) => {
} else { } else {
goodsList.value = goodsList.value.concat(rows); goodsList.value = goodsList.value.concat(rows);
} }
goodsList.value.forEach(e => {
e.price = userStore.getRealGoodsPrice(e.price, e.priceExt);
});
}; };
const loadMore = () => { const loadMore = () => {

View File

@ -3,7 +3,7 @@
<view class='swiper-container'> <view class='swiper-container'>
<swiper class='swiper' :interval='1500' :duration='1000' @change='swiperChange'> <swiper class='swiper' :interval='1500' :duration='1000' @change='swiperChange'>
<swiper-item v-for='(item,index) in [goodsBean?.images]' :key='index'> <swiper-item v-for='(item,index) in [goodsBean?.images]' :key='index'>
<image :src='item||defaultImage' /> <image :src='item||defaultImage' mode='aspectFill' />
</swiper-item> </swiper-item>
</swiper> </swiper>
<view class='indicator' style='display: none'> <view class='indicator' style='display: none'>
@ -25,7 +25,7 @@
</view> </view>
<view class='c-flex-row'> <view class='c-flex-row'>
<text style='flex: 1'>{{ goodsBean?.name }}</text> <text style='flex: 1'>{{ goodsBean?.name || '未知' }}</text>
<view class='share-button'> <view class='share-button'>
<image :src='assetsUrl("ic_share.png")'></image> <image :src='assetsUrl("ic_share.png")'></image>
<button class='btn' plain open-type='share'>分享</button> <button class='btn' plain open-type='share'>分享</button>
@ -129,6 +129,7 @@ const swiperIndex = ref(0);
onLoad(async (e: any) => { onLoad(async (e: any) => {
await uni.showLoading(); await uni.showLoading();
goodsBean.value = await getGoodsDetail(e.goodsId); goodsBean.value = await getGoodsDetail(e.goodsId);
goodsBean.value.price = userStore.getRealGoodsPrice(goodsBean.value?.price, goodsBean.value?.priceExt);
const { rows } = await getGoodsList({ const { rows } = await getGoodsList({
page: { page: {
page: 1, page: 1,
@ -140,6 +141,9 @@ onLoad(async (e: any) => {
} }
}); });
recommendList.value = rows; recommendList.value = rows;
recommendList.value?.forEach(e => {
e.price = userStore.getRealGoodsPrice(e.price, e.priceExt);
});
uni.hideLoading(); uni.hideLoading();
}); });

View File

@ -42,7 +42,7 @@
<image class='goods-image' :src='item.images||defaultImage' /> <image class='goods-image' :src='item.images||defaultImage' />
<view class='c-flex-column' style='flex: 1;'> <view class='c-flex-column' style='flex: 1;'>
<view class='c-flex-row'> <view class='c-flex-row'>
<text class='goods-name'>{{ item.name }}</text> <text class='goods-name'>{{ item.name || '未知' }}</text>
</view> </view>
<text style='color: #999999;margin-top: 30rpx'> <text style='color: #999999;margin-top: 30rpx'>
{{ item.code }} {{ item.code }}
@ -193,6 +193,10 @@ const navigateTo = (e: any) => {
}, },
onFailure: () => { onFailure: () => {
console.error('pay onFailure'); console.error('pay onFailure');
if(orderBean.value?.id) {
orderBean.value.id = '';
}
createOrder();
} }
}); });
}; };
@ -233,10 +237,12 @@ const createOrder = async () => {
)) ))
}; };
await uni.showLoading(); if(orderBean.value?.id == undefined || orderBean.value?.id == '') {
const result = await orderCreate(params); await uni.showLoading();
orderBean.value!.id = result.id; const result = await orderCreate(params);
uni.hideLoading(); orderBean.value!.id = result.id;
uni.hideLoading();
}
// //
orderBean?.value?.orderGoods?.forEach(item => { orderBean?.value?.orderGoods?.forEach(item => {

View File

@ -2,12 +2,12 @@
<view class='card-view'> <view class='card-view'>
<view class='c-flex-row'> <view class='c-flex-row'>
<text class='key'>姓名</text> <text class='key'>姓名</text>
<text class='value'>{{ companyConfigInfo.contactname}}</text> <text class='value'>{{ companyConfigInfo?.contactname}}</text>
</view> </view>
<view class='divider' /> <view class='divider' />
<view class='c-flex-row'> <view class='c-flex-row'>
<text class='key'>手机号</text> <text class='key'>手机号</text>
<text class='value'>{{companyConfigInfo.contacttelephone}}</text> <text class='value'>{{companyConfigInfo?.contacttelephone}}</text>
<image :src='assetsUrl("ic_contact_merchant.png")' @click.stop='call' /> <image :src='assetsUrl("ic_contact_merchant.png")' @click.stop='call' />
</view> </view>
</view> </view>

View File

@ -52,21 +52,25 @@ const useUserStore = defineStore('user', {
// } // }
getUserDiscount(): number { getUserDiscount(): number {
if(this.userInfo.levelEntity.discount > 0 && this.userInfo.levelEntity.discount < 10) { if(this.userInfo.levelEntity?.discount > 0 && this.userInfo.levelEntity?.discount < 10) {
return this.userInfo.levelEntity.discount / 10; return this.userInfo.levelEntity?.discount / 10;
} else if(this.userInfo.levelEntity.discount >= 10 && this.userInfo.levelEntity.discount <= 100) { } else if(this.userInfo.levelEntity?.discount >= 10 && this.userInfo.levelEntity?.discount <= 100) {
return this.userInfo.levelEntity.discount / 100; return this.userInfo.levelEntity?.discount / 100;
} }
return 1; return 1;
}, },
getRealGoodsPrice: (state) => (price: number, priceExt: number) => {
return state.userInfo.salePrice == 'price_ext' ? priceExt||0 : price;
}
}, },
actions: { actions: {
// 设置用户的信息 // 设置用户的信息
async setUserInfo(partial: Partial<UserBean>) { async setUserInfo(partial: Partial<UserBean>) {
this.userInfo = partial as UserBean; this.userInfo = partial as UserBean;
this.userInfo.levelEntity.discount = 79; // this.userInfo.levelEntity?.discount = 79;
// this.userInfo.salePrice = 'price_ext';
this.userInfo.userDiscount = this.getUserDiscount; this.userInfo.userDiscount = this.getUserDiscount;
await setCompanyId(this.userInfo.companyId); await setCompanyId(this.userInfo.companyId);
await this.fetchTerminal(); await this.fetchTerminal();

View File

@ -38,7 +38,7 @@ export interface UserBean {
registerDay: number; registerDay: number;
relatedRate: number; relatedRate: number;
remark: string; remark: string;
salePrice: number; salePrice: string;
source: string; source: string;
status: string; status: string;
storeId: string; storeId: string;