新增商品其他售价逻辑
修复下单重复创建订单问题
This commit is contained in:
parent
62c9994444
commit
f547216c2b
@ -26,6 +26,7 @@ export interface GoodsBean {
|
||||
name: string;
|
||||
price: number;
|
||||
send_num: number;
|
||||
priceExt: number;
|
||||
price_ext: number;
|
||||
payPrice: number;
|
||||
profile: string;
|
||||
|
@ -85,6 +85,7 @@ const show = async (goodsId: string, fn: Function) => {
|
||||
callback = fn;
|
||||
|
||||
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));
|
||||
|
||||
if((goodsDetailBean.value?.stocks?.length || 0) <= 0) {
|
||||
|
@ -24,7 +24,8 @@
|
||||
<text class='goods-name'>{{ item.goodsName || '未知' }}</text>
|
||||
<text class='goods-price'>¥{{ (item.price * userInfo.userDiscount).toFixed(2) }}
|
||||
<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>
|
||||
<image class='add-image' :src='assetsUrl("ic_add_goods.png")' @click.stop='addShoppingCart(item)' />
|
||||
@ -46,6 +47,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import SkuDialog from '@/components/sku-dialog.vue';
|
||||
import { assetsUrl, defaultImage } from '@/utils/assets';
|
||||
import { goLogin, goPath, isLogin, showToast } from '@/utils';
|
||||
@ -55,7 +57,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);
|
||||
|
||||
@ -84,6 +86,19 @@ onLoad(() => {
|
||||
fetchCategoryList();
|
||||
});
|
||||
|
||||
onShareAppMessage((e) => {
|
||||
return {
|
||||
title: 'VIP顾客中心',
|
||||
path: '/pages/mall/index'
|
||||
};
|
||||
});
|
||||
|
||||
onShareTimeline((e) => {
|
||||
return {
|
||||
title: 'VIP顾客中心',
|
||||
path: '/pages/mall/index'
|
||||
};
|
||||
});
|
||||
const fetchCategoryList = async () => {
|
||||
if(companyConfigInfo.value.mallopen == 1) {
|
||||
const list = await getCategoryList();
|
||||
@ -131,6 +146,10 @@ const fetchGoodsList = async (refresh: boolean = true) => {
|
||||
} else {
|
||||
goodsList.value = goodsList.value.concat(rows);
|
||||
}
|
||||
|
||||
goodsList.value.forEach(e => {
|
||||
e.price = userStore.getRealGoodsPrice(e.price, e.priceExt);
|
||||
});
|
||||
};
|
||||
|
||||
const loadMore = () => {
|
||||
|
@ -3,7 +3,7 @@
|
||||
<view class='swiper-container'>
|
||||
<swiper class='swiper' :interval='1500' :duration='1000' @change='swiperChange'>
|
||||
<swiper-item v-for='(item,index) in [goodsBean?.images]' :key='index'>
|
||||
<image :src='item||defaultImage' />
|
||||
<image :src='item||defaultImage' mode='aspectFill' />
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view class='indicator' style='display: none'>
|
||||
@ -25,7 +25,7 @@
|
||||
</view>
|
||||
|
||||
<view class='c-flex-row'>
|
||||
<text style='flex: 1'>{{ goodsBean?.name }}</text>
|
||||
<text style='flex: 1'>{{ goodsBean?.name || '未知' }}</text>
|
||||
<view class='share-button'>
|
||||
<image :src='assetsUrl("ic_share.png")'></image>
|
||||
<button class='btn' plain open-type='share'>分享</button>
|
||||
@ -129,6 +129,7 @@ const swiperIndex = ref(0);
|
||||
onLoad(async (e: any) => {
|
||||
await uni.showLoading();
|
||||
goodsBean.value = await getGoodsDetail(e.goodsId);
|
||||
goodsBean.value.price = userStore.getRealGoodsPrice(goodsBean.value?.price, goodsBean.value?.priceExt);
|
||||
const { rows } = await getGoodsList({
|
||||
page: {
|
||||
page: 1,
|
||||
@ -140,6 +141,9 @@ onLoad(async (e: any) => {
|
||||
}
|
||||
});
|
||||
recommendList.value = rows;
|
||||
recommendList.value?.forEach(e => {
|
||||
e.price = userStore.getRealGoodsPrice(e.price, e.priceExt);
|
||||
});
|
||||
uni.hideLoading();
|
||||
});
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
<image class='goods-image' :src='item.images||defaultImage' />
|
||||
<view class='c-flex-column' style='flex: 1;'>
|
||||
<view class='c-flex-row'>
|
||||
<text class='goods-name'>{{ item.name }}</text>
|
||||
<text class='goods-name'>{{ item.name || '未知' }}</text>
|
||||
</view>
|
||||
<text style='color: #999999;margin-top: 30rpx'>
|
||||
{{ item.code }}
|
||||
@ -193,6 +193,10 @@ const navigateTo = (e: any) => {
|
||||
},
|
||||
onFailure: () => {
|
||||
console.error('pay onFailure');
|
||||
if(orderBean.value?.id) {
|
||||
orderBean.value.id = '';
|
||||
}
|
||||
createOrder();
|
||||
}
|
||||
});
|
||||
};
|
||||
@ -233,10 +237,12 @@ const createOrder = async () => {
|
||||
))
|
||||
};
|
||||
|
||||
if(orderBean.value?.id == undefined || orderBean.value?.id == '') {
|
||||
await uni.showLoading();
|
||||
const result = await orderCreate(params);
|
||||
orderBean.value!.id = result.id;
|
||||
uni.hideLoading();
|
||||
}
|
||||
|
||||
//删除购物车已存在商品
|
||||
orderBean?.value?.orderGoods?.forEach(item => {
|
||||
|
@ -2,12 +2,12 @@
|
||||
<view class='card-view'>
|
||||
<view class='c-flex-row'>
|
||||
<text class='key'>姓名</text>
|
||||
<text class='value'>{{ companyConfigInfo.contactname}}</text>
|
||||
<text class='value'>{{ companyConfigInfo?.contactname}}</text>
|
||||
</view>
|
||||
<view class='divider' />
|
||||
<view class='c-flex-row'>
|
||||
<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' />
|
||||
</view>
|
||||
</view>
|
||||
|
@ -52,21 +52,25 @@ const useUserStore = defineStore('user', {
|
||||
// }
|
||||
|
||||
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;
|
||||
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;
|
||||
},
|
||||
|
||||
getRealGoodsPrice: (state) => (price: number, priceExt: number) => {
|
||||
return state.userInfo.salePrice == 'price_ext' ? priceExt||0 : price;
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
// 设置用户的信息
|
||||
async setUserInfo(partial: Partial<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;
|
||||
await setCompanyId(this.userInfo.companyId);
|
||||
await this.fetchTerminal();
|
||||
|
@ -38,7 +38,7 @@ export interface UserBean {
|
||||
registerDay: number;
|
||||
relatedRate: number;
|
||||
remark: string;
|
||||
salePrice: number;
|
||||
salePrice: string;
|
||||
source: string;
|
||||
status: string;
|
||||
storeId: string;
|
||||
|
Loading…
Reference in New Issue
Block a user