合并冲突解决
This commit is contained in:
@@ -327,6 +327,15 @@
|
||||
|
||||
function socketInit() {
|
||||
cartsSocket = useWebSocket();
|
||||
cartStore.socketSendMsg=(data)=>{
|
||||
cartsSocket.sendMessage({
|
||||
...data,
|
||||
table_code: uni.cache.get("tableCode"),
|
||||
shop_id: uni.cache.get("shopId"),
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
cartsSocket.connect(socketInitPar, onMessage);
|
||||
}
|
||||
const noPayStatus = {
|
||||
|
||||
@@ -557,7 +557,7 @@
|
||||
<script setup>
|
||||
import xbSwiperPreview from '@/components/xb-swiper-preview/index.vue';
|
||||
//价格计算辅助函数
|
||||
|
||||
|
||||
import {
|
||||
limitUtils
|
||||
} from 'ysk-utils';
|
||||
@@ -604,9 +604,9 @@
|
||||
import Loading from '@/components/Loading.vue';
|
||||
import dayjs from 'dayjs';
|
||||
import isBetween from 'dayjs/plugin/isBetween';
|
||||
|
||||
|
||||
import {
|
||||
APIshopUserInfo
|
||||
APIshopUserInfo,APIusershopInfodetail
|
||||
} from "@/common/api/member.js";
|
||||
dayjs.extend(isBetween);
|
||||
import {
|
||||
@@ -619,9 +619,12 @@
|
||||
import {
|
||||
getDistance
|
||||
} from '@/utils/address.js';
|
||||
import {isObjectEqual,isArrayEqual} from './components/utils.js'
|
||||
|
||||
|
||||
import {
|
||||
isObjectEqual,
|
||||
isArrayEqual
|
||||
} from './components/utils.js'
|
||||
|
||||
|
||||
//点单智能推荐
|
||||
function onBuyClick(item) {
|
||||
let index = -1;
|
||||
@@ -1078,9 +1081,9 @@
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 根据购物车的数据匹配选中的商品查找是否有匹配的数组
|
||||
const matchingProduct = async (data) => {
|
||||
return matchedProducts.value.find((product, index) => {
|
||||
@@ -1516,6 +1519,44 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 购物车初始化时进行判断商品是否可以使用限时折扣,然后更新
|
||||
let socketTimer = null
|
||||
|
||||
function cartInit(arr) {
|
||||
const result = []
|
||||
cartStore.carts = arr.map(v => {
|
||||
const is_time_discount = limitUtils.canUseLimitTimeDiscount(v, cartStore.limitTimeDiscount, shopInfo,
|
||||
shopUserInfo.value, 'product_id');
|
||||
return {
|
||||
...v,
|
||||
is_time_discount: is_time_discount ? 1 : 0
|
||||
}
|
||||
})
|
||||
|
||||
for (let cart of arr) {
|
||||
const findItem = cartStore.carts.find(v => v.id == cart.id)
|
||||
if (findItem&&findItem.is_time_discount != cart.is_time_discount) {
|
||||
result.push({
|
||||
id: cart.id,
|
||||
is_time_discount: findItem.is_time_discount
|
||||
})
|
||||
}
|
||||
}
|
||||
if (result.length > 0) {
|
||||
useSocket.sendMessage({
|
||||
table_code: uni.cache.get('tableCode'),
|
||||
shop_id: uni.cache.get('shopId'),
|
||||
type: "shopping",
|
||||
operate_type: "bulk_edit",
|
||||
data: {
|
||||
cart: result
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
let socketInitFinished = false
|
||||
// 收到的消息变化
|
||||
async function onMessage(Message) {
|
||||
if (Message) {
|
||||
@@ -1533,12 +1574,17 @@
|
||||
|
||||
// 初始化
|
||||
if (Message.operate_type == 'init') {
|
||||
cartStore.carts = Message.data;
|
||||
cartStore.limitTimeDiscount = Message.time_dis_info;
|
||||
cartInit(Message.data)
|
||||
|
||||
uni.hideLoading();
|
||||
isLoading.value = false;
|
||||
// 初始化商品数量
|
||||
// setGoodsInitSel(Message.data)
|
||||
|
||||
if (!socketInitFinished) {
|
||||
useSocket.chnageInitMessage(options.initMessage)
|
||||
socketInitFinished = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 转桌成功
|
||||
@@ -1834,7 +1880,7 @@
|
||||
|
||||
const matchedProductsCount = matchedProducts.value.reduce((sum, item) => {
|
||||
const num = typeof item.cartNumber === 'string' ? parseFloat(item.cartNumber) : item
|
||||
.cartNumber;
|
||||
.cartNumber;
|
||||
return sum + num;
|
||||
}, 0);
|
||||
|
||||
@@ -2048,14 +2094,14 @@
|
||||
|
||||
websocketsendMessage(data);
|
||||
}
|
||||
|
||||
const juli=computed(()=>{
|
||||
|
||||
const juli = computed(() => {
|
||||
const juli = getDistance(userStore.location.latitude, userStore.location.longitude, shopInfo.lat,
|
||||
shopInfo.lng);
|
||||
return juli.toFixed(2)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
//计算距离判断是否可以点餐
|
||||
async function computedDistance(shopInfo) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -2112,8 +2158,7 @@
|
||||
console.log('shopInfoRes===', shopInfoRes);
|
||||
|
||||
await computedDistance(shopInfoRes.shopInfo);
|
||||
|
||||
if (shopInfoRes.shopInfo.id !== tableShopInfo.value.id) {
|
||||
if (shopInfoRes.shopInfo.id !== shopInfo.id) {
|
||||
uni.showModal({
|
||||
title: '注意',
|
||||
content: '扫码店铺与当前店铺不一致,请重新加载页面',
|
||||
@@ -2151,13 +2196,22 @@
|
||||
orderType.value = e.type;
|
||||
}
|
||||
//获取用户信息
|
||||
const userInfo= await APIshopUserInfo({
|
||||
shopId:uni.cache.get('shopId')
|
||||
const userInfo = await APIshopUserInfo({
|
||||
shopId: uni.cache.get('shopId')
|
||||
})
|
||||
|
||||
if(userInfo&& typeof userInfo ==='object'){
|
||||
shopUserInfo.value=userInfo
|
||||
uni.cache.set('shopUserInfo',userInfo)
|
||||
//获取店铺信息
|
||||
const shopInfoRes = await APIusershopInfodetail({
|
||||
shopId: uni.cache.get('shopId')
|
||||
});
|
||||
if(shopInfoRes&&shopInfoRes.shopInfo){
|
||||
Object.assign(shopInfo, shopInfoRes.shopInfo);
|
||||
uni.cache.set('shopInfo',shopInfoRes.shopInfo)
|
||||
}
|
||||
|
||||
|
||||
if (userInfo && typeof userInfo === 'object') {
|
||||
shopUserInfo.value = userInfo
|
||||
uni.cache.set('shopUserInfo', userInfo)
|
||||
}
|
||||
|
||||
const extraInitPar = {}
|
||||
@@ -2170,9 +2224,7 @@
|
||||
...options.initMessage,
|
||||
...extraInitPar
|
||||
}, onMessage);
|
||||
setTimeout(()=>{
|
||||
useSocket.chnageInitMessage(options.initMessage)
|
||||
},500)
|
||||
|
||||
|
||||
console.log('onLoad:e', e);
|
||||
cartStore.setOldOrder({
|
||||
@@ -2308,7 +2360,7 @@
|
||||
fullAmount = item;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return fullAmount;
|
||||
});
|
||||
|
||||
|
||||
@@ -141,9 +141,9 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
deep: true,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -152,21 +152,23 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
enableRewards: 0, //是否开启
|
||||
pointsPerYuan: 0,
|
||||
maxDeductionAmount: Infinity,
|
||||
maxDeductionRatio: 0 ,//积分抵扣比例
|
||||
minPaymentAmount:0,//门槛
|
||||
maxDeductionRatio: 0, //积分抵扣比例
|
||||
minPaymentAmount: 0, //门槛
|
||||
});
|
||||
|
||||
function setPointDeductionRule(args) {
|
||||
const {
|
||||
equivalentPoints,
|
||||
maxDeductionAmount,enableRewards,minPaymentAmount,
|
||||
maxDeductionAmount,
|
||||
enableRewards,
|
||||
minPaymentAmount,
|
||||
maxDeductionRatio
|
||||
} = args
|
||||
pointDeductionRule.value.pointsPerYuan =equivalentPoints||0;
|
||||
pointDeductionRule.value.maxDeductionAmount = maxDeductionAmount||0;
|
||||
pointDeductionRule.value.maxDeductionRatio = maxDeductionRatio||0;
|
||||
pointDeductionRule.value.enableRewards = enableRewards||0;
|
||||
pointDeductionRule.value.minPaymentAmount = minPaymentAmount||0;
|
||||
pointDeductionRule.value.pointsPerYuan = equivalentPoints || 0;
|
||||
pointDeductionRule.value.maxDeductionAmount = maxDeductionAmount || 0;
|
||||
pointDeductionRule.value.maxDeductionRatio = maxDeductionRatio || 0;
|
||||
pointDeductionRule.value.enableRewards = enableRewards || 0;
|
||||
pointDeductionRule.value.minPaymentAmount = minPaymentAmount || 0;
|
||||
}
|
||||
|
||||
// 初始配置:默认无减免(固定金额 0 元)
|
||||
@@ -309,15 +311,55 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
// 用于记录已经处理过的消息的 msg_id
|
||||
const processedMessageIds = new Set();
|
||||
|
||||
|
||||
// 发送消息
|
||||
let socketSendMsg = (data) => {
|
||||
|
||||
}
|
||||
|
||||
//购物车商品信息补全初始化
|
||||
function cartsGoodsInfoInit(arr) {
|
||||
console.log('cartsGoodsInfoInit', arr)
|
||||
carts.value = arr
|
||||
.map((v) => {
|
||||
|
||||
const item = getProductDetails(v);
|
||||
if (!item) {
|
||||
return null
|
||||
}
|
||||
const is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount(v, limitTimeDiscount
|
||||
.value,
|
||||
shopInfo.value,
|
||||
shopUserInfo.value, 'product_id');
|
||||
return {
|
||||
...item,
|
||||
is_time_discount: is_time_discount ? 1 : 0
|
||||
}
|
||||
})
|
||||
.filter((v) => v);
|
||||
|
||||
const result = []
|
||||
if (arr && Array.isArray(arr)) {
|
||||
carts.value = arr
|
||||
.map((v) => {
|
||||
return getProductDetails(v);
|
||||
})
|
||||
.filter((v) => v);
|
||||
for (let cart of arr) {
|
||||
const findItem = carts.value.find(v => v.id == cart.id)
|
||||
if (findItem && findItem.is_time_discount != cart.is_time_discount) {
|
||||
result.push({
|
||||
id: cart.id,
|
||||
is_time_discount: findItem.is_time_discount
|
||||
})
|
||||
}
|
||||
}
|
||||
if (result.length > 0) {
|
||||
socketSendMsg({
|
||||
type: "shopping",
|
||||
operate_type: "bulk_edit",
|
||||
data: {
|
||||
cart: result
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -341,8 +383,6 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
const msgData = Message.data;
|
||||
// 初始化
|
||||
if (Message.operate_type == "init") {
|
||||
console.log("carts init Message", Message);
|
||||
console.log("carts init", msgData);
|
||||
if (!oldOrder.value.id) {
|
||||
limitTimeDiscount.value = Message.time_dis_info;
|
||||
}
|
||||
@@ -670,7 +710,8 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
orderCostSummary,
|
||||
setCoupons,
|
||||
userPoints,
|
||||
setUserPoints,pointDeductionRule,
|
||||
setUserPoints,
|
||||
pointDeductionRule,
|
||||
setPointDeductionRule,
|
||||
setOldOrder,
|
||||
//返回商品信息
|
||||
@@ -699,5 +740,6 @@ export const useCartsStore = defineStore("cart", () => {
|
||||
//限时折扣
|
||||
limitTimeDiscount,
|
||||
shopUserInfo,
|
||||
socketSendMsg,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user