代码更新
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user