合并冲突解决
This commit is contained in:
@@ -327,6 +327,15 @@
|
|||||||
|
|
||||||
function socketInit() {
|
function socketInit() {
|
||||||
cartsSocket = useWebSocket();
|
cartsSocket = useWebSocket();
|
||||||
|
cartStore.socketSendMsg=(data)=>{
|
||||||
|
cartsSocket.sendMessage({
|
||||||
|
...data,
|
||||||
|
table_code: uni.cache.get("tableCode"),
|
||||||
|
shop_id: uni.cache.get("shopId"),
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
cartsSocket.connect(socketInitPar, onMessage);
|
cartsSocket.connect(socketInitPar, onMessage);
|
||||||
}
|
}
|
||||||
const noPayStatus = {
|
const noPayStatus = {
|
||||||
|
|||||||
@@ -606,7 +606,7 @@
|
|||||||
import isBetween from 'dayjs/plugin/isBetween';
|
import isBetween from 'dayjs/plugin/isBetween';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
APIshopUserInfo
|
APIshopUserInfo,APIusershopInfodetail
|
||||||
} from "@/common/api/member.js";
|
} from "@/common/api/member.js";
|
||||||
dayjs.extend(isBetween);
|
dayjs.extend(isBetween);
|
||||||
import {
|
import {
|
||||||
@@ -619,7 +619,10 @@
|
|||||||
import {
|
import {
|
||||||
getDistance
|
getDistance
|
||||||
} from '@/utils/address.js';
|
} from '@/utils/address.js';
|
||||||
import {isObjectEqual,isArrayEqual} from './components/utils.js'
|
import {
|
||||||
|
isObjectEqual,
|
||||||
|
isArrayEqual
|
||||||
|
} from './components/utils.js'
|
||||||
|
|
||||||
|
|
||||||
//点单智能推荐
|
//点单智能推荐
|
||||||
@@ -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) {
|
async function onMessage(Message) {
|
||||||
if (Message) {
|
if (Message) {
|
||||||
@@ -1533,12 +1574,17 @@
|
|||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
if (Message.operate_type == 'init') {
|
if (Message.operate_type == 'init') {
|
||||||
cartStore.carts = Message.data;
|
|
||||||
cartStore.limitTimeDiscount = Message.time_dis_info;
|
cartStore.limitTimeDiscount = Message.time_dis_info;
|
||||||
|
cartInit(Message.data)
|
||||||
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
// 初始化商品数量
|
|
||||||
// setGoodsInitSel(Message.data)
|
if (!socketInitFinished) {
|
||||||
|
useSocket.chnageInitMessage(options.initMessage)
|
||||||
|
socketInitFinished = true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 转桌成功
|
// 转桌成功
|
||||||
@@ -2049,7 +2095,7 @@
|
|||||||
websocketsendMessage(data);
|
websocketsendMessage(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const juli=computed(()=>{
|
const juli = computed(() => {
|
||||||
const juli = getDistance(userStore.location.latitude, userStore.location.longitude, shopInfo.lat,
|
const juli = getDistance(userStore.location.latitude, userStore.location.longitude, shopInfo.lat,
|
||||||
shopInfo.lng);
|
shopInfo.lng);
|
||||||
return juli.toFixed(2)
|
return juli.toFixed(2)
|
||||||
@@ -2112,8 +2158,7 @@
|
|||||||
console.log('shopInfoRes===', shopInfoRes);
|
console.log('shopInfoRes===', shopInfoRes);
|
||||||
|
|
||||||
await computedDistance(shopInfoRes.shopInfo);
|
await computedDistance(shopInfoRes.shopInfo);
|
||||||
|
if (shopInfoRes.shopInfo.id !== shopInfo.id) {
|
||||||
if (shopInfoRes.shopInfo.id !== tableShopInfo.value.id) {
|
|
||||||
uni.showModal({
|
uni.showModal({
|
||||||
title: '注意',
|
title: '注意',
|
||||||
content: '扫码店铺与当前店铺不一致,请重新加载页面',
|
content: '扫码店铺与当前店铺不一致,请重新加载页面',
|
||||||
@@ -2151,13 +2196,22 @@
|
|||||||
orderType.value = e.type;
|
orderType.value = e.type;
|
||||||
}
|
}
|
||||||
//获取用户信息
|
//获取用户信息
|
||||||
const userInfo= await APIshopUserInfo({
|
const userInfo = await APIshopUserInfo({
|
||||||
shopId:uni.cache.get('shopId')
|
shopId: uni.cache.get('shopId')
|
||||||
})
|
})
|
||||||
|
//获取店铺信息
|
||||||
|
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
|
if (userInfo && typeof userInfo === 'object') {
|
||||||
uni.cache.set('shopUserInfo',userInfo)
|
shopUserInfo.value = userInfo
|
||||||
|
uni.cache.set('shopUserInfo', userInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
const extraInitPar = {}
|
const extraInitPar = {}
|
||||||
@@ -2170,9 +2224,7 @@
|
|||||||
...options.initMessage,
|
...options.initMessage,
|
||||||
...extraInitPar
|
...extraInitPar
|
||||||
}, onMessage);
|
}, onMessage);
|
||||||
setTimeout(()=>{
|
|
||||||
useSocket.chnageInitMessage(options.initMessage)
|
|
||||||
},500)
|
|
||||||
|
|
||||||
console.log('onLoad:e', e);
|
console.log('onLoad:e', e);
|
||||||
cartStore.setOldOrder({
|
cartStore.setOldOrder({
|
||||||
|
|||||||
@@ -152,21 +152,23 @@ export const useCartsStore = defineStore("cart", () => {
|
|||||||
enableRewards: 0, //是否开启
|
enableRewards: 0, //是否开启
|
||||||
pointsPerYuan: 0,
|
pointsPerYuan: 0,
|
||||||
maxDeductionAmount: Infinity,
|
maxDeductionAmount: Infinity,
|
||||||
maxDeductionRatio: 0 ,//积分抵扣比例
|
maxDeductionRatio: 0, //积分抵扣比例
|
||||||
minPaymentAmount:0,//门槛
|
minPaymentAmount: 0, //门槛
|
||||||
});
|
});
|
||||||
|
|
||||||
function setPointDeductionRule(args) {
|
function setPointDeductionRule(args) {
|
||||||
const {
|
const {
|
||||||
equivalentPoints,
|
equivalentPoints,
|
||||||
maxDeductionAmount,enableRewards,minPaymentAmount,
|
maxDeductionAmount,
|
||||||
|
enableRewards,
|
||||||
|
minPaymentAmount,
|
||||||
maxDeductionRatio
|
maxDeductionRatio
|
||||||
} = args
|
} = args
|
||||||
pointDeductionRule.value.pointsPerYuan =equivalentPoints||0;
|
pointDeductionRule.value.pointsPerYuan = equivalentPoints || 0;
|
||||||
pointDeductionRule.value.maxDeductionAmount = maxDeductionAmount||0;
|
pointDeductionRule.value.maxDeductionAmount = maxDeductionAmount || 0;
|
||||||
pointDeductionRule.value.maxDeductionRatio = maxDeductionRatio||0;
|
pointDeductionRule.value.maxDeductionRatio = maxDeductionRatio || 0;
|
||||||
pointDeductionRule.value.enableRewards = enableRewards||0;
|
pointDeductionRule.value.enableRewards = enableRewards || 0;
|
||||||
pointDeductionRule.value.minPaymentAmount = minPaymentAmount||0;
|
pointDeductionRule.value.minPaymentAmount = minPaymentAmount || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始配置:默认无减免(固定金额 0 元)
|
// 初始配置:默认无减免(固定金额 0 元)
|
||||||
@@ -309,15 +311,55 @@ export const useCartsStore = defineStore("cart", () => {
|
|||||||
// 用于记录已经处理过的消息的 msg_id
|
// 用于记录已经处理过的消息的 msg_id
|
||||||
const processedMessageIds = new Set();
|
const processedMessageIds = new Set();
|
||||||
|
|
||||||
|
|
||||||
|
// 发送消息
|
||||||
|
let socketSendMsg = (data) => {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//购物车商品信息补全初始化
|
//购物车商品信息补全初始化
|
||||||
function cartsGoodsInfoInit(arr) {
|
function cartsGoodsInfoInit(arr) {
|
||||||
console.log('cartsGoodsInfoInit', arr)
|
console.log('cartsGoodsInfoInit', arr)
|
||||||
if (arr && Array.isArray(arr)) {
|
|
||||||
carts.value = arr
|
carts.value = arr
|
||||||
.map((v) => {
|
.map((v) => {
|
||||||
return getProductDetails(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);
|
.filter((v) => v);
|
||||||
|
|
||||||
|
const result = []
|
||||||
|
if (arr && Array.isArray(arr)) {
|
||||||
|
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;
|
const msgData = Message.data;
|
||||||
// 初始化
|
// 初始化
|
||||||
if (Message.operate_type == "init") {
|
if (Message.operate_type == "init") {
|
||||||
console.log("carts init Message", Message);
|
|
||||||
console.log("carts init", msgData);
|
|
||||||
if (!oldOrder.value.id) {
|
if (!oldOrder.value.id) {
|
||||||
limitTimeDiscount.value = Message.time_dis_info;
|
limitTimeDiscount.value = Message.time_dis_info;
|
||||||
}
|
}
|
||||||
@@ -670,7 +710,8 @@ export const useCartsStore = defineStore("cart", () => {
|
|||||||
orderCostSummary,
|
orderCostSummary,
|
||||||
setCoupons,
|
setCoupons,
|
||||||
userPoints,
|
userPoints,
|
||||||
setUserPoints,pointDeductionRule,
|
setUserPoints,
|
||||||
|
pointDeductionRule,
|
||||||
setPointDeductionRule,
|
setPointDeductionRule,
|
||||||
setOldOrder,
|
setOldOrder,
|
||||||
//返回商品信息
|
//返回商品信息
|
||||||
@@ -699,5 +740,6 @@ export const useCartsStore = defineStore("cart", () => {
|
|||||||
//限时折扣
|
//限时折扣
|
||||||
limitTimeDiscount,
|
limitTimeDiscount,
|
||||||
shopUserInfo,
|
shopUserInfo,
|
||||||
|
socketSendMsg,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user