更改购物车

This commit is contained in:
wwz 2025-03-25 10:05:16 +08:00
parent 429336c736
commit 1169e300df
8 changed files with 47 additions and 29 deletions

10
App.vue
View File

@ -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 {

View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -272,7 +272,7 @@
shopUserId: Orderinfo.shopUserId,
})
if (Orderinfo.typeOrder == 2) {
if (Orderinfo.typeOrder == 2 && res.length>0) {
res.forEach((item) => {
item.Selected = false
})

View File

@ -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 {
// *

View File

@ -327,6 +327,7 @@
returnUrl: '', //
buyerRemark: ''
})
asyncshopUserInfo()
}

View File

@ -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;
});