白屏,首页,霸王餐,网络完善
This commit is contained in:
10
App.vue
10
App.vue
@@ -10,7 +10,8 @@
|
|||||||
onShow
|
onShow
|
||||||
} from '@dcloudio/uni-app';
|
} from '@dcloudio/uni-app';
|
||||||
import {
|
import {
|
||||||
getCurrentInstance
|
getCurrentInstance,
|
||||||
|
nextTick
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import {
|
import {
|
||||||
Storelogin
|
Storelogin
|
||||||
@@ -21,15 +22,12 @@
|
|||||||
// 小程序启动时执行
|
// 小程序启动时执行
|
||||||
onLaunch(async () => {
|
onLaunch(async () => {
|
||||||
// 标记应用启动完成
|
// 标记应用启动完成
|
||||||
|
// clear
|
||||||
|
await nextTick()
|
||||||
const store = useNavbarStore();
|
const store = useNavbarStore();
|
||||||
await store.initNavbarHeight();
|
await store.initNavbarHeight();
|
||||||
|
|
||||||
});
|
});
|
||||||
// export default {
|
|
||||||
// onLaunch: async function() {
|
|
||||||
|
|
||||||
|
|
||||||
// },
|
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
try {
|
try {
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const useWebSocket = (options = {}) => {
|
|||||||
const initMessageSendAttempts = ref(0); //初始化连接多少次
|
const initMessageSendAttempts = ref(0); //初始化连接多少次
|
||||||
const reconnectStartTime = ref(0); //新增:记录重连开始时间
|
const reconnectStartTime = ref(0); //新增:记录重连开始时间
|
||||||
const isPongReceived = ref(false)
|
const isPongReceived = ref(false)
|
||||||
|
const allowReconnect = ref(true); // 新增:控制是否允许重连
|
||||||
// 关闭现有连接并清理资源
|
// 关闭现有连接并清理资源
|
||||||
const closeExistingConnection = () => {
|
const closeExistingConnection = () => {
|
||||||
if (socketTask.value) {
|
if (socketTask.value) {
|
||||||
@@ -80,7 +81,7 @@ const useWebSocket = (options = {}) => {
|
|||||||
},
|
},
|
||||||
fail: () => {
|
fail: () => {
|
||||||
console.error('WebSocket 连接失败,尝试重连');
|
console.error('WebSocket 连接失败,尝试重连');
|
||||||
if (autoReconnect.value) {
|
if (autoReconnect.value && allowReconnect.value) {
|
||||||
handleReconnect();
|
handleReconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,6 +99,7 @@ const useWebSocket = (options = {}) => {
|
|||||||
console.log('初始化正常,心跳响应正常');
|
console.log('初始化正常,心跳响应正常');
|
||||||
// 清除重连定时器
|
// 清除重连定时器
|
||||||
clearTimeout(reconnectTimer.value);
|
clearTimeout(reconnectTimer.value);
|
||||||
|
allowReconnect.value = false
|
||||||
reconnectTimer.value = null;
|
reconnectTimer.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +110,7 @@ const useWebSocket = (options = {}) => {
|
|||||||
isConnected.value = false;
|
isConnected.value = false;
|
||||||
clearInterval(heartbeatTimer.value); // 停止心跳定时器
|
clearInterval(heartbeatTimer.value); // 停止心跳定时器
|
||||||
clearTimeout(reconnectTimer.value); // 清除重连定时器
|
clearTimeout(reconnectTimer.value); // 清除重连定时器
|
||||||
if (res.code == '1006') {
|
if (res.code == '1006' && !allowReconnect.value) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '网络异常,请重新扫码',
|
title: '网络异常,请重新扫码',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@@ -166,7 +168,7 @@ const useWebSocket = (options = {}) => {
|
|||||||
console.error('心跳超时,未收到响应,尝试重连');
|
console.error('心跳超时,未收到响应,尝试重连');
|
||||||
clearInterval(heartbeatTimer.value);
|
clearInterval(heartbeatTimer.value);
|
||||||
if (autoReconnect.value && reconnectAttempts.value <
|
if (autoReconnect.value && reconnectAttempts.value <
|
||||||
maxReconnectAttempts) {
|
maxReconnectAttempts && allowReconnect.value) {
|
||||||
handleReconnect();
|
handleReconnect();
|
||||||
} else {
|
} else {
|
||||||
console.error('重连次数达到上限,停止重连和心跳');
|
console.error('重连次数达到上限,停止重连和心跳');
|
||||||
@@ -197,7 +199,7 @@ const useWebSocket = (options = {}) => {
|
|||||||
console.error('心跳消息发送失败,尝试重连');
|
console.error('心跳消息发送失败,尝试重连');
|
||||||
clearInterval(heartbeatTimer.value);
|
clearInterval(heartbeatTimer.value);
|
||||||
if (autoReconnect.value && reconnectAttempts.value <
|
if (autoReconnect.value && reconnectAttempts.value <
|
||||||
maxReconnectAttempts) {
|
maxReconnectAttempts && allowReconnect.value) {
|
||||||
handleReconnect();
|
handleReconnect();
|
||||||
} else {
|
} else {
|
||||||
console.error('重连次数达到上限,停止重连和心跳');
|
console.error('重连次数达到上限,停止重连和心跳');
|
||||||
@@ -246,6 +248,11 @@ const useWebSocket = (options = {}) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!allowReconnect.value) {
|
||||||
|
console.log('重连功能已关闭,不进行重连');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (reconnectAttempts.value < maxReconnectAttempts) {
|
if (reconnectAttempts.value < maxReconnectAttempts) {
|
||||||
reconnectAttempts.value++;
|
reconnectAttempts.value++;
|
||||||
const reconnectInterval = initialReconnectInterval * Math.pow(2, reconnectAttempts.value - 1);
|
const reconnectInterval = initialReconnectInterval * Math.pow(2, reconnectAttempts.value - 1);
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
<up-radio-group v-model="radiovalue" iconPlacement="right" @change="groupChanges" :size="28"
|
<up-radio-group v-model="radiovalue" iconPlacement="right" @change="groupChanges" :size="28"
|
||||||
placement="column">
|
placement="column">
|
||||||
<block v-for="(item,index) in paymentMethodList" :key="index">
|
<block v-for="(item,index) in paymentMethodList" :key="index">
|
||||||
<view class="method_list" @click="groupChanges(item.type)" v-if="index == 0?!changeFreeenable:true">
|
<view class="method_list" @click="groupChanges(item.type)"
|
||||||
|
v-if="(index+1) == radiovalue?!changeFreeenable:true">
|
||||||
<view class="method_list_top">
|
<view class="method_list_top">
|
||||||
<view class="method_list_top_left">
|
<view class="method_list_top_left">
|
||||||
<image class="icon" :src="item.url" mode="aspectFill" />
|
<image class="icon" :src="item.url" mode="aspectFill" />
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ const proxyApi = "/api"
|
|||||||
// #ifdef MP-WEIXIN || APP || MP-ALIPAY
|
// #ifdef MP-WEIXIN || APP || MP-ALIPAY
|
||||||
const proxyApi = 'https://tapi.cashier.sxczgkj.cn' // 调试地址
|
const proxyApi = 'https://tapi.cashier.sxczgkj.cn' // 调试地址
|
||||||
const proxyApiwws = 'wss://sockets.sxczgkj.com/wss' // 调试地址
|
const proxyApiwws = 'wss://sockets.sxczgkj.com/wss' // 调试地址
|
||||||
|
|
||||||
|
// // 本地
|
||||||
|
// const proxyApi = 'http://192.168.1.31' // 固定的测试
|
||||||
|
// const proxyApiwws = 'ws://192.168.1.43:2348' //宏哥本地
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
@@ -15,7 +19,7 @@ const baseUrlwws = 'wss://sockets.sxczgkj.com/wss'
|
|||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef APP || MP-WEIXIN || MP-ALIPAY
|
// #ifdef APP || MP-WEIXIN || MP-ALIPAY
|
||||||
const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.com' //
|
const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.com' // 线上
|
||||||
const baseUrlwws = debug ? proxyApiwws : 'wss://czgeatws.sxczgkj.com/wss' // 线上
|
const baseUrlwws = debug ? proxyApiwws : 'wss://czgeatws.sxczgkj.com/wss' // 线上
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|||||||
@@ -65,12 +65,15 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="info">
|
<view class="info">
|
||||||
<text class="productName">{{item.productName}}</text>
|
<text class="productName">{{item.productName}}</text>
|
||||||
<text class="productSkuName" v-if="item.productSkuName">{{item.productSkuName}}</text>
|
<text class="productSkuName" v-if="item.skuName">{{item.skuName}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="price">
|
<view class="price">
|
||||||
<view class="priceAmount">
|
<view class="priceAmount">
|
||||||
|
<text v-if="changeFreeenable">{{item.price}}</text>
|
||||||
|
<text v-else>
|
||||||
¥{{orderVIP.isVip ==1 && ordershopUserInfo.isMemberPrice==1?(item.memberPrice|| item.price):item.price}}
|
¥{{orderVIP.isVip ==1 && ordershopUserInfo.isMemberPrice==1?(item.memberPrice|| item.price):item.price}}
|
||||||
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="num">x{{item.num}}</view>
|
<view class="num">x{{item.num}}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
@@ -212,11 +212,11 @@
|
|||||||
// 监听价格算法
|
// 监听价格算法
|
||||||
watchEffect(async () => {
|
watchEffect(async () => {
|
||||||
if (listinfo.combinedArray.length > 0) {
|
if (listinfo.combinedArray.length > 0) {
|
||||||
|
console.log(11)
|
||||||
// 打包费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 == 0 ? listinfo.Seatcharge : 0);
|
.value == 0 ? listinfo.Seatcharge : 0);
|
||||||
console.log(listinfo.totalPrices,11)
|
|
||||||
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
|
||||||
@@ -226,27 +226,20 @@
|
|||||||
.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(listinfo.combinedArray, listinfo.packFeess, listinfo.totalPrices, listinfo
|
// console.log(listinfo.combinedArray, listinfo.packFeess, listinfo.totalPrices, listinfo
|
||||||
.Seatcharge, listinfo.Productroll, listinfo.coupondiscountAmount, sums)
|
// .Seatcharge, listinfo.Productroll, listinfo.coupondiscountAmount, sums) // 霸王餐
|
||||||
// 霸王餐
|
console.log(orderVIP.value.freeDineConfig.enable, changeFreeenable.value)
|
||||||
try {
|
|
||||||
// console.log(orderVIP.value.freeDineConfig.enable, changeFreeenable.value)
|
|
||||||
if (orderVIP.value.freeDineConfig.enable && changeFreeenable.value) {
|
if (orderVIP.value.freeDineConfig.enable && changeFreeenable.value) {
|
||||||
listinfo.totalCost = (parseFloat(listinfo.totalCost) * parseFloat(orderVIP.value
|
listinfo.totalCost = (parseFloat(listinfo.totalCost) * parseFloat(orderVIP.value
|
||||||
.freeDineConfig
|
.freeDineConfig.rechargeTimes)).toFixed(2)
|
||||||
.rechargeTimes)).toFixed(2)
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
//TODO handle the exception
|
|
||||||
}
|
}
|
||||||
// 积分
|
// 积分
|
||||||
if (listinfo.totalCost && listinfo.status == 'unpaid' && orderVIP.value.id) {
|
if (listinfo.totalCost && listinfo.status == 'unpaid' && orderVIP.value.id) {
|
||||||
uni.$u.debounce(memberPointscalcUsablePoints, 500)
|
uni.$u.debounce(memberPointscalcUsablePoints, 500)
|
||||||
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
//TODO handle the exception
|
|
||||||
}
|
}
|
||||||
|
// } catch (error) {
|
||||||
|
// //TODO handle the exception
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -259,22 +252,21 @@
|
|||||||
uniqueIds.value = [] // 筛选出商品卷的id
|
uniqueIds.value = [] // 筛选出商品卷的id
|
||||||
listinfo.coupondiscountAmount = 0 // 优惠卷减去的金额
|
listinfo.coupondiscountAmount = 0 // 优惠卷减去的金额
|
||||||
listinfo.pointsNum = 0 // 商品卷总价价格
|
listinfo.pointsNum = 0 // 商品卷总价价格
|
||||||
let res = cartStore.getTotalTotalPrices(listinfo.combinedArray, 1)
|
// 商品价格
|
||||||
|
listinfo.totalPrices = cartStore.getTotalTotalPrices(listinfo.combinedArray, false)
|
||||||
// 支付方式切换
|
// 支付方式切换
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
paymentMethodref.value.groupChanges(2)
|
paymentMethodref.value.groupChanges(2)
|
||||||
// paymentmethod.radiovalue = 2;
|
|
||||||
// paymentmethod.paymentBtnText = "微信支付";
|
|
||||||
// paymentmethod.payType = 'wechatPay';
|
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef MP-ALIPAY
|
// #ifdef MP-ALIPAY
|
||||||
paymentMethodref.value.groupChanges(3)
|
paymentMethodref.value.groupChanges(3)
|
||||||
// paymentmethod.radiovalue = 3;
|
|
||||||
// paymentmethod.paymentBtnText = "支付宝支付";
|
|
||||||
// paymentmethod.payType = 'wechatPay';
|
|
||||||
// #endif
|
// #endif
|
||||||
|
} else {
|
||||||
|
// 商品价格
|
||||||
|
listinfo.totalPrices = cartStore.getTotalTotalPrices(listinfo.combinedArray)
|
||||||
}
|
}
|
||||||
changeFreeenable.value = e
|
changeFreeenable.value = e
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const saveImage = (url) => {
|
const saveImage = (url) => {
|
||||||
@@ -482,7 +474,6 @@
|
|||||||
//TODO handle the exception
|
//TODO handle the exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
orderorderInfo()
|
orderorderInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="item" @click="tabCut(-1)">
|
<view class="item" @click="tabCut(-1)">
|
||||||
<view class="num_item" :style="numIndex==-1?'background-color: #E8AD7B;':'' ">
|
<view class="num_item" :style="numIndex==-1?'background-color: #E8AD7B;':'' ">
|
||||||
<up--input v-model="otherNum" @input="isOtherNum" @blur="blur()"
|
<up--input v-model="otherNum" @input="isOtherNum" @blur="blur()" border="none" type="nubmer"
|
||||||
border="none" type="nubmer" maxlength="3" placeholder='请输入..'></up--input>
|
maxlength="3" placeholder='请输入..'></up--input>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<Loading :isLoading="isLoading" />
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -35,7 +35,8 @@
|
|||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
onMounted,
|
onMounted,
|
||||||
getCurrentInstance
|
getCurrentInstance,
|
||||||
|
nextTick
|
||||||
} from 'vue'
|
} from 'vue'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -46,6 +47,8 @@
|
|||||||
Storelogin
|
Storelogin
|
||||||
} from '@/stores/user.js';
|
} from '@/stores/user.js';
|
||||||
|
|
||||||
|
import Loading from '@/components/Loading.vue';
|
||||||
|
|
||||||
// 获取全局属性
|
// 获取全局属性
|
||||||
const {
|
const {
|
||||||
proxy
|
proxy
|
||||||
@@ -55,6 +58,9 @@
|
|||||||
productStore
|
productStore
|
||||||
} from '@/stores/user.js';
|
} from '@/stores/user.js';
|
||||||
|
|
||||||
|
// 初始加载中
|
||||||
|
const isLoading = ref(true);
|
||||||
|
|
||||||
const otherNum = ref('')
|
const otherNum = ref('')
|
||||||
|
|
||||||
const numIndex = ref(0)
|
const numIndex = ref(0)
|
||||||
@@ -125,6 +131,8 @@
|
|||||||
await store.scanCodeactions(getApp().globalData.tableCode)
|
await store.scanCodeactions(getApp().globalData.tableCode)
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
await nextTick()
|
||||||
|
isLoading.value = uni.cache.get('shopInfo').isTableFee == 0 ? false : true
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@
|
|||||||
v-for="(item1,index1) in item.productList" :key="index1">
|
v-for="(item1,index1) in item.productList" :key="index1">
|
||||||
<image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true"
|
<image class="goodsImg" v-if="item1.coverImg!=null" :lazy-load="true"
|
||||||
@load="imageLoaded(item1,index,index1)"
|
@load="imageLoaded(item1,index,index1)"
|
||||||
:src="`${item1.coverImg}${!item1.imgLoad?'?x-oss-process=image/resize,m_lfit,w_300,h_300':''}`"
|
:src="`${item1.coverImg}${!item1.imgLoad?'?x-oss-process=image/resize,m_lfit,w_150,h_150':''}`"
|
||||||
mode="aspectFill"></image>
|
mode="aspectFill"></image>
|
||||||
<image class="goodsImg"
|
<image class="goodsImg"
|
||||||
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/index/1.gif" mode="" v-else
|
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/index/1.gif" mode="" v-else
|
||||||
@@ -466,7 +466,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
const shopExtend = uni.cache.get('shopTable').shopExtendMap.shopinfo_bg
|
const shopExtend = uni.cache.get('shopTable').shopExtendMap.shopinfo_bg
|
||||||
|
} catch (error) {
|
||||||
|
//TODO handle the exception
|
||||||
|
}
|
||||||
|
|
||||||
// 计算高度
|
// 计算高度
|
||||||
const navScroll = ref(null)
|
const navScroll = ref(null)
|
||||||
@@ -495,7 +499,7 @@
|
|||||||
const topArr = ref([])
|
const topArr = ref([])
|
||||||
|
|
||||||
// 填充高度,用于最后一项低于滚动区域时使用
|
// 填充高度,用于最后一项低于滚动区域时使用
|
||||||
const fillHeight = ref(0)
|
const fillHeight = ref(200)
|
||||||
|
|
||||||
//距离顶部的高度
|
//距离顶部的高度
|
||||||
const scrollTopSize = ref(0)
|
const scrollTopSize = ref(0)
|
||||||
@@ -1066,9 +1070,10 @@
|
|||||||
// 初始化
|
// 初始化
|
||||||
if (Message.operate_type == "init") {
|
if (Message.operate_type == "init") {
|
||||||
cartList.value = Message.data
|
cartList.value = Message.data
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
|
uni.hideLoading();
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
},1000)
|
}, 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清空购物车
|
// 清空购物车
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/points.png">
|
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/points.png">
|
||||||
</image>
|
</image>
|
||||||
<view class="my_list_item_name">积分</view>
|
<view class="my_list_item_name">积分</view>
|
||||||
<view class="my_list_item_num">{{userInfo.accountPoints || userInfo.points}}</view>
|
<view class="my_list_item_num">{{userInfo.accountPoints || 0}}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="my_list_item">
|
<view class="my_list_item">
|
||||||
<image class="my_list_item_icon"
|
<image class="my_list_item_icon"
|
||||||
|
|||||||
@@ -31,8 +31,19 @@ export const useCartStore = defineStore('cart', () => {
|
|||||||
return rounded / 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)) {
|
if (!matchedProducts || !Array.isArray(matchedProducts)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -42,7 +53,7 @@ export const useCartStore = defineStore('cart', () => {
|
|||||||
let cart = matchedProducts.reduce((total, item) => {
|
let cart = matchedProducts.reduce((total, item) => {
|
||||||
// 是否启用会员价 0否1是
|
// 是否启用会员价 0否1是
|
||||||
if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo')
|
if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo')
|
||||||
.isMemberPrice == 1) {
|
.isMemberPrice == 1 && changeFreeenable) {
|
||||||
// memberPrice会员价
|
// memberPrice会员价
|
||||||
return total + (parseFloat(item.memberPrice || item.price) * parseFloat(item
|
return total + (parseFloat(item.memberPrice || item.price) * parseFloat(item
|
||||||
.num - item
|
.num - item
|
||||||
@@ -52,7 +63,8 @@ export const useCartStore = defineStore('cart', () => {
|
|||||||
return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
|
return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
cart.toFixed(2)
|
|
||||||
|
cart = cart.toFixed(2)
|
||||||
// 向上取整并保留两位小数
|
// 向上取整并保留两位小数
|
||||||
// let result = roundUpToTwoDecimals(cart, 'upward')
|
// let result = roundUpToTwoDecimals(cart, 'upward')
|
||||||
return cart;
|
return cart;
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export const productStore = defineStore('product', {
|
|||||||
let data = await this.actionsproductqueryShop()
|
let data = await this.actionsproductqueryShop()
|
||||||
// -4请求登录
|
// -4请求登录
|
||||||
const store = Storelogin()
|
const store = Storelogin()
|
||||||
if (data.code == '-4') {
|
if (data.code == '500') {
|
||||||
if (await store.actionslogin()) {
|
if (await store.actionslogin()) {
|
||||||
// 成功 接着在调用
|
// 成功 接着在调用
|
||||||
await this.actionsproductqueryShop()
|
await this.actionsproductqueryShop()
|
||||||
@@ -121,10 +121,9 @@ export const productStore = defineStore('product', {
|
|||||||
if (uni.cache.get('shopInfo').isTableFee == 0) {
|
if (uni.cache.get('shopInfo').isTableFee == 0) {
|
||||||
uni.pro.navigateTo('product/choosetable')
|
uni.pro.navigateTo('product/choosetable')
|
||||||
} else {
|
} else {
|
||||||
uni.pro.navigateTo(
|
uni.reLaunch({
|
||||||
'product/index', {
|
url: '/pages/product/index'
|
||||||
tableCode: tableCode,
|
});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user