代码更新
This commit is contained in:
131
pagesCreateOrder/confirm-order/components/pack-number.vue
Normal file
131
pagesCreateOrder/confirm-order/components/pack-number.vue
Normal file
@@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||
<template #desc>
|
||||
<view class="u-text-left u-p-l-30 u-p-r-30 u-p-t-30 ">
|
||||
<view class="u-m-t-32 u-flex ">
|
||||
<uni-easyinput type="number" v-model="form.pack_number" placeholder="打包数量"></uni-easyinput>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-p-l-30 u-p-r-30 u-m-t-28 u-p-b-30">
|
||||
<view class="">
|
||||
<my-button @tap="confirm" shape="circle" fontWeight="700">确认</my-button>
|
||||
<view class="u-m-t-10">
|
||||
<my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, nextTick, ref } from 'vue';
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
|
||||
const $form = {
|
||||
pack_number: 1
|
||||
}
|
||||
const form = reactive({
|
||||
number: null,
|
||||
...$form
|
||||
})
|
||||
|
||||
function resetForm() {
|
||||
Object.assign(form, {
|
||||
...$form
|
||||
})
|
||||
}
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open(data) {
|
||||
console.log(data)
|
||||
form.number = data.number
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const emits = defineEmits(['confirm'])
|
||||
|
||||
function confirm() {
|
||||
const { pack_number } = form
|
||||
if( pack_number > form.number){
|
||||
uni.showToast({
|
||||
title: '打包数量不能大于菜品数量',
|
||||
icon: 'none'
|
||||
})
|
||||
return false;
|
||||
}
|
||||
emits('confirm', pack_number)
|
||||
close()
|
||||
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.lh34{
|
||||
line-height: 34rpx;
|
||||
}
|
||||
.tag {
|
||||
background-color: #fff;
|
||||
border: 1px solid #E5E5E5;
|
||||
line-height: inherit;
|
||||
font-size: 24rpx;
|
||||
color: #666666;
|
||||
padding: 6rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
|
||||
&.active {
|
||||
border-color: #E6F0FF;
|
||||
color: $my-main-color;
|
||||
}
|
||||
}
|
||||
|
||||
.hover-class {
|
||||
background-color: #E5E5E5;
|
||||
}
|
||||
|
||||
.discount {
|
||||
.u-absolute {
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.bg1 {
|
||||
background: #F7F7FA;
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 0 80rpx;
|
||||
}
|
||||
|
||||
.border {
|
||||
border: 1px solid #E5E5E5;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
padding: 22rpx 32rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.placeholder-class {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
@@ -135,7 +135,7 @@
|
||||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
</view>
|
||||
<view class="u-m-r-20 u-flex" v-if="item.is_pack" style="flex-shrink: 0;" >
|
||||
<view class="u-m-r-20 u-flex" v-if="item.pack_number>0" style="flex-shrink: 0;" >
|
||||
<uni-tag
|
||||
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
|
||||
size="small" text="打包" inverted type="success" />
|
||||
@@ -149,7 +149,7 @@
|
||||
{{item.name}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-font-24 color-999 u-m-t-10">{{item.specSnap||' '}}</view>
|
||||
<view class="u-font-24 color-999 u-m-t-10">{{item.specInfo||' '}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="">
|
||||
@@ -199,7 +199,7 @@
|
||||
</view>
|
||||
<view class="u-flex u-m-r-20 ">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="toggleGoodsItemKey(item,index,'is_pack')">{{item.is_pack?'取消打包':'打包'}}</button>
|
||||
@tap="showModel('packNumber',index,item)">{{item.pack_number>0?'取消打包':'打包'}}</button>
|
||||
</view>
|
||||
<view class="u-flex u-m-r-20 ">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@@ -262,7 +262,7 @@
|
||||
<view class="btn ">
|
||||
<my-button shape="circle" @click="createAnOrder">
|
||||
<view class="font-bold u-font-32">
|
||||
{{(pageData.shopInfo.registerType=='munchies'||pageData.eatTypes.active=='take-out')?'结算': '下单'}}
|
||||
{{(pageData.shopInfo.registerType=='before'||pageData.eatTypes.active=='take-out')?'结算': '下单'}}
|
||||
</view>
|
||||
</my-button>
|
||||
</view>
|
||||
@@ -272,6 +272,7 @@
|
||||
@confirm="discountconfirm"></model-discount>
|
||||
<give-food title="赠菜" :ref="setModel" name="giveFood"></give-food>
|
||||
<one-remark @confirm="goodsOneRemarkConfirm" title="单品备注" :ref="setModel" name="remark"></one-remark>
|
||||
<pack-number @confirm="goodsOnePackNumberConfirm" title="打包" :ref="setModel" name="packNumber"></pack-number>
|
||||
<edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount>
|
||||
</view>
|
||||
|
||||
@@ -284,6 +285,7 @@
|
||||
import { getSafeBottomHeight } from '@/commons/utils/safe-bottom.js'
|
||||
import modelDiscount from './components/discount'
|
||||
import giveFood from './components/give-food'
|
||||
import packNumber from './components/pack-number'
|
||||
import oneRemark from './components/remark'
|
||||
import editDiscount from '@/pagesCreateOrder/components/edit-discount.vue'
|
||||
import go from '@/commons/utils/go.js';
|
||||
@@ -297,6 +299,7 @@
|
||||
import { getShopTableDetail } from '@/api/table.js'
|
||||
import { getProductList } from '@/api/product.js'
|
||||
import { createOrder } from '@/api/order.js'
|
||||
import { number } from 'uview-plus/libs/function/test';
|
||||
|
||||
const models = new Map();
|
||||
const modelData = reactive({
|
||||
@@ -307,7 +310,9 @@
|
||||
masterId: '',
|
||||
tableId: ""
|
||||
})
|
||||
//用餐人数
|
||||
/**
|
||||
* 用餐人数
|
||||
*/
|
||||
const userNumbers = reactive({
|
||||
list: new Array(100).fill(1).map((v, index) => {
|
||||
// return index === 0 ? '无' : index + '人'
|
||||
@@ -360,7 +365,6 @@
|
||||
getTbShopInfo()
|
||||
init()
|
||||
|
||||
// updateChoseCount()
|
||||
})
|
||||
let bottomHeight = ref(100)
|
||||
onReady(() => {
|
||||
@@ -390,6 +394,26 @@
|
||||
totalAmount: 0,
|
||||
})
|
||||
|
||||
/**
|
||||
* 打包费
|
||||
*/
|
||||
const $packFee = computed(() => {
|
||||
return goods.list.reduce((prve, cur) => {
|
||||
return prve + (cur.packFee*parseFloat(cur.pack_number).toFixed(0))
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
|
||||
/**
|
||||
* 菜品数量
|
||||
*/
|
||||
const goodsNumber = computed(() => {
|
||||
const result = goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
return result
|
||||
})
|
||||
|
||||
|
||||
const isVip = computed(() => {
|
||||
console.log("pageData==",pageData)
|
||||
return pageData.shopInfo.isMemberPrice && pageData.user && pageData.user.id && pageData.user.isVip
|
||||
@@ -405,17 +429,19 @@
|
||||
})
|
||||
|
||||
const goodsPrice = computed(() => {
|
||||
console.log("isVip.value===",isVip.value)
|
||||
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 = cur.is_pack ? cur.packFee * 1 : 0
|
||||
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)
|
||||
})
|
||||
@@ -433,10 +459,8 @@
|
||||
}, 0)
|
||||
return goodsTotalPrice - allPrice.value
|
||||
} else {
|
||||
console.log(discount_sale_amount.value, '优惠金额')
|
||||
return (discount_sale_amount.value)
|
||||
}
|
||||
console.log(discount_sale_amount.value, '优惠金额1')
|
||||
return (goodsTotalPrice + discount_sale_amount.value * 1).toFixed(2)
|
||||
})
|
||||
|
||||
@@ -447,6 +471,13 @@
|
||||
websocketUtil.onMessage(data => {
|
||||
let msg = JSON.parse(data);
|
||||
let cartItem;
|
||||
if( msg.msg_id ){
|
||||
// console.log('Received data:', msg);
|
||||
websocketUtil.send(JSON.stringify({
|
||||
type: 'receipt',
|
||||
msg_id: msg.msg_id,
|
||||
}))
|
||||
}
|
||||
if( msg.status == 0 ){
|
||||
infoBox.showToast('添加失败')
|
||||
return false;
|
||||
@@ -462,13 +493,7 @@
|
||||
break;
|
||||
|
||||
}
|
||||
if( msg.msg_id ){
|
||||
// console.log('Received data:', msg);
|
||||
websocketUtil.send(JSON.stringify({
|
||||
type: 'receipt',
|
||||
msg_id: msg.msg_id,
|
||||
}))
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -507,15 +532,10 @@
|
||||
operate_type:'init',
|
||||
table_code: pageData.table.tableCode,
|
||||
}))
|
||||
|
||||
// console.log(useType);
|
||||
// pageData.eatTypes.active = useType == 'take-out' ? useType : useType.replace(
|
||||
// /-after|-before/g, '');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取店铺信息
|
||||
*/
|
||||
@@ -561,8 +581,8 @@
|
||||
*/
|
||||
async function changeUseType() {
|
||||
const { registerType } = pageData.shopInfo
|
||||
//munchies 先付 restaurant 后付
|
||||
const isPayAfter = registerType == "munchies" ? false : true;
|
||||
//before 先付 after 后付
|
||||
const isPayAfter = registerType == "before" ? false : true;
|
||||
let useType = "take-out";
|
||||
if (pageData.eatTypes.active == "take-out") {
|
||||
uni.setStorageSync("useType", "take-out");
|
||||
@@ -605,7 +625,7 @@
|
||||
* 菜品赠送/等叫/打印修改
|
||||
* @param {Object} item
|
||||
*/
|
||||
async function toggleItem(item,key) {
|
||||
function toggleItem(item,key) {
|
||||
let par = {
|
||||
id: item.id,
|
||||
product_id: item.product_id ,
|
||||
@@ -615,7 +635,24 @@
|
||||
updateCart(par)
|
||||
}
|
||||
|
||||
// 单品打折
|
||||
/**
|
||||
* 打包
|
||||
*/
|
||||
function toggleIsPack (item,key) {
|
||||
let par = {
|
||||
id: item.id,
|
||||
product_id: item.product_id ,
|
||||
sku_id: item.sku_id,
|
||||
pack_num: 0
|
||||
}
|
||||
par['pack_number'] = item['pack_number'] == 0 ? 1 : 0
|
||||
updateCart(par)
|
||||
}
|
||||
|
||||
/**
|
||||
* 单品打折
|
||||
* @param {Object} form
|
||||
*/
|
||||
async function discountconfirm(form) {
|
||||
if (form.discountMoney != '.') {
|
||||
let str = ''
|
||||
@@ -640,6 +677,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打包
|
||||
*/
|
||||
function goodsOnePackNumberConfirm (e) {
|
||||
let par = {
|
||||
id: modelData.data.id,
|
||||
product_id: modelData.data.product_id ,
|
||||
sku_id: modelData.data.sku_id,
|
||||
pack_number: e
|
||||
}
|
||||
updateCart(par)
|
||||
}
|
||||
|
||||
/**
|
||||
* 单品备注确认
|
||||
* @param {Object} e
|
||||
@@ -669,13 +719,31 @@
|
||||
* @param {Object} key
|
||||
* @param {Object} index
|
||||
*/
|
||||
function showModel(key, index) {
|
||||
function showModel(key, index, item) {
|
||||
modelData.data = goods.list[index]
|
||||
modelData.selIndex = index
|
||||
const model = models.get(key)
|
||||
model && model.open({
|
||||
remark: modelData.data.note || ''
|
||||
})
|
||||
|
||||
if( key == 'packNumber'){
|
||||
if( item.pack_number > 0 ){
|
||||
let par = {
|
||||
id: modelData.data.id,
|
||||
product_id: modelData.data.product_id ,
|
||||
sku_id: modelData.data.sku_id,
|
||||
pack_number: 0
|
||||
}
|
||||
updateCart(par)
|
||||
return false;
|
||||
}
|
||||
model && model.open({
|
||||
number: item.number
|
||||
})
|
||||
|
||||
} else {
|
||||
model && model.open({
|
||||
packNumber: modelData.data.remark || ''
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function formatPrice(n) {
|
||||
@@ -688,10 +756,9 @@
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//更新就餐人数
|
||||
/**
|
||||
* 更新就餐人数
|
||||
*/
|
||||
async function updateChoseCount() {
|
||||
const maxCapacity = pageData.table.id ? (pageData.table.maxCapacity || 0) : 100
|
||||
if (pageData.table.id && userNumbers.defaultCateIndex * 1 + 1 > maxCapacity) {
|
||||
@@ -703,17 +770,21 @@
|
||||
}
|
||||
if (!pageData.shopInfo.isTableFee && pageData.table.id) {
|
||||
//不免餐位费
|
||||
const res = await Api.$choseCount({
|
||||
masterId: option.masterId,
|
||||
tableId: pageData.table.id || '',
|
||||
num: userNumbers.defaultCateIndex * 1 + 1,
|
||||
})
|
||||
Object.assign($seatFee, res)
|
||||
userNumbers.defaultCateIndex = res.totalNumber - 1
|
||||
|
||||
let seatFee = {
|
||||
totalNumber: userNumbers.defaultCateIndex * 1 + 1,
|
||||
totalAmount: (userNumbers.defaultCateIndex * 1 + 1) * pageData.shopInfo.tableFee,
|
||||
}
|
||||
Object.assign($seatFee, seatFee)
|
||||
userNumbers.defaultCateIndex = $seatFee.totalNumber - 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 选择就餐人数
|
||||
* @param {Object} e
|
||||
*/
|
||||
function userNumberChange(e) {
|
||||
console.log(e);
|
||||
userNumbers.defaultCateIndex = e.detail.value
|
||||
@@ -721,20 +792,7 @@
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 打包费
|
||||
*/
|
||||
const $packFee = computed(() => {
|
||||
return goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.packFee
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
const goodsNumber = computed(() => {
|
||||
const result = goods.list.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
return result
|
||||
})
|
||||
|
||||
|
||||
function chooseUser() {
|
||||
go.to('PAGES_CHOOSE_USER')
|
||||
@@ -771,41 +829,40 @@
|
||||
* 创建订单
|
||||
*/
|
||||
async function createAnOrder() {
|
||||
if (!pageData.shopInfo.isTableFee) {
|
||||
//不免餐位费
|
||||
await Api.$choseCount({
|
||||
masterId: option.masterId,
|
||||
tableId: pageData.table.id || "",
|
||||
num: userNumbers.defaultCateIndex + 1,
|
||||
})
|
||||
}
|
||||
if (pageData.shopInfo.registerType == 'munchies' || pageData.eatTypes.active == 'take-out') {
|
||||
|
||||
if (pageData.shopInfo.registerType == 'before' || pageData.eatTypes.active == 'take-out') {
|
||||
const canJiesuan = await hasPermission('允许收款')
|
||||
if (!canJiesuan) {
|
||||
return
|
||||
}
|
||||
}
|
||||
// updateChoseCount()
|
||||
let originAmount = allPrice.value
|
||||
|
||||
console.log(originAmount)
|
||||
|
||||
let vipPrice = isVip.value ? 1 : 0
|
||||
let par = {
|
||||
shopId: pageData.shopInfo.id, //店铺Id
|
||||
userId: pageData.user.id, //用户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: 0, //用餐人数
|
||||
packFee: 0, //打包费
|
||||
originAmount: originAmount, //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
seatNum: userNumbers.defaultCateIndex * 1 + 1, //用餐人数
|
||||
packFee: $packFee.value, //打包费
|
||||
originAmount: goodsPrice.value, //订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
placeNum: 0, //当前订单下单次数
|
||||
waitCall: 0, //是否等叫 0 否 1 等叫
|
||||
vipPrice: pageData.shopInfo.isMemberPrice, //是否使用会员价
|
||||
vipPrice: vipPrice, //是否使用会员价
|
||||
}
|
||||
console.log(userNumbers.defaultCateIndex * 1 + 1)
|
||||
console.log(pageData.shopInfo.registerType)
|
||||
const res = await createOrder(par)
|
||||
uni.$emit('update:createOrderIndex')
|
||||
|
||||
if (pageData.shopInfo.registerType == 'munchies' || pageData.eatTypes.active == 'take-out') {
|
||||
websocketUtil.send(JSON.stringify({
|
||||
type:'onboc',
|
||||
account: uni.getStorageSync("iToken").loginId,
|
||||
shop_id: uni.getStorageSync("shopInfo").id,
|
||||
operate_type:'cleanup',
|
||||
table_code: pageData.table.tableCode,
|
||||
}))
|
||||
if (pageData.shopInfo.registerType == 'before' || pageData.eatTypes.active == 'take-out') {
|
||||
//先付
|
||||
return go.to('PAGES_ORDER_PAY', {
|
||||
orderId: res.id,
|
||||
|
||||
Reference in New Issue
Block a user