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