霸王餐更改

This commit is contained in:
wwz 2025-03-25 21:58:59 +08:00
parent 1169e300df
commit 3a6fa55234
14 changed files with 130 additions and 100 deletions

27
App.vue
View File

@ -6,7 +6,8 @@
APIgeocodelocation
} from "@/common/api/api.js"
import {
onLaunch
onLaunch,
onShow
} from '@dcloudio/uni-app';
import {
getCurrentInstance
@ -22,23 +23,25 @@
//
const store = useNavbarStore();
await store.initNavbarHeight();
// #ifndef H5
// try {
const storelogin = Storelogin();
await storelogin.actionslogin()
proxy.$isResolve()
// } catch (error) {
// proxy.$isResolve()
// console.log(error)
// }
// #endif
});
// export default {
// onLaunch: async function() {
// },
// onShow: function() {},
onShow(async () => {
// #ifndef H5
// try {
const storelogin = Storelogin();
await storelogin.actionslogin()
proxy.$isResolve()
// } catch (error) {
// proxy.$isResolve()
// console.log(error)
// }
// #endif
})
// onHide: function() {}
// }
</script>

View File

@ -90,7 +90,6 @@ const useWebSocket = (options = {}) => {
socketTask.value.onOpen(() => {
// 初始化 初始购物车
sendMessage(initMessage)
uni.hideLoading();
});
socketTask.value.onMessage((res) => {
receivedMessages.value = JSON.parse(res.data)
@ -113,11 +112,10 @@ const useWebSocket = (options = {}) => {
title: '操作异常,请重新扫码',
icon: 'none'
});
console.log('服务器正常关闭,停止重连');
autoReconnect.value = false;
setTimeout(() => {
uni.pro.switchTab('index/index');
}, 1000)
}, 1500)
return false;
}
if (autoReconnect.value && !isManuallyClosed.value) {
@ -157,7 +155,8 @@ const useWebSocket = (options = {}) => {
isPongReceived.value = false; // 每次发送心跳消息前重置标记
socketTask.value.send({
data: JSON.stringify({
type: 'ping_interval'
type: 'ping_interval',
set: 'shopping'
}),
success: () => {
console.log('心跳消息发送成功');
@ -180,8 +179,7 @@ const useWebSocket = (options = {}) => {
const handlePong = (res) => {
try {
let data = JSON.parse(res.data);
if (data.msg === 'ok' && data.msg_id ==
'ping_interval') {
if (data.msg === 'ok' && data.msg_id == 'ping_interval') {
isPongReceived.value = true;
console.log('收到心跳响应,清除超时定时器');
clearTimeout(pongTimer);
@ -250,10 +248,13 @@ const useWebSocket = (options = {}) => {
const reconnectInterval = initialReconnectInterval * Math.pow(2, reconnectAttempts.value - 1);
const randomizedInterval = reconnectInterval + Math.floor(Math.random() * 1000);
uni.showLoading({
title: `尝试第 ${reconnectAttempts.value} 次重连`,
title: `正在努力连接..`,
mask: true
})
console.log(`尝试第 ${reconnectAttempts.value} 次重连,重连间隔: ${randomizedInterval}ms...`);
setTimeout(() => {
uni.hideLoading();
}, 1000)
reconnectTimer.value = setTimeout(() => {
connect();
}, randomizedInterval);

View File

@ -73,12 +73,7 @@
orderVIP.value = data
}
const paymentMethodList = ref([{
name: "余额支付",
type: 1,
url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/wechat.png",
payType: 'accountPay'
},
const paymentMethodList = ref([
// #ifdef MP-WEIXIN
{
name: "微信支付",
@ -95,6 +90,12 @@
payType: 'aliPay'
},
// #endif
{
name: "余额支付",
type: 1,
url: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/drder/wechat.png",
payType: 'accountPay'
}
])

View File

@ -3,7 +3,7 @@
<view class="therecontent_box_item">
<view class="therecontent_box_imge flex-between" @click="jrtoday(0)">
<view class="therecontent_box_imge_text">
{{todayList.name}}
{{todayList.name|| ''}}
</view>
<view class="therecontent_box_imge_right flex-start">
<view>

View File

@ -32,7 +32,7 @@
</view>
<!-- 首页抢购区域 -->
<view class="fivecontent">
<view class="fivecontent_item" v-for="(item,index) in homelist" :key="index"
<view class="fivecontent_item" v-for="(item,index) in formhomelist.list" :key="index"
@click="fivecontentclick(item)">
<view class="fivecontent_item_nav flex-start">
<image :src="item.shopImage" mode="aspectFill"></image>
@ -124,7 +124,7 @@
</view>
</view>
</view>
<up-loadmore height='40' :status="formhomelist.status" iconSize='16' fontSize='16' />
<up-loadmore :status="formhomelist.status" fontSize="14" color="#999" iconSize="14" />
</view>
</view>
<indexs v-if="showindex == 'shopIndex'"></indexs>
@ -234,7 +234,8 @@
page: 1, //
size: 10, //
status: 'loadmore',
name: '1'
name: '1',
list:[]
})
// 使 reactive
const timeData = ref({});
@ -243,7 +244,6 @@
const onChange = (e) => {
timeData.value = e;
};
const homelist = ref([]) //
const onLoadhome = async () => {
try {
let res = await APIhome(formhomelist)
@ -265,30 +265,34 @@
item.end_times = 0
}
})
if (res.pages < formhomelist.page) {
if ((res.totalPage == 0 || res.totalPage == 1) && res.totalRow <= 10) {
console.log(res)
formhomelist.status = 'nomore'
if (form.page == 1 && res.list.length == 0) {
formhomelist.list = res.records
if (formhomelist.page == 1 && res.records.length == 0) {
formhomelist.list = []
}
return false;
} else {
formhomelist.status = 'loading';
if (formhomelist.page == 1) {
formhomelist.list = res.records
} else {
formhomelist.list = [...formhomelist.list, ...res.records];
}
formhomelist.page = ++formhomelist.page;
setTimeout(() => {
homelist.value = [...homelist.value, ...res.list];
if (formhomelist.page > res.totalPage) {
formhomelist.status = 'nomore';
} else {
formhomelist.status = 'loading';
if (res.pageNum == res.pages) {
formhomelist.status = 'nomore';
} else {
formhomelist.status = 'loading';
}
}, 500)
}
}
} catch (e) {}
}
// /
const init_fn = async () => {
homelist.value = []
formhomelist.list = []
Object.assign(formhomelist, {
address: uni.cache.get('getLocationstorage').address, //
lng: uni.cache.get('getLocationstorage').lng,

View File

@ -1,7 +1,7 @@
<template>
<view class="content">
<view class="contentbox"
:style="'background:url('+(shopExtend?shopExtend.shopExtendList[0].value:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png')+') no-repeat center center / cover' ">
:style="'background:url('+(shopExtend[0]?shopExtend[0].value:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png')+') no-repeat center center / cover' ">
<view class="contentboxitem flex-between">
<view class="contentboxitemleft flex-colum" @click="scanCodehandle(0)">
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/Xdiancan.png" mode="aspectFill">
@ -42,7 +42,7 @@
import {
productStore
} from '@/stores/user.js';
const shopExtend = uni.cache.get('shopId') ? uni.cache.get('shopUserInfo') : 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png'
const shopExtend = uni.cache.get('shopUserInfo').shopExtendList ? uni.cache.get('shopUserInfo').shopExtendList : 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png'
const scanCodehandle = async (i) => {
const store = productStore();
await store.scanCodeactions()

View File

@ -70,7 +70,7 @@
<view class="price">
<view class="priceAmount">
{{orderVIP.isVip ==1 && ordershopUserInfo.isMemberPrice==1?item.memberPrice:item.price}}
{{orderVIP.isVip ==1 && ordershopUserInfo.isMemberPrice==1?(item.memberPrice|| item.price):item.price}}
</view>
<view class="num">x{{item.num}}</view>
</view>
@ -122,8 +122,7 @@
<!-- 支付之前 -->
<block v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'">
<view v-for="(item,indexe) in favorablelist" :key="indexe">
<view class="favorable" :class="{column:item.value.length>0&&item.type=='product'}"
@click="goUrl(item)">
<view class="favorable" :class="{column:item.type=='product'}" @click="goUrl(item)">
<view class="favorable_left">
<text class="name"> {{ item.name }} </text>
</view>
@ -161,7 +160,7 @@
</view>
</block>
<block v-else>
<view class="cell-item column" v-if="listinfo.discountInfo.length > 0">
<view class="cell-item column" v-if="listinfo.discountInfo">
<view class="label">优惠折扣</view>
<view class="val column">
<view class="productCoupon" v-for="(item,index) in listinfo.discountInfo" :key="index">
@ -343,6 +342,7 @@
//
const goUrl = (item) => {
console.log(props.listinfo.totalPrices, props.listinfo.Productroll)
if (props.changeFreeenable) {
uni.showToast({
title: '不可与其他优惠共享!',
@ -360,7 +360,8 @@
type: "confirm_order_coupon",
shopId: uni.cache.get('orderVIP').shopId,
shopUserId: props.orderVIP.id,
payAmount: props.listinfo.totalCost,
payAmount: (parseFloat(props.listinfo.totalPrices) - parseFloat(props.listinfo
.Productroll)).toFixed(2),
shoppingCart: JSON.stringify(props.listinfo.combinedArray)
})
break;

View File

@ -336,6 +336,7 @@
Orderinfo.shopUserId = options.shopUserId
Orderinfo.payAmount = options.payAmount
console.log(Orderinfo.payAmount)
Orderinfo.shoppingCart = JSON.parse(decodeURIComponent(options.shoppingCart))
}
getCouponList()

View File

@ -173,13 +173,6 @@
})
if (res) {
Object.assign(listinfo, res);
// if (listinfo.status == 'unpaid') {
// try {
// let res = await APIhistoryOrder({
// orderId: orderId.value
// })
// } catch (error) {}
// }
//
if (listinfo.detailMap) {
let combinedArray = [];
@ -190,12 +183,12 @@
}
}
listinfo.combinedArray = combinedArray
listinfo.packFeess = await cartStore.getTotalPackFee(listinfo.combinedArray)
listinfo.packFeess = cartStore.getTotalPackFee(listinfo.combinedArray)
//
listinfo.totalPrices = await cartStore.getTotalTotalPrices(listinfo
.combinedArray)
listinfo.totalPrices = cartStore.getTotalTotalPrices(listinfo
.combinedArray, changeFreeenable)
// listinfo.seatNum
listinfo.Seatcharge = await cartStore.getTotalSeatcharge(listinfo.seatNum)
listinfo.Seatcharge = cartStore.getTotalSeatcharge(listinfo.seatNum)
}
if (listinfo.discountInfo) {
const discountObj = JSON.parse(listinfo.discountInfo);
@ -207,8 +200,10 @@
});
}
listinfo.discountInfo = tempArray;
console.log(tempArray)
}
//
listinfo.pointsDiscountAmount = 0
// console.log(listinfo)
}
}
@ -231,6 +226,7 @@
0 ? listinfo.Seatcharge : 0) - (listinfo.Productroll || 0) - (listinfo
.coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0);
listinfo.totalCost = Math.round(sums * 100) / 100;
//
try {
console.log(orderVIP.value.freeDineConfig.enable, changeFreeenable.value)
@ -257,12 +253,13 @@
const changeFreeenable = ref(false)
const changeFree = (e) => {
console.log(e)
if (e) {
orderInfoAfterRef.value.bwcclear()
uniqueIds.value = [] // id
listinfo.coupondiscountAmount = 0 //
listinfo.pointsNum = 0 //
let res = cartStore.getTotalTotalPrices(listinfo.combinedArray, 1)
console.log(res)
//
// #ifdef MP-WEIXIN
paymentMethodref.value.groupChanges(2)
@ -453,7 +450,7 @@
amount: listinfo.totalCost, //
returnUrl: '', //
buyerRemark: '',
seatNum: listinfo.seatNum
seatNum: is_type.value == 0 ? listinfo.seatNum : 0, //
})
return false;
} else {
@ -549,9 +546,13 @@
onShow(() => {
console.log(uni.cache.get('orderVIP'))
try {
paymentMethodref.value.orderVIPfun(uni.cache.get('orderVIP'))
//
if (orderVIP.value) {
orderVIP.value = uni.cache.get('orderVIP')
ordershopUserInfo.value = orderVIP.value.shopInfo
paymentMethodref.value.orderVIPfun(uni.cache.get('orderVIP'))
}
} catch (error) {
//TODO handle the exception
}

View File

@ -43,7 +43,7 @@
<view class="price">
<view class="priceAmount">
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item.memberPrice:item.price}}
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice||item.price):item.price}}
</view>
<view class="num">x{{item.num}}</view>
</view>
@ -74,7 +74,7 @@
</view>
</view>
<text
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item.memberPrice:item.salePrice}}</text>
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice||item.salePrice):item.salePrice}}</text>
</view>
<!-- 餐位费 -->
@ -218,10 +218,11 @@
// 01
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
// memberPrice
return total + (parseFloat(item.memberPrice) * parseFloat(item.num - item.returnNum));
return total + (parseFloat(item.memberPrice || item.price) * parseFloat(item.num - item
.returnNum));
} else {
// salePrice
return total + (parseFloat(item.price) * parseFloat(item.num - item.returnNum));
return total + (parseFloat(item.price || 0) * parseFloat(item.num - item.returnNum));
}
}, 0);
//
@ -229,10 +230,11 @@
// 01
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
// memberPrice
return total + parseFloat(item.memberPrice) * parseFloat(item.cartNumber);
return total + parseFloat(item.memberPrice || item.salePrice) * parseFloat(item
.cartNumber);
} else {
// salePrice
return total + parseFloat(item.salePrice) * parseFloat(item.cartNumber);
return total + parseFloat(item.salePrice || 0) * parseFloat(item.cartNumber);
}
}, 0);
cart = cartone + cart
@ -416,6 +418,7 @@
border-radius: 30rpx 30rpx 0 0;
max-height: 80vh;
overflow: auto;
.scroll-view {
max-height: 80vh;
margin-bottom: 190rpx;

View File

@ -38,7 +38,7 @@
<text class="i"></text>
<!-- 会员价与价格 -->
<text
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item.memberPrice:item.salePrice}}</text>
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice || item.salePrice):item.salePrice}}</text>
<!-- <text class="originalprice"
v-if="item.originPrice">¥{{item.originPrice}}</text>
<text class="unit" v-if="item.unitName">/{{item.unitName}}</text> -->

View File

@ -55,7 +55,7 @@
:class="shopInfo.isVip == 0 || shopInfo.isMemberPrice==0?'lineThrough':''">¥</text>
<!-- 会员价与价格 -->
<text
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item.memberPrice:item.salePrice}}</text>
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice||item.salePrice):item.salePrice}}</text>
<!-- 原价 -->
<!-- <text class="originalprice" v-if="item.originPrice">¥{{item.originPrice}}</text> -->
<!-- 单位 -->
@ -77,7 +77,7 @@
:class="shopInfo.isVip ==0 || shopInfo.isMemberPrice==0?'lineThrough':''">¥</text>
<!-- 会员价与价格 -->
<text
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item.memberPrice:item.salePrice}}</text>
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item.memberPrice|| item.salePrice):item.salePrice}}</text>
<!-- 原价 -->
<!-- <text class="originalprice" v-if="item.originPrice">¥{{item.originPrice}}</text> -->
<!-- 单位 -->
@ -164,7 +164,7 @@
<view class="money">
<view></view>
<text class="money_num" style="margin-right: 10rpx;">
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item1.memberPrice:item1.salePrice}}
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1 ?(item1.memberPrice||item1.salePrice):item1.salePrice}}
</text>
<text v-if="item1.unitName">/{{item1.unitName}}</text>
</view>
@ -179,7 +179,7 @@
<view class="money">
<view></view>
<text class="money_num" style="margin-right: 10rpx;">
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item1.memberPrice:item1.salePrice}}
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?(item1.memberPrice||item1.salePrice):item1.salePrice}}
</text>
<text v-if="item1.unitName">/{{item1.unitName}}</text>
</view>
@ -284,6 +284,10 @@
v-if="specifications.item.result&& specifications.item.result.isPauseSale== 1 && selectedSpecs[specType] === option">
<view>售罄</view>
</view>
<view class="shop_sku_box_item_tip"
v-if="specifications.item.result == 'kong' && canSubmit == false && selectedSpecs[specType] === option">
<view>已下架</view>
</view>
</view>
</view>
</view>
@ -315,7 +319,7 @@
<view class="price">
<text class="i"></text>
<text
class="num">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?specifications.item.memberPrice:specifications.item.salePrice}}</text>
class="num">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1? (specifications.item.memberPrice||specifications.item.salePrice):specifications.item.salePrice}}</text>
<text class="i">/{{specifications.item.unitName}}</text>
</view>
<view class="operation-wrap">
@ -635,16 +639,23 @@
specInfo: selectedSpecsStr.value,
id: specifications.item.id
});
specifications.sku_id = result.id
specifications.product_id = result.productId
//
specifications.item.result = result
console.log(specifications.item)
if (result.isPauseSale == 0) {
canSubmit.value = true;
console.log(result)
if (result != true) {
specifications.sku_id = result.id
specifications.product_id = result.productId
//
specifications.item.result = result
console.log(specifications.item)
if (result.isPauseSale == 0) {
canSubmit.value = true;
} else {
canSubmit.value = false;
}
} else {
specifications.item.result = 'kong'
canSubmit.value = false;
}
} else {
canSubmit.value = false;
}
@ -1152,10 +1163,11 @@
// 01
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
// memberPrice
return total + parseFloat(item.memberPrice) * parseFloat(item.cartNumber);
return total + parseFloat(item.memberPrice || item.salePrice) * parseFloat(item
.cartNumber);
} else {
// salePrice
return total + parseFloat(item.salePrice) * parseFloat(item.cartNumber);
return total + parseFloat(item.salePrice || 0) * parseFloat(item.cartNumber);
}
}, 0);
//

View File

@ -1,13 +1,13 @@
<template>
<view class="container">
<image class="topBack"
:src="ShopId?shopExtend.shopExtendList[1].value:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/myTopBack.png'"
:src="userInfo.shopExtendList?(userInfo.shopExtendList[1].value?userInfo.shopExtendList[1].value:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/myTopBack.png'):'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/myTopBack.png'"
mode="aspectFill"></image>
<view class="myContent">
<view class="my_info flex-between">
<view class="my_info_left">
<image class="my_info_left_head" :src="userInfo.headImg" mode="aspectFill"></image>
<view class="name">{{userInfo.nickName || '无'}}</view>
<view class="name">{{userInfo.nickName}}</view>
</view>
<image class="my_info_right_qr" @click="clickEvent" v-if="userInfo.isVip == 1 && ShopId"
:src="'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/my_qRcode.png'" mode="aspectFill">
@ -32,7 +32,7 @@
src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/points.png">
</image>
<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 || userInfo.points}}</view>
</view>
<view class="my_list_item">
<image class="my_list_item_icon"
@ -104,12 +104,12 @@
},
// { name: "", type: "", icon: "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/my/inRegard.png"},
])
const teblist = ref([])
const shopExtend = uni.cache.get('shopId') ? uni.cache.get('shopUserInfo') : 'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png'
const userInfo = reactive({})
const ShopId = ref(uni.cache.get('shopId'))
const clickEvent = () => {
if (ShopId.value) {
if (userInfo.isVip == 0) {
@ -195,9 +195,9 @@
break;
}
}
onShow(async () => {
await store.actionsAPIuser()
onShow(() => {
console.log(111)
store.actionsAPIuser()
if (uni.cache.get('shopId')) {
Object.assign(userInfo, uni.cache.get('orderVIP'))
} else {

View File

@ -32,7 +32,7 @@ export const useCartStore = defineStore('cart', () => {
};
// 计算购物车商品总价格
const getTotalTotalPrices = (matchedProducts) => computed(() => {
const getTotalTotalPrices = (matchedProducts, bwc = 2) => computed(() => {
if (!matchedProducts || !Array.isArray(matchedProducts)) {
return 0;
}
@ -42,9 +42,10 @@ 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 && bwc == 2) {
// memberPrice会员价
return total + (parseFloat(item.memberPrice) * parseFloat(item.num - item
return total + (parseFloat(item.memberPrice || item.price) * parseFloat(item
.num - item
.returnNum));
} else {
// salePrice销售价
@ -67,7 +68,7 @@ export const useCartStore = defineStore('cart', () => {
if (uni.cache.get('orderVIP').isVip == 1 && uni.cache.get('ordershopUserInfo')
.isMemberPrice == 1) {
// memberPrice会员价
return total + parseFloat(item.memberPrice)
return total + parseFloat(item.memberPrice || item.price)
} else {
// salePrice销售价
return total + parseFloat(item.price)
@ -84,8 +85,10 @@ export const useCartStore = defineStore('cart', () => {
let cart = 0
if (uni.cache.get('ordershopUserInfo').isTableFee == 0 && seatNum) {
cart = Math.ceil(parseFloat(seatNum) * parseFloat(
uni.cache.get('ordershopUserInfo').tableFee) * 100) / 100;
cart = parseFloat(seatNum) * parseFloat(uni.cache.get('ordershopUserInfo').tableFee)
// Math.ceil(parseFloat(seatNum) * parseFloat(
// uni.cache.get('ordershopUserInfo').tableFee) * 100) / 100;
}
// 向下取整并保留两位小数
let result = roundUpToTwoDecimals(cart, 'downward')