From 07367263363622105ca88fa47e453bb5aacdbca2 Mon Sep 17 00:00:00 2001
From: YeMingfei666 <1619116647@qq.com>
Date: Wed, 24 Dec 2025 13:42:00 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=83=A8=E5=88=86=E8=B0=83?=
=?UTF-8?q?=E8=AF=95=E6=89=93=E5=8D=B0=EF=BC=8C=E4=BC=98=E5=8C=96=E7=8E=AF?=
=?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=E6=8E=A7=E5=88=B6=EF=BC=8C=E4=BF=AE?=
=?UTF-8?q?=E5=A4=8D=E5=86=8D=E6=9D=A5=E4=B8=80=E5=8D=95=E5=8F=AA=E6=9C=89?=
=?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=95=86=E5=93=81=E6=97=B6=E8=87=AA=E5=8A=A8?=
=?UTF-8?q?=E5=BC=B9=E5=87=BA=E5=9B=BE=E7=89=87=E9=A2=84=E8=A7=88=E9=97=AE?=
=?UTF-8?q?=E9=A2=98=EF=BC=8C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
common/api/request.js | 29 +++++++++-
common/config.js | 51 ++++++++++-------
components/modal-list.vue | 1 -
components/order-finish-modal.vue | 1 -
components/xb-swiper-preview/index.vue | 2 +-
pages/order/components/orderInfo.vue | 15 ++++-
pages/order/confirm-order.vue | 14 ++++-
.../components/recommend-goods-modal.vue | 1 -
pages/product/components/shoppingCartes.vue | 9 +--
pages/product/index.vue | 57 ++++++++++++-------
stores/carts-websocket.js | 1 -
stores/carts.js | 14 ++++-
.../wmf-code/components/w-qrcode/w-qrcode.vue | 1 -
vite.config.js | 5 ++
14 files changed, 136 insertions(+), 65 deletions(-)
diff --git a/common/api/request.js b/common/api/request.js
index d708f06..d4d6a86 100644
--- a/common/api/request.js
+++ b/common/api/request.js
@@ -1,4 +1,3 @@
-
export default async (params) => {
let url = params.url;
let method = params.method || "get";
@@ -9,7 +8,31 @@ export default async (params) => {
const shopId = uni.cache.get("shopId") * 1;
const userInfo = uni.cache.get("userInfo") || {};
// #ifdef H5
- token = "b61c8b0f1c9d47ad924e33c48b496ce6";
+ token = "1b5e8baf0cc1492a858a208f113d0971";
+ uni.cache.set('userInfo', {
+ "acQrcodeValidTime": "2026-01-13 13:35:59",
+ "alipayOpenId": "",
+ "birthDay": "",
+ "createTime": "2024-03-13 10:56:40",
+ "distributionAmount": 0,
+ "headImg": "https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132",
+ "id": "36689",
+ "idCard": "",
+ "isAc": 0,
+ "lastLoginTime": "2025-12-24 11:24:12",
+ "nickName": "微信用户",
+ "password": "",
+ "payPwd": "e10adc3949ba59abbe56e057f20f883e",
+ "phone": "",
+ "realName": "",
+ "sex": null,
+ "status": 1,
+ "updateTime": "2025-12-24 11:22:47",
+ "usePayPwd": 0,
+ "wechatAcOpenId": "",
+ "wechatAcQrcode": "http://weixin.qq.com/q/029s5JtP1xfmJ1g_HDxFco",
+ "wechatOpenId": "or1l86yipGvwyfPhrKIAcQuSfAV8"
+ })
// #endif
let header = {
version: uni.conf.version,
@@ -37,7 +60,7 @@ export default async (params) => {
mask: true,
});
}
-
+
return new Promise((resolve, reject) => {
const timeoutDuration = params.timeout || 10000; // 可以通过 params 传入超时时间,默认 10 秒
uni.request({
diff --git a/common/config.js b/common/config.js
index 226f1b6..a1d0fa7 100644
--- a/common/config.js
+++ b/common/config.js
@@ -1,29 +1,38 @@
// const debug = process.env.NODE_ENV == 'development' ? true : false;
const debug = false; // false线上 true本地
-// #ifdef H5
-const proxyApi = "/api";
-// #endif
+let baseUrl = ''
+let baseUrlwws = ''
-// #ifdef MP-WEIXIN || APP || MP-ALIPAY
-const proxyApi = "http://192.168.1.42"; // 调试地址
-const proxyApiwws = "ws://192.168.1.42:2348"; // 调试地址
-// #endif
-// #ifdef H5
-const baseUrl = debug ? proxyApi : "http://192.168.1.42";
-const baseUrlwws = "ws://192.168.1.42:2348";
-// #endif
-
-// #ifdef APP || MP-WEIXIN || MP-ALIPAY
-const baseUrl = debug ? proxyApi : "https://cashier.sxczgkj.com"; // 线上
-const baseUrlwws = debug ? proxyApiwws : "wss://czgeatws.sxczgkj.com/wss"; // 线上
-// #endif
const version = "100";
const autoRemoveCache = {
count: 100000,
size: 100000,
};
+
+function init(){
+ if (debug) {
+ baseUrl = 'http://192.168.1.42'
+ baseUrlwws = "ws://192.168.1.42:2348";
+ } else {
+ baseUrl = 'https://cashier.sxczgkj.com'
+ baseUrlwws = "wss://czgeatws.sxczgkj.com/wss";
+ }
+ // #ifdef H5
+
+ if (debug) {
+ baseUrl = "/api";
+ baseUrlwws = "http://192.168.1.42:2348";
+ } else {
+ baseUrl = "/prodApi";
+ baseUrlwws = "https://czgeatws.sxczgkj.com/wss";
+ }
+ // #endif
+}
+
+init()
+
uni.conf = {
debug,
baseUrl,
@@ -36,10 +45,10 @@ uni.conf = {
export const changeEnv = (env) => {
if (env === "test") {
let baseUrl = "http://192.168.1.42"
- let baseUrlwws="ws://192.168.1.42:2348"
+ let baseUrlwws = "ws://192.168.1.42:2348"
// #ifdef H5
baseUrl = "/api"
- baseUrlwws="http://192.168.1.42:2348"
+ baseUrlwws = "http://192.168.1.42:2348"
// #endif
uni.conf = {
debug: true,
@@ -52,9 +61,13 @@ export const changeEnv = (env) => {
};
}
if (env === "prod") {
+ let baseUrl = "https://cashier.sxczgkj.com"
+ // #ifdef H5
+ baseUrl = "/prodApi"
+ // #endif
uni.conf = {
debug: false,
- baseUrl: "https://cashier.sxczgkj.com",
+ baseUrl,
version: 100,
autoRemoveCache,
baseUrlwws: "wss://czgeatws.sxczgkj.com/wss",
diff --git a/components/modal-list.vue b/components/modal-list.vue
index 49d1714..0b0005c 100644
--- a/components/modal-list.vue
+++ b/components/modal-list.vue
@@ -34,7 +34,6 @@ const showCoupon = ref(false);
const showOfficialAccount = ref(false);
function modelClose(e, type) {
- console.log("modelClose", type);
if (type == "birthdayGift") {
showCoupon.value = true;
return;
diff --git a/components/order-finish-modal.vue b/components/order-finish-modal.vue
index b2c6d25..af51db7 100644
--- a/components/order-finish-modal.vue
+++ b/components/order-finish-modal.vue
@@ -33,7 +33,6 @@ watch(showDrainage, (newVal, oldVal) => {
const showOfficialAccount = ref(false);
function modelClose(e, type) {
- console.log('modelClose', type);
if (type == 'drainage') {
showOfficialAccount.value = true;
return;
diff --git a/components/xb-swiper-preview/index.vue b/components/xb-swiper-preview/index.vue
index fce147e..d2b0068 100644
--- a/components/xb-swiper-preview/index.vue
+++ b/components/xb-swiper-preview/index.vue
@@ -75,7 +75,7 @@
export default {
props: {
imgs: {
- type: [],
+ type: Array,
default: () => [],
},
visable: {
diff --git a/pages/order/components/orderInfo.vue b/pages/order/components/orderInfo.vue
index 32dedf6..84d569f 100644
--- a/pages/order/components/orderInfo.vue
+++ b/pages/order/components/orderInfo.vue
@@ -475,6 +475,9 @@
}
const showDiscount = computed(() => {
+ if(!props.listinfo.id||props.listinfo.status!='done'){
+ return false
+ }
const keys = ['productCouponDiscountAmount', 'otherCouponDiscountAmount',
'pointsDiscountAmount', 'discountActAmount', 'newCustomerDiscountAmount', 'vipDiscountAmount'
]
@@ -715,9 +718,15 @@
const newUserDiscount = ref(0);
const back_favorablelist = toRaw(favorablelist.value);
async function getConsumeDiscount() {
- const consumeDiscountRes = await consumeDiscount({
- shopId: uni.cache.get("shopId"),
- });
+ let consumeDiscountRes =null
+ if(cartStore.consumeDiscount&&cartStore.newUserDiscount){
+ consumeDiscountRes=cartStore.consumeDiscount
+ }else{
+ consumeDiscountRes = await consumeDiscount({
+ shopId: uni.cache.get("shopId"),
+ });
+ }
+
if (!consumeDiscountRes) {
favorablelist.value = back_favorablelist.filter(
(v) => v.name != "新客立减"
diff --git a/pages/order/confirm-order.vue b/pages/order/confirm-order.vue
index ae3ad22..813a544 100644
--- a/pages/order/confirm-order.vue
+++ b/pages/order/confirm-order.vue
@@ -1032,7 +1032,17 @@
// 跳转到加菜页面
function toJiacai() {
console.log("跳转到加菜页面");
- back();
+ const arr= getCurrentPages()
+ console.log(arr);
+ if(arr[arr.length-1]&&arr[arr.length-1].route=='pages/product/index'){
+ back();
+ }else{
+ uni.cache.set('tableCode',listinfo.tableCode)
+ uni.cache.set('shopId',listinfo.shopId)
+ uni.redirectTo({
+ url:'/pages/product/index?noJump=1'
+ })
+ }
}
const packfee = computed(() => {
return cartStore.orderCostSummary.packFee;
@@ -1068,6 +1078,8 @@
//支付成功后的处理
async function paySucessCallback() {
console.log("paySucessCallback");
+ uni.$emit('updateProductIndex')
+ cartStore.clearDiscount()
orderorderInfo(true);
cartsSocket.closeSocket();
showDrainage.value = true;
diff --git a/pages/product/components/recommend-goods-modal.vue b/pages/product/components/recommend-goods-modal.vue
index 1c47c5a..90e2ac6 100644
--- a/pages/product/components/recommend-goods-modal.vue
+++ b/pages/product/components/recommend-goods-modal.vue
@@ -124,7 +124,6 @@ onMounted(() => {
};
})
.filter((v) => v.goods);
- console.log('list.value ', list.value )
startWatch();
}
});
diff --git a/pages/product/components/shoppingCartes.vue b/pages/product/components/shoppingCartes.vue
index a2c52f0..907f439 100644
--- a/pages/product/components/shoppingCartes.vue
+++ b/pages/product/components/shoppingCartes.vue
@@ -195,14 +195,7 @@
);
}
- watch(
- () => props.cartList,
- (newCartList) => {
- console.log("购物车数据变化", newCartList);
- }, {
- deep: true,
- }
- );
+
const shopInfo = ref(uni.cache.get("shopInfo"));
const shopUserInfo = ref(uni.cache.get("shopUserInfo"));
diff --git a/pages/product/index.vue b/pages/product/index.vue
index 3221308..63dcd80 100644
--- a/pages/product/index.vue
+++ b/pages/product/index.vue
@@ -26,7 +26,7 @@
距离您{{ juli }}km
-
+
新客立减¥
{{ newUserDiscount.amount }}
@@ -52,7 +52,7 @@
-
限时折扣{{ limitDiscountCountdown }}
@@ -197,8 +197,8 @@
-
-
+
@@ -810,10 +810,7 @@
productInfo: []
});
- // * 图片加载
- const imageLoaded = (item, index, index1) => {
- // shopProductList.productInfo[index].products[index1]['imgLoad'] = true;
- };
+
// 计算左侧位置
const leftIndex = ref(0);
@@ -1272,6 +1269,10 @@
//预览图
const showPrveImg = ref(false);
const prveImgsList = ref([]);
+
+ function updateShowPrveImg(e){
+ showPrveImg.value=e
+ }
function prveImgs(images) {
prveImgsList.value = images;
@@ -1283,14 +1284,15 @@
});
}
- async function getImgs(item) {
+ async function getProductImgs(item) {
+ console.log('getProductImgs',item)
let res = await APIminiAppinfo(item.id);
prveImgs(res.images);
}
//获取多规格数据
const clickspecifications = async (item, index, indexs, type) => {
- console.log(item);
+ console.log('clickspecifications',item);
// 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
// if (
// item.isSoldStock == 1 ||
@@ -1584,9 +1586,10 @@
function cartInit(arr) {
const result = []
- console.log('cartInit arr',arr);
+ console.log('cartInitArr',arr);
+ console.log('allGoodsArr',allGoodsArr);
cartStore.carts = arr.map(v => {
- const goods = matchedProducts.value.find(g => g.id == v.product_id)
+ const goods = allGoodsArr.find(g => g.id == v.product_id)
const goodsSkuList = goods?goods.skuList : []
const findSku = goodsSkuList.find(sku => sku.id == v.sku_id)
const memberPrice = findSku ? findSku.memberPrice : 0
@@ -1614,8 +1617,6 @@
for (let cart of arr) {
const findItem = cartStore.carts.find(v => v.id == cart.id)
- console.log('findItem', findItem)
- console.log('matchedProducts', matchedProducts.value)
if (findItem && findItem.is_time_discount != cart.is_time_discount) {
result.push({
id: cart.id,
@@ -1656,7 +1657,6 @@
// 初始化
if (Message.operate_type == 'init') {
// cartStore.limitTimeDiscount = Message.time_dis_info;
- console.log('onMessage:限时折扣', cartStore.limitTimeDiscount)
cartInit(Message.data)
uni.hideLoading();
@@ -1950,7 +1950,6 @@
shopUserInfo: shopUserInfo.value,
idKey: 'id'
});
- console.log('限时折扣', price)
return total + parseFloat(price) * parseFloat(item.cartNumber);
}
// 是否启用会员价 0否1是
@@ -1973,8 +1972,8 @@
const allDiscountMoney = computed(() => {
let discountMoney = 0;
// 新客立减
- if (newUserDiscount.value && newUserDiscount.value.discountAmount) {
- discountMoney += newUserDiscount.value.discountAmount;
+ if (newUserDiscount.value && newUserDiscount.value.amount) {
+ discountMoney += newUserDiscount.value.amount;
}
// 满减活动
if (fullAmountActivty.value && fullAmountActivty.value.discountAmount) {
@@ -2085,10 +2084,11 @@
}
return currentTime >= startTime && currentTime <= endTime;
});
-
+ let allGoodsArr=[]
// 列表请求
const productqueryProduct = async () => {
cartStore.goodsIsloading = false;
+ allGoodsArr=[]
try {
shopProductList.hots = await productminiApphotsquery();
shopProductList.productInfo = await APIgroupquery();
@@ -2101,7 +2101,6 @@
uni.pro.switchTab('index/index');
}, 1000);
}
- let allGoodsArr=[]
if (shopProductList.productInfo.length > 0 || shopProductList.hots.length > 0) {
//TODO handle the exception
//第一步:将所有商品的 cartNumber 初始化为 0
@@ -2382,7 +2381,7 @@
tableCode: uni.cache.get('tableCode')
});
oldOrder.value = res;
- if (res && res.id && shopInfo.registerType == 'after') {
+ if (res && res.id && shopInfo.registerType == 'after'&&!e.noJump) {
toHistory();
return;
}
@@ -2442,10 +2441,18 @@
idKey: 'id'
});
}
+
+ function watchEmit(){
+ uni.$off('updateProductIndex')
+ uni.$on('updateProductIndex', function(data) {
+ getNewUserDiscount()
+ })
+ }
onShow(async () => {
isAutoClose = true;
// 监听页面显示和隐藏
+ watchEmit()
useSocket.setOnMessage(onMessage);
useSocket.onShowconnect();
let res = await APIhistoryOrder({
@@ -2489,6 +2496,12 @@
});
if (res && typeof res == 'object') {
newUserDiscount.value = res;
+ cartStore.consumeDiscount=res
+ cartStore.newUserDiscount=res.amount
+ }else{
+ newUserDiscount.value = null;
+ cartStore.consumeDiscount={}
+ cartStore.newUserDiscount=0
}
}
diff --git a/stores/carts-websocket.js b/stores/carts-websocket.js
index facdd39..c79e699 100644
--- a/stores/carts-websocket.js
+++ b/stores/carts-websocket.js
@@ -233,7 +233,6 @@ export const useWebSocket = defineStore('socketTask', () => {
// 发送消息
const sendMessage = (data) => {
- console.log('data',data)
if(!data){
return
}
diff --git a/stores/carts.js b/stores/carts.js
index 384c1f2..824a79a 100644
--- a/stores/carts.js
+++ b/stores/carts.js
@@ -97,7 +97,6 @@ export const useCartsStore = defineStore("cart", () => {
.flat()
.map(convertToBaseCartItem);
- console.log('oldOrder.value', oldOrder.value)
if (!oldOrder.value.id) {
}
@@ -469,7 +468,6 @@ export const useCartsStore = defineStore("cart", () => {
});
function setOldOrder(data) {
- console.log("setOldOrder", data);
oldOrder.value = data;
allGoods.value = getAllGoodsList();
}
@@ -695,8 +693,18 @@ export const useCartsStore = defineStore("cart", () => {
originAmount: 0,
};
}
-
+
+ // 重置优惠
+ function clearDiscount(){
+ newUserDiscount.value=0;
+ consumeDiscount.value={}
+ fullReductionActivities.value = [];
+ isFreeDine.value = false;
+ userPoints.value = 0;
+ }
+
return {
+ clearDiscount,
getTotalPackFee,
getTotalSeatcharge,
getTotalTotalPrices,
diff --git a/uni_modules/wmf-code/components/w-qrcode/w-qrcode.vue b/uni_modules/wmf-code/components/w-qrcode/w-qrcode.vue
index e2f2f36..a9c87c7 100644
--- a/uni_modules/wmf-code/components/w-qrcode/w-qrcode.vue
+++ b/uni_modules/wmf-code/components/w-qrcode/w-qrcode.vue
@@ -44,7 +44,6 @@
id: getUUid(),
})
onMounted(()=>{
- console.log('w-qrcode:mounted')
SpecialTreatment(opt);
nextTick(()=>{
generateCode(opt)
diff --git a/vite.config.js b/vite.config.js
index 9eab6e6..d52247b 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -39,6 +39,11 @@ module.exports = defineConfig({
changeOrigin: true, // 是否更改请求源
rewrite: path => path.replace(/^\/api/, '')
},
+ '/prodApi': {
+ target: 'https://cashier.sxczgkj.com', // 目标服务器地址
+ changeOrigin: true, // 是否更改请求源
+ rewrite: path => path.replace(/^\/prodApi/, '')
+ },
},
},
});
\ No newline at end of file