部分显示问题调整,问题修复,增加购物车初始化和商品更新未找到对应商品发送删除消息

This commit is contained in:
2025-12-24 09:21:14 +08:00
parent 9a09ac901f
commit addb9f0e75
12 changed files with 319 additions and 237 deletions

View File

@@ -347,6 +347,9 @@
console.log(opt) console.log(opt)
Object.assign(query, opt) Object.assign(query, opt)
console.log(query) console.log(query)
if(query.shopId){
uni.cache.set('shopId', query.shopId)
}
await storelogin.actionslogin() await storelogin.actionslogin()
getDetail() getDetail()
} }

View File

@@ -977,9 +977,6 @@ function calcVipDiscountAmount(
shopUserInfo : ShopUserInfo shopUserInfo : ShopUserInfo
) : number { ) : number {
if (!shopUserInfo.isVip || shopUserInfo.discount === 0) return 0; if (!shopUserInfo.isVip || shopUserInfo.discount === 0) return 0;
if (shopUserInfo.isVip == 1 && shopUserInfo.isMemberPrice != 1) {
return 0;
}
return truncateToTwoDecimals( return truncateToTwoDecimals(
new BigNumber(goodsRealAmount) new BigNumber(goodsRealAmount)
.times((100 - (shopUserInfo.discount || 100)) / 100) .times((100 - (shopUserInfo.discount || 100)) / 100)

View File

@@ -41,33 +41,10 @@
:limitDiscount="cartStore.limitTimeDiscount" :limitDiscount="cartStore.limitTimeDiscount"
></orderItemVue> --> ></orderItemVue> -->
<orderItemVue :useVipPrice="useVipPrice" v-if="cartStore.allGoods.length" :nowCarts="cartStore.allGoods" <orderItemVue :useVipPrice="useVipPrice" v-if="cartStore.allGoods.length" :nowCarts="cartStore.allGoods"
:shopInfo="cartStore.shopInfo" :shopInfo="cartStore.shopInfo" :shopUserInfo="cartStore.shopUserInfo"
:shopUserInfo="cartStore.shopUserInfo"
:limitDiscount="cartStore.limitTimeDiscount"></orderItemVue> :limitDiscount="cartStore.limitTimeDiscount"></orderItemVue>
<template v-if="listinfo.id&&listinfo.status=='done'">
<view class="total-wrap u-m-t-30" v-if="listinfo.status == 'unpaid' || !listinfo.id">
<text>总计</text>
<text class="u-font-32"></text>
<text class="price">
{{ cartStore.orderCostSummary.goodsRealAmount }}
</text>
</view>
<view class="total-wrap u-m-t-30" v-else>
<text>总计</text>
<text class="u-font-32"></text>
<text class="price">
{{ cartStore.orderCostSummary.goodsRealAmount }}
</text>
</view>
<!-- <view class="total-wrap" v-else>
<view>实付</view>
<view class="price"> {{listinfo.payAmount||''}} </view>
</view> -->
<view class="cell-item" v-if="is_type != 0"> <view class="cell-item" v-if="is_type != 0">
<view class="label">打包费</view> <view class="label">打包费</view>
<view class="val"> <view class="val">
@@ -77,7 +54,6 @@
</view> </view>
</view> </view>
<!-- isTableFee == 0是不免除 -->
<view class="cell-item" v-if="cartStore.orderCostSummary.seatFee"> <view class="cell-item" v-if="cartStore.orderCostSummary.seatFee">
<view class="label">餐位费</view> <view class="label">餐位费</view>
<view class="val"> <view class="val">
@@ -86,6 +62,50 @@
<view>{{ cartStore.orderCostSummary.seatFee }}</view> <view>{{ cartStore.orderCostSummary.seatFee }}</view>
</view> </view>
</view> </view>
</template>
<view class="total-wrap u-m-t-30" v-if="listinfo.status == 'unpaid' || !listinfo.id">
<text>总计</text>
<text class="u-font-32"></text>
<text class="price">
{{ cartStore.orderCostSummary.goodsRealAmount }}
</text>
</view>
<view class="total-wrap u-m-t-30" v-else-if="listinfo.status != 'unpaid'">
<text>实付</text>
<text class="u-font-32"></text>
<text class="price">
{{ listinfo.payAmount }}
</text>
</view>
<!-- <view class="total-wrap" v-else>
<view>实付</view>
<view class="price"> {{listinfo.payAmount||''}} </view>
</view> -->
<template v-if="!listinfo.id||listinfo.status=='unpaid'">
<view class="cell-item" v-if="is_type != 0">
<view class="label">打包费</view>
<view class="val">
<view></view>
<view style="font-size: 28rpx"></view>
<view>{{ cartStore.orderCostSummary.packFee }}</view>
</view>
</view>
<view class="cell-item" v-if="cartStore.orderCostSummary.seatFee">
<view class="label">餐位费</view>
<view class="val">
<view>X{{ cartStore.seatFeeConfig.personCount }}</view>
<view style="font-size: 28rpx"></view>
<view>{{ cartStore.orderCostSummary.seatFee }}</view>
</view>
</view>
</template>
<!-- <view class="cell-item" v-else> <!-- <view class="cell-item" v-else>
<view class="label">免餐位费</view> <view class="label">免餐位费</view>

View File

@@ -104,27 +104,8 @@
</view> </view>
</view> </view>
<view class="cell-item" v-if="is_type != 0">
<view class="label">打包费</view>
<view class="val">
<view></view>
<view style="font-size: 28rpx;"></view>
<view>{{listinfo.packFeess}}</view>
</view>
</view>
<!-- isTableFee == 0是不免除 -->
<view class="cell-item"
v-if="ordershopUserInfo.isTableFee == 0 && is_type == 0 && listinfo.Seatcharge != 0">
<view class="label">餐位费</view>
<view class="val">
<view>X{{listinfo.Seatcharge}}</view>
<view style="font-size: 28rpx;"></view>
<view>{{listinfo.Seatcharge}}</view>
</view>
</view>
<!-- <view class="cell-item" v-else> <!-- <view class="cell-item" v-else>
<view class="label">免餐位费</view> <view class="label">免餐位费</view>
<view class="val"> <view class="val">
@@ -185,6 +166,26 @@
</view> </view>
</view> </view>
</block> --> </block> -->
<view class="cell-item" v-if="is_type != 0">
<view class="label">打包费</view>
<view class="val">
<view></view>
<view style="font-size: 28rpx;"></view>
<view>{{listinfo.packFeess}}</view>
</view>
</view>
<!-- isTableFee == 0是不免除 -->
<view class="cell-item"
v-if="ordershopUserInfo.isTableFee == 0 && is_type == 0 && listinfo.Seatcharge != 0">
<view class="label">餐位费</view>
<view class="val">
<view>X{{listinfo.Seatcharge}}</view>
<view style="font-size: 28rpx;"></view>
<view>{{listinfo.Seatcharge}}</view>
</view>
</view>
<view class="total-wrap" v-if="listinfo.status == 'unpaid'"> <view class="total-wrap" v-if="listinfo.status == 'unpaid'">
<text>总计</text> <text>总计</text>
@@ -198,6 +199,8 @@
</view> </view>
</view> </view>
</view> </view>
@@ -1133,14 +1136,18 @@
} }
} }
.disocunt { .disocunt {
background: #FFFFFF; background: #FFFFFF;
border-radius: 18rpx 18rpx 18rpx 18rpx;overflow: hidden; border-radius: 18rpx 18rpx 18rpx 18rpx;
overflow: hidden;
margin-top: 32rpx; margin-top: 32rpx;
.row { .row {
padding: 16rpx 24rpx; padding: 16rpx 24rpx;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
.t { .t {
font-weight: bold; font-weight: bold;
font-size: 28rpx; font-size: 28rpx;
@@ -1154,10 +1161,12 @@
color: #666666; color: #666666;
} }
} }
.price { .price {
color: #FF1C1C; color: #FF1C1C;
} }
} }
.orderInfo { .orderInfo {
background: #FFFFFF; background: #FFFFFF;
border-radius: 18rpx 18rpx 18rpx 18rpx; border-radius: 18rpx 18rpx 18rpx 18rpx;
@@ -1236,6 +1245,4 @@
} }
} }
} }
</style> </style>

View File

@@ -88,7 +88,7 @@
<view class="btn s" @click.stop="$u.debounce(orderinfo(item),1000)" <view class="btn s" @click.stop="$u.debounce(orderinfo(item),1000)"
v-if="item.status == 'unpaid' || item.status == 'paying'"> 去付款 </view> v-if="item.status == 'unpaid' || item.status == 'paying'"> 去付款 </view>
<view class="btn s" @click.stop="agignOrder(item)" v-if="item.status == 'done'"> 再来一单 </view> <view class="btn s" @click.stop="agignOrder(item)" v-if="item.status != 'unpaid'"> 再来一单 </view>
</view> </view>
</view> </view>
</view> </view>

View File

@@ -58,7 +58,8 @@
限时折扣{{ limitDiscountCountdown }}</view> 限时折扣{{ limitDiscountCountdown }}</view>
<!-- <view class="limitDiscount" v-if="item.is_time_discount"> <!-- <view class="limitDiscount" v-if="item.is_time_discount">
限时折扣{{ limitDiscountCountdown }}</view> --> 限时折扣{{ limitDiscountCountdown }}</view> -->
<view class="stock_warning" v-if="item.isStock&&item.stockNumber<=10"> <view class="stock_warning"
v-if="item.isStock&&item.stockNumber<=10&&item.stockNumber>0">
仅剩{{item.stockNumber}}</view> 仅剩{{item.stockNumber}}</view>
</view> </view>
@@ -208,7 +209,8 @@
<!-- <view class="limitDiscount" v-if="item1.is_time_discount"> <!-- <view class="limitDiscount" v-if="item1.is_time_discount">
限时折扣{{ limitDiscountCountdown }}</view> --> 限时折扣{{ limitDiscountCountdown }}</view> -->
<view class="stock_warning" v-if="item1.isStock&&item1.stockNumber<=10"> <view class="stock_warning"
v-if="item1.isStock&&item1.stockNumber<=10&&item.stockNumber>0">
仅剩{{item1.stockNumber}}</view> 仅剩{{item1.stockNumber}}</view>
</view> </view>
@@ -575,46 +577,62 @@
</template> </template>
<script setup> <script setup>
import xbSwiperPreview from '@/components/xb-swiper-preview/index.vue'; /**
//价格计算辅助函数 * api合集 start
*/
import * as discountActivityApi from '@/common/api/market/discountActivity';
import {
consumeDiscount
} from '@/common/api/market/index.js';
import * as limitTimeDiscountapi from '@/common/api/market/limitTimeDiscount.js';
import {
APIshopUserInfo,
APIusershopInfodetail
} from "@/common/api/member.js";
import {
productminiApphotsquery,
APIgroupquery,
APIminiAppinfo,
APIminiAppskuinfo
} from '@/common/api/product/product.js';
import {
APIhistoryOrder,
APIcancelOrder,
APIrmPlaceOrder
} from '@/common/api/order/index.js';
import {
APIproductqueryShop
} from '@/common/api/member.js';
/**
* api合集 end
*/
/**
* 三方库 start
*/
import BigNumber from 'bignumber.js';
//价格计算辅助函数
import { import {
limitUtils limitUtils
} from 'ysk-utils'; } from 'ysk-utils';
// 满减活动api import dayjs from 'dayjs';
import * as discountActivityApi from '@/common/api/market/discountActivity'; import isBetween from 'dayjs/plugin/isBetween';
dayjs.extend(isBetween);
/**
* 三方库 end
*/
import BigNumber from 'bignumber.js'; /**
import { * 组件 start
consumeDiscount */
} from '@/common/api/market/index.js';
import xbSwiperPreview from '@/components/xb-swiper-preview/index.vue';
import GoodsPrice from '@/components/goods-price.vue'; import GoodsPrice from '@/components/goods-price.vue';
import * as limitTimeDiscountapi from '@/common/api/market/limitTimeDiscount.js';
import ModalList from '@/components/modal-list.vue'; import ModalList from '@/components/modal-list.vue';
import recommendGoodsModal from './components/recommend-goods-modal.vue'; import recommendGoodsModal from './components/recommend-goods-modal.vue';
import {
ref,
reactive,
onMounted,
watchEffect,
getCurrentInstance,
computed,
provide,
watch
} from 'vue';
import {
onLoad,
onReady,
onShow,
onHide,
onUnload,
onPageScroll
} from '@dcloudio/uni-app';
//导航栏 //导航栏
import Nav from '@/components/CustomNavbar.vue'; import Nav from '@/components/CustomNavbar.vue';
import shopindex from './components/shopindex.vue'; import shopindex from './components/shopindex.vue';
@@ -622,21 +640,18 @@
import shoppingCartes from './components/shoppingCartes.vue'; import shoppingCartes from './components/shoppingCartes.vue';
import confirmorder from './components/confirmorder.vue'; import confirmorder from './components/confirmorder.vue';
import Loading from '@/components/Loading.vue'; import Loading from '@/components/Loading.vue';
import dayjs from 'dayjs'; /**
import isBetween from 'dayjs/plugin/isBetween'; * 组件 end
*/
import {
APIshopUserInfo, /**
APIusershopInfodetail * 项目代码辅助方法 start
} from "@/common/api/member.js"; */
dayjs.extend(isBetween);
import { import {
filterNumberInput, filterNumberInput,
isJsonArrayString isJsonArrayString
} from '@/utils/util.js'; } from '@/utils/util.js';
import {
APIproductqueryShop
} from '@/common/api/member.js';
import { import {
getDistance getDistance
} from '@/utils/address.js'; } from '@/utils/address.js';
@@ -644,6 +659,56 @@
isObjectEqual, isObjectEqual,
isArrayEqual isArrayEqual
} from './components/utils.js' } from './components/utils.js'
/**
* 项目代码辅助方法 end
*/
/**
* store本地存储 start
*/
import {
useNavbarStore
} from '@/stores/navbarStore';
import {
useWebSocket
} from '@/stores/carts-websocket.js';
// 结账管理
import {
Memberpay
} from '@/stores/pay.js';
import {
productStore
} from '@/stores/user.js';
const storeMemberpay = Memberpay();
const store = useNavbarStore();
// 动态更新导航栏配置
store.updateNavbarConfig({
showBack: true, //左边返回键
rightText: '', //右边文字
showSearch: false, //true是标题其他事文字
title: '',
isTransparent: false,
hasPlaceholder: false //是否要占位符
});
const userStore = productStore();
// 金额管理
import {
useCartStore
} from '@/stores/order.js';
const cartStore = useCartStore();
/**
* store本地存储 end
*/
// 获取全局属性
const {
proxy
} = getCurrentInstance();
//点单智能推荐 //点单智能推荐
@@ -681,81 +746,51 @@
} }
} }
// 获取全局属性
const {
proxy
} = getCurrentInstance();
//接口引入 /**
import { * 通用数据合集 start
productminiApphotsquery, */
APIgroupquery, // 门店信息
APIminiAppinfo,
APIminiAppskuinfo
} from '@/common/api/product/product.js';
import {
APIhistoryOrder,
APIcancelOrder,
APIrmPlaceOrder
} from '@/common/api/order/index.js';
// websocket
// import useWebSocket from '@/common/js/websocket.js';
import {
useWebSocket
} from '@/stores/carts-websocket.js';
// pinia管理
import {
useNavbarStore
} from '@/stores/navbarStore';
// 结账管理
import {
Memberpay
} from '@/stores/pay.js';
const storeMemberpay = Memberpay();
const store = useNavbarStore();
import {
productStore
} from '@/stores/user.js';
const userStore = productStore();
// 金额管理
import {
useCartStore
} from '@/stores/order.js';
const cartStore = useCartStore();
// 动态更新导航栏配置
store.updateNavbarConfig({
showBack: true, //左边返回键
rightText: '', //右边文字
showSearch: false, //true是标题其他事文字
title: '',
isTransparent: false,
hasPlaceholder: false //是否要占位符
});
const shopInfo = reactive({}); const shopInfo = reactive({});
Object.assign(shopInfo, uni.cache.get('shopInfo')); Object.assign(shopInfo, uni.cache.get('shopInfo'));
// 台桌信息
const shopTable = uni.cache.get('shopTable'); const shopTable = uni.cache.get('shopTable');
const distance = uni.cache.get('distance'); //距离 //距离
const distance = uni.cache.get('distance');
//店铺详情
const showShopInfoRef = ref(null);
// 计算高度
const navScroll = ref(null);
// 初始加载中
const isLoading = ref(true);
// 分步取值 + 每层兜底,避免某一环不存在导致 undefined
const shopExtendShopTable = uni.cache.get('shopTable') || {}; // 兜底空对象
const shopExtendMap = shopExtendShopTable.shopExtendMap || {}; // 兜底空对象
// 最终声明:即使 shopinfo_bg 不存在,也兜底为空字符串/默认值
const shopExtend = ref(shopExtendMap.shopinfo_bg || '');
/**
* 通用数据合集 end
*/
/**
* 轮播功能 staart
*/
const swiperCurrent = ref(0); const swiperCurrent = ref(0);
function swiperChange(e) { function swiperChange(e) {
swiperCurrent.value = e.current; swiperCurrent.value = e.current;
} }
/**
* 轮播功能 end
*/
//店铺详情
const showShopInfoRef = ref(null);
// 初始加载中
const isLoading = ref(true);
//调用shop组件 //调用shop组件
const callChildMethod = () => { const callChildMethod = () => {
@@ -764,21 +799,10 @@
} }
}; };
// const shopExtend = ref(uni.cache.get('shopTable').shopExtendMap.shopinfo_bg);
// console.log('shopExtend', shopExtend);
// 分步取值 + 每层兜底,避免某一环不存在导致 undefined
const shopExtendShopTable = uni.cache.get('shopTable') || {}; // 兜底空对象
const shopExtendMap = shopExtendShopTable.shopExtendMap || {}; // 兜底空对象
// 最终声明:即使 shopinfo_bg 不存在,也兜底为空字符串/默认值
const shopExtend = ref(shopExtendMap.shopinfo_bg || '');
// try {
// const shopExtend = uni.cache.get('shopTable').shopExtendMap.shopinfo_bg;
// } catch (error) {}
// 计算高度
const navScroll = ref(null);
// 获取商品数据 // 获取商品数据
const shopProductList = reactive({ const shopProductList = reactive({
@@ -1560,19 +1584,33 @@
function cartInit(arr) { function cartInit(arr) {
const result = [] const result = []
console.log('cartInit arr',arr);
cartStore.carts = arr.map(v => { cartStore.carts = arr.map(v => {
const goods = matchedProducts.value.find(g => g.id == v.product_id) const goods = matchedProducts.value.find(g => g.id == v.product_id)
const goodsSkuList=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
const is_time_discount = limitUtils.canUseLimitTimeDiscount({...v,memberPrice}, cartStore.limitTimeDiscount, shopInfo, const is_time_discount = limitUtils.canUseLimitTimeDiscount({
...v,
memberPrice
}, cartStore.limitTimeDiscount, shopInfo,
shopUserInfo.value, 'product_id'); shopUserInfo.value, 'product_id');
if(!goods){
useSocket.sendMessage({
id: v.id,
operate_type: "del",
table_code: uni.cache.get('tableCode'),
shop_id: uni.cache.get('shopId'),
type: "shopping",
});
return null
}
return { return {
...v, ...v,
is_time_discount: is_time_discount ? 1 : 0, is_time_discount: is_time_discount ? 1 : 0,
memberPrice memberPrice
} }
}) }).filter(v=>v)
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)
@@ -1603,12 +1641,12 @@
// 收到的消息变化 // 收到的消息变化
async function onMessage(Message) { async function onMessage(Message) {
if (Message) { if (Message) {
console.log('product index 收到消息', Message);
// 心跳返回 过滤 // 心跳返回 过滤
if (Message.type == 'ping_interval' || Message.msg_id == 'ping_interval') { if (Message.type == 'ping_interval' || Message.msg_id == 'ping_interval') {
isLoading.value = false; isLoading.value = false;
return false; return false;
} }
console.log('product index 收到消息', Message);
// 检查消息是否已经处理过 // 检查消息是否已经处理过
if (processedMessageIds.has(Message.msg_id)) { if (processedMessageIds.has(Message.msg_id)) {
return; return;
@@ -1617,7 +1655,7 @@
// 初始化 // 初始化
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) console.log('onMessage限时折扣', cartStore.limitTimeDiscount)
cartInit(Message.data) cartInit(Message.data)
@@ -1752,9 +1790,7 @@
}); });
} }
if (Message.operate_type == 'time_discount_save') {
cartStore.limitTimeDiscount = Message.data;
}
//除去p 每次返回都回执消息 //除去p 每次返回都回执消息
await websocketsendMessage({ await websocketsendMessage({
@@ -1903,7 +1939,6 @@
} }
}); });
} }
console.log('limitTimeDiscountRes', item)
if (cartStore.limitTimeDiscount && cartStore.limitTimeDiscount.id && item.cartListinfo if (cartStore.limitTimeDiscount && cartStore.limitTimeDiscount.id && item.cartListinfo
.is_time_discount == .is_time_discount ==
1) { 1) {
@@ -2066,6 +2101,7 @@
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
@@ -2075,15 +2111,23 @@
product.isSaleTimeshow = await isProductAvailable(product.days, product product.isSaleTimeshow = await isProductAvailable(product.days, product
.startTime, product.endTime); .startTime, product.endTime);
allGoodsArr.push(product)
cartStore.setGoodsMap(product.id, product); cartStore.setGoodsMap(product.id, product);
}); });
}); });
shopProductList.hots.forEach(async (i) => { shopProductList.hots.forEach(async (i) => {
i.cartNumber = 0; i.cartNumber = 0;
i.isSaleTimeshow = await isProductAvailable(i.days, i.startTime, i.endTime); i.isSaleTimeshow = await isProductAvailable(i.days, i.startTime, i.endTime);
allGoodsArr.push(i)
cartStore.setGoodsMap(i.id, i); cartStore.setGoodsMap(i.id, i);
}); });
console.log('shopProductList', shopProductList); console.log('shopProductList', shopProductList);
if(cartStore.carts.length>0){
cartInit(cartStore.carts)
}
cartStore.goodsIsloading = true; cartStore.goodsIsloading = true;
scrollTopSize.value = 0; scrollTopSize.value = 0;
topArr.value = []; topArr.value = [];
@@ -2285,7 +2329,6 @@
}); });
} }
const limitTimeDiscountRes = ref(null);
onLoad(async (e) => { onLoad(async (e) => {
if (e.type) { if (e.type) {
orderType.value = e.type; orderType.value = e.type;
@@ -2506,9 +2549,9 @@
}) })
const oldOrder = ref(null); const oldOrder = ref(null);
// 限时折扣 // 限时折扣
async function getLimitDiscount() { async function getLimitDiscount() {
const limitRes = await limitTimeDiscountapi.getConfig({ const limitRes = await limitTimeDiscountapi.getConfig({
shopId: uni.cache.get('shopId') shopId: uni.cache.get('shopId')
}); });
@@ -2517,15 +2560,6 @@
} else { } else {
cartStore.limitTimeDiscount = null; cartStore.limitTimeDiscount = null;
} }
websocketsendMessage({
type: 'shopping',
operate_type: 'time_discount_save',
table_code: uni.cache.get('tableCode'),
shop_id: uni.cache.get('shopId'),
operate_type: 'time_discount_save',
data: cartStore.limitTimeDiscount
});
console.log('onMounted:限时折扣', cartStore.limitTimeDiscount);
return cartStore.limitTimeDiscount return cartStore.limitTimeDiscount
} }
onMounted(async () => { onMounted(async () => {

View File

@@ -205,7 +205,7 @@
uni.hideLoading() uni.hideLoading()
if (openId) { if (openId) {
pointGoodsApi.exchange({ pointGoodsApi.exchange({
pointsGoodsId: item.id, paramId: item.id,
shopId: item.shopId, shopId: item.shopId,
number: 1, number: 1,
price: item.extraPrice, price: item.extraPrice,

View File

@@ -4,6 +4,7 @@
title="兑换成功" title="兑换成功"
bgColor="transparent" bgColor="transparent"
leftIconColor="#333" leftIconColor="#333"
@leftClick="back()"
titleStyle="color:#333" titleStyle="color:#333"
></up-navbar> ></up-navbar>
<view class="content"> <view class="content">

View File

@@ -246,14 +246,15 @@ export const useCartsStore = defineStore("cart", () => {
const goodsIsloading = ref(true); const goodsIsloading = ref(true);
//商品数据Map //商品数据Map
const goodsMap = reactive({}); const goodsMap = ref({})
function returnGoods(product_id) { function returnGoods(product_id) {
return goodsMap[product_id * 1]; return goodsMap.value[product_id * 1];
} }
//获取商品数据 //获取商品数据
async function goodsInit() { async function goodsInit() {
goodsMap.value={}
goodsIsloading.value = true; goodsIsloading.value = true;
//获取招牌菜商品 //获取招牌菜商品
const hotres = await productminiApphotsquery(); const hotres = await productminiApphotsquery();
@@ -272,13 +273,13 @@ export const useCartsStore = defineStore("cart", () => {
} }
function setGoodsMap(product_id, data) { function setGoodsMap(product_id, data) {
goodsMap[product_id] = data; goodsMap.value[product_id] = data;
} }
const isLoading = ref(true); const isLoading = ref(true);
function getProductDetails(v) { function getProductDetails(v) {
const goods = goodsMap[v.product_id]; const goods = goodsMap.value[v.product_id];
if (!goods) { if (!goods) {
return undefined; return undefined;
} }
@@ -327,17 +328,18 @@ export const useCartsStore = defineStore("cart", () => {
const item = getProductDetails(v); const item = getProductDetails(v);
if (!item) { if (!item) {
socketSendMsg({
id: v.id,
operate_type: "del",
type: "shopping",
});
return null return null
} }
console.log('v',v);
console.log('limitTimeDiscount',limitTimeDiscount.value);
console.log('shopInfo',shopInfo.value);
console.log('shopUserInfo',shopUserInfo.value);
const is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount({...v,memberPrice:item.memberPrice}, limitTimeDiscount const is_time_discount = yskUtils.limitUtils.canUseLimitTimeDiscount({...v,memberPrice:item.memberPrice}, limitTimeDiscount
.value, .value,
shopInfo.value, shopInfo.value,
shopUserInfo.value, 'product_id'); shopUserInfo.value, 'product_id');
console.log('is_time_discount',is_time_discount);
return { return {
...item, ...item,
is_time_discount: is_time_discount ? 1 : 0 is_time_discount: is_time_discount ? 1 : 0
@@ -391,7 +393,7 @@ export const useCartsStore = defineStore("cart", () => {
// 初始化 // 初始化
if (Message.operate_type == "init") { if (Message.operate_type == "init") {
if (!oldOrder.value.id) { if (!oldOrder.value.id) {
limitTimeDiscount.value = Message.time_dis_info; // limitTimeDiscount.value = Message.time_dis_info;
} }
cartsGoodsInfoInit(msgData); cartsGoodsInfoInit(msgData);
isLoading.value = false; isLoading.value = false;
@@ -428,7 +430,7 @@ export const useCartsStore = defineStore("cart", () => {
Message.operate_type == "product_update" Message.operate_type == "product_update"
) { ) {
await goodsInit(); await goodsInit();
await cartsGoodsInfoInit(); await cartsGoodsInfoInit(carts.value);
} }
// 提示 // 提示
@@ -440,12 +442,11 @@ export const useCartsStore = defineStore("cart", () => {
} }
//获取限时折扣 //获取限时折扣
if (Message.operate_type == "time_discount_get") { if (Message.operate_type == "time_discount_get") {
console.log("time_discount_get", Message.data); // limitTimeDiscount.value = Message.data;
limitTimeDiscount.value = Message.data;
}
if (Message.operate_type == "time_discount_save") {
limitTimeDiscount.value = Message.data;
} }
// if (Message.operate_type == "time_discount_save") {
// limitTimeDiscount.value = Message.data;
// }
if (Message.type == "no_suit_num") { if (Message.type == "no_suit_num") {
uni.showModal({ uni.showModal({
@@ -703,7 +704,7 @@ export const useCartsStore = defineStore("cart", () => {
carts, carts,
isEmpty, isEmpty,
setGoodsMap, setGoodsMap,
goodsMap: goodsMap, goodsMap: goodsMap.value,
goodsIsloading, goodsIsloading,
goodsInit, goodsInit,
onMessage, onMessage,

View File

@@ -366,7 +366,7 @@
shopId: item.shopId, shopId: item.shopId,
}).then(res=>{ }).then(res=>{
if(res){ if(res){
uni.navigateTo({ uni.redirectTo({
url:'/userPackage/order/detail?orderId='+res url:'/userPackage/order/detail?orderId='+res
}) })
}else{ }else{

View File

@@ -91,9 +91,9 @@
</view> </view>
</view> </view>
<template v-if="item.status"> <template v-if="item.status">
<view class="refund" v-if="item.status=='refunding'">已申请退款需等待商家审核</view> <view class="refund" v-if="item.status=='refunding'&&item.isMyself">已申请退款需等待商家审核</view>
<view class="refund" v-if="returnTime==='00:00:00'&&!item.isMyself">当前订单已失效</view> <view class="refund" v-else-if="returnTime==='00:00:00'&&!item.isMyself">当前订单已失效</view>
<view class="refund" v-if="item.status=='cancel'&&!item.isMyself">当前订单已失效</view> <view class="refund" v-else-if="item.status!='ing'&&!item.isMyself">当前订单已失效</view>
</template> </template>
<view class="shop-box"> <view class="shop-box">
@@ -528,7 +528,9 @@
console.log(opt) console.log(opt)
Object.assign(query, opt) Object.assign(query, opt)
console.log(query) console.log(query)
if(query.shopId){
uni.cache.set('shopId', query.shopId)
}
} }
function refund(item) { function refund(item) {
@@ -711,9 +713,10 @@
if (!nowStep.value) { if (!nowStep.value) {
return 0 return 0
} }
const index = item.packageInfo.tieredDiscount.findIndex(v => v.peopleNum) const index = item.packageInfo.tieredDiscount.findIndex(v => v.peopleNum==nowStep.value.peopleNum)
if (index != -1) { if (index != -1) {
return (index + 1) / item.packageInfo.tieredDiscount.length * 100 const percent= (index + 1) / item.packageInfo.tieredDiscount.length * 100
return percent>=100?100:0;
} }
return 0 return 0
}) })
@@ -959,7 +962,7 @@
} }
.pin-btn { .pin-btn {
padding: 14rpx 60rpx; padding: 22rpx 60rpx;
border-radius: 200rpx; border-radius: 200rpx;
text-align: center; text-align: center;
font-size: 32rpx; font-size: 32rpx;
@@ -1090,6 +1093,7 @@
$height: 10rpx; $height: 10rpx;
height: $height; height: $height;
border-radius: $height; border-radius: $height;
overflow: hidden;
.progress { .progress {
height: $height; height: $height;

View File

@@ -1,6 +1,21 @@
const accountInfo = wx.getAccountInfoSync();
export const envVersion = accountInfo.miniProgram.envVersion;
let type = 3;
if (envVersion === 'trial') {
console.log('当前环境是体验版');
type = 2;
} else if (envVersion === 'release') {
console.log('当前环境是正式版');
type = 0;
} else {
type = 1;
console.log('当前环境是开发版或其他');
}
export function wxShare(par) { export function wxShare(par) {
return { return {
...par, ...par,
type: 2 type
} }
} }