更改购物车
This commit is contained in:
parent
429336c736
commit
1169e300df
10
App.vue
10
App.vue
|
|
@ -23,14 +23,14 @@
|
|||
const store = useNavbarStore();
|
||||
await store.initNavbarHeight();
|
||||
// #ifndef H5
|
||||
try {
|
||||
// try {
|
||||
const storelogin = Storelogin();
|
||||
await storelogin.actionslogin()
|
||||
proxy.$isResolve()
|
||||
} catch (error) {
|
||||
proxy.$isResolve()
|
||||
console.log(error)
|
||||
}
|
||||
// } catch (error) {
|
||||
// proxy.$isResolve()
|
||||
// console.log(error)
|
||||
// }
|
||||
// #endif
|
||||
});
|
||||
// export default {
|
||||
|
|
|
|||
|
|
@ -54,9 +54,7 @@
|
|||
|
||||
const goBack = () => {
|
||||
try {
|
||||
uni.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
uni.pro.switchTab('index/index')
|
||||
} catch (error) {
|
||||
uni.pro.switchTab('index/index')
|
||||
//TODO handle the exception
|
||||
|
|
|
|||
|
|
@ -63,9 +63,15 @@
|
|||
|
||||
});
|
||||
|
||||
const orderVIP = ref(uni.cache.get('orderVIP'))
|
||||
const orderVIP = ref(null)
|
||||
const emits = defineEmits(['customevent', 'groupChange']);
|
||||
watchEffect(() => {
|
||||
orderVIP.value = uni.cache.get('orderVIP')
|
||||
})
|
||||
|
||||
const orderVIPfun = (data) => {
|
||||
orderVIP.value = data
|
||||
}
|
||||
|
||||
const paymentMethodList = ref([{
|
||||
name: "余额支付",
|
||||
|
|
@ -140,7 +146,8 @@
|
|||
}
|
||||
// 将方法暴露给父组件
|
||||
defineExpose({
|
||||
groupChanges
|
||||
groupChanges,
|
||||
orderVIPfun
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// const debug = process.env.NODE_ENV == 'development' ? true : false;
|
||||
const debug = true;
|
||||
const debug = false;
|
||||
// #ifdef H5
|
||||
const proxyApi = "/api"
|
||||
// #endif
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@
|
|||
shopUserId: Orderinfo.shopUserId,
|
||||
})
|
||||
|
||||
if (Orderinfo.typeOrder == 2) {
|
||||
if (Orderinfo.typeOrder == 2 && res.length>0) {
|
||||
res.forEach((item) => {
|
||||
item.Selected = false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@
|
|||
import rechargeFree from './components/rechargeFree.vue'
|
||||
import paymentMethodes from '@/components/paymentMethod.vue'; //支付方式
|
||||
import {
|
||||
onShow,
|
||||
onBackPress
|
||||
} from '@dcloudio/uni-app';
|
||||
|
||||
|
|
@ -221,8 +222,7 @@
|
|||
// 打包费packFeess 计算购物车商品费用totalPrices 餐位费Seatcharge
|
||||
try {
|
||||
let sum = (is_type.value != 0 ? listinfo.packFeess : 0) + listinfo.totalPrices + (is_type
|
||||
.value ==
|
||||
0 ? listinfo.Seatcharge : 0);
|
||||
.value == 0 ? listinfo.Seatcharge : 0);
|
||||
listinfo.originAmount = Math.round(sum * 100) / 100;
|
||||
|
||||
// 打包费packFeess 计算购物车商品费用totalPrices 餐位费Seatcharge 商品卷Productroll 优惠卷coupondiscountAmount 积分listinfo.pointsDiscountAmount
|
||||
|
|
@ -232,11 +232,15 @@
|
|||
.coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0);
|
||||
listinfo.totalCost = Math.round(sums * 100) / 100;
|
||||
// 霸王餐
|
||||
console.log(orderVIP.value.freeDineConfig.enable, changeFreeenable.value)
|
||||
if (orderVIP.value.freeDineConfig.enable && changeFreeenable.value) {
|
||||
listinfo.totalCost = (parseFloat(listinfo.totalCost) * parseFloat(orderVIP.value
|
||||
.freeDineConfig
|
||||
.rechargeTimes)).toFixed(2)
|
||||
try {
|
||||
console.log(orderVIP.value.freeDineConfig.enable, changeFreeenable.value)
|
||||
if (orderVIP.value.freeDineConfig.enable && changeFreeenable.value) {
|
||||
listinfo.totalCost = (parseFloat(listinfo.totalCost) * parseFloat(orderVIP.value
|
||||
.freeDineConfig
|
||||
.rechargeTimes)).toFixed(2)
|
||||
}
|
||||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
// 积分
|
||||
if (listinfo.totalCost && listinfo.status == 'unpaid') {
|
||||
|
|
@ -258,7 +262,6 @@
|
|||
orderInfoAfterRef.value.bwcclear()
|
||||
uniqueIds.value = [] // 筛选出商品卷的id
|
||||
listinfo.coupondiscountAmount = 0 // 优惠卷减去的金额
|
||||
listinfo.Productroll = 0 // 商品卷总价价格
|
||||
listinfo.pointsNum = 0 // 商品卷总价价格
|
||||
// 支付方式切换
|
||||
// #ifdef MP-WEIXIN
|
||||
|
|
@ -330,23 +333,28 @@
|
|||
}
|
||||
} else {
|
||||
// 筛选出商品卷的id
|
||||
uniqueIds.value = [...uniqueIds.value, ...new Set(data.map(item => item.id))]
|
||||
// 商品卷总价价格
|
||||
listinfo.Productroll = await cartStore.getTotalProductroll(data)
|
||||
// uniqueIds.value = [...uniqueIds.value, ...new Set(data.map(item => item.id))]
|
||||
uniqueIds.value = [...uniqueIds.value, ...data.map(item => item.id)]
|
||||
listinfo.Productroll = cartStore.getTotalProductroll(data).value
|
||||
// TODO handle the exception
|
||||
let res = {
|
||||
Productroll: listinfo.Productroll,
|
||||
uniqueIds: uniqueIds.value.length
|
||||
}
|
||||
orderInfoAfterRef.value.dataprocessing(res)
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const learcoupons = (data) => {
|
||||
if (data == 'product') {
|
||||
console.log(listinfo)
|
||||
uniqueIds.value = [] // 筛选出商品卷的id
|
||||
listinfo.coupondiscountAmount = 0 // 优惠卷减去的金额
|
||||
listinfo.Productroll = 0 // 商品卷总价价格
|
||||
listinfo.pointsNum = 0 // 积分总价格
|
||||
} else {
|
||||
// 每次点击优惠卷删除优惠卷里的id
|
||||
if (listinfo.coupondiscountAmount != 0) {
|
||||
|
|
@ -539,6 +547,16 @@
|
|||
uni.$off('returnData', handleReturnData);
|
||||
});
|
||||
|
||||
|
||||
onShow(() => {
|
||||
console.log(uni.cache.get('orderVIP'))
|
||||
try {
|
||||
paymentMethodref.value.orderVIPfun(uni.cache.get('orderVIP'))
|
||||
} catch (error) {
|
||||
//TODO handle the exception
|
||||
}
|
||||
});
|
||||
|
||||
// 监听页面返回事件
|
||||
onMounted(async () => {
|
||||
// 获取当前页面栈
|
||||
|
|
@ -552,13 +570,6 @@
|
|||
// 每次进来全局更新shopId
|
||||
uni.cache.set('shopId', options.shopId, 30)
|
||||
uni.$on('returnData', handleReturnData);
|
||||
// let res = await APIshopUserInfo({
|
||||
// shopId: options.shopId
|
||||
// })
|
||||
// uni.cache.set('orderVIP', res)
|
||||
// uni.cache.set('ordershopUserInfo', res.shopInfo)
|
||||
// orderVIP.value = res
|
||||
// ordershopUserInfo.value = res.shopInfo
|
||||
}
|
||||
try {
|
||||
// * 获取会员信息
|
||||
|
|
|
|||
|
|
@ -327,6 +327,7 @@
|
|||
returnUrl: '', //跳转地址
|
||||
buyerRemark: ''
|
||||
})
|
||||
asyncshopUserInfo()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ export const useCartStore = defineStore('cart', () => {
|
|||
}, 0);
|
||||
// 向下取整并保留两位小数
|
||||
let result = roundUpToTwoDecimals(total, 'downward')
|
||||
console.log(result)
|
||||
return result;
|
||||
// return Math.floor(total * 100) / 100;
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue