代码更新

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

@@ -115,7 +115,7 @@
const areaId=area.list[area.defaultCateIndex].id||''
let res = await getShopTable({...query,areaId,name:searchValue.value,status:'idle'})
tables.list = res.records
tables.selIndex = res.records.findIndex(v => v.tableId == option.tableId)
tables.selIndex = res.records.findIndex(v => v.id == option.id)
query.totalElements= res.totalRow;
tables.hasAjax = true;

View File

@@ -103,11 +103,7 @@
default: []
}
})
const discounts = [95, 90, 85, 80]
const causes = reactive([{
name: '顾客投诉质量问题',

View File

@@ -70,7 +70,7 @@
</view>
</view>
</template>
<template v-if="!pageData.shopInfo.isTableFee">
<template v-if="!pageData.shopInfo.isTableFee&&pageData.table&&pageData.table.id">
<!-- 不免餐位费 -->
<view class="block">
<view class=" ">
@@ -297,7 +297,6 @@
import oneRemark from './components/remark'
import editDiscount from '@/pagesCreateOrder/components/edit-discount.vue'
import go from '@/commons/utils/go.js';
import * as Api from '@/http/yskApi/Instead.js'
import $storageManage from '@/commons/utils/storageManage.js'
import { hasPermission } from '@/commons/utils/hasPermission.js'
import { getNowCart } from '@/pagesCreateOrder/util.js'
@@ -313,8 +312,8 @@
selIndex: -1
})
const option = reactive({
masterId: '',
tableId: ""
id: '',
tableId: "",
})
/**
* 用餐人数
@@ -362,12 +361,11 @@
onLoad((opt) => {
Object.assign(option, opt)
console.log(opt);
if (opt.tableId) {
userNumbers.list = new Array(opt.maxCapacity ? opt.maxCapacity * 1 : 100).fill(1).map((v, index) => {
return (index + 1) + '人'
})
getTableInfo(opt.tableId)
console.log("opt====",opt);
if (opt.tableId||opt.tableCode) {
pageData.table.id = opt.tableId
pageData.table.tableCode = opt.tableCode
getTableInfo(opt)
}
getTbShopInfo()
init()
@@ -511,23 +509,26 @@
break;
case 'onboc_add':
case 'add':
cartItem = getNowCart(msg.data,$originGoods,pageData.user)
cartItem = getNowCart(msg.data,$goods,pageData.user)
cartControls(cartItem,'add')
break;
case 'onboc_edit':
case 'edit':
cartItem = getNowCart(msg.data,$originGoods,pageData.user)
cartItem = getNowCart(msg.data,$goods,pageData.user)
cartControls(cartItem,'edit')
break;
case 'onboc_del':
case 'del':
cartItem = getNowCart(msg.data,$originGoods,pageData.user)
cartItem = getNowCart(msg.data,$goods,pageData.user)
cartControls(cartItem,'del')
break;
case 'onboc_cleanup':
case 'cleanup':
goods.lis = []
break;
case 'product_update':
init()
break;
}
});
@@ -556,7 +557,6 @@
let goodsRes = await getGoods()
// await getCart()
$goods = goodsRes.records
console.log($seatFee);
if (!$seatFee.totalNumber) {
updateChoseCount()
}
@@ -603,10 +603,16 @@
/**
* 获取桌台信息
*/
async function getTableInfo(id) {
const res = await getShopTableDetail({id: id})
pageData.table = res
getHistoryOrderDetail(res.tableCode)
async function getTableInfo(opt) {
const res = await getShopTableDetail({id: opt.tableId,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) + '人'
})
}
getHistoryOrderDetail(opt.tableCode)
}
/**
@@ -797,15 +803,16 @@
* 更新就餐人数
*/
async function updateChoseCount() {
const maxCapacity = pageData.table.id ? (pageData.table.maxCapacity || 0) : 100
if (pageData.table.id && userNumbers.defaultCateIndex * 1 + 1 > maxCapacity) {
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
})
userNumbers.defaultCateIndex = maxCapacity - 1
return
}
if (!pageData.shopInfo.isTableFee && pageData.table.id) {
console.log(pageData.table)
if (!pageData.shopInfo.isTableFee && pageData.table && pageData.table.id) {
//不免餐位费
let seatFee = {
@@ -827,10 +834,6 @@
userNumbers.defaultCateIndex = e.detail.value
}
function chooseUser() {
go.to('PAGES_CHOOSE_USER')
}
@@ -841,11 +844,6 @@
})
}
function watchChooseTable() {
uni.$off('choose-table')
uni.$on('choose-table', (data) => {
@@ -854,9 +852,6 @@
})
}
function changeGoodsSel(index) {
goods.sel = index
}
@@ -878,23 +873,24 @@
let placeNum = pageData.shopInfo.registerType == 'after'&&pageData.orderInfo ? pageData.orderInfo.placeNum + 1 : 1;
let par = {
shopId: pageData.shopInfo.id, //店铺Id
userId: pageData.user.userId, //用户Id
userId: pageData.user.userId, //用户Id
tableCode: pageData.table.tableCode, //台桌编码
dineMode: pageData.eatTypes.active, //用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
remark: pageData.form.note, //备注
seatNum: userNumbers.defaultCateIndex * 1 + 1, //用餐人数
seatNum: 0, //用餐人数
packFee: $packFee.value, //打包费
originAmount: goodsPrice.value, //订单原金额(包含打包费+餐位费) 不含折扣价格
placeNum: placeNum, //当前订单下单次数
waitCall: 0, //是否等叫 0 否 1 等叫
vipPrice: vipPrice, //是否使用会员价
}
if(!pageData.shopInfo.isTableFee&&pageData.table&&pageData.table.id){
par.seatNum = userNumbers.defaultCateIndex * 1 + 1
}
if(pageData.shopInfo.registerType == 'after'&&pageData.orderInfo){
par.orderId = pageData.orderInfo.id
}
console.log(userNumbers.defaultCateIndex * 1 + 1)
console.log(pageData.shopInfo.registerType)
const res = await createOrder(par)
uni.$emit('update:createOrderIndex')
websocketUtil.send(JSON.stringify({

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)
}

View File

@@ -10,7 +10,6 @@ export function getNowCart(carItem,goodsList,user) {
if(carItem.product_id == goodsItem.id){
goodsItem.skuList.map(item=>{
if(carItem.sku_id == item.id){
console.log(item)
carItem.lowPrice = item.salePrice
carItem.lowMemberPrice = item.memberPrice
carItem.specInfo = item.specInfo