优化会员,商品,下单

This commit is contained in:
wwz 2025-03-15 12:03:34 +08:00
parent e6ca187e5a
commit fc957feb72
19 changed files with 484 additions and 978 deletions

49
App.vue
View File

@ -32,6 +32,55 @@
console.log(error)
}
// #endif
try {
uni.getLocation({
type: 'wgs84',
success: async (res) => {
let successres = await APIgeocodelocation({
lng: res.longitude,
lat: res.latitude,
})
if (successres) {
let datastorage = {
country: successres.addressComponent.country, // ""
province: successres.addressComponent
.province, //province: "西"
address: successres.addressComponent.city, //district: "西"
district: successres.addressComponent.district, //district: ""
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
//
proxy.$isResolve()
}
},
});
} catch (error) {
try {
let successres = await APIgeocodelocation({
lng: '',
lat: '',
})
if (successres) {
let datastorage = {
country: successres.addressComponent.country, // ""
province: successres.addressComponent
.province, //province: "西"
address: successres.addressComponent.city, //district: "西"
district: successres.addressComponent.district, //district: ""
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
proxy.$isResolve()
}
} catch (error) {
}
}
proxy.$isResolve()
});
// export default {

View File

@ -31,11 +31,13 @@ export default (params) => {
})
}
return new Promise((resolve, reject) => {
const timeoutDuration = params.timeout || 10000; // 可以通过 params 传入超时时间,默认 10 秒
uni.request({
url: uni.conf.baseUrl + url,
method: method,
header: header,
data: data,
timeout: timeoutDuration,
success(response) {
const res = response.data
// 根据返回的状态码做出对应的操作
@ -43,7 +45,7 @@ export default (params) => {
if (res.code == 200) {
uni.hideLoading();
uni.hideToast();
resolve(res.data);
resolve(res.data ?res.data: true);
} else {
switch (res.code) {
case '501':
@ -68,15 +70,14 @@ export default (params) => {
break;
default:
// 是否提示
console.log(res)
if (toast) {
uni.showToast({
title: res.message || res.msg || res.error,
icon: "none",
success: () => {
setTimeout(res => {
}, 2000)
reject(false);
}, 1000)
}
})
}
@ -85,21 +86,18 @@ export default (params) => {
}
},
fail(err) {
console.log(err)
if (err.errMsg.indexOf('request:fail') !== -1) {
uni.showToast({
title: '网络异常',
icon: "error",
duration: 2000
})
} else {
uni.showToast({
title: '未知异常',
duration: 2000
})
if (err.errMsg.indexOf('timeout') !== -1) {
if (toast) {
uni.showToast({
title: `请求超时,请稍后重试`,
icon: "error",
duration: 2000
});
}
}
}
reject(err);
},
complete() {
// 不管成功还是失败都会执行

View File

@ -24,10 +24,10 @@ const useWebSocket = (options = {}) => {
const reconnectAttempts = ref(0); //重连的尝试次数
const isNetworkConnected = ref(true); //监听当前网络连接状态
const isManuallyClosed = ref(false); //是否是被手动关闭的
const receivedMessages = ref([]); //储从 WebSocket 服务器接收到的消息
const receivedMessages = ref(); //储从 WebSocket 服务器接收到的消息
const initMessageSendAttempts = ref(0); //初始化连接多少次
const reconnectStartTime = ref(0); //新增:记录重连开始时间
const isPongReceived = ref(false)
// 关闭现有连接并清理资源
const closeExistingConnection = () => {
if (socketTask.value) {
@ -75,9 +75,8 @@ const useWebSocket = (options = {}) => {
url: uni.conf.baseUrlwws,
success: (res) => {
isConnected.value = true;
reconnectAttempts.value = 0;
// 监听初始化成功在开启心跳
// startHeartbeat();
startHeartbeat();
},
fail: () => {
console.error('WebSocket 连接失败,尝试重连');
@ -91,12 +90,12 @@ const useWebSocket = (options = {}) => {
socketTask.value.onOpen(() => {
// 初始化 初始购物车
sendMessage(initMessage)
uni.hideLoading();
});
socketTask.value.onMessage((res) => {
let list = JSON.parse(res.data)
console.log(list, 'receivedMessages.value')
receivedMessages.value.push(list);
if (res.msg == 'ok') {
receivedMessages.value = JSON.parse(res.data)
// receivedMessages.value.push(list);
if (receivedMessages.value == 'ok') {
console.log('心跳响应正常');
// 心跳正常,重置重连尝试次数
reconnectAttempts.value = 0;
@ -110,8 +109,15 @@ const useWebSocket = (options = {}) => {
clearInterval(heartbeatTimer.value); // 停止心跳定时器
clearTimeout(reconnectTimer.value); // 清除重连定时器
if (res.code == '1006') {
uni.showToast({
title: '操作异常,请重新扫码',
icon: 'none'
});
console.log('服务器正常关闭,停止重连');
autoReconnect.value = false;
setTimeout(() => {
uni.pro.switchTab('index/index');
}, 1000)
return false;
}
if (autoReconnect.value && !isManuallyClosed.value) {
@ -139,14 +145,16 @@ const useWebSocket = (options = {}) => {
uni.showToast({
title: '网络未连接...',
icon: 'none'
})
});
setTimeout(() => {
uni.pro.switchTab('index/index')
}, 1000)
uni.pro.switchTab('index/index');
}, 1000);
return;
}
heartbeatTimer.value = setInterval(() => {
if (isConnected.value) {
console.log('发送心跳消息');
isPongReceived.value = false; // 每次发送心跳消息前重置标记
socketTask.value.send({
data: JSON.stringify({
type: 'ping_interval'
@ -154,24 +162,47 @@ const useWebSocket = (options = {}) => {
success: () => {
console.log('心跳消息发送成功');
const pongTimer = setTimeout(() => {
console.error('心跳超时,未收到响应,尝试重连');
clearInterval(heartbeatTimer.value);
if (autoReconnect) {
handleReconnect();
if (!isPongReceived.value) {
console.error('心跳超时,未收到响应,尝试重连');
clearInterval(heartbeatTimer.value);
if (autoReconnect.value && reconnectAttempts.value <
maxReconnectAttempts) {
handleReconnect();
} else {
console.error('重连次数达到上限,停止重连和心跳');
clearInterval(heartbeatTimer.value);
autoReconnect.value = false;
uni.pro.switchTab('index/index');
}
}
}, heartbeatInterval * 1.2);
socketTask.value.onMessage((res) => {
if (res.msg == 'ok') {
clearTimeout(pongTimer);
const handlePong = (res) => {
try {
let data = JSON.parse(res.data);
if (data.msg === 'ok' && data.msg_id ==
'ping_interval') {
isPongReceived.value = true;
console.log('收到心跳响应,清除超时定时器');
clearTimeout(pongTimer);
}
} catch (error) {
console.error('解析心跳响应数据时出错:', error);
}
});
};
socketTask.value.onMessage(handlePong);
},
fail: () => {
console.error('心跳消息发送失败,尝试重连');
clearInterval(heartbeatTimer.value);
if (autoReconnect) {
if (autoReconnect.value && reconnectAttempts.value <
maxReconnectAttempts) {
handleReconnect();
} else {
console.error('重连次数达到上限,停止重连和心跳');
clearInterval(heartbeatTimer.value);
autoReconnect.value = false;
uni.pro.switchTab('index/index');
}
}
});
@ -179,6 +210,7 @@ const useWebSocket = (options = {}) => {
}, heartbeatInterval);
};
// 手动关闭连接
const closeSocket = () => {
isManuallyClosed.value = true;
@ -217,6 +249,10 @@ const useWebSocket = (options = {}) => {
reconnectAttempts.value++;
const reconnectInterval = initialReconnectInterval * Math.pow(2, reconnectAttempts.value - 1);
const randomizedInterval = reconnectInterval + Math.floor(Math.random() * 1000);
uni.showLoading({
title: `尝试第 ${reconnectAttempts.value} 次重连`,
mask: true
})
console.log(`尝试第 ${reconnectAttempts.value} 次重连,重连间隔: ${randomizedInterval}ms...`);
reconnectTimer.value = setTimeout(() => {
connect();
@ -227,36 +263,14 @@ const useWebSocket = (options = {}) => {
title: '重连次数达到上限,停止重连',
icon: 'none'
});
}
};
// 发送初始化消息
const sendInitMessage = async () => {
if (initMessageSendAttempts.value < initMessageRetryCount) {
initMessageSendAttempts.value++;
await socketTask.value.send({
data: JSON.stringify(initMessage),
success: () => {
console.log('初始化消息发送成功');
initMessageSendAttempts.value = 0; // 重置尝试次数
},
fail: () => {
console.log(
`初始化消息发送失败,第 ${initMessageSendAttempts.value} 次尝试,将在 ${initMessageRetryInterval} 后重试`
);
setTimeout(() => {
sendInitMessage();
}, initMessageRetryInterval);
}
});
} else {
console.error('初始化消息发送失败,已达到最大重试次数');
// initMessageSendAttempts.value = 0; // 重置尝试次数
clearInterval(heartbeatTimer.value);
autoReconnect.value = false;
uni.pro.switchTab('index/index');
}
};
// 网络状态监听
// / 网络状态监听
const initNetworkListener = () => {
uni.getSystemInfo({
success: (res) => {
@ -295,10 +309,12 @@ const useWebSocket = (options = {}) => {
});
};
onMounted(() => {
initNetworkListener();
connect();
});
// 页面显示,尝试连接 WebSocket
const onShowconnect = () => {
if (autoReconnect.value) {
connect();
}
}
onBeforeUnmount(() => {
closeSocket();
@ -308,7 +324,10 @@ const useWebSocket = (options = {}) => {
isConnected,
sendMessage,
closeSocket,
receivedMessages
receivedMessages,
closeExistingConnection,
onShowconnect,
initNetworkListener
};
};

View File

@ -74,7 +74,7 @@
:style="{'background':c.backColor,'color':c.backColor}">
<image class="fivecontent_item_boxitemlefttowimage" v-if="c.shareImg"
:src="c.shareImg" mode="aspectFill"></image>
<text class="fivecontent_item_boxitemlefttowtext">{{c.name}}</text>
<text class="fivecontent_item_boxitemlefttowtext">{{c.name || ''}}</text>
</view>
</view>
<view class="indexboxitemleftthere flex-colum-start">
@ -338,66 +338,19 @@
uni.$u.debounce(store.scrollTop = res.scrollTop, 500)
});
onShow(async () => {
})
onMounted(async () => {
await proxy.$onLaunched;
if (uni.cache.get('shopId')) {
showindex.value = 'shopIndex'
await storeuser.actionsAPIuser()
} else {
showindex.value = 'index'
hometop()
init_fn()
showindex.value = 'index'
//
}
})
onMounted(async () => {
try {
uni.getLocation({
type: 'wgs84',
success: async (res) => {
let successres = await APIgeocodelocation({
lng: res.longitude,
lat: res.latitude,
})
if (successres) {
let datastorage = {
country: successres.addressComponent.country, // ""
province: successres.addressComponent
.province, //province: "西"
address: successres.addressComponent.city, //district: "西"
district: successres.addressComponent.district, //district: ""
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
//
proxy.$isResolve()
}
},
});
} catch (error) {
try {
let successres = await APIgeocodelocation({
lng: '',
lat: '',
})
if (successres) {
let datastorage = {
country: successres.addressComponent.country, // ""
province: successres.addressComponent
.province, //province: "西"
address: successres.addressComponent.city, //district: "西"
district: successres.addressComponent.district, //district: ""
lng: res.longitude,
lat: res.latitude,
}
uni.cache.set('getLocationstorage', datastorage);
proxy.$isResolve()
}
} catch (error) {
proxy.$isResolve()
}
}
});
onReachBottom(() => {

View File

@ -42,9 +42,8 @@
import {
productStore
} from '@/stores/user.js';
const shopExtend = uni.cache.get('shopUserInfo')? uni.cache.get('shopUserInfo').shopExtendList[0] : ''
const shopExtend = uni.cache.get('shopUserInfo') ? uni.cache.get('shopUserInfo').shopExtendList[0] : ''
const scanCodehandle = async (i) => {
console.log(11)
const store = productStore();
await store.scanCodeactions()
}
@ -64,8 +63,7 @@
}
return null;
}
onMounted(() => {
})
onMounted(() => {})
</script>
<style scoped lang="scss">

View File

@ -41,7 +41,7 @@
});
//
const emits = defineEmits(['confirm', 'close','IntegralInputclose']);
const emits = defineEmits(['confirm', 'close', 'IntegralInputclose']);
//
const inputValue = ref('');
@ -133,6 +133,10 @@
bottom: 0;
left: 0;
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-color: #fff;
padding: 20px;
box-sizing: border-box;

View File

@ -148,8 +148,7 @@
</view>
<!-- 积分 -->
<view class="favorable_right" v-if="item.type=='points'"
@click.stop="calcUsablePointsData.showModal = true">
<view class="favorable_right" v-if="item.type=='points'">
<text class="favorable_right_text" style="color: #666;margin-right: 16rpx;"
v-if="calcUsablePointsData.integral">
使用 {{ calcUsablePointsData.integral}}

View File

@ -1,557 +0,0 @@
<template>
<view class="card_box">
<view class="card_head_box">
<view class="card_head_item" v-for="(item,index) in 8" :key="index"></view>
</view>
<view class="card">
<!-- 订单头部 -->
<view class="head">
<view class="head_left">
<text class="shopName">{{listinfo.name}}</text>
<text class="tableName" v-if="listinfo.tableName">桌号{{listinfo.tableName}}</text>
</view>
<text class="status" v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'">
<text> 待支付 </text>
</text>
<text class="status" v-if="listinfo.status == 'unsend'">
<text>待发货</text>
</text>
<text class="status" v-if="listinfo.status == 'closed'">
<text>订单完成</text>
</text>
<text class="status" v-if="listinfo.status == 'send'">
<text> 已发</text>
</text>
<text class="status" v-if="listinfo.status == 'refunding'">
<text>申请退单</text>
</text>
<text class="status" v-if="listinfo.status == 'refund'">
<text>退单</text>
</text>
<text class="status" v-if="listinfo.status == 'cancelled'">
<text>已取消</text>
</text>
<text class="status" v-if="listinfo.status == 'merge'">
<text>合台</text>
</text>
</view>
<!-- 取餐号 -->
<view class="number-wrap"
v-if="listinfo.status != 'unpaid' && listinfo.status != 'paying'&& listinfo.status != 'cancelled'">
<text class="t">取餐号</text>
<text class="number">{{listinfo.outNumber}}</text>
</view>
<block>
</block>
<!-- 订单详情 -->
<view class="shop-box">
<view class="shop-head">
<view class="shop-head-left" v-if="listinfo.dineMod">
<view class="tag-wrap">
<text class="tag" v-if="listinfo.dineMod == 'dine-in'">堂食</text>
<text class="tag" v-if="listinfo.dineMod == 'take-out'">外带</text>
<text class="tag" v-if="listinfo.dineMod == 'take-away'">外卖</text>
</view>
<text class="title">订单详情</text>
</view>
<view style="display: flex;align-items: center;"
v-if="listinfo.status == 'unpaid' || listinfo.status == 'paying'">
<!-- <text style="font-size:24rpx;">支付时间:</text> -->
<uni-countdown :show-day="false" color="#E3AD7F" border-color="#E3AD7F" splitorColor="#E3AD7F"
:font-size="16" :hour="0" :minute="listinfo.expiredMinutes"
:second="listinfo.expiredSeconds" />
</view>
</view>
<view class="shop-info">
<view class="item" v-for="(value, key) in Object.entries(listinfo.detailMap)" :key="key">
<view>{{key}}下单</view>
<view class="" v-for="item in value" :key="item.id">
<view class="cover">
<u-image width="152" height="152" radius="16" :src='item.productImg'
v-if="item.productId!=-999"></u-image>
<u-image width="152" height="152" radius="16"
:src="'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/table.png'"
mode="heightFix" v-else></u-image>
</view>
<view class="info">
<text class="productName">{{item.productName}}</text>
<text class="productSkuName" v-if="item.productSkuName">{{item.productSkuName}}</text>
</view>
<view class="price">
<view class="priceAmount">{{item.priceAmount}}</view>
<view class="num">x{{item.num}}</view>
</view>
</view>
</view>
</view>
<view class="cell-item" v-if="listinfo.seatAmount > 0">
<view class="label">餐位费</view>
<view class="val">
<view>X{{listinfo.seatNum}}</view>
<view style="font-size: 28rpx;"></view>
<view>{{listinfo.seatAmount}}</view>
</view>
</view>
<block v-if="listinfo&&listinfo.couponInfoList && listinfo.couponInfoList.fullReductionCoupon">
<view class="cell-item" v-for="(item,index) in listinfo.couponInfoList.fullReductionCoupon"
:key="index">
<view class="label">优惠券</view>
<view class="val">
<view></view>
<view style="font-size: 28rpx;">-</view>
<view>{{item.discountAmount}}</view>
</view>
</view>
</block>
<view class="cell-item column"
v-if="listinfo&&listinfo.couponInfoList && listinfo.couponInfoList.productCoupon">
<view class="label">商品券</view>
<view class="val column">
<view class="productCoupon" v-for="(item,index) in listinfo.couponInfoList.productCoupon"
:key="index">
<view class="name">{{item.name}}</view>
<view class="num">X{{item.finalUseNum}}</view>
<view class="amount">-{{item.finalDiscountAmount}}</view>
</view>
</view>
</view>
<view class="cell-item"
v-if="listinfo && listinfo.pointsDiscountAmount && listinfo.pointsDiscountAmount > 0">
<view class="label">积分抵扣</view>
<view class="val">
<view></view>
<view style="font-size: 28rpx;"></view>
<view>{{listinfo.pointsDiscountAmount.toFixed(2)}}</view>
</view>
</view>
<view class="total-wrap">
<view>合计</view>
<view class="price"> {{listinfo.payAmount}} </view>
</view>
</view>
<!-- 订单信息 -->
<view class="order_footer">
<view class="order_footer_icon">
<view class="order_footer_left_icon"></view>
<view class="order_footer_right_icon"></view>
</view>
<view class="order-info">
<view class="row" @click="copyHandle(listinfo.orderNo)">
<text class="t">订单编号</text>
<text class="info">{{listinfo.orderNo}}点击复制</text>
</view>
<view class="row" v-if="listinfo.dineMod">
<text class="t">用餐模式</text>
<text class="info" v-if="listinfo.dineMod == 'dine-in'">堂食</text>
<text class="info" v-if="listinfo.dineMod == 'take-out'">外带</text>
<text class="info" v-if="listinfo.dineMod == 'take-away'">外卖</text>
</view>
<view class="row">
<text class="t">下单时间</text>
<text class="info">{{$u.timeFormat(listinfo.updateTime, 'yyyy-mm-dd hh:MM:ss')}}</text>
</view>
<!--<view class="row">
<text class="t">下单门店</text>
<text class="info">{{listinfo.name}}</text>
</view>
-->
<view class="row" v-if="listinfo.remark">
<text class="t">备注</text>
<text class="info">{{ listinfo.remark||""}}</text>
</view>
<view class="row" v-if="listinfo.seatNum">
<text class="t">就餐人数</text>
<text class="info">{{ listinfo.seatNum || ""}}</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import {
defineProps
} from 'vue'
const props = defineProps({
listinfo: {
type: Object,
default: {}
}
})
// *
const copyHandle = (e) => {
uni.setClipboardData({
data: e,
success() {
uni.showToast({
title: '复制成功',
icon: 'none'
});
}
});
}
</script>
<style lang="scss">
.card_box {
background-color: #fff;
// box-shadow: 0rpx 8rpx 12rpx 2rpx rgba(87,86,86,0.35);
position: relative;
width: 100%;
height: 100%;
// box-shadow: 0rpx 4rpx 12rpx 2rpx rgba(87,86,86,0.35);
border-radius: 18rpx;
.card_head_box {
width: 100%;
display: flex;
justify-content: space-between;
position: absolute;
top: -22.5rpx;
padding: 0 44rpx;
.card_head_item {
width: 45rpx;
height: 45rpx;
background-color: #f9f9f9;
border-radius: 50%;
// box-shadow: inset 0rpx -13rpx 18rpx -16rpx rgba(87, 86, 86, 0.35);
}
}
.card {
// background-color: #fff;
border-radius: 20upx;
margin-bottom: 28upx;
position: relative;
.head {
display: flex;
justify-content: space-between;
padding: 50rpx 34rpx 32rpx 34rpx;
border-bottom: 2rpx dashed #E3E3E3;
.head_left {
.shopName {
font-weight: bold;
font-size: 32rpx;
color: #333333;
}
.tableName {
font-weight: 400;
font-size: 28rpx;
color: #333333;
}
}
.status {
text {
font-weight: 500;
font-size: 28rpx;
color: #333333;
}
}
}
.number-wrap {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 32rpx;
.t {
font-weight: 400;
font-size: 28rpx;
color: #333333;
}
.number {
font-weight: bold;
font-size: 56rpx;
color: #333333;
}
}
.price {
.i {
font-size: 20upx;
}
.num {
font-size: 38upx;
}
}
.shop-box {
padding: 36rpx 34rpx 30rpx 34rpx;
border-bottom: 2rpx dashed #E3E3E3;
.shop-head {
display: flex;
justify-content: space-between;
align-items: center;
.shop-head-left {
display: flex;
align-items: center;
.tag-wrap {
width: 80rpx;
height: 48rpx;
background: #FFFFFF;
border-radius: 10rpx 10rpx 10rpx 10rpx;
border: 2rpx solid #E3AD7F;
margin-right: 18rpx;
display: flex;
align-items: center;
justify-content: center;
.tag {
font-weight: 400;
font-size: 24rpx;
color: #E3AD7F;
}
}
.title {
font-weight: bold;
font-size: 28rpx;
color: #333333;
}
}
}
.shop-info {
margin-top: 32rpx;
margin-bottom: 32rpx;
.item:nth-child(1) {
margin-top: 0;
}
.item {
margin-bottom: 32rpx;
display: flex;
.cover {}
.info {
flex: 1;
display: flex;
flex-direction: column;
padding-left: 16upx;
.productName {
font-weight: bold;
font-size: 28rpx;
color: #333333;
margin-top: 20rpx;
}
.productSkuName {
font-weight: 400;
font-size: 24rpx;
color: #999999;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
text-overflow: ellipsis;
}
.n {
font-size: 24upx;
color: #999;
}
}
.price {
display: flex;
flex-direction: column;
align-items: flex-end;
padding-left: 68rpx;
.priceAmount {
font-weight: 500;
font-size: 28rpx;
color: #333333;
margin-top: 26rpx;
}
.num {
font-weight: 400;
font-size: 24rpx;
color: #999999;
margin-top: 22rpx;
}
}
}
}
.cell-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 0 32rpx 0;
.label {
font-weight: bold;
font-size: 28rpx;
color: #333333;
padding-bottom: 32rpx;
}
.val {
display: flex;
align-items: flex-end;
padding-bottom: 32rpx;
border-bottom: 2rpx dashed #e5e5e5;
>view:nth-child(1) {
font-weight: 400;
font-size: 24rpx;
color: #999999;
margin-right: 42rpx;
}
>view:nth-child(2) {
display: flex;
align-items: flex-end;
font-weight: bold;
font-size: 36rpx;
color: #333333;
}
}
.val.column {
display: flex;
flex-direction: column;
.productCoupon {
display: flex;
align-items: flex-end;
margin: 0 0 10rpx 0;
.name {
font-weight: 400;
font-size: 26rpx;
color: #999;
margin: 0;
}
.num {
font-weight: 400;
font-size: 26rpx;
color: #999;
margin: 0 30rpx;
line-height: 20rpx;
}
.amount {
font-weight: bold;
font-size: 26rpx;
color: #333;
}
}
}
}
.cell-item.column {
align-items: flex-start;
}
.total-wrap {
width: 100%;
display: flex;
justify-content: space-between;
font-weight: bold;
font-size: 28rpx;
color: #333;
.price {
font-weight: bold;
font-size: 32rpx;
}
}
}
.order_footer {
display: flex;
flex-direction: column;
padding: 34rpx;
position: relative;
.order_footer_icon {
width: 100%;
position: absolute;
top: -22.5rpx;
left: 0;
display: flex;
justify-content: space-between;
.order_footer_left_icon {
width: 45rpx;
height: 45rpx;
margin-left: -22.5rpx;
background-color: #f9f9f9;
border-radius: 50%;
// box-shadow: inset -20rpx 0rpx 22rpx -20rpx rgba(87, 86, 86, 0.35);
}
.order_footer_right_icon {
width: 45rpx;
height: 45rpx;
margin-right: -22.5rpx;
background-color: #f9f9f9;
border-radius: 50%;
// box-shadow: inset 13rpx 0rpx 16rpx -9rpx rgba(87, 86, 86, 0.35);
}
}
.title {
font-weight: bold;
font-size: 28rpx;
color: #333333;
}
.order-info {
.row {
display: flex;
justify-content: space-between;
padding-top: 32upx;
.t {
font-weight: bold;
font-size: 28rpx;
color: #333333;
}
.info {
font-weight: 400;
font-size: 24rpx;
color: #666666;
}
}
}
}
}
}
</style>

View File

@ -251,11 +251,13 @@
};
});
}
if (!res) {
console.log(res)
if (res.length > 0) {
fromInfo.list = res
} else {
fromInfo.list = []
return false
}
fromInfo.list = res
console.log(res)
}

View File

@ -39,8 +39,6 @@
@clickPointsamount='clickPointsamount' @learcoupons="learcoupons">
</orderInfoAfter>
<!-- 先支付后下单 -->
<!-- <orderInfoBefore ref="orderInfoBefore" :listinfo="listinfo" v-else></orderInfoBefore> -->
<!-- 充值免单 -->
<!-- <block v-if="listinfo.useType == 'dine-in-after'">
<rechargeFree
@ -196,39 +194,34 @@
// listinfo.couponInfoList = JSON.parse(listinfo.couponInfoList)
// }
}
try {
//
if (listinfo.detailMap) {
let combinedArray = [];
for (const key in listinfo.detailMap) {
if (listinfo.detailMap.hasOwnProperty(key)) {
let subArray = listinfo.detailMap[key];
combinedArray = [...combinedArray, ...subArray]
}
//
if (listinfo.detailMap) {
let combinedArray = [];
for (const key in listinfo.detailMap) {
if (listinfo.detailMap.hasOwnProperty(key)) {
let subArray = listinfo.detailMap[key];
combinedArray = [...combinedArray, ...subArray]
}
listinfo.combinedArray = combinedArray
listinfo.packFee = await cartStore.getTotalPackFee(listinfo.combinedArray)
//
listinfo.totalPrices = await cartStore.getTotalTotalPrices(listinfo
.combinedArray)
// listinfo.seatNum
listinfo.Seatcharge = await cartStore.getTotalSeatcharge(listinfo.seatNum)
}
if (listinfo.discountInfo) {
const discountObj = JSON.parse(listinfo.discountInfo);
const tempArray = [];
for (const [key, value] of Object.entries(discountObj)) {
tempArray.push({
name: key,
amount: value
});
}
listinfo.discountInfo = tempArray;
console.log(tempArray)
listinfo.combinedArray = combinedArray
listinfo.packFee = await cartStore.getTotalPackFee(listinfo.combinedArray)
//
listinfo.totalPrices = await cartStore.getTotalTotalPrices(listinfo
.combinedArray)
// listinfo.seatNum
listinfo.Seatcharge = await cartStore.getTotalSeatcharge(listinfo.seatNum)
}
if (listinfo.discountInfo) {
const discountObj = JSON.parse(listinfo.discountInfo);
const tempArray = [];
for (const [key, value] of Object.entries(discountObj)) {
tempArray.push({
name: key,
amount: value
});
}
} catch (e) {
listinfo.discountInfo = tempArray;
console.log(tempArray)
}
}
@ -241,19 +234,25 @@
// console.log(listinfo.combinedArray, listinfo.packFee, listinfo.totalPrices, listinfo.Seatcharge,
// listinfo.Productroll, listinfo.coupondiscountAmount)
// packFee totalPrices Seatcharge
let sum = (is_type.value != 0 ? listinfo.packFee : 0) + listinfo.totalPrices + (is_type.value ==
0 ? listinfo.Seatcharge : 0);
listinfo.originAmount = Math.round(sum * 100) / 100;
try {
let sum = (is_type.value != 0 ? listinfo.packFee : 0) + listinfo.totalPrices + (is_type
.value ==
0 ? listinfo.Seatcharge : 0);
listinfo.originAmount = Math.round(sum * 100) / 100;
// packFee totalPrices Seatcharge Productroll coupondiscountAmount listinfo.pointsDiscountAmount
let sums = (is_type.value != 0 ? listinfo.packFee : 0) + listinfo.totalPrices + (is_type.value ==
0 ? listinfo.Seatcharge : 0) - (listinfo.Productroll || 0) - (listinfo
.coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0);
listinfo.totalCost = Math.round(sums * 100) / 100;
//
if (listinfo.totalCost && listinfo.status == 'unpaid') {
uni.$u.debounce(await memberPointscalcUsablePoints(), 500)
// packFee totalPrices Seatcharge Productroll coupondiscountAmount listinfo.pointsDiscountAmount
let sums = (is_type.value != 0 ? listinfo.packFee : 0) + listinfo.totalPrices + (is_type
.value ==
0 ? listinfo.Seatcharge : 0) - (listinfo.Productroll || 0) - (listinfo
.coupondiscountAmount || 0) - (listinfo.pointsDiscountAmount || 0);
listinfo.totalCost = Math.round(sums * 100) / 100;
//
if (listinfo.totalCost && listinfo.status == 'unpaid') {
uni.$u.debounce(await memberPointscalcUsablePoints(), 500)
}
} catch (error) {
//TODO handle the exception
}
}
});
@ -434,7 +433,7 @@
} catch (error) {
//TODO handle the exception
}
orderorderInfo()
await orderorderInfo()
}
onUnmounted(() => {

View File

@ -15,7 +15,7 @@
<view class="item">
<up--input class="num_item" v-model="otherNum" :class="{'active':numIndex==-1 }"
@input="isOtherNum" @focus="tabCut(-1)" @blur="blur()" border="none" type="nubmer"
maxlength="3"></up--input>
maxlength="3" placeholder='请输入..'></up--input>
</view>
<!-- <view class="num_item" v-else :class="{'active':numIndex==-1 }"></view> -->
</view>
@ -33,7 +33,7 @@
ref
} from 'vue'
const otherNum = ref('其他')
const otherNum = ref('')
const numIndex = ref(0)

View File

@ -281,8 +281,6 @@
paymentmethod.payType = e.payType;
}
//
const orderdetail = async () => {
let res = await storeMemberpay.actionscreateOrder({

View File

@ -19,9 +19,15 @@
</view>
<view class="info">
<view class="name"> {{ item.name }} </view>
<view class="select-sku-wrap" v-if="item.skuList">
<view class="select-sku-wrap" v-if="item.type == 'sku'">
<text v-for="i in item.skuList" :key="i.id">
{{item.id == i.productId && item.skuId == i.id ? i.specInfo :""}}
{{item.cartListinfo.sku_id == i.id? i.name:"" }}
</text>
</view>
<view class="select-sku-wrap" v-if="item.type == 'package'">
<view>{{dataprocessing(item.cartListinfo).title}}</view>
<text v-for="i in dataprocessing(item.cartListinfo).goods" :key="i.id">
{{i.proName }}
</text>
</view>
<view class="price-wrap" style="padding-top: 0;">
@ -93,6 +99,7 @@
type: Boolean
},
});
const shopInfo = uni.cache.get('shopInfo')
// ifcartNumber
@ -138,6 +145,12 @@
})
}
const dataprocessing = computed(() => {
return (item) => {
return JSON.parse(item.pro_group_info);
};
})
//
const calculateValue = (cartNumber, i, step = 1) => {
if (i == '+') {

View File

@ -98,7 +98,8 @@
<view class="Controls" v-else>
<view class="btn" v-if="item.cartNumber != '0'">
<up-icon name="minus-circle-fill" color="#E9AB7A" size="25"></up-icon>
<view class="btnClick" @click.stop="singleclick(item,'-')">
<view class="btnClick"
@tap.stop="$u.throttle(() => singleclick(item, '-'), 500)">
</view>
</view>
<text class="num"> {{ ifcartNumber(item) }} </text>
@ -106,7 +107,8 @@
v-if="item.suitNum>1">{{item.suitNum<99?item.suitNum:'99+'}}</text>
<view class="btn">
<up-icon name="plus-circle-fill" color="#E9AB7A" size="25"></up-icon>
<view class="btnClick" @click.stop="singleclick(item,'+')">
<view class="btnClick"
@tap.stop="$u.throttle(() => singleclick(item, '+'), 500)">
</view>
</view>
</view>
@ -161,15 +163,9 @@
<view v-if="item1.isSoldStock == 1 || item1.isSaleTime == 0" class="flex-between">
<view class="money">
<view></view>
<text class="money_num"
v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1"
style="margin-right: 10rpx;">{{ item1.memberPrice }}</text>
<!--<view v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1"
:class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}">
</view>
<text class="money_num"
:class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}">{{ item1.salePrice }}</text> -->
<text class="money_num" style="margin-right: 10rpx;">
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item1.memberPrice:item1.salePrice}}
</text>
<text v-if="item1.unitName">/{{item1.unitName}}</text>
</view>
<view class="flex-end">
@ -182,18 +178,11 @@
<view v-else class="flex-between">
<view class="money">
<view></view>
<text class="money_num"
v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1"
style="margin-right: 10rpx;">{{ item1.memberPrice }}</text>
<!--<view v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1"
:class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}">
</view>
<text class="money_num"
:class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}">{{ item1.salePrice }}</text> -->
<text class="money_num" style="margin-right: 10rpx;">
{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item1.memberPrice:item1.salePrice}}
</text>
<text v-if="item1.unitName">/{{item1.unitName}}</text>
</view>
<view class="flex-end"
v-if="item1.type == 'sku' || (item1.type == 'package' && item1.groupType == '1')">
<view class="sku-wrap flex-center"
@ -204,24 +193,25 @@
v-if="item1.cartNumber >0">{{ ifcartNumber(item1) <99?ifcartNumber(item1):'99+'}}</text>
</view>
</view>
<view class="Controls" v-else>
<view class="btn" v-if="item1.cartNumber != '0'">
<up-icon name="minus-circle-fill" color="#E9AB7A" size="25"></up-icon>
<view class="btnClick" @click.stop="singleclick(item1,'-')">
<view class="btnClick"
@tap.stop="$u.throttle(() => singleclick(item1, '-'), 500)">
</view>
</view>
<text class="num"> {{ ifcartNumber(item1) }} </text>
<view class="btn">
<up-icon name="plus-circle-fill" color="#E9AB7A" size="25"></up-icon>
<view class="btnClick" @click.stop="singleclick(item1,'+')">
<view class="btnClick"
@tap.stop="$u.throttle(() => singleclick(item1, '+'), 500)">
</view>
</view>
</view>
</view>
</view>
<view v-if="item1.isSoldStock != 0 || item1.isSale == 0"
style="width: 100%;height: 100%;position: absolute;top: 0;left: 0;z-index: 9background-color: rgba(255,255,255,0.5);">
</view>
@ -232,10 +222,12 @@
</view>
</view>
</view>
<confirmorder ref="confirmorderref" :cartLists_count="cartLists_count" :cartList="matchedProducts"
:totalPrices='totalPrices' :confirmordershow="confirmordershow"
@close="confirmordershow = !confirmordershow" @customevent='websocketsendMessage' :orderinfo="orderinfo">
</confirmorder>
<!-- 店铺详情 -->
<shopindex ref="showShopInfoRef"></shopindex>
<!-- 购物车 -->
@ -244,7 +236,7 @@
</shoppingCartes>
<!-- 显示购物车栏 -->
<view class="cart-wrap" v-if="cartLists_count>0 && !confirmordershow">
<view class="cart-wrap" v-if="cartLists_count > 0 && !confirmordershow">
<view class="cart-content">
<view class="left">
<view class="iconBox">
@ -294,6 +286,7 @@
</view>
</view>
</view>
<!-- 套餐 -->
<view v-else>
<view class="shop_sku_box">
<view class="shop_sku_box_name">
@ -362,6 +355,7 @@
onLoad,
onReady,
onShow,
onHide,
onPageScroll
} from '@dcloudio/uni-app'
@ -579,9 +573,7 @@
type: '',
product_id: '',
sku_id: '',
groupSnap: {
goods: []
}
groupSnap: {}
})
//
const isDataLoaded = ref(false);
@ -621,10 +613,11 @@
});
specifications.sku_id = result.id
specifications.product_id = result.productId
specifications.item = Object.assign({}, result, specifications.item);
//
specifications.item.result = result
if (result.isPauseSale == 0) {
canSubmit.value = true;
skuBtnText.value = '添加到购物车'
// skuBtnText.value = ''
}
} catch (error) {
canSubmit.value = false;
@ -682,55 +675,78 @@
}
}
// 使 find
//
const matchingProduct = async (data) => {
return matchedProducts.value.find(product => {
if (data.type === 'single') {
return product.skuId == data.skuId && product.id == data.id
console.log(specifications, matchedProducts.value, selectedOptions.value, '11111')
return matchedProducts.value.find((product, index) => {
if (data.type == 'package') {
//
let result = [];
if (product.type == "package") {
JSON.parse(product.cartListinfo.pro_group_info).goods.forEach(item1 => {
selectedOptions.value.forEach(item2 => {
if (item1.proId === item2.proId && item1.skuId === item2
.skuId) {
result.push(item1);
}
});
});
}
return result.length > 0 ? result : false;
} else if (specifications.item.type == 'sku') {
//
return product.skuId == data.id && product.id == data.productId
} else {
return product.skuId == data.sku_id && product.id == data.product_id
//
return product.skuId == data.skuId && product.id == data.id
}
});
}
//
const submitSelection = async () => {
if (!canSubmit.value) {
return false;
if (shopCartNumber.value > 0 && canSubmit.value) {
// package
let res = await matchingProduct(specifications.item.type == "package" ? specifications.item :
specifications.item.result)
console.log(res)
if (res) {
await calculateValue(res.cartNumber, '+', shopCartNumber.value)
}
//
if (specifications.item.type == "package") {
specifications.groupSnap.goods = selectedOptions.value
} else {
specifications.groupSnap = null
}
console.log(specifications.groupSnap, 'specifications.groupSnap.goods')
websocketsendMessage({
id: res ? res.cartListId : '',
type: 'shopping',
table_code: uni.cache.get('tableCode'),
shop_id: uni.cache.get('shopId'),
operate_type: res ? 'edit' : 'add',
product_id: specifications.product_id,
sku_id: specifications.sku_id,
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber.value) :
shopCartNumber.value,
pro_group_info: specifications.groupSnap,
goods_type: specifications.item.type == "package" ? 'package' : ''
})
//
showShopsku.value = false
}
let res = await matchingProduct(specifications)
if (res) {
await calculateValue(res.cartNumber, '+', shopCartNumber.value)
}
//
if (selectedOptions.value) {
specifications.groupSnap.goods = selectedOptions.value
}
websocketsendMessage({
type: 'shopping',
table_code: uni.cache.get('tableCode'),
shop_id: uni.cache.get('shopId'),
operate_type: res ? 'edit' : 'add',
product_id: specifications.product_id,
sku_id: specifications.sku_id,
number: res ? await calculateValue(res.cartNumber, '+', shopCartNumber
.value) : shopCartNumber.value,
pro_group_info: specifications.groupSnap
})
showShopsku.value = false
//
}
//
const clickspecifications = async (item, index, indexs, type) => {
// console.log(item, index, indexs, type)
//
shopCartNumber.value = 0
//
let data = {
item: item,
index: '',
inedxs: '',
type: '',
product_id: '',
sku_id: ''
@ -739,21 +755,18 @@
//
selectedSpecs.value = {}
canSubmit.value = false
skuBtnText.value = '请选择规格'
// skuBtnText.value = ''
// single- sku- package- weight- coupon-
let res = await APIminiAppinfo(item.id)
specifications.item = res
if (specifications.item.type == "package") {
selectedOptions.value = []
specifications.product_id = item.id
specifications.product_id = res.id
specifications.sku_id = item.skuId
specifications.groupSnap = res.groupSnap[0]
}
//
specifications.item.cartListId = await matchingProduct(specifications.item) ? item.cartListId : ''
specifications.index = index
specifications.indexs = indexs
specifications.type = type
specifications.type = res.type
specifications.item.selectSpecInfo = Object.fromEntries(
Object.entries(specifications.item.selectSpecInfo).filter(([_, value]) => value.length > 0)
);
@ -764,11 +777,15 @@
//
const singleclick = async (item, i) => {
if (selectedOptions.value.length > 0) {
specifications.groupSnap.goods = selectedOptions.value
}
//
let res = await matchingProduct(item)
//
console.log(specifications, '单规格')
if (specifications.item.type == "package") {
specifications.groupSnap.goods = selectedOptions.value
} else {
specifications.groupSnap = null
}
websocketsendMessage({
id: res ? item.cartListId : '',
type: 'shopping',
@ -777,19 +794,21 @@
operate_type: await calculateValue(item.cartNumber, i) == 'del' ? 'del' : res ? 'edit' : 'add',
product_id: item.id,
sku_id: item.skuId,
number: await calculateValue(item.cartNumber, i),
pro_group_info: specifications.groupSnap,
number: await calculateValue(item.cartNumber, i)
// pro_group_info: specifications.groupSnap,
// goods_type: specifications.item.type == "package" ? 'package' : ''
// pro_group_info: specifications.groupSnap
})
}
//
const calculateValue = (cartNumber, i, step = 1) => {
if (i == '+') {
const result = parseFloat(cartNumber) + step;
const result = parseFloat(cartNumber) + parseFloat(step);
return result.toFixed(2);
} else {
// 0del
const result = parseFloat(cartNumber) - step;
const result = parseFloat(cartNumber) - parseFloat(step);
return result == 0 ? 'del' : result.toFixed(2);
}
}
@ -808,7 +827,10 @@
isConnected,
sendMessage,
closeSocket: manualClose,
receivedMessages
receivedMessages,
closeExistingConnection,
onShowconnect,
initNetworkListener
} = useWebSocket(options);
@ -823,68 +845,70 @@
//
const updateProductQuantities = () => {
//
if (cartListFilter.value.length > 0) {
cartListFilter.value.forEach((cartItem) => {
shopProductList.productInfo.forEach((group) => {
group.productList.forEach((product) => {
if (product.id == cartItem.product_id && product.skuId == cartItem
.sku_id) {
product.cartNumber = cartItem.number
product.cartListId = cartItem.id
}
});
});
// cartNumber 0
shopProductList.hots.forEach((i) => {
i.cartNumber = 0
})
//
shopProductList.productInfo.forEach((group) => {
group.productList.forEach((product) => {
product.cartNumber = 0
});
//
cartListFilter.value.forEach((cartItem) => {
//
shopProductList.hots.forEach((group) => {
// id
if (group.id == cartItem.product_id) {
//
group.cartListId = cartItem.id
group.cartNumber = cartItem.number
});
//
cartListFilter.value.forEach((cartItem) => {
shopProductList.productInfo.forEach((group) => {
group.productList.forEach((product) => {
if (product.id == cartItem.product_id && product.skuId == cartItem
.sku_id) {
product.cartNumber = cartItem.number
product.cartListId = cartItem.id
}
});
});
} else {
shopProductList.hots.forEach((i) => {
i.cartNumber = 0
})
});
//
cartListFilter.value.forEach((cartItem) => {
//
shopProductList.productInfo.forEach((group) => {
group.productList.forEach((product) => {
product.cartNumber = 0
});
shopProductList.hots.forEach((group) => {
// id
if (group.id == cartItem.product_id) {
//
group.cartListId = cartItem.id
group.cartNumber = cartItem.number
}
});
}
});
}
//websocket
const websocketsendMessage = (data) => {
sendMessage(data)
uni.$u.debounce(sendMessage(data), 500)
}
// msg_id
const processedMessageIds = new Set();
//
watchEffect(async () => {
if (isDataLoaded.value && receivedMessages.value.length > 0) {
const Message = receivedMessages.value[receivedMessages.value.length - 1];
if (isDataLoaded.value && receivedMessages.value) {
const Message = receivedMessages.value
if (Message) {
//
if (Message.type == "ping_interval" || Message.msg_id == "ping_interval") {
return false
}
//
if (Message.operate_type == "shopping_init") {
cartList.value = Message.data
}
//
if (Message.type == 'product') {
isDataLoaded.value = false;
uni.$u.debounce(productqueryProduct(), 500)
//
//
if (Message.operate_type == 'shopping_cleanup') {
cartList.value = []
showCart.value = false
}
//
@ -893,8 +917,8 @@
}
//
if (Message.operate_type == 'shopping_del') {
cartList.value = cartList.value.filter(item => item.id !== Message.data.id);
if (Message.operate_type == 'shopping_del' && Message.status == 1) {
cartList.value = cartList.value.filter(item => item.id != Message.data.id);
}
//
@ -910,10 +934,11 @@
});
}
//
if (Message.operate_type == 'shopping_cleanup') {
//
if (Message.type == 'product') {
cartList.value = []
showCart.value = false
isDataLoaded.value = false;
productqueryProduct()
}
//p
@ -922,11 +947,11 @@
msg_id: Message.msg_id
})
// if(Message.status != 1){
// uni.showToast({
// title:'~'
// })
// }
//
if (processedMessageIds.has(Message.msg_id)) {
return;
}
processedMessageIds.add(Message.msg_id);
//
await updateProductQuantities()
@ -937,78 +962,78 @@
// shopProductList.hots
const matchedProducts = computed(() => {
if (!cartList.value) {
return false;
}
let Specialstop = null
if (cartList.value.length > 0) {
let Specialstop = null
try {
Specialstop = [...[{
id: "",
name: "",
productList: shopProductList.hots
}], ...shopProductList.productInfo]
} catch (error) {
Specialstop = shopProductList.productInfo
//TODO handle the exception
}
return cartList.value.map((cartItem) => {
for (const group of Specialstop) {
for (const product of group.productList) {
if (product.id == cartItem.product_id) {
return {
...product,
cartListinfo: cartItem,
cartListId: cartItem.id, //id
cartNumber: cartItem.number //
// cartNumberToAdd: cartItem.number //
};
try {
Specialstop = [...[{
id: "",
name: "",
productList: shopProductList.hots
}], ...shopProductList.productInfo]
} catch (error) {
Specialstop = shopProductList.productInfo
//TODO handle the exception
}
return cartList.value.map((cartItem) => {
for (const group of Specialstop) {
for (const product of group.productList) {
if (product.id == cartItem.product_id) {
//
if (product.type == 'sku') {
product.skuList.forEach((item) => {
if (item.id == product.id && item.productId == product.id) {
product.salePrice = item.salePrice
product.memberPrice = item.memberPrice
product.originPrice = item.originPrice
}
})
}
//
return {
...product,
// cartListinfo:cartItem
cartListId: cartItem.id,
// cartNumberToAdd: product.type == 'weight' ? 1 : cartItem.number //
cartNumberToAdd: cartItem.number //
};
}
}
}
// null null
return null;
}).filter(item => item !== null);
// null null
return null;
}).filter(item => item !== null);
} else {
return []
}
})
//
const cartLists_count = computed(() => {
return matchedProducts.value.reduce((sum, item) => {
// cartNumberToAdd
const num = typeof item.cartNumberToAdd === 'string' ? parseFloat(item
.cartNumberToAdd) : item
.cartNumberToAdd;
return sum + num;
}, 0);
if (matchedProducts.value.length > 0) {
return matchedProducts.value.reduce((sum, item) => {
// cartNumberToAdd
// const num = typeof item.cartNumberToAdd === 'string' ? parseFloat(item.cartNumberToAdd) : item.cartNumberToAdd;
const num = typeof item.cartNumber === 'string' ? parseFloat(item.cartNumber) : item
.cartNumber;
return sum + num;
}, 0);
} else {
return 0;
}
});
//
const totalPrices = computed(() => {
//
let cart = matchedProducts.value.reduce((total, item) => {
// 01
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
// memberPrice
return total + parseFloat(item.memberPrice) * parseFloat(item.cartNumber);
} else {
// salePrice
return total + parseFloat(item.salePrice) * parseFloat(item.cartNumber);
}
}, 0);
//
return cart = Math.ceil(cart * 100) / 100;
if (matchedProducts.value.length > 0) {
//
let cart = matchedProducts.value.reduce((total, item) => {
// 01
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
// memberPrice
return total + parseFloat(item.memberPrice) * parseFloat(item.cartNumber);
} else {
// salePrice
return total + parseFloat(item.salePrice) * parseFloat(item.cartNumber);
}
}, 0);
//
return cart = Math.ceil(cart * 100) / 100;
} else {
return 0
}
});
//
@ -1085,30 +1110,44 @@
try {
shopProductList.hots = await productminiApphotsquery()
shopProductList.productInfo = await APIgroupquery()
// cartNumber 0
shopProductList.productInfo.forEach((group) => {
group.productList.forEach((product) => {
product.cartNumber = 0;
});
});
shopProductList.hots.forEach((i) => {
i.cartNumber = 0
})
scrollTopSize.value = 0
topArr.value = []
userStore.actionsAPIuser()
//
isDataLoaded.value = true;
} catch (error) {
} catch (error) {}
//
if (!shopProductList.productInfo || !shopProductList.hots) {
uni.navigateBack()
//TODO handle the exception
return false;
}
//TODO handle the exception
// cartNumber 0
shopProductList.productInfo.forEach((group) => {
group.productList.forEach((product) => {
product.cartNumber = 0;
});
});
shopProductList.hots.forEach((i) => {
i.cartNumber = 0
})
scrollTopSize.value = 0
topArr.value = []
// userStore.actionsAPIuser()
//
isDataLoaded.value = true;
}
onLoad(async (e) => {
await proxy.$onLaunched;
})
onShow(() => {
//
onShowconnect()
})
onHide(() => {
closeExistingConnection()
})
onMounted(async () => {
await proxy.$onLaunched;
//
@ -1133,6 +1172,8 @@
await productqueryProduct()
setTimeout(() => {
//
initNetworkListener()
getElementTop()
}, 500)
})

View File

@ -90,7 +90,8 @@
} from 'vue';
import {
APIshopUser
APIshopUser,
APIshopUserInfo
} from '@/common/api/member.js'
import {
@ -112,6 +113,8 @@
},
});
//
const formInfo = reactive({
nickName: "",
telephone: "",
@ -302,13 +305,7 @@
const registerMember = async () => {
// if ( userHeadImg.value == "" || userHeadImg.value == null ) {
// uni.showToast({
// title: '',
// icon: 'none'
// });
// return;
// }
if (formInfo.nickName == "" || formInfo.nickName == null) {
uni.showToast({
title: '请输入会员昵称',
@ -316,13 +313,7 @@
});
return;
}
// if ( this.birthDay == "" || this.birthDay == null ) {
// uni.showToast({
// title: '',
// icon: 'none'
// });
// return;
// }
if (formInfo.telephone == "" || formInfo.telephone == null) {
uni.showToast({
title: '请获取手机号',
@ -337,7 +328,7 @@
});
return;
}
let res = await APIshopUser({
await APIshopUser({
// id: uni.cache.get('userInfo').id,
// shopId: uni.cache.get('shopId'),
nickName: formInfo.nickName,
@ -345,7 +336,6 @@
phone: formInfo.telephone,
birthDay: formInfo.birthDay
})
//
let APIshopUserInfores = await APIshopUserInfo({
shopId: uni.cache.get('shopId')
})
@ -355,11 +345,11 @@
title: '会员加入成功',
icon: 'none'
})
//
setTimeout(() => {
if (props.detailtype == 'detail') {
uni.navigateBack()
}
uni.navigateBack()
}, 1500)
}
</script>

View File

@ -320,7 +320,6 @@
});
return false;
}
console.log(infoForn, 111)
console.log({
shopId: infoForn.shopId,
activateId: infoForn.id,
@ -340,6 +339,7 @@
console.log(res)
}
//
const asyncshopUserInfo = async () => {
let res = await APIshopUserInfo({
@ -349,6 +349,7 @@
uni.cache.set('ordershopUserInfo', res.shopInfo)
infoForn.show = res.isVip == 1 ? false : true
infoForn.userInfo = res
infoForn.shopUserInfo = res.shopInfo
}
const detailtype = ref('')
@ -377,10 +378,10 @@
infoForn.shopId = options.shopId ? options.shopId : uni.cache.get('shopId')
}
let resone = await APIusershopInfodetail({
shopId: infoForn.shopId
})
infoForn.shopUserInfo = resone.shopInfo
// let resone = await APIusershopInfodetail({
// shopId: infoForn.shopId
// })
// infoForn.shopUserInfo = resone.shopInfo
asyncshopUserInfo()
if (options.type == 'detail') {
detailtype.value = 'detail'

View File

@ -115,7 +115,7 @@
})
const form = reactive({
memberOpen: false,
memberOpen: true,
shopName: "",
amount: '',
lucky: {
@ -153,11 +153,6 @@
})
}
// *
const getRegisterMember = () => {
this.memberOpen = e;
this.init()
}
//
const asyncshopUserInfo = async () => {
@ -167,6 +162,7 @@
uni.cache.set('orderVIP', res)
uni.cache.set('ordershopUserInfo', res.shopInfo)
form.memberOpen = res.isVip == 1 ? false : true
shopUserInfo.shopExtend = res.shopExtendList[2]
}
@ -184,14 +180,15 @@
//
const pageParams = currentPage.options;
if (pageParams.shopId) {
asyncshopUserInfo()
uni.cache.set('shopId', pageParams.shopId, 30)
let res = await APIusershopInfodetail({
shopId: pageParams.shopId
})
// shopInfo
shopUserInfo.shopExtend = res.shopExtend.member_bg
shopUserInfo.shopId = pageParams.shopId
uni.cache.set('shopId', pageParams.shopId, 30)
// let res = await APIusershopInfodetail({
// shopId: pageParams.shopId
// })
// shopInfo
// shopUserInfo.shopExtend = res.shopExtend.member_bg
asyncshopUserInfo()
console.log(shopUserInfo.shopId)
}
})

View File

@ -107,7 +107,7 @@
const teblist = ref([])
const shopExtend = ref(null)
const userInfo = reactive({})
const ShopId = ref(uni.cache.get('shopId'))
const clickEvent = () => {

View File

@ -229,6 +229,8 @@ export const productStore = defineStore('product', {
try {
let res = await APIshopUserInfo()
uni.cache.set('shopUserInfo', res);
uni.cache.set('orderVIP', res)
uni.cache.set('ordershopUserInfo', res.shopInfo)
resolve(true)
} catch (e) {
reject(false)
@ -244,10 +246,10 @@ export const productStore = defineStore('product', {
// 获取店铺用户会员信息
if (uni.cache.get('shopId')) {
this.actionsproductqueryProduct()
} else {
let res = await APIuser()
uni.cache.set('userInfo', res);
}
let res = await APIuser()
uni.cache.set('userInfo', res);
// }
resolve(true)
} catch (e) {
reject(false)