This commit is contained in:
@@ -15,6 +15,7 @@ interface CardList {
|
||||
number: string;
|
||||
price: number;
|
||||
exchange: number;
|
||||
discount_integral: number;
|
||||
}
|
||||
|
||||
const show = ref(false);
|
||||
@@ -38,7 +39,11 @@ const openModal = async () => {
|
||||
show.value = !show.value;
|
||||
};
|
||||
|
||||
const add_cart = async (item: CardList, num: number = 1) => {
|
||||
const add_cart = async (
|
||||
item: CardList,
|
||||
num: number = 1,
|
||||
bid: string = props.merInfo.bid,
|
||||
) => {
|
||||
try {
|
||||
const res = await addCart({
|
||||
Bid: item.bid,
|
||||
@@ -49,7 +54,7 @@ const add_cart = async (item: CardList, num: number = 1) => {
|
||||
title: res.msg,
|
||||
icon: 'none',
|
||||
});
|
||||
await get_cart_list();
|
||||
await get_cart_list(bid);
|
||||
} catch (e) {
|
||||
Taro.showToast({
|
||||
title: e.msg,
|
||||
@@ -73,12 +78,13 @@ const cartInfo = ref({
|
||||
count: 0,
|
||||
price: 0,
|
||||
exchange: 0,
|
||||
discount_integral: 0,
|
||||
});
|
||||
|
||||
const get_cart_list = async () => {
|
||||
const get_cart_list = async (bid: string = props.merInfo.bid) => {
|
||||
try {
|
||||
const res = await getCart({
|
||||
Bid: props.merInfo.bid,
|
||||
Bid: bid,
|
||||
});
|
||||
|
||||
card_list.value = res.data.data || [];
|
||||
@@ -86,11 +92,13 @@ const get_cart_list = async () => {
|
||||
count: 0,
|
||||
price: 0,
|
||||
exchange: 0,
|
||||
discount_integral: 0,
|
||||
};
|
||||
card_list.value.forEach((item: CardList) => {
|
||||
cartInfo.value.count += Number(item.number);
|
||||
cartInfo.value.price += Number(item.price);
|
||||
cartInfo.value.exchange += Number(item.exchange);
|
||||
cartInfo.value.discount_integral += Number(item.discount_integral);
|
||||
});
|
||||
emit('updateCart', res.data.data || []);
|
||||
} catch (e) {
|
||||
@@ -142,11 +150,10 @@ const create_order = async () => {
|
||||
url: `/pages/admin/add_order/pending_order/pending_order_detail/index?oid=${res.data.oid}&bid=${props.merInfo.bid}`,
|
||||
});
|
||||
} else {
|
||||
const mer_info = Taro.getStorageSync('mer_info');
|
||||
const user_info = Taro.getStorageSync('userInfo');
|
||||
const data = await getUserPoint({
|
||||
phone: user_info.data.phone,
|
||||
bid: mer_info.bid,
|
||||
bid: props.merInfo.bid,
|
||||
});
|
||||
res = await createActiveOrder({
|
||||
Bid: [props.merInfo.bid],
|
||||
@@ -159,7 +166,7 @@ const create_order = async () => {
|
||||
};
|
||||
// isShowPay.value = true;
|
||||
Taro.navigateTo({
|
||||
url: `/pages/goods/pay/index?oid=${res.data.oid}&bid=${mer_info.bid}&OrderType=1`,
|
||||
url: `/pages/goods/pay/index?oid=${res.data.oid}&bid=${props.merInfo.bid}&OrderType=1`,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -199,16 +206,16 @@ defineExpose({
|
||||
<text>{{ cartInfo.count }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="ml-1">
|
||||
<view class="ml-1 text-[25px]">
|
||||
<text>总金额: {{ cartInfo.price.toFixed(2) }}元</text>
|
||||
<text v-if="!IsPendingOrder"
|
||||
>,总积分: {{ cartInfo.exchange.toFixed(2) }}</text
|
||||
>
|
||||
>,积分抵扣: {{ cartInfo.discount_integral.toFixed(2) }}
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="cartInfo.count > 0" class="payBtn" @click.stop="create_order"
|
||||
>去结算</view
|
||||
>
|
||||
>去结算
|
||||
</view>
|
||||
</view>
|
||||
<!-- 购物车弹窗 -->
|
||||
<nut-popup
|
||||
@@ -295,10 +302,12 @@ $h-border-radius: 50px;
|
||||
|
||||
.cardImg {
|
||||
position: relative;
|
||||
|
||||
image {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.count-text {
|
||||
position: absolute;
|
||||
top: -10px;
|
||||
@@ -310,6 +319,7 @@ $h-border-radius: 50px;
|
||||
height: 35px;
|
||||
text-align: center;
|
||||
line-height: 35px;
|
||||
|
||||
text {
|
||||
margin: auto;
|
||||
font-size: 25px;
|
||||
|
||||
Reference in New Issue
Block a user