tapd相关修改更新
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user