tapd相关修改更新

This commit is contained in:
GaoHao
2025-03-19 18:19:34 +08:00
parent 994cf8bf2b
commit f01bc839f7
53 changed files with 1084 additions and 1032 deletions

View File

@@ -155,7 +155,7 @@
<view class="">
<view class=" u-relative">
<template v-if="item.is_gift">
<text class="line-th color-999">{{formatPrice(item.lowPrice*item.number) }}</text>
<text class="line-th color-999">{{$utils.toFixed(item.lowPrice*item.number,item) }}</text>
<view class="u-absolute" style="right: 0;bottom: 100%;">
<text class="font-bold">0</text>
</view>
@@ -163,24 +163,24 @@
<template v-else>
<template v-if="item.discount_sale_amount&&item.discount_sale_amount*1>0">
<text
class="line-th color-999">{{formatPrice(item.lowPrice*item.number) }}</text>
class="line-th color-999">{{$utils.toFixed(item.lowPrice*item.number,item) }}</text>
<view class="u-absolute" style="right: 0;bottom: 100%;">
<text
class="font-bold">{{formatPrice(item.discount_sale_amount*item.number) }}</text>
class="font-bold">{{$utils.toFixed(item.discount_sale_amount*item.number,item) }}</text>
</view>
</template>
<template v-else-if="isVip&&item.lowMemberPrice&&item.lowMemberPrice*1!=item.lowPrice*1">
<text
class="line-th color-999">{{formatPrice(item.lowPrice*item.number) }}</text>
class="line-th color-999">{{$utils.toFixed(item.lowPrice*item.number,item) }}</text>
<view class="u-absolute" style="right: 0;bottom: 100%;">
<text
class="font-bold">{{formatPrice(item.lowMemberPrice*item.number) }}</text>
class="font-bold">{{$utils.toFixed(item.lowMemberPrice*item.number,item) }}</text>
</view>
</template>
<template v-else>
<view class="font-bold">
<text></text>
<text class="">{{formatPrice(item.lowPrice*item.number) }}</text>
<text class="">{{$utils.toFixed(item.lowPrice*item.number,item) }}</text>
</view>
</template>
@@ -250,7 +250,7 @@
<view class="u-flex">
<view class="u-flex price" v-if="youhui*1>0">
<view class="">优惠金额</view>
<view class="font-bold u-font-32">{{formatPrice(youhui) }}</view>
<view class="font-bold u-font-32">{{$utils.toFixed(youhui) }}</view>
</view>
</view>
@@ -368,7 +368,6 @@
if (opt.tableId||opt.tableCode) {
pageData.table.id = opt.tableId
pageData.table.tableCode = opt.tableCode
getTableInfo(opt)
}
getTbShopInfo()
@@ -490,10 +489,8 @@
// 获取商品列表
$goods = await getProductList({},'product', false)
console.log("商品列表===",$goods)
getTableInfo(pageData.table)
// 获取购物车数据
getCart()
}
/**
@@ -569,6 +566,7 @@
$seatFee.totalNumber = 0
$seatFee.totalAmount = 0
userNumbers.defaultCateIndex = 0
init()
break;
case 'product_update':
init()
@@ -647,13 +645,16 @@
* 获取桌台信息
*/
async function getTableInfo(opt) {
const res = await getShopTableDetail({id: opt.tableId,tableCode: opt.tableCode})
const res = await getShopTableDetail({id: opt.id,tableCode: opt.tableCode})
Object.assign(pageData.table, res)
if(!pageData.shopInfo.isTableFee&&pageData.table&&pageData.table.id){
userNumbers.list = new Array(res.maxCapacity ? res.maxCapacity * 1 : 100).fill(1).map((v, index) => {
return (index + 1) + '人'
})
}
// 获取购物车数据
getCart()
// 获取购物车数据
getHistoryOrderDetail(opt.tableCode)
}
@@ -831,9 +832,7 @@
async function updateChoseCount() {
const maxCapacity = pageData.table&&pageData.table.id ? (pageData.table.maxCapacity || 0) : 100
if (pageData.table&&pageData.table.id && userNumbers.defaultCateIndex * 1 + 1 > maxCapacity) {
uni.showToast({
title: '当前台桌最大人数为: ' + maxCapacity
})
uni.$utils.showToast('当前台桌最大人数为: ' + maxCapacity)
userNumbers.defaultCateIndex = maxCapacity - 1
return
}

View File

@@ -4,7 +4,7 @@
<scroll-view scroll-y="true" style="height: 50vh;" class="u-p-30 guigeModel">
<view class="u-m-b-40" v-for="(item,index) in skus" :key="index">
<view class="u-text-left">
<view class="color-333">{{item.name}}</view>
<view class="color-333 up-line-1" >{{item.name}}</view>
</view>
<view class="u-flex u-m-t-20 u-flex-wrap">
<view class="item" @tap="chooseSkd(index,skd)"

View File

@@ -113,7 +113,7 @@
</template>
<script setup>
import { onLoad, onReady, onShow } from '@dcloudio/uni-app';
import { computed, reactive, ref, nextTick, watch, getCurrentInstance, onUnmounted, onBeforeUnmount } from 'vue';
import { inject, computed, reactive, ref, nextTick, watch, getCurrentInstance, onUnmounted, onBeforeUnmount } from 'vue';
import guigeModel from './components/guige'
import taocanModel from './components/taocanModel.vue'
@@ -124,7 +124,6 @@
import util from './util.js';
import color from '@/commons/color.js';
import go from '@/commons/utils/go.js';
import infoBox from '@/commons/utils/infoBox.js';
import { getNowCart } from '@/pagesCreateOrder/util.js'
import storageManage from '@/commons/utils/storageManage.js'
import { hasPermission } from '@/commons/utils/hasPermission.js'
@@ -133,7 +132,6 @@
import { getShopTable,getShopTableDetail } from '@/http/api/table.js'
import { getProductList } from '@/http/api/product.js'
import { categoryPage } from '@/http/api/cateGory.js'
import { inject } from 'vue';
import { getShopInfo } from '@/http/api/shop.js'
@@ -196,6 +194,7 @@
let option = {
type: ''
}
const websocketUtil = inject('websocketUtil'); // 注入 WebSocket 工具类实例
onLoad((opt) => {
option = opt
@@ -208,9 +207,10 @@
if (JSON.stringify(opt) == '{}') {
isCreateOrderToDetail.value = true
}
if(uni.getStorageSync("table_code")){
if(uni.getStorageSync("table_code")&&!opt.tableCode){
data.table.tableCode = uni.getStorageSync("table_code")
}
// init()
xiadanClick()
})
@@ -222,10 +222,12 @@
onShow(() => {
watchChooseTable()
watchUpdate()
watchSocketOpen()
data.isGoodsAdd = true;
nextTick(()=>{
onMessage()
})
init()
})
onReady(() => {
@@ -233,6 +235,7 @@
data.topZhanwei = res.height
})
getMenuItemTop()
})
onBeforeUnmount(() => {
@@ -242,6 +245,7 @@
});
/**
* 判断是否允许下单
*/
@@ -286,6 +290,24 @@
initCart()
}
/**
* 监听socket是否连接正常
*/
function watchSocketOpen (){
uni.$off('is-socket-open')
uni.$on('is-socket-open', (res) => {
console.log("is-socket-open===",res)
if( res){
data.isCars = true;
data.isGoodsAdd = true;
initCart()
} else {
data.isCars = false;
data.isGoodsAdd = false;
}
})
}
/**
* socket消息监听
*/
@@ -296,11 +318,6 @@
let cartItem;
let cartArr = [];
console.log("onMessage===",msg)
if( msg.msg == "收到了"){
data.isCars = true;
data.isGoodsAdd = true;
initCart()
}
if( msg.msg_id ){
websocketUtil.send(JSON.stringify({
type: 'receipt',
@@ -308,7 +325,7 @@
}))
}
if( msg.status == 0 ){
infoBox.showToast('添加失败')
uni.$utils.showToast('添加失败')
data.isGoodsAdd = true;
return;
}
@@ -344,13 +361,13 @@
case 'add':
cartItem = getNowCart(msg.data,cartArr)
cartControls(cartItem,'add')
infoBox.showToast('操作成功')
uni.$utils.showToast('操作成功')
break;
case 'onboc_edit':
case 'edit':
cartItem = getNowCart(msg.data,cartArr)
cartControls(cartItem,'edit')
infoBox.showToast('操作成功')
uni.$utils.showToast('操作成功')
break;
case 'onboc_del':
case 'del':
@@ -501,7 +518,7 @@
})
// #endif
// #ifndef MP-WEIXIN
infoBox.showToast('桌台不存在或不是该店铺的桌台')
uni.$utils.showToast('桌台不存在或不是该店铺的桌台')
// #endif
return
}
@@ -526,10 +543,10 @@
return;
}
if (item.status == "unbind") {
return infoBox.showToast('该台桌未绑定,清先去桌台管理里绑定码牌')
return uni.$utils.showToast('该台桌未绑定,清先去桌台管理里绑定码牌')
}
if (item.status != "idle") {
return infoBox.showToast('该台桌已在使用中')
return uni.$utils.showToast('该台桌已在使用中')
}
data.table = item
if( cars.length > 0){
@@ -548,14 +565,14 @@
*/
async function goodsUpdate(foodsindex, index, isAdd, searchGoodsIndex, showCurrentInput) { // showCurrentInput 称重才会传的参数
// if (!data.table.id) {
// return infoBox.showToast('请先选择桌台', 0.5).then(res => {
// return uni.$utils.showToast('请先选择桌台', 0.5).then(res => {
// chooseTable()
// })
// }
if( !data.isCars ){
return infoBox.showToast('购物车加载失败请刷新重试...')
return uni.$utils.showToast('购物车加载失败请刷新重试...')
}
if( !data.isGoodsAdd ){ return;infoBox.showToast('isGoodsAdd...') }
if( !data.isGoodsAdd ){ return;uni.$utils.showToast('isGoodsAdd...') }
let $goods = data.tabbar[index].foods[foodsindex]
if ($goods.type !== 'sku') {
//单规格
@@ -563,6 +580,7 @@
return carsGoods.sku_id == $goods.skuList[0].id && carsGoods.product_id == $goods.id;
});
let product_id = $goods.id
let product_type = $goods.type
let sku_id = $goods.skuList[0].id
let suitNum = $goods.skuList[0].suitNum || 1
if (goodsInCarIndex !== -1) {
@@ -586,6 +604,7 @@
id: cartItem.id,
number: number,
product_id: product_id,
product_type: product_type,
sku_id: sku_id,
is_temporary: cartItem.is_temporary
},'edit')
@@ -602,6 +621,7 @@
editCart({
number: suitNum,
product_id: product_id,
product_type: product_type,
sku_id: sku_id,
is_temporary: 0, //是否是临时菜
},'add')
@@ -663,7 +683,13 @@
if( !data.isGoodsAdd ){ return; }
let $sku;
let $goods;
let params = {
number: e.num,
id: e.goods.id,
product_id: e.goods.product_id,
sku_id: e.goods.sku_id,
is_temporary: e.goods.is_temporary
}
if( e.goods.is_temporary != 1){
data.tabbar.map(tabbarItem=>{
if(tabbarItem.foods.find(v => v.id == e.goods.product_id)){
@@ -687,15 +713,13 @@
delCart(e.goods.id)
return
}
console.log(e)
// product_name
params.product_name = e.goods.name
params.sku_name = e.goods.sku_name
}
editCart({
number: e.num,
id: e.goods.id,
product_id: e.goods.product_id,
sku_id: e.goods.sku_id,
is_temporary: e.goods.is_temporary
},'edit')
editCart(params,'edit')
data.isGoodsAdd = false;
}
@@ -708,6 +732,7 @@
editCart({
number: item.skuList[0].suitNum,
product_id: item.id,
product_type: item.type,
sku_id: item.skuList[0].id,
pro_group_info: JSON.stringify(d),
is_temporary: 0, //是否是临时菜
@@ -726,7 +751,7 @@
function chooseGuige(foodsindex, index) {
if( !data.isCars ){
return infoBox.showToast('购物车加载失败请刷新重试...')
return uni.$utils.showToast('购物车加载失败请刷新重试...')
}
const $goods = data.tabbar[index].foods[foodsindex]
selGoods.value = $goods
@@ -789,6 +814,7 @@
let goods = guigeModelData.chooseGoods.item
let sku_id = sku.id
let product_id = goods.id
let product_type = goods.type
let res = findGoodsInCar(goods, sku_id)
if (res) {
//更新
@@ -810,6 +836,7 @@
editCart({
number: suitNum,
product_id: product_id,
product_type: product_type,
sku_id: sku_id,
is_temporary: 0, //是否是临时菜
},'add')
@@ -1084,7 +1111,7 @@
const refweighitem = ref(null)
const tapweigh = (foodsindex, index) => {
if( !data.isCars ){
return infoBox.showToast('购物车加载失败请刷新重试...')
return uni.$utils.showToast('购物车加载失败请刷新重试...')
}
const goods = data.tabbar[index].foods[foodsindex]
refweighitem.value.open(foodsindex, index, goods)