This commit is contained in:
2025-12-24 13:44:00 +08:00
14 changed files with 137 additions and 66 deletions

View File

@@ -1,4 +1,3 @@
export default async (params) => { export default async (params) => {
let url = params.url; let url = params.url;
let method = params.method || "get"; let method = params.method || "get";
@@ -9,7 +8,31 @@ export default async (params) => {
const shopId = uni.cache.get("shopId") * 1; const shopId = uni.cache.get("shopId") * 1;
const userInfo = uni.cache.get("userInfo") || {}; const userInfo = uni.cache.get("userInfo") || {};
// #ifdef H5 // #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 // #endif
let header = { let header = {
version: uni.conf.version, version: uni.conf.version,
@@ -37,7 +60,7 @@ export default async (params) => {
mask: true, mask: true,
}); });
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const timeoutDuration = params.timeout || 10000; // 可以通过 params 传入超时时间,默认 10 秒 const timeoutDuration = params.timeout || 10000; // 可以通过 params 传入超时时间,默认 10 秒
uni.request({ uni.request({

View File

@@ -1,29 +1,38 @@
// const debug = process.env.NODE_ENV == 'development' ? true : false; // const debug = process.env.NODE_ENV == 'development' ? true : false;
const debug = true; // false线上 true本地 const debug = false; // false线上 true本地
// #ifdef H5 let baseUrl = ''
const proxyApi = "/api"; let baseUrlwws = ''
// #endif
// #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 version = "100";
const autoRemoveCache = { const autoRemoveCache = {
count: 100000, count: 100000,
size: 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 = { uni.conf = {
debug, debug,
baseUrl, baseUrl,
@@ -36,10 +45,10 @@ uni.conf = {
export const changeEnv = (env) => { export const changeEnv = (env) => {
if (env === "test") { if (env === "test") {
let baseUrl = "http://192.168.1.42" 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 // #ifdef H5
baseUrl = "/api" baseUrl = "/api"
baseUrlwws="http://192.168.1.42:2348" baseUrlwws = "http://192.168.1.42:2348"
// #endif // #endif
uni.conf = { uni.conf = {
debug: true, debug: true,
@@ -52,9 +61,13 @@ export const changeEnv = (env) => {
}; };
} }
if (env === "prod") { if (env === "prod") {
let baseUrl = "https://cashier.sxczgkj.com"
// #ifdef H5
baseUrl = "/prodApi"
// #endif
uni.conf = { uni.conf = {
debug: false, debug: false,
baseUrl: "https://cashier.sxczgkj.com", baseUrl,
version: 100, version: 100,
autoRemoveCache, autoRemoveCache,
baseUrlwws: "wss://czgeatws.sxczgkj.com/wss", baseUrlwws: "wss://czgeatws.sxczgkj.com/wss",

View File

@@ -34,7 +34,6 @@ const showCoupon = ref(false);
const showOfficialAccount = ref(false); const showOfficialAccount = ref(false);
function modelClose(e, type) { function modelClose(e, type) {
console.log("modelClose", type);
if (type == "birthdayGift") { if (type == "birthdayGift") {
showCoupon.value = true; showCoupon.value = true;
return; return;

View File

@@ -33,7 +33,6 @@ watch(showDrainage, (newVal, oldVal) => {
const showOfficialAccount = ref(false); const showOfficialAccount = ref(false);
function modelClose(e, type) { function modelClose(e, type) {
console.log('modelClose', type);
if (type == 'drainage') { if (type == 'drainage') {
showOfficialAccount.value = true; showOfficialAccount.value = true;
return; return;

View File

@@ -75,7 +75,7 @@
export default { export default {
props: { props: {
imgs: { imgs: {
type: [], type: Array,
default: () => [], default: () => [],
}, },
visable: { visable: {

View File

@@ -475,6 +475,9 @@
} }
const showDiscount = computed(() => { const showDiscount = computed(() => {
if(!props.listinfo.id||props.listinfo.status!='done'){
return false
}
const keys = ['productCouponDiscountAmount', 'otherCouponDiscountAmount', const keys = ['productCouponDiscountAmount', 'otherCouponDiscountAmount',
'pointsDiscountAmount', 'discountActAmount', 'newCustomerDiscountAmount', 'vipDiscountAmount' 'pointsDiscountAmount', 'discountActAmount', 'newCustomerDiscountAmount', 'vipDiscountAmount'
] ]
@@ -715,9 +718,15 @@
const newUserDiscount = ref(0); const newUserDiscount = ref(0);
const back_favorablelist = toRaw(favorablelist.value); const back_favorablelist = toRaw(favorablelist.value);
async function getConsumeDiscount() { async function getConsumeDiscount() {
const consumeDiscountRes = await consumeDiscount({ let consumeDiscountRes =null
shopId: uni.cache.get("shopId"), if(cartStore.consumeDiscount&&cartStore.newUserDiscount){
}); consumeDiscountRes=cartStore.consumeDiscount
}else{
consumeDiscountRes = await consumeDiscount({
shopId: uni.cache.get("shopId"),
});
}
if (!consumeDiscountRes) { if (!consumeDiscountRes) {
favorablelist.value = back_favorablelist.filter( favorablelist.value = back_favorablelist.filter(
(v) => v.name != "新客立减" (v) => v.name != "新客立减"

View File

@@ -1032,7 +1032,17 @@
// 跳转到加菜页面 // 跳转到加菜页面
function toJiacai() { function toJiacai() {
console.log("跳转到加菜页面"); 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(() => { const packfee = computed(() => {
return cartStore.orderCostSummary.packFee; return cartStore.orderCostSummary.packFee;
@@ -1068,6 +1078,8 @@
//支付成功后的处理 //支付成功后的处理
async function paySucessCallback() { async function paySucessCallback() {
console.log("paySucessCallback"); console.log("paySucessCallback");
uni.$emit('updateProductIndex')
cartStore.clearDiscount()
orderorderInfo(true); orderorderInfo(true);
cartsSocket.closeSocket(); cartsSocket.closeSocket();
showDrainage.value = true; showDrainage.value = true;

View File

@@ -124,7 +124,6 @@ onMounted(() => {
}; };
}) })
.filter((v) => v.goods); .filter((v) => v.goods);
console.log('list.value ', list.value )
startWatch(); startWatch();
} }
}); });

View File

@@ -195,14 +195,7 @@
); );
} }
watch(
() => props.cartList,
(newCartList) => {
console.log("购物车数据变化", newCartList);
}, {
deep: true,
}
);
const shopInfo = ref(uni.cache.get("shopInfo")); const shopInfo = ref(uni.cache.get("shopInfo"));
const shopUserInfo = ref(uni.cache.get("shopUserInfo")); const shopUserInfo = ref(uni.cache.get("shopUserInfo"));

View File

@@ -26,7 +26,7 @@
<view class="paneltow">距离您{{ juli }}km</view> <view class="paneltow">距离您{{ juli }}km</view>
<!-- <up-icon name="arrow-right" color="#999999" size="14"></up-icon> --> <!-- <up-icon name="arrow-right" color="#999999" size="14"></up-icon> -->
</view> </view>
<view class="new-user-discount u-font-28" v-if="newUserDiscount"> <view class="new-user-discount u-font-28" v-if="newUserDiscount&&newUserDiscount.amount">
<text class="">新客立减¥</text> <text class="">新客立减¥</text>
<text class="u-font-32">{{ newUserDiscount.amount }}</text> <text class="u-font-32">{{ newUserDiscount.amount }}</text>
<!-- <text class="u-m-l-60">新客可随机减免金额</text> --> <!-- <text class="u-m-l-60">新客可随机减免金额</text> -->
@@ -52,7 +52,7 @@
<view class="relative"> <view class="relative">
<image @click.stop="getImgs(item)" class="panelfiveitemimage" :src="item.coverImg" <image @click.stop="getProductImgs(item)" class="panelfiveitemimage" :src="item.coverImg"
mode="aspectFill"></image> mode="aspectFill"></image>
<view class="limitDiscount" v-if="showLimitDiscount(item)"> <view class="limitDiscount" v-if="showLimitDiscount(item)">
限时折扣{{ limitDiscountCountdown }}</view> 限时折扣{{ limitDiscountCountdown }}</view>
@@ -197,8 +197,8 @@
<view class="goods" @click="clickspecifications(item1, index, index1)" <view class="goods" @click="clickspecifications(item1, index, index1)"
v-for="(item1, index1) in item.productList" :key="item1.id"> v-for="(item1, index1) in item.productList" :key="item1.id">
<view class="relative"> <view class="relative">
<image class="goodsImg" @click.stop="getImgs(item1)" v-if="item1.coverImg != null" <image class="goodsImg" @click.stop="getProductImgs(item1)" v-if="item1.coverImg != null"
:lazy-load="true" @load="imageLoaded(item1, index, index1)" :lazy-load="true"
:src="`${item1.coverImg}${!item1.imgLoad ? '?x-oss-process=image/resize,m_lfit,w_150,h_150' : ''}`" :src="`${item1.coverImg}${!item1.imgLoad ? '?x-oss-process=image/resize,m_lfit,w_150,h_150' : ''}`"
mode="aspectFill"></image> mode="aspectFill"></image>
<image class="goodsImg" <image class="goodsImg"
@@ -537,7 +537,7 @@
<ModalList></ModalList> <ModalList></ModalList>
<recommendGoodsModal v-if="isDataLoaded" @onBuyClick="onBuyClick"></recommendGoodsModal> <recommendGoodsModal v-if="isDataLoaded" @onBuyClick="onBuyClick"></recommendGoodsModal>
<goodsModal></goodsModal> <goodsModal></goodsModal>
<xbSwiperPreview :visable="showPrveImg" :imgs="prveImgsList" @update:visable="showPrveImg = $event"> <xbSwiperPreview :visable="showPrveImg" :imgs="prveImgsList" @update:visable="updateShowPrveImg">
</xbSwiperPreview> </xbSwiperPreview>
<!-- 显示选择人数popup --> <!-- 显示选择人数popup -->
<u-popup mode="bottom" :safe-area-inset-bottom="false" :show="showTableInfoPeopleNumPopup"> <u-popup mode="bottom" :safe-area-inset-bottom="false" :show="showTableInfoPeopleNumPopup">
@@ -810,10 +810,7 @@
productInfo: [] productInfo: []
}); });
// * 图片加载
const imageLoaded = (item, index, index1) => {
// shopProductList.productInfo[index].products[index1]['imgLoad'] = true;
};
// 计算左侧位置 // 计算左侧位置
const leftIndex = ref(0); const leftIndex = ref(0);
@@ -1272,6 +1269,10 @@
//预览图 //预览图
const showPrveImg = ref(false); const showPrveImg = ref(false);
const prveImgsList = ref([]); const prveImgsList = ref([]);
function updateShowPrveImg(e){
showPrveImg.value=e
}
function prveImgs(images) { function prveImgs(images) {
prveImgsList.value = 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); let res = await APIminiAppinfo(item.id);
prveImgs(res.images); prveImgs(res.images);
} }
//获取多规格数据 //获取多规格数据
const clickspecifications = async (item, index, indexs, type) => { const clickspecifications = async (item, index, indexs, type) => {
console.log(item); console.log('clickspecifications',item);
// 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券 // 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
// if ( // if (
// item.isSoldStock == 1 || // item.isSoldStock == 1 ||
@@ -1584,9 +1586,10 @@
function cartInit(arr) { function cartInit(arr) {
const result = [] const result = []
console.log('cartInit arr',arr); console.log('cartInitArr',arr);
console.log('allGoodsArr',allGoodsArr);
cartStore.carts = arr.map(v => { 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 goodsSkuList = goods?goods.skuList : []
const findSku = goodsSkuList.find(sku => sku.id == v.sku_id) const findSku = goodsSkuList.find(sku => sku.id == v.sku_id)
const memberPrice = findSku ? findSku.memberPrice : 0 const memberPrice = findSku ? findSku.memberPrice : 0
@@ -1614,8 +1617,6 @@
for (let cart of arr) { for (let cart of arr) {
const findItem = cartStore.carts.find(v => v.id == cart.id) 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) { if (findItem && findItem.is_time_discount != cart.is_time_discount) {
result.push({ result.push({
id: cart.id, id: cart.id,
@@ -1656,7 +1657,6 @@
// 初始化 // 初始化
if (Message.operate_type == 'init') { if (Message.operate_type == 'init') {
// cartStore.limitTimeDiscount = Message.time_dis_info; // cartStore.limitTimeDiscount = Message.time_dis_info;
console.log('onMessage限时折扣', cartStore.limitTimeDiscount)
cartInit(Message.data) cartInit(Message.data)
uni.hideLoading(); uni.hideLoading();
@@ -1950,7 +1950,6 @@
shopUserInfo: shopUserInfo.value, shopUserInfo: shopUserInfo.value,
idKey: 'id' idKey: 'id'
}); });
console.log('限时折扣', price)
return total + parseFloat(price) * parseFloat(item.cartNumber); return total + parseFloat(price) * parseFloat(item.cartNumber);
} }
// 是否启用会员价 0否1是 // 是否启用会员价 0否1是
@@ -1973,8 +1972,8 @@
const allDiscountMoney = computed(() => { const allDiscountMoney = computed(() => {
let discountMoney = 0; let discountMoney = 0;
// 新客立减 // 新客立减
if (newUserDiscount.value && newUserDiscount.value.discountAmount) { if (newUserDiscount.value && newUserDiscount.value.amount) {
discountMoney += newUserDiscount.value.discountAmount; discountMoney += newUserDiscount.value.amount;
} }
// 满减活动 // 满减活动
if (fullAmountActivty.value && fullAmountActivty.value.discountAmount) { if (fullAmountActivty.value && fullAmountActivty.value.discountAmount) {
@@ -2085,10 +2084,11 @@
} }
return currentTime >= startTime && currentTime <= endTime; return currentTime >= startTime && currentTime <= endTime;
}); });
let allGoodsArr=[]
// 列表请求 // 列表请求
const productqueryProduct = async () => { const productqueryProduct = async () => {
cartStore.goodsIsloading = false; cartStore.goodsIsloading = false;
allGoodsArr=[]
try { try {
shopProductList.hots = await productminiApphotsquery(); shopProductList.hots = await productminiApphotsquery();
shopProductList.productInfo = await APIgroupquery(); shopProductList.productInfo = await APIgroupquery();
@@ -2101,7 +2101,6 @@
uni.pro.switchTab('index/index'); uni.pro.switchTab('index/index');
}, 1000); }, 1000);
} }
let allGoodsArr=[]
if (shopProductList.productInfo.length > 0 || shopProductList.hots.length > 0) { if (shopProductList.productInfo.length > 0 || shopProductList.hots.length > 0) {
//TODO handle the exception //TODO handle the exception
//第一步:将所有商品的 cartNumber 初始化为 0 //第一步:将所有商品的 cartNumber 初始化为 0
@@ -2382,7 +2381,7 @@
tableCode: uni.cache.get('tableCode') tableCode: uni.cache.get('tableCode')
}); });
oldOrder.value = res; oldOrder.value = res;
if (res && res.id && shopInfo.registerType == 'after') { if (res && res.id && shopInfo.registerType == 'after'&&!e.noJump) {
toHistory(); toHistory();
return; return;
} }
@@ -2442,10 +2441,18 @@
idKey: 'id' idKey: 'id'
}); });
} }
function watchEmit(){
uni.$off('updateProductIndex')
uni.$on('updateProductIndex', function(data) {
getNewUserDiscount()
})
}
onShow(async () => { onShow(async () => {
isAutoClose = true; isAutoClose = true;
// 监听页面显示和隐藏 // 监听页面显示和隐藏
watchEmit()
useSocket.setOnMessage(onMessage); useSocket.setOnMessage(onMessage);
useSocket.onShowconnect(); useSocket.onShowconnect();
let res = await APIhistoryOrder({ let res = await APIhistoryOrder({
@@ -2489,6 +2496,12 @@
}); });
if (res && typeof res == 'object') { if (res && typeof res == 'object') {
newUserDiscount.value = res; newUserDiscount.value = res;
cartStore.consumeDiscount=res
cartStore.newUserDiscount=res.amount
}else{
newUserDiscount.value = null;
cartStore.consumeDiscount={}
cartStore.newUserDiscount=0
} }
} }

View File

@@ -233,7 +233,6 @@ export const useWebSocket = defineStore('socketTask', () => {
// 发送消息 // 发送消息
const sendMessage = (data) => { const sendMessage = (data) => {
console.log('data',data)
if(!data){ if(!data){
return return
} }

View File

@@ -97,7 +97,6 @@ export const useCartsStore = defineStore("cart", () => {
.flat() .flat()
.map(convertToBaseCartItem); .map(convertToBaseCartItem);
console.log('oldOrder.value', oldOrder.value)
if (!oldOrder.value.id) { if (!oldOrder.value.id) {
} }
@@ -469,7 +468,6 @@ export const useCartsStore = defineStore("cart", () => {
}); });
function setOldOrder(data) { function setOldOrder(data) {
console.log("setOldOrder", data);
oldOrder.value = data; oldOrder.value = data;
allGoods.value = getAllGoodsList(); allGoods.value = getAllGoodsList();
} }
@@ -695,8 +693,18 @@ export const useCartsStore = defineStore("cart", () => {
originAmount: 0, originAmount: 0,
}; };
} }
// 重置优惠
function clearDiscount(){
newUserDiscount.value=0;
consumeDiscount.value={}
fullReductionActivities.value = [];
isFreeDine.value = false;
userPoints.value = 0;
}
return { return {
clearDiscount,
getTotalPackFee, getTotalPackFee,
getTotalSeatcharge, getTotalSeatcharge,
getTotalTotalPrices, getTotalTotalPrices,

View File

@@ -44,7 +44,6 @@
id: getUUid(), id: getUUid(),
}) })
onMounted(()=>{ onMounted(()=>{
console.log('w-qrcode:mounted')
SpecialTreatment(opt); SpecialTreatment(opt);
nextTick(()=>{ nextTick(()=>{
generateCode(opt) generateCode(opt)

View File

@@ -39,6 +39,11 @@ module.exports = defineConfig({
changeOrigin: true, // 是否更改请求源 changeOrigin: true, // 是否更改请求源
rewrite: path => path.replace(/^\/api/, '') rewrite: path => path.replace(/^\/api/, '')
}, },
'/prodApi': {
target: 'https://cashier.sxczgkj.com', // 目标服务器地址
changeOrigin: true, // 是否更改请求源
rewrite: path => path.replace(/^\/prodApi/, '')
},
}, },
}, },
}); });