代码更新

This commit is contained in:
GaoHao
2025-03-04 18:30:16 +08:00
parent fd0c452a76
commit 4f65b08c06
32 changed files with 622 additions and 1616 deletions

View File

@@ -161,7 +161,15 @@
</view>
</template>
<template v-else>
<template v-if="isVip&&item.lowMemberPrice&&item.lowMemberPrice*1!=item.lowPrice*1">
<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>
<view class="u-absolute" style="right: 0;bottom: 100%;">
<text
class="font-bold">{{formatPrice(item.discount_sale_amount*item.number) }}</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>
<view class="u-absolute" style="right: 0;bottom: 100%;">
@@ -289,8 +297,6 @@
import oneRemark from './components/remark'
import editDiscount from '@/pagesCreateOrder/components/edit-discount.vue'
import go from '@/commons/utils/go.js';
import { returnBoolean } from '@/commons/utils/format.js';
import color from '@/commons/color.js';
import * as Api from '@/http/yskApi/Instead.js'
import $storageManage from '@/commons/utils/storageManage.js'
import { hasPermission } from '@/commons/utils/hasPermission.js'
@@ -298,7 +304,7 @@
import { getShopInfo } from '@/api/shop.js'
import { getShopTableDetail } from '@/api/table.js'
import { getProductList } from '@/api/product.js'
import { createOrder } from '@/api/order.js'
import { createOrder,getHistoryOrder } from '@/api/order.js'
import { number } from 'uview-plus/libs/function/test';
const models = new Map();
@@ -350,13 +356,14 @@
},
form: {
note: ""
}
},
orderInfo: {}
})
onLoad((opt) => {
Object.assign(option, opt)
console.log(opt);
if (opt) {
if (opt.tableId) {
userNumbers.list = new Array(opt.maxCapacity ? opt.maxCapacity * 1 : 100).fill(1).map((v, index) => {
return (index + 1) + '人'
})
@@ -377,7 +384,7 @@
updateChoseCount()
})
watch(() => eatTypes.active, (newval) => {
watch(() => pageData.eatTypes.active, (newval) => {
changeUseType()
})
onBeforeUnmount(() => {
@@ -388,6 +395,15 @@
watchChooseTable()
})
/**
* 获取订单详情
* @param {Object} tableCode
*/
async function getHistoryOrderDetail(tableCode){
let res = await getHistoryOrder({tableCode:tableCode});
pageData.orderInfo = res;
}
//餐位费
const $seatFee = reactive({
totalNumber: 0,
@@ -413,9 +429,10 @@
return result
})
/**
* 判断是否是会员
*/
const isVip = computed(() => {
console.log("pageData==",pageData)
return pageData.shopInfo.isMemberPrice && pageData.user && pageData.user.id && pageData.user.isVip
})
@@ -429,19 +446,19 @@
})
const goodsPrice = computed(() => {
console.log("isVip===",isVip.value)
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
const lowMemberPrice = cur.lowMemberPrice ? cur.lowMemberPrice : cur.lowPrice
const tPrice = (isVip.value ? lowMemberPrice : cur.lowPrice) * cur.number
const tpackFee = parseFloat(cur.pack_number).toFixed(0) > 0 ? cur.packFee*parseFloat(cur.pack_number).toFixed(0) : 0
return prve + (cur.is_gift ? 0 : tPrice) + tpackFee
}, 0)
console.log("discount_sale_amount===",discount_sale_amount)
return ((goodsTotalPrice - discount_sale_amount.value) || 0).toFixed(2)
})
/**
* 实收金额
*/
const allPrice = computed(() => {
console.log("isVip===",goodsPrice.value)
const n = goodsPrice.value * 1 + $seatFee.totalAmount
return n.toFixed(2)
})
@@ -454,10 +471,12 @@
if (pageData.user && pageData.user.id && pageData.user.isVip) {
goodsTotalPrice = goods.list.reduce((prve, cur) => {
const tPrice = cur.lowPrice * cur.number
const tpackFee = cur.is_pack ? cur.packFee * 1 : 0
return prve + tPrice + tpackFee
const tpackFee = (cur.pack_number*1) > 0 ? cur.packFee * (cur.pack_number*1) : 0
console.log(cur)
return prve + tPrice + tpackFee
}, 0)
return goodsTotalPrice - allPrice.value
console.log(goodsTotalPrice)
return (goodsTotalPrice + $seatFee.totalAmount) - allPrice.value
} else {
return (discount_sale_amount.value)
}
@@ -468,11 +487,10 @@
/**
* socket消息监听
*/
websocketUtil.onMessage(data => {
let msg = JSON.parse(data);
websocketUtil.onMessage(res => {
let msg = JSON.parse(res);
let cartItem;
if( msg.msg_id ){
// console.log('Received data:', msg);
websocketUtil.send(JSON.stringify({
type: 'receipt',
msg_id: msg.msg_id,
@@ -482,20 +500,57 @@
infoBox.showToast('添加失败')
return false;
}
switch (msg.operate_type) {
case 'onboc_init':
goods.list = []
msg.data.map(item=>{
cartItem = getNowCart(item,$goods)
goods.list.push(cartItem)
cartItem = getNowCart(item,$goods,pageData.user)
cartControls(cartItem,'add')
})
console.log("goods.list===",goods.list)
break;
case 'onboc_add':
case 'add':
cartItem = getNowCart(msg.data,$originGoods,pageData.user)
cartControls(cartItem,'add')
break;
case 'onboc_edit':
case 'edit':
cartItem = getNowCart(msg.data,$originGoods,pageData.user)
cartControls(cartItem,'edit')
break;
case 'onboc_del':
case 'del':
cartItem = getNowCart(msg.data,$originGoods,pageData.user)
cartControls(cartItem,'del')
break;
case 'onboc_cleanup':
case 'cleanup':
goods.lis = []
break;
}
});
/**
* socket通知购物车商品数量修改处理
*/
function cartControls (cartItem,type) {
if( !pageData.table.tableCode ){
pageData.table.tableCode = cartItem.table_code
}
let cartIndex = 0;
if( type == 'del' ) {
goods.list.splice(cartIndex, 1)
return;
}
if( type == 'add' ){
goods.list.push(cartItem)
}
if( type == 'edit' ){
goods.list[cartIndex].number = cartItem.number
}
}
async function init() {
let goodsRes = await getGoods()
@@ -542,6 +597,7 @@
async function getTbShopInfo() {
const res = await getShopInfo({id: uni.getStorageSync('shopInfo').id})
pageData.shopInfo = res
uni.setStorageSync('shopInfo',res)
}
/**
@@ -550,6 +606,7 @@
async function getTableInfo(id) {
const res = await getShopTableDetail({id: id})
pageData.table = res
getHistoryOrderDetail(res.tableCode)
}
/**
@@ -559,20 +616,6 @@
uni.$off('choose-user')
uni.$on('choose-user', (data) => {
pageData.user = data
goods.list.map(item => {
let par = {
id: item.id,
product_id: item.product_id ,
sku_id: item.sku_id
}
let lowMemberPrice = item.lowMemberPrice ? item.lowMemberPrice : item.lowPrice
let tPrice = (isVip.value ? lowMemberPrice : item.lowPrice)
let discount_sale_amount = item.is_gift ? 0 : tPrice
par['discount_sale_amount'] = discount_sale_amount
updateCart(par)
}, 0)
})
}
@@ -595,13 +638,7 @@
if (!goods.list.length) {
return
}
const res = await Api.$changeUseType({
useType,
tableId: tableId || '',
cartIds: goods.list.map((v) => v.id),
})
getCart()
return res
}
/**
@@ -665,7 +702,7 @@
}
let lowMemberPrice = modelData.data.lowMemberPrice ? modelData.data.lowMemberPrice : modelData.data.lowPrice
let tPrice = (isVip.value ? lowMemberPrice : modelData.data.lowPrice)
let discount_sale_amount = modelData.data.is_gift ? 0 : tPrice - form.discountMoney
let discount_sale_amount = modelData.data.is_gift ? 0 : form.discountMoney
let par = {
id: modelData.data.id,
product_id: modelData.data.product_id,
@@ -723,7 +760,7 @@
modelData.data = goods.list[index]
modelData.selIndex = index
const model = models.get(key)
console.log("弹窗数据===",modelData.data)
if( key == 'packNumber'){
if( item.pack_number > 0 ){
let par = {
@@ -838,6 +875,7 @@
}
let vipPrice = isVip.value ? 1 : 0
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
@@ -847,10 +885,14 @@
seatNum: userNumbers.defaultCateIndex * 1 + 1, //用餐人数
packFee: $packFee.value, //打包费
originAmount: goodsPrice.value, //订单原金额(包含打包费+餐位费) 不含折扣价格
placeNum: 0, //当前订单下单次数
placeNum: placeNum, //当前订单下单次数
waitCall: 0, //是否等叫 0 否 1 等叫
vipPrice: vipPrice, //是否使用会员价
}
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)

View File

@@ -88,6 +88,7 @@
$table,
tableswitch
} from '@/http/yskApi/table.js'
import { getShopTable } from '@/api/table.js'
let datas = reactive({
current: 0,
item: "",
@@ -108,10 +109,28 @@
})
onLoad((opt) => {
datas.item = JSON.parse(opt.item)
console.log(datas.item)
})
onShow(() => {
gettableList()
})
/**
* 获取桌台
*/
async function gettableList() {
const res = await getShopTable({
status: 'idle',
})
let arr = []
res.records.forEach((ele) => {
if (ele.status == 'using' && props.tableId != ele.tableId) {
arr.push(ele)
}
});
datas.tableList = arr
}
async function confirm() {
// 是否选择其他桌
if (datas.selecttableList) {
@@ -167,20 +186,7 @@
datas.current = e.currentIndex
}
}
// 获取桌台
async function gettableList() {
const res = await $table.get({
page: 1,
size: 999
})
let arr = []
res.content.forEach((ele) => {
if (ele.status == 'using' && props.tableId != ele.tableId) {
arr.push(ele)
}
});
datas.tableList = arr
}
function formatPrice(n) {
return Number(n).toFixed(2)

View File

@@ -152,13 +152,8 @@
if (props.data.length <= 0) {
return infoBox.showToast('还没有选择商品')
}
const {
name,
maxCapacity,
status,
type
} = props.table
const { name, maxCapacity, status, type } = props.table
console.log(props.table)
if (props.table.id == '') {
go.to('PAGES_CONFIRM_ORDER', {
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0

View File

@@ -94,7 +94,6 @@
})
const goods = computed(() => {
console.log(props.skuMap[selSku.value])
return props.skuMap[selSku.value]
})
watch(() => goods.value, (newval) => {

View File

@@ -185,7 +185,7 @@
},
table: {
tableId: ""
id: ""
},
socketData: {
type:'onboc',
@@ -261,7 +261,7 @@
const useType = data.table.status == 'using' ? data.table.useType : $returnUseType(uni.getStorageSync("shopInfo"))
uni.setStorageSync('useType', useType)
await getTableInfo()
// await getTableInfo()
// 获取分类数据
let categoryRes = await categoryPage({ page: 1, size: 300 })
@@ -294,9 +294,7 @@
websocketUtil.onMessage(res => {
let msg = JSON.parse(res);
let cartItem;
console.log(msg)
if( msg.msg_id ){
// console.log('Received data:', msg);
websocketUtil.send(JSON.stringify({
type: 'receipt',
msg_id: msg.msg_id,
@@ -338,7 +336,6 @@
}
}
break;
}
});
@@ -468,6 +465,7 @@
data.table = {
...item
}
initCart()
return;
}
if (item.status == "unbind") {
@@ -477,6 +475,7 @@
return infoBox.showToast('该台桌已在使用中')
}
data.table = item
initCart()
}
/**
@@ -488,11 +487,11 @@
* @param {Object} showCurrentInput
*/
async function goodsUpdate(foodsindex, index, isAdd, searchGoodsIndex, showCurrentInput) { // showCurrentInput 称重才会传的参数
if (!data.table.id) {
return infoBox.showToast('请先选择桌台', 0.5).then(res => {
chooseTable()
})
}
// if (!data.table.id) {
// return infoBox.showToast('请先选择桌台', 0.5).then(res => {
// chooseTable()
// })
// }
let $goods = data.tabbar[index].foods[foodsindex]
if ($goods.type !== 'sku') {
//单规格
@@ -552,6 +551,9 @@
* socket通知购物车商品数量修改处理
*/
function cartControls (cartItem,type) {
if( !data.table.tableCode ){
data.table.tableCode = cartItem.table_code
}
let cartIndex = 0;
let product_id = cartItem.product_id
let sku_id = cartItem.sku_id
@@ -569,7 +571,7 @@
$goods = !product_id ? undefined : tabbarItem.foods.find(v => v.id == product_id)
}
})
console.log($goods)
let $sku;
if( $goods.type != 'package'){
//临时菜没有skuList
@@ -592,8 +594,6 @@
$goods.chooseNumber = cartItem.number
}
}
console.log(cars)
}
/**
@@ -651,11 +651,11 @@
* @param {Object} index
*/
function chooseGuige(foodsindex, index) {
if (!data.table.id) {
return infoBox.showToast('请先选择桌台', 0.5).then(res => {
chooseTable()
})
}
// if (!data.table.id) {
// return infoBox.showToast('请先选择桌台', 0.5).then(res => {
// chooseTable()
// })
// }
const $goods = data.tabbar[index].foods[foodsindex]
console.log($goods)
selGoods.value = $goods
@@ -869,18 +869,6 @@
}
const instance = getCurrentInstance();
let canXiadan = ref(false)
async function xiadanClick() {
@@ -906,7 +894,7 @@
const tableId = par.code
onChooseTable({
tableId
id: tableId
})
} else {
uni.showToast({
@@ -971,40 +959,6 @@
}
//更新购物车
function updateCartGoods(par) {
const submitPar = {
cartId: '',
tableId: data.table.id,
isPack: false,
num: 1,
productId: '',
skuId: '',
vipUserId: data.vipUser.id
}
Object.assign(submitPar, par)
return Api.$updateCart(submitPar)
}
//更新选择用户
function setUser(par) {
const submitPar = {
tableId: data.table.id,
vipUserId: data.vipUser.id ? data.vipUser.id : '',
type: data.vipUser.id ? 0 : 1 //0 设置 1 取消
}
Object.assign(submitPar, par)
return Api.$setUser(submitPar)
}
// 监听选择用户事件
const surcharge = ref(null)

View File

@@ -1,6 +1,6 @@
// 返回购物车未下单的数据
export function getNowCart(carItem,goodsList) {
export function getNowCart(carItem,goodsList,user) {
// console.log("carItem===",carItem)
// console.log("goodsList===",goodsList)
// const nowCart = records.find(v => v.placeNum == 0)
@@ -10,9 +10,16 @@ export function getNowCart(carItem,goodsList) {
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
if( uni.getStorageSync('shopInfo').isMemberPrice && user && user.id && user.isVip ){
carItem.salePrice = item.memberPrice
} else {
carItem.salePrice = item.salePrice
}
}
})
carItem.name = goodsItem.name