优惠卷和商品卷
This commit is contained in:
@@ -232,8 +232,10 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<confirmorder :cartLists_count="cartLists_count" :cartList="matchedProducts" :totalPrices='totalPrices'
|
||||
:confirmordershow="confirmordershow" @close="confirmordershow = !confirmordershow"></confirmorder>
|
||||
<confirmorder ref="confirmorderref" :cartLists_count="cartLists_count" :cartList="matchedProducts"
|
||||
:totalPrices='totalPrices' :confirmordershow="confirmordershow"
|
||||
@close="confirmordershow = !confirmordershow" @customevent='websocketsendMessage' :orderinfo="orderinfo">
|
||||
</confirmorder>
|
||||
<!-- 店铺详情 -->
|
||||
<shopindex ref="showShopInfoRef"></shopindex>
|
||||
<!-- 购物车 -->
|
||||
@@ -381,6 +383,10 @@
|
||||
APIminiAppskuinfo
|
||||
} from "@/common/api/product/product.js";
|
||||
|
||||
import {
|
||||
APIhistoryOrder
|
||||
} from "@/common/api/order/index.js";
|
||||
|
||||
// websocket
|
||||
import useWebSocket from '@/common/js/websocket.js';
|
||||
|
||||
@@ -871,13 +877,11 @@
|
||||
if (Message.type == "ping_interval" || Message.msg_id == "ping_interval") {
|
||||
return false
|
||||
}
|
||||
|
||||
// 初始化
|
||||
if (Message.operate_type == "shopping_init") {
|
||||
cartList.value = Message.data
|
||||
}
|
||||
|
||||
|
||||
// 购物车数据更新从新请求
|
||||
if (Message.type == 'product') {
|
||||
isDataLoaded.value = false;
|
||||
@@ -908,6 +912,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 清空购物车
|
||||
if (Message.operate_type == 'shopping_cleanup') {
|
||||
cartList.value = []
|
||||
showCart.value = false
|
||||
}
|
||||
|
||||
//除去p 每次返回都回执消息
|
||||
await websocketsendMessage({
|
||||
type: 'receipt',
|
||||
@@ -972,23 +982,54 @@
|
||||
});
|
||||
|
||||
// 计算购物车商品费用
|
||||
const totalPrices = ref(0);
|
||||
// const totalPrices = ref(0);
|
||||
|
||||
watchEffect(() => {
|
||||
if (matchedProducts.value.length > 0) {
|
||||
totalPrices.value = cartStore.getTotalTotalPrices(matchedProducts.value).value;
|
||||
}
|
||||
});
|
||||
// watchEffect(() => {
|
||||
// if (matchedProducts.value.length > 0) {
|
||||
// totalPrices.value = cartStore.getTotalTotalPrices(matchedProducts.value).value;
|
||||
// }
|
||||
// });
|
||||
|
||||
// matchedProducts 变化时,更新总打包费用
|
||||
watch(() => matchedProducts.value, () => {
|
||||
if (matchedProducts.value.length > 0) {
|
||||
totalPrices.value = cartStore.getTotalTotalPrices(matchedProducts.value).value;
|
||||
}
|
||||
// watch(() => matchedProducts.value, () => {
|
||||
// if (matchedProducts.value.length > 0) {
|
||||
// totalPrices.value = cartStore.getTotalTotalPrices(matchedProducts.value).value;
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
// 计算购物车商品总价格
|
||||
const totalPrices = computed(() => {
|
||||
// 购物车总数价格
|
||||
let cart = matchedProducts.value.reduce((total, item) => {
|
||||
// 是否启用会员价 0否1是
|
||||
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
|
||||
// memberPrice会员价
|
||||
return total + parseFloat(item.memberPrice) * parseFloat(item.cartNumber);
|
||||
} else {
|
||||
// salePrice销售价
|
||||
return total + parseFloat(item.salePrice) * parseFloat(item.cartNumber);
|
||||
}
|
||||
}, 0);
|
||||
// 向上取整并保留两位小数
|
||||
return cart = Math.ceil(cart * 100) / 100;
|
||||
});
|
||||
|
||||
// 储存是否存在多次下单
|
||||
const orderinfo = ref({})
|
||||
const confirmorderref = ref(null)
|
||||
// 结账
|
||||
const orderdetail = async () => {
|
||||
try {
|
||||
let res = await APIhistoryOrder({
|
||||
tableCode: uni.cache.get('tableCode'),
|
||||
})
|
||||
orderinfo.value = {
|
||||
id: res.id,
|
||||
detailMap: res.detailMap,
|
||||
placeNum: res.placeNum
|
||||
}
|
||||
} catch (error) {}
|
||||
confirmordershow.value = true
|
||||
}
|
||||
|
||||
@@ -1074,13 +1115,20 @@
|
||||
const currentPage = pages[pages.length - 1];
|
||||
// 获取页面参数
|
||||
const options = currentPage.options;
|
||||
await productqueryProduct()
|
||||
|
||||
orderId.value = options.orderId
|
||||
let res = await APIshopUserInfo({
|
||||
shopId: uni.cache.get('shopId')
|
||||
})
|
||||
cartStore.shopInfo = uni.cache.get('shopInfo')
|
||||
// #ifdef MP-WEIXIN
|
||||
if (options.q) {
|
||||
const store = productStore();
|
||||
await store.scanCodeactions(options.q)
|
||||
}
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
if (getApp().globalData.tableCode) {
|
||||
await store.scanCodeactions(getApp().globalData.tableCode)
|
||||
}
|
||||
// #endif
|
||||
|
||||
await productqueryProduct()
|
||||
setTimeout(() => {
|
||||
getElementTop()
|
||||
}, 500)
|
||||
|
||||
Reference in New Issue
Block a user