购物车计算

This commit is contained in:
wwz
2025-03-01 18:30:19 +08:00
parent 04a84aa17f
commit c0af79f666
10 changed files with 216 additions and 152 deletions

View File

@@ -46,19 +46,19 @@ export default (params) => {
resolve(res.data); resolve(res.data);
} else { } else {
switch (res.code) { switch (res.code) {
case '-4': case '501':
resolve(res) uni.cache.remove('shopId')
// uni.showToast({ uni.showToast({
// title: res.message || res.msg || res.error, title: '',
// icon: "none", icon: "none",
// success: () => { success: () => {
// setTimeout(() => { setTimeout(() => {
// uni.reLaunch({ uni.reLaunch({
// url: "/pages/login/index", url: "/pages/index/index",
// }) })
// }, 1000); }, 1000);
// } }
// }) })
break; break;
case 404: case 404:
uni.showToast({ uni.showToast({

View File

@@ -5,24 +5,38 @@
* @return {String} 缓存值 * @return {String} 缓存值
*/ */
function get(key) { function get(key) {
try { try {
let res = uni.getStorageSync(key) let res = uni.getStorageSync(key)
if (!res) {
return ''
}
if (!res) {
return ''
}
// res = JSON.parse(res)
if (res.__expiretime && res.__expiretime < uni.utils.timestamp()) { if (res.expiretime && res.expiretime < Date.now()) {
remove(key) remove(key)
return '' return ''
} else { } else {
return res // #ifdef APP-PLUS
} return res.value
} catch (e) { // #endif
return '' // #ifdef H5
} res = JSON.parse(res)
return res.value
// #endif
// #ifdef MP-WEIXIN
return res.value
// #endif
// #ifdef MP-ALIPAY
return res.value
// #endif
}
} catch (e) {
return ''
}
} }
@@ -33,19 +47,19 @@ function get(key) {
* @return {String} 缓存值 * @return {String} 缓存值
*/ */
function getStorageData(key) { function getStorageData(key) {
try { try {
let res = uni.getStorageSync(key); let res = uni.getStorageSync(key);
if (!res) { if (!res) {
return '' return ''
} }
res = JSON.parse(res) res = JSON.parse(res)
return res.data return res.data
} catch (e) { } catch (e) {
return '' return ''
} }
} }
/** /**
@@ -57,14 +71,14 @@ function getStorageData(key) {
* @return void * @return void
*/ */
function set(key, value, expire = uni.conf.default_expire) { function set(key, value, expire = uni.conf.default_expire) {
let cacheItem = {} let cacheItem = {}
cacheItem = value cacheItem.value = value
// console.log(cacheItem) // console.log(cacheItem)
if (expire > 0) { if (expire > 0) {
cacheItem.__expiretime = uni.utils.timestamp() + expire cacheItem.expiretime = Date.now() + expire * 60 * 1000;
} }
// uni.setStorageSync(key,JSON.stringify(cacheItem)) // uni.setStorageSync(key,JSON.stringify(cacheItem))
uni.setStorageSync(key,cacheItem) uni.setStorageSync(key, cacheItem)
} }
/** /**
@@ -76,14 +90,14 @@ function set(key, value, expire = uni.conf.default_expire) {
* @return {Promise} Promise对象 * @return {Promise} Promise对象
*/ */
async function remember(key, callback, expire = uni.conf.default_expire) { async function remember(key, callback, expire = uni.conf.default_expire) {
let ret = this.get(key) let ret = this.get(key)
if (ret) { if (ret) {
return ret return ret
} else { } else {
ret = await callback() ret = await callback()
set(key, ret, expire) set(key, ret, expire)
return ret return ret
} }
} }
/** /**
@@ -93,7 +107,7 @@ async function remember(key, callback, expire = uni.conf.default_expire) {
* @return {void} * @return {void}
*/ */
function remove(key) { function remove(key) {
uni.removeStorageSync(key) uni.removeStorageSync(key)
} }
/** /**
@@ -103,22 +117,22 @@ function remove(key) {
* @return void * @return void
*/ */
function removeList(prefix) { function removeList(prefix) {
let keys = uni.getStorageInfoSync().keys let keys = uni.getStorageInfoSync().keys
if (keys && keys.length > 0) { if (keys && keys.length > 0) {
keys.forEach(key => { keys.forEach(key => {
if (key.indexOf(prefix) === 0) { if (key.indexOf(prefix) === 0) {
uni.removeStorageSync(key) uni.removeStorageSync(key)
} }
}) })
} }
} }
function _randomRemove() { function _randomRemove() {
const info = uni.getStorageInfoSync() const info = uni.getStorageInfoSync()
if (info.currentSize > 0.7 * info.limitSize if (info.currentSize > 0.7 * info.limitSize ||
|| info.keys.length > uni.conf.autoRemoveCache.count info.keys.length > uni.conf.autoRemoveCache.count ||
|| info.currentSize > uni.conf.autoRemoveCache.size) { info.currentSize > uni.conf.autoRemoveCache.size) {
for (let i = 0; i < 100; i++) { for (let i = 0; i < 100; i++) {
if (info.keys.length < 1) { if (info.keys.length < 1) {
return return
} }
@@ -131,24 +145,24 @@ function _randomRemove() {
function _removeExpired(key) { function _removeExpired(key) {
let res = uni.getStorageSync(key); let res = uni.getStorageSync(key);
if (!res) { if (!res) {
return return
} }
res = JSON.parse(res) res = JSON.parse(res)
if (res.__expiretime && res.__expiretime < uni.utils.timestamp()) { if (res.expiretime && res.expiretime < uni.utils.timestamp()) {
remove(key) remove(key)
} }
} }
function _autoRemoveExpired() { function _autoRemoveExpired() {
const info = uni.getStorageInfoSync() const info = uni.getStorageInfoSync()
if (info.currentSize > 0.7 * info.limitSize if (info.currentSize > 0.7 * info.limitSize ||
|| info.keys.length > uni.conf.autoRemoveCache.count info.keys.length > uni.conf.autoRemoveCache.count ||
|| info.currentSize > uni.conf.autoRemoveCache.size) { info.currentSize > uni.conf.autoRemoveCache.size) {
if (info.keys && info.keys.length > 0) { if (info.keys && info.keys.length > 0) {
info.keys.forEach(key => { info.keys.forEach(key => {
_removeExpired(key) _removeExpired(key)
}) })
} }
} }
} }
@@ -169,13 +183,13 @@ function autoRemove(is_once = true) {
function clearFetch(url) { function clearFetch(url) {
const prefixCacheKey = 'memory:fetch:' + url const prefixCacheKey = 'memory:fetch:' + url
removeList(prefixCacheKey) removeList(prefixCacheKey)
} }
function clearMemory() { function clearMemory() {
const prefixCacheKey = 'memory:' const prefixCacheKey = 'memory:'
removeList(prefixCacheKey) removeList(prefixCacheKey)
} }
/** /**
@@ -184,22 +198,22 @@ function clearMemory() {
* @return void * @return void
*/ */
function clear() { function clear() {
uni.clearStorageSync() uni.clearStorageSync()
} }
function getInfo() { function getInfo() {
return uni.getStorageInfoSync() return uni.getStorageInfoSync()
} }
uni.cache = { uni.cache = {
get, get,
getStorageData, getStorageData,
set, set,
remove, remove,
remember, remember,
clearFetch, clearFetch,
clearMemory, clearMemory,
clear, clear,
getInfo, getInfo,
autoRemove, autoRemove,
} }

View File

@@ -1,7 +1,7 @@
<template> <template>
<view class="content"> <view class="content">
<view class="contentbox" <view class="contentbox"
:style="'background:url('+(shopExtend?shopExtend.value:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png')+') no-repeat center center / cover' "> :style="'background:url('+(shopExtend.index_bg?shopExtend.index_bg.value:'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png')+') no-repeat center center / cover' ">
<view class="contentboxitem flex-between"> <view class="contentboxitem flex-between">
<view class="contentboxitemleft flex-colum" @click="scanCodehandle(0)"> <view class="contentboxitemleft flex-colum" @click="scanCodehandle(0)">
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/Xdiancan.png" mode="aspectFill"> <image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/Xdiancan.png" mode="aspectFill">
@@ -10,7 +10,8 @@
<text class="contentboxitemlefttexttow">在线点不排队</text> <text class="contentboxitemlefttexttow">在线点不排队</text>
</view> </view>
<view class="contentboxitemright"> <view class="contentboxitemright">
<view class="contentboxitemright_item flex-between" @click="memberindex('user/member/memberdetails')"> <view class="contentboxitemright_item flex-between"
@click="memberindex('user/member/memberdetails')">
<image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/Xvip.png" mode="aspectFill"> <image src="https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/Xvip.png" mode="aspectFill">
</image> </image>
<view class="contentboxitemright_itembox flex-colum"> <view class="contentboxitemright_itembox flex-colum">
@@ -41,11 +42,14 @@
import { import {
productStore productStore
} from '@/stores/user.js'; } from '@/stores/user.js';
const shopExtend = uni.cache.get('shopTable').shopExtendMap.index_bg const shopExtend = uni.cache.get('shopTable').shopExtendMap
const scanCodehandle = async (i) => { const scanCodehandle = async (i) => {
const store = productStore(); const store = productStore();
await store.scanCodeactions() await store.scanCodeactions()
} }
const memberindex = (url) => { const memberindex = (url) => {
uni.pro.navigateTo(url, { uni.pro.navigateTo(url, {
shopId: uni.cache.get('shopId'), shopId: uni.cache.get('shopId'),
@@ -60,6 +64,8 @@
} }
return null; return null;
} }
onMounted(() => {
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -6,7 +6,7 @@
<view class="content"> <view class="content">
<view class="title"> <view class="title">
<view class="title_text">请选择就餐人数</view> <view class="title_text">请选择就餐人数</view>
<view class="title_tabNum">桌号{{tableCode}}</view> <view class="title_tabNum">桌号{{shopTable.name}}</view>
</view> </view>
<view class="num" :class="{'active':numIndex==-1}"> <view class="num" :class="{'active':numIndex==-1}">
<view class="item" @click="tabCut(index)" v-for="(item,index) in 9" :key="index"> <view class="item" @click="tabCut(index)" v-for="(item,index) in 9" :key="index">

View File

@@ -15,7 +15,7 @@
<view class="shop-item" v-for="(item,index) in props.cartList" :key="item.id"> <view class="shop-item" v-for="(item,index) in props.cartList" :key="item.id">
<view class="shop-item-content"> <view class="shop-item-content">
<view class="cover" v-if="item.productId!=-999"> <view class="cover" v-if="item.productId!=-999">
<up-image :src="item.coverImg" width="120" radius="10" height="120"></up-image> <up-image :src="item.coverImg" width="80" radius="10" height="80"></up-image>
</view> </view>
<view class="info"> <view class="info">
<view class="name"> {{ item.name }} </view> <view class="name"> {{ item.name }} </view>

View File

@@ -52,12 +52,12 @@
<view class="panelfiveitemsex flex-between"> <view class="panelfiveitemsex flex-between">
<view class="panelfiveitemsex_oen"> <view class="panelfiveitemsex_oen">
<text class="tips" <text class="tips"
:class="shopInfo.isVip ==0 || shopInfo.isMemberPrice==0?'lineThrough':''">¥</text> :class="shopInfo.isVip == 0 || shopInfo.isMemberPrice==0?'lineThrough':''">¥</text>
<!-- 会员价与价格 --> <!-- 会员价与价格 -->
<text <text
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item.memberPrice:item.salePrice}}</text> class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item.memberPrice:item.salePrice}}</text>
<!-- 原价 --> <!-- 原价 -->
<text class="originalprice" v-if="item.originPrice">¥{{item.originPrice}}</text> <!-- <text class="originalprice" v-if="item.originPrice">¥{{item.originPrice}}</text> -->
<!-- 单位 --> <!-- 单位 -->
<text class="unit" v-if="item.unitName">/{{item.unitName}}</text> <text class="unit" v-if="item.unitName">/{{item.unitName}}</text>
</view> </view>
@@ -79,7 +79,7 @@
<text <text
class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item.memberPrice:item.salePrice}}</text> class="price">{{shopInfo.isVip ==1 && shopInfo.isMemberPrice==1?item.memberPrice:item.salePrice}}</text>
<!-- 原价 --> <!-- 原价 -->
<text class="originalprice" v-if="item.originPrice">¥{{item.originPrice}}</text> <!-- <text class="originalprice" v-if="item.originPrice">¥{{item.originPrice}}</text> -->
<!-- 单位 --> <!-- 单位 -->
<text class="unit" v-if="item.unitName">/{{item.unitName}}</text> <text class="unit" v-if="item.unitName">/{{item.unitName}}</text>
</view> </view>
@@ -164,12 +164,12 @@
<text class="money_num" <text class="money_num"
v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1" v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1"
style="margin-right: 10rpx;">{{ item1.memberPrice }}</text> style="margin-right: 10rpx;">{{ item1.memberPrice }}</text>
<view v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1" <!--<view v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1"
:class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}"> :class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}">
</view> </view>
<text class="money_num" <text class="money_num"
:class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}">{{ item1.salePrice }}</text> :class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}">{{ item1.salePrice }}</text> -->
<text v-if="item1.unitName">/{{item1.unitName}}</text> <text v-if="item1.unitName">/{{item1.unitName}}</text>
</view> </view>
<view class="flex-end"> <view class="flex-end">
@@ -185,12 +185,12 @@
<text class="money_num" <text class="money_num"
v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1" v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1"
style="margin-right: 10rpx;">{{ item1.memberPrice }}</text> style="margin-right: 10rpx;">{{ item1.memberPrice }}</text>
<view v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1" <!--<view v-if="shopInfo.isVip ==1 && shopInfo.isMemberPrice==1"
:class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}"> :class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}">
</view> </view>
<text class="money_num" <text class="money_num"
:class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}">{{ item1.salePrice }}</text> :class="{lineThrough: shopInfo.isVip ==1 && shopInfo.isMemberPrice==1}">{{ item1.salePrice }}</text> -->
<text v-if="item1.unitName">/{{item1.unitName}}</text> <text v-if="item1.unitName">/{{item1.unitName}}</text>
</view> </view>
@@ -240,7 +240,7 @@
@customevent='websocketsendMessage' @close="showCart = !showCart"> @customevent='websocketsendMessage' @close="showCart = !showCart">
</shoppingCartes> </shoppingCartes>
<!-- 购物车 --> <!-- 显示购物车 -->
<view class="cart-wrap" v-if="cartLists_count>0"> <view class="cart-wrap" v-if="cartLists_count>0">
<view class="cart-content"> <view class="cart-content">
<view class="left"> <view class="left">
@@ -253,9 +253,7 @@
</view> </view>
<text class="i"></text> <text class="i"></text>
<!-- <text class="num" <text class="num">{{TotalPrices}}</text>
v-if="shopInfo.isVip == 1 && cartLists.memberAmount > 0">{{cartLists.memberAmount||'0.00'}}</text>
<text class="num" v-else>{{cartLists.amount||'0.00'}}</text> -->
</view> </view>
<view class="btn" @tap="$u.debounce(orderdetail, 500)"> <view class="btn" @tap="$u.debounce(orderdetail, 500)">
<text class="t">去结算</text> <text class="t">去结算</text>
@@ -436,6 +434,9 @@
// 计算高度 // 计算高度
const navScroll = ref(null) const navScroll = ref(null)
// 用餐人数
const dinersNum = ref(0)
// 获取商品数据 // 获取商品数据
const shopProductList = reactive({ const shopProductList = reactive({
hots: [], hots: [],
@@ -762,7 +763,6 @@
} }
// 判断购物车是否有该选中商品 // 判断购物车是否有该选中商品
let res = await matchingProduct(item) let res = await matchingProduct(item)
console.log(res)
websocketsendMessage({ websocketsendMessage({
id: res ? item.cartListId : '', id: res ? item.cartListId : '',
type: 'shopping', type: 'shopping',
@@ -873,10 +873,6 @@
showCart.value = false showCart.value = false
} }
if (Message.type == 'bc') {
console.log(Message)
}
// 初始化购物车数据 // 初始化购物车数据
if (Message.operate_type == "shopping_init") { if (Message.operate_type == "shopping_init") {
cartList.value = Message.data cartList.value = Message.data
@@ -888,7 +884,8 @@
} }
// 添加或者减少购物后返回 // 添加或者减少购物后返回
if (Message.operate_type == 'shopping_add' || Message.operate_type == 'sopping_edit' || Message.type == 'bc') { if (Message.operate_type == 'shopping_add' || Message.operate_type == 'sopping_edit' || Message
.type == 'bc') {
[Message.data].forEach((objA) => { [Message.data].forEach((objA) => {
const index = cartList.value.findIndex((objB) => objB.id == objA.id); const index = cartList.value.findIndex((objB) => objB.id == objA.id);
if (index !== -1) { if (index !== -1) {
@@ -924,14 +921,25 @@
for (const group of shopProductList.productInfo) { for (const group of shopProductList.productInfo) {
for (const product of group.productList) { for (const product of group.productList) {
if (product.id == cartItem.product_id) { if (product.id == cartItem.product_id) {
console.log(cartItem, product) // 多规格
// 找到匹配的商品,添加 cartListId 属性 if (product.type == 'sku') {
product.skuList.forEach((item) => {
if (item.id == product.id && item.productId == product.id) {
product.salePrice = item.salePrice
product.memberPrice = item.memberPrice
product.originPrice = item.originPrice
}
})
}
// 单规格
return { return {
...product, ...product,
// cartListinfo:cartItem // cartListinfo:cartItem
cartListId: cartItem.id, cartListId: cartItem.id,
cartNumberToAdd: product.type == 'weight' ? 1 : cartItem.number //增加一个数量算法 // cartNumberToAdd: product.type == 'weight' ? 1 : cartItem.number //增加一个数量算法
cartNumberToAdd: cartItem.number //增加一个数量算法
}; };
} }
} }
} }
@@ -944,12 +952,36 @@
const cartLists_count = computed(() => { const cartLists_count = computed(() => {
return matchedProducts.value.reduce((sum, item) => { return matchedProducts.value.reduce((sum, item) => {
// 将 cartNumberToAdd 转换为数字 // 将 cartNumberToAdd 转换为数字
const num = typeof item.cartNumberToAdd === 'string' ? parseFloat(item.cartNumberToAdd) : item const num = typeof item.cartNumberToAdd === 'string' ? parseFloat(item
.cartNumberToAdd) : item
.cartNumberToAdd; .cartNumberToAdd;
return sum + num; return sum + num;
}, 0); }, 0);
}); });
// 使用 computed 计算购物车总价格
const TotalPrices = computed(() => {
// 购物车总数价格
let cart = matchedProducts.value.reduce((total, item) => {
// 是否启用会员价 0否1是
if (shopInfo.isVip == 1 && shopInfo.isMemberPrice == 1) {
// memberPrice会员价
return total + parseFloat(item.memberPrice) * parseFloat(item.cartNumber);
} else {
// salePrice销售价
return total + parseFloat(item.salePrice) * parseFloat(item.salePrice);
}
}, 0);
// 是否免除桌位费 0否1是
if (uni.cache.get('shopInfo').isTableFee == 0) {
console.log( cart + dinersNum.value * parseFloat(uni.cache.get('shopInfo').tableFee))
return cart + parseFloat(dinersNum.value) * parseFloat(uni.cache.get('shopInfo').tableFee)
} else {
return cart;
}
});
// 定义 ifcartNumber 计算属性方法 展示数量 // 定义 ifcartNumber 计算属性方法 展示数量
const ifcartNumber = computed(() => { const ifcartNumber = computed(() => {
return (item) => { return (item) => {
@@ -978,7 +1010,6 @@
// 计算处理后的购物车列表 // 用于筛选后的购物车数组 // 计算处理后的购物车列表 // 用于筛选后的购物车数组
const cartListFilter = computed(() => { const cartListFilter = computed(() => {
console.log(cartList.value)
// 使用 reduce 方法对 cartList 进行处理 // 使用 reduce 方法对 cartList 进行处理
const grouped = cartList.value.reduce((acc, item) => { const grouped = cartList.value.reduce((acc, item) => {
const productId = item.product_id; const productId = item.product_id;
@@ -1033,7 +1064,6 @@
scrollTopSize.value = 0 scrollTopSize.value = 0
topArr.value = [] topArr.value = []
userStore.actionsAPIuser() userStore.actionsAPIuser()
userInfo.value = uni.cache.get('userInfo')
// 数据可以更新 // 数据可以更新
isDataLoaded.value = true; isDataLoaded.value = true;
} }
@@ -1043,6 +1073,13 @@
}) })
onMounted(async () => { onMounted(async () => {
// 获取当前页面栈
const pages = getCurrentPages();
// 获取当前页面实例
const currentPage = pages[pages.length - 1];
// 获取页面参数
const options = currentPage.options;
dinersNum.value = options.dinersNum
await productqueryProduct() await productqueryProduct()
setTimeout(() => { setTimeout(() => {
getElementTop() getElementTop()

View File

@@ -40,9 +40,9 @@
<!-- <u-picker :show="calendarShow" ref="uPicker" :columns="columns" @confirm="confirm" @change="changeHandler"></u-picker> --> <!-- <u-picker :show="calendarShow" ref="uPicker" :columns="columns" @confirm="confirm" @change="changeHandler"></u-picker> -->
<!-- <picker :show="calendarShow" mode="date"></picker> --> <!-- <picker :show="calendarShow" mode="date"></picker> -->
<up-datetime-picker mode="date" @cancel="calendarShow = false" :show="calendarShow" <up-datetime-picker mode="date" @cancel="calendarShow = false" :show="calendarShow"
minDate="-2208988800000" v-model="value1" itemHeight="66" visibleItemCount="5" :minDate="-2208988800000" v-model="value1" itemHeight="66" visibleItemCount="5"
@confirm="confirmTime"></up-datetime-picker> @confirm="confirmTime"></up-datetime-picker>
<u-icon name="arrow-down-fill" color="#000" size="23"></u-icon> <up-icon name="arrow-down-fill" color="#000" size="10"></up-icon>
</view> </view>
<view class="reg-cell"> <view class="reg-cell">
<view class="lable">手机号</view> <view class="lable">手机号</view>
@@ -92,6 +92,10 @@
type: Object, type: Object,
default: () => ({}) default: () => ({})
}, },
memberOpen: {
type: Boolean,
default: false
},
}); });
const formInfo = reactive({ const formInfo = reactive({
@@ -107,8 +111,6 @@
// 用户图片 // 用户图片
const userHeadImg = ref('') const userHeadImg = ref('')
//显示隐藏
const memberOpen = ref(false)
//显示隐藏 //显示隐藏
const isProtocol = ref(false) const isProtocol = ref(false)
@@ -286,7 +288,7 @@
} }
const registerMember = async() => { const registerMember = async () => {
// if ( userHeadImg.value == "" || userHeadImg.value == null ) { // if ( userHeadImg.value == "" || userHeadImg.value == null ) {
// uni.showToast({ // uni.showToast({
// title: '请选择会员头像', // title: '请选择会员头像',

View File

@@ -94,7 +94,8 @@
</view> </view>
<view class="recharge" @tap="$u.debounce(userbalancerechangesub, 500)">立即充值</view> <view class="recharge" @tap="$u.debounce(userbalancerechangesub, 500)">立即充值</view>
</view> </view>
<!-- <registermember :show="memberOpen" :shopId="shopId" @getRegisterMember="getRegisterMember"></registermember> --> <registermember :show="infoForn.shopUserInfo.isVip == 1? false : true" :shopUserInfo="infoForn.shopUserInfo">
</registermember>
</view> </view>
</template> </template>
@@ -105,7 +106,7 @@
reactive, reactive,
onMounted onMounted
} from 'vue'; } from 'vue';
// import registermember from './components/registermember.vue' import registermember from './components/registermember.vue'
import { import {
APIuseractivate, APIuseractivate,

View File

@@ -88,7 +88,7 @@
</view> </view>
</view> </view>
<registermember :show="memberOpen" :shopUserInfo="shopUserInfo.shopInfo" @getRegisterMember="getRegisterMember"> <registermember :show="shopUserInfo.shopInfo.isVip == 1? false : true" :shopUserInfo="shopUserInfo.shopInfo">
</registermember> </registermember>
</view> </view>
@@ -115,7 +115,7 @@
}) })
const form = reactive({ const form = reactive({
memberOpen: '', memberOpen: false,
shopName: "", shopName: "",
amount: '', amount: '',
lucky: { lucky: {

View File

@@ -116,6 +116,7 @@ export const productStore = defineStore('product', {
await this.actionsproductqueryShop() await this.actionsproductqueryShop()
} }
} }
// 是否免除桌位费 0否1是
if (uni.cache.get('shopInfo').isTableFee == 0) { if (uni.cache.get('shopInfo').isTableFee == 0) {
uni.pro.navigateTo('product/choosetable') uni.pro.navigateTo('product/choosetable')
} else { } else {
@@ -132,6 +133,8 @@ export const productStore = defineStore('product', {
} }
}); });
// #endif // #endif
// #ifdef H5 // #ifdef H5
if (uni.cache.get('tableCode')) { if (uni.cache.get('tableCode')) {
let data = await this.actionsproductqueryShop() let data = await this.actionsproductqueryShop()
@@ -143,12 +146,14 @@ export const productStore = defineStore('product', {
await this.actionsproductqueryShop() await this.actionsproductqueryShop()
} }
} }
if (uni.cache.get('shopTable').status != 'idle') { // idle-空闲 using-使用中 subscribe预定closed--关台, opening 开台中cleaning 台桌清理中
if (uni.cache.get('shopTable').status == 'cleaning' || uni.cache.get(
'shopTable').status == 'cleaning') {
uni.showToast({ uni.showToast({
title: '此台桌暂不可用...', title: '此台桌暂不可用...',
icon: 'none' icon: 'none'
}) })
return false return false;
} }
if (uni.cache.get('shopInfo').isTableFee == 0) { if (uni.cache.get('shopInfo').isTableFee == 0) {
@@ -164,37 +169,36 @@ export const productStore = defineStore('product', {
}) })
}, },
// /通过桌码获取店铺信息 // /通过桌码获取当前店铺信息
actionsproductqueryShop() { actionsproductqueryShop() {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
try { // try {
let res = await APIproductqueryShop({ let res = await APIproductqueryShop({
tableCode: uni.cache.get('tableCode'), tableCode: uni.cache.get('tableCode'),
}) })
res.shopInfo.isVip = res.vip ? '1' : '0' res.shopInfo.isVip = res.vip ? '1' : '0'
res.shopTable.shopExtendMap = res.shopExtendMap res.shopTable.shopExtendMap = res.shopExtendMap
// 店铺信息 // 店铺信息
uni.cache.set('shopTable', res.shopTable) uni.cache.set('shopTable', res.shopTable)
// 台桌信息 // 台桌信息
uni.cache.set('shopInfo', res.shopInfo) uni.cache.set('shopInfo', res.shopInfo)
uni.cache.set('shopId', res.shopTable.shopId) uni.cache.set('shopId', res.shopTable.shopId,30)
// 当前用户距离店铺的米数 // 当前用户距离店铺的米数
uni.cache.set('distance', res.distance,5000) uni.cache.set('distance', res.distance)
resolve(res) resolve(res)
} catch (e) { // } catch (e) {
reject(false) // reject(false)
} // }
}) })
}, },
// 获取店铺会员信息 // 通过shopId 获取店铺会员信息
actionsproductqueryProduct() { actionsproductqueryProduct() {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
try { try {
let res = await APIshopUserInfo() let res = await APIshopUserInfo()
// uni.cache.set('ShopUser', res)
uni.cache.set('userInfo', res); uni.cache.set('userInfo', res);
resolve(true) resolve(true)
} catch (e) { } catch (e) {