白屏,首页,霸王餐,网络完善

This commit is contained in:
wwz
2025-03-27 14:41:50 +08:00
parent 98ce8b5544
commit 9094818ea1
11 changed files with 104 additions and 76 deletions

View File

@@ -30,9 +30,20 @@ export const useCartStore = defineStore('cart', () => {
// 再除以 100 得到保留两位小数的结果
return rounded / 100;
};
// 精确计算函数
const preciseCalculation = (num1, num2) => {
// 将数字转换为整数,乘以 100 以保留两位小数
const int1 = BigInt(Math.round(num1 * 100));
const int2 = BigInt(Math.round(num2 * 100));
// 执行乘法运算
const result = int1 * int2;
// 再除以 10000 以还原为原来的小数
return Number(result) / 10000;
};
// 计算购物车商品总价格
const getTotalTotalPrices = (matchedProducts) => computed(() => {
const getTotalTotalPrices = (matchedProducts, changeFreeenable = true) => computed(() => {
if (!matchedProducts || !Array.isArray(matchedProducts)) {
return 0;
}
@@ -42,7 +53,7 @@ export const useCartStore = defineStore('cart', () => {
let cart = matchedProducts.reduce((total, item) => {
// 是否启用会员价 0否1是
if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo')
.isMemberPrice == 1) {
.isMemberPrice == 1 && changeFreeenable) {
// memberPrice会员价
return total + (parseFloat(item.memberPrice || item.price) * parseFloat(item
.num - item
@@ -52,7 +63,8 @@ export const useCartStore = defineStore('cart', () => {
return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
}
}, 0);
cart.toFixed(2)
cart = cart.toFixed(2)
// 向上取整并保留两位小数
// let result = roundUpToTwoDecimals(cart, 'upward')
return cart;

View File

@@ -111,7 +111,7 @@ export const productStore = defineStore('product', {
let data = await this.actionsproductqueryShop()
// -4请求登录
const store = Storelogin()
if (data.code == '-4') {
if (data.code == '500') {
if (await store.actionslogin()) {
// 成功 接着在调用
await this.actionsproductqueryShop()
@@ -121,10 +121,9 @@ export const productStore = defineStore('product', {
if (uni.cache.get('shopInfo').isTableFee == 0) {
uni.pro.navigateTo('product/choosetable')
} else {
uni.pro.navigateTo(
'product/index', {
tableCode: tableCode,
})
uni.reLaunch({
url: '/pages/product/index'
});
}
}