代码更新

This commit is contained in:
GaoHao
2025-03-10 09:14:57 +08:00
parent 4f65b08c06
commit 490c513f48
48 changed files with 1162 additions and 537 deletions

View File

@@ -25,11 +25,11 @@
<!-- 占位 -->
<view class="color-333 item border-top u-flex u-row-center u-row-between"
v-for="(item,index) in data" :key="index">
<view class="">
<view class="u-line-1">{{item.name}}</view>
<view class="u-m-t-10 u-font-24 color-666 u-line-1">{{item.specInfo||''}}</view>
<view>
<view class="up-line-1" >{{item.name}}</view>
<view class="u-m-t-10 u-font-24 color-666 up-line-1">{{item.specInfo||''}}</view>
</view>
<view class="u-flex">
<view class="u-flex" style="flex-shrink: 0;">
<view class="font-bold red u-m-r-32">{{formatPrice(item.lowPrice*item.number) }}</view>
<view class="u-flex" @tap="updateNumber(false,index,item)">
<image src="/pagesCreateOrder/static/images/icon-reduce-black.svg" class="icon" mode="">
@@ -51,7 +51,7 @@
</view>
<view class="icon-car-box" @tap="toggleGoods">
<image src="/pagesCreateOrder/static/images/icon-car.svg" class="icon-car" />
<view class="dot">{{goodsNumber}}</view>
<view class="dot" v-if="goodsNumber>0">{{goodsNumber}}</view>
</view>
<view class="price font-bold u-flex">
<view></view>
@@ -152,9 +152,9 @@
if (props.data.length <= 0) {
return infoBox.showToast('还没有选择商品')
}
const { name, maxCapacity, status, type } = props.table
const { name, status, type } = props.table
console.log(props.table)
if (props.table.id == '') {
if (props.table.id == ''&&props.table.tableCode == '') {
go.to('PAGES_CONFIRM_ORDER', {
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
})
@@ -163,8 +163,8 @@
go.to('PAGES_CONFIRM_ORDER', {
type: type,
tableId: props.table.id,
tableCode: props.table.tableCode,
name:name,
maxCapacity:maxCapacity,
status:status,
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
})

View File

@@ -97,6 +97,8 @@
arr.push(group)
datas.selectNumber += ele.number
})
console.log(arrlength)
console.log(datas.selectNumber)
if (arrlength == datas.selectNumber) {
emits('confirm', arr, datas.item)
close()

View File

@@ -116,13 +116,6 @@
import { onLoad, onReady, onShow } from '@dcloudio/uni-app';
import { computed, reactive, ref, nextTick, watch, getCurrentInstance, onUnmounted, onBeforeUnmount } from 'vue';
import * as Api from '@/http/yskApi/Instead.js'
import {
$table,
} from '@/http/yskApi/table.js'
import {
$tbShopCategory
} from '@/http/yskApi/goods.js'
import util from './util.js';
import color from '@/commons/color.js';
import guigeModel from './components/guige'
@@ -130,8 +123,8 @@
import weighItem from './components/weigh.vue'
import listGoodsItem from './components/list-goods-item.vue'
import mySurcharge from './components/surcharge'
import myCar from './components/car'
import go from '@/commons/utils/go.js';
import infoBox from '@/commons/utils/infoBox.js';
import { getNowCart } from '@/pagesCreateOrder/util.js'
@@ -149,7 +142,7 @@
import { getProductList } from '@/api/product.js'
import { categoryPage } from '@/api/cateGory.js'
import { inject } from 'vue';
import { getShopInfo } from '@/api/shop.js'
const modal = reactive({
@@ -194,8 +187,9 @@
is_gift: 0
},
orderId: null,
isCars: false,
isGoodsAdd: true,
goodsData: null,
})
const guigeModelData = reactive({
title: '',
@@ -213,6 +207,7 @@
onLoad((opt) => {
option = opt
console.log("opt===",opt)
Object.assign(data.table, opt)
if (opt.useType) {
uni.setStorageSync('useType', opt.useType)
@@ -224,6 +219,7 @@
isCreateOrderToDetail.value = true
}
init()
xiadanClick()
})
watch(() => data.table.id, (newval, oldval) => {
if (option.type != 'add') {
@@ -249,6 +245,15 @@
onUnmounted(() => {
});
/**
* 判断是否允许下单
*/
let canXiadan = ref(false)
async function xiadanClick() {
canXiadan.value = await hasPermission('允许下单')
}
let $originGoods = []
let $category = []
@@ -257,8 +262,8 @@
if (option.type == 'add') {
setTabBar($category, $originGoods, [])
}
const useType = data.table.status == 'using' ? data.table.useType : $returnUseType(uni.getStorageSync("shopInfo"))
let shopInfo = await getShopInfo({id:uni.getStorageSync('shopInfo').id})
const useType = data.table.status == 'using' ? data.table.useType : $returnUseType(shopInfo)
uni.setStorageSync('useType', useType)
// await getTableInfo()
@@ -276,14 +281,16 @@
return isShow;
});
$originGoods = goods;
if (option.type == 'add') {
cars.length = 0
initCart()
setTabBar($category, goods, [])
return
}
setTabBar($category, goods, cars)
initCart()
}
@@ -294,6 +301,8 @@
websocketUtil.onMessage(res => {
let msg = JSON.parse(res);
let cartItem;
let cartArr = [];
console.log(msg)
if( msg.msg_id ){
websocketUtil.send(JSON.stringify({
type: 'receipt',
@@ -302,29 +311,42 @@
}
if( msg.status == 0 ){
infoBox.showToast('添加失败')
return false;
data.isGoodsAdd = true;
return;
}
if ( msg.data ) {
cartArr = data.tabbar.reduce((prve,cur)=>{
prve = [...prve,...cur.foods]
return prve
},[])
}
switch (msg.operate_type) {
case 'onboc_init':
cars.length = 0
data.isCars = true;
console.log("购物车信息onboc_init===",msg)
msg.data.map(item=>{
cartItem = getNowCart(item,$originGoods)
cartItem = getNowCart(item,cartArr)
cartControls(cartItem,'add')
})
uni.hideLoading()
break;
case 'onboc_add':
case 'add':
cartItem = getNowCart(msg.data,$originGoods)
cartItem = getNowCart(msg.data,cartArr)
cartControls(cartItem,'add')
infoBox.showToast('添加成功')
break;
case 'onboc_edit':
case 'edit':
cartItem = getNowCart(msg.data,$originGoods)
cartItem = getNowCart(msg.data,cartArr)
cartControls(cartItem,'edit')
infoBox.showToast('添加成功')
break;
case 'onboc_del':
case 'del':
cartItem = getNowCart(msg.data,$originGoods)
cartItem = getNowCart(msg.data,cartArr)
cartControls(cartItem,'del')
break;
case 'onboc_cleanup':
@@ -336,6 +358,13 @@
}
}
break;
case 'init':
case 'rottable':
initCart()
break;
case 'product_update':
init()
break;
}
});
@@ -351,6 +380,9 @@
table_code: data.table.tableCode,
}
websocketUtil.send(JSON.stringify(params))
}
/**
@@ -358,6 +390,7 @@
*/
function editCart (par,operate_type) {
console.log('购物车添加菜品',par)
if( !data.isGoodsAdd ){ return; }
let params = {
...data.socketData,
operate_type: operate_type,
@@ -369,6 +402,7 @@
}
Object.assign(params, par)
websocketUtil.send(JSON.stringify(params))
data.isGoodsAdd = false;
}
/**
@@ -461,11 +495,24 @@
return
}
console.log('---table:detail-----',item);
console.log('---table_code-----',data.table.tableCode);
console.log('---new_table_code-----',item.tableCode);
let params = {
...data.socketData,
operate_type: 'rottable',
table_code: data.table.tableCode,
new_table_code: item.tableCode,
}
console.log(cars)
if (data.table.id || cars.length <= 0) {
data.table = {
...item
}
initCart()
if( cars.length > 0){
websocketUtil.send(JSON.stringify(params))
}
// initCart()
return;
}
if (item.status == "unbind") {
@@ -475,7 +522,10 @@
return infoBox.showToast('该台桌已在使用中')
}
data.table = item
initCart()
if( cars.length > 0){
websocketUtil.send(JSON.stringify(params))
}
// initCart()
}
/**
@@ -492,6 +542,10 @@
// chooseTable()
// })
// }
if( !data.isCars ){
return infoBox.showToast('购物车加载中请稍等...')
}
if( !data.isGoodsAdd ){ return; }
let $goods = data.tabbar[index].foods[foodsindex]
if ($goods.type !== 'sku') {
//单规格
@@ -525,6 +579,7 @@
product_id: product_id,
sku_id: sku_id,
},'edit')
data.isGoodsAdd = false;
setSearchGoods(searchGoodsIndex, number)
} else {
// 不影响之前的代码 称重suit单独处理
@@ -539,7 +594,7 @@
product_id: product_id,
sku_id: sku_id,
},'add')
infoBox.showToast('添加成功')
data.isGoodsAdd = false;
}
}
return
@@ -554,6 +609,7 @@
if( !data.table.tableCode ){
data.table.tableCode = cartItem.table_code
}
data.isGoodsAdd = true;
let cartIndex = 0;
let product_id = cartItem.product_id
let sku_id = cartItem.sku_id
@@ -565,28 +621,19 @@
sku_id = item.sku_id
}
})
data.tabbar.map(tabbarItem=>{
if(tabbarItem.foods.find(v => v.id == product_id)){
$goods = !product_id ? undefined : tabbarItem.foods.find(v => v.id == product_id)
$goods = product_id < 0 ? {} : tabbarItem.foods.find(v => v.id == product_id)
}
})
console.log($goods)
let $sku;
if( $goods.type != 'package'){
//临时菜没有skuList
$sku = !product_id ? { suitNum: 1 } : $goods.skuList.find(v => v.id == sku_id)
} else {
$sku = !product_id ? { suitNum: 1 } : $goods.skuList.find(v => v.id == sku_id)
}
if( type == 'del' ) {
cars.splice(cartIndex, 1)
$goods.chooseNumber = 0
if($goods)$goods.chooseNumber = 0;
return;
}
if( type == 'add' ){
cars.push(cartItem)
$goods.chooseNumber = cartItem.number
if($goods)$goods.chooseNumber = cartItem.number
}
if( type == 'edit' ){
cars[cartIndex].number = cartItem.number
@@ -602,6 +649,7 @@
*/
async function carsNumberChange(e) {
console.log("carsNumberChange===",e)
if( !data.isGoodsAdd ){ return; }
let $sku;
let $goods;
data.tabbar.map(tabbarItem=>{
@@ -626,6 +674,7 @@
product_id: e.goods.product_id,
sku_id: e.goods.sku_id
},'edit')
data.isGoodsAdd = false;
}
/**
@@ -635,15 +684,47 @@
*/
async function taocanConfirm(d, item) {
console.log(d)
editCart({
number: item.skuList[0].suitNum,
product_id: item.id,
sku_id: item.skuList[0].id,
pro_group_info: JSON.stringify(d),
},'add')
let carGoods = null;
cars.some(item=>{
if(item.product_id == data.goodsData.id){
let arr = []
JSON.parse(item.pro_group_info).some((v,i)=>{
if( JSON.stringify(v.selectData) == JSON.stringify(d[i].selectData) ){
arr.push(v)
}
})
if( arr.length == d.length ) {
carGoods = item
return carGoods;
}
}
})
if (carGoods) {
//更新
let newNumber = carGoods.number * 1 + 1
editCart({
id: carGoods.id,
number: newNumber,
product_id: carGoods.product_id,
sku_id: carGoods.sku_id,
},'edit')
data.isGoodsAdd = false;
} else {
//添加
editCart({
number: item.skuList[0].suitNum,
product_id: item.id,
sku_id: item.skuList[0].id,
pro_group_info: JSON.stringify(d),
},'add')
data.isGoodsAdd = false;
}
}
const instance = getCurrentInstance();
let selGoods = ref({});
/**
* 打开规格弹窗
@@ -656,10 +737,14 @@
// chooseTable()
// })
// }
if( !data.isCars ){
return infoBox.showToast('购物车加载中请稍等...')
}
const $goods = data.tabbar[index].foods[foodsindex]
console.log($goods)
selGoods.value = $goods
if ($goods.groupType == 1) {
data.goodsData = $goods
instance.ctx.$refs.taocanModelRef.open()
} else {
console.log($goods)
@@ -716,6 +801,7 @@
*/
async function guigeConfirm(sku, suitNum) {
console.log(sku)
if( !data.isGoodsAdd ){ return; }
let goods = guigeModelData.chooseGoods.item
let sku_id = sku.id
let product_id = goods.id
@@ -732,7 +818,8 @@
number: newNumber,
product_id: product_id,
sku_id: sku_id,
},'add')
},'edit')
data.isGoodsAdd = false;
} else {
//添加
editCart({
@@ -740,7 +827,7 @@
product_id: product_id,
sku_id: sku_id,
},'add')
infoBox.showToast('添加成功')
data.isGoodsAdd = false;
}
}
@@ -868,13 +955,7 @@
}
}
const instance = getCurrentInstance();
let canXiadan = ref(false)
async function xiadanClick() {
canXiadan.value = await hasPermission('允许下单')
}
// xiadanClick()
@@ -1037,9 +1118,14 @@
// 称重
/**
* 称重
*/
const refweighitem = ref(null)
const tapweigh = (foodsindex, index) => {
if( !data.isCars ){
return infoBox.showToast('购物车加载中请稍等...')
}
const goods = data.tabbar[index].foods[foodsindex]
refweighitem.value.open(foodsindex, index, goods)
}