代客下单增加临时菜
This commit is contained in:
parent
d8738f4e74
commit
7e994f84f0
|
|
@ -390,3 +390,26 @@ export function $calcDeDuctionPoints(data) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//购物车-临时菜添加
|
||||||
|
export function $temporaryDishes(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/place/temporaryDishes',
|
||||||
|
method: "post",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//单品改价
|
||||||
|
export function $updatePrice(data) {
|
||||||
|
return request({
|
||||||
|
url: '/api/place/updatePrice',
|
||||||
|
method: "put",
|
||||||
|
data:{
|
||||||
|
shopId: uni.getStorageSync("shopId"),
|
||||||
|
...data
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
</picker>
|
</picker>
|
||||||
|
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
<uni-forms-item required label="" name="price">
|
<uni-forms-item required label="" name="num">
|
||||||
<template #label>
|
<template #label>
|
||||||
<view class=" u-text-left">
|
<view class=" u-text-left">
|
||||||
<text class="color-333">下单数量</text>
|
<text class="color-333">下单数量</text>
|
||||||
|
|
@ -84,7 +84,7 @@
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<view class="border-bottom ">
|
<view class="border-bottom ">
|
||||||
<uni-easyinput :inputBorder="false" paddingNone v-model="form.number" placeholder="填写数量"
|
<uni-easyinput :inputBorder="false" paddingNone v-model="form.num" placeholder="填写数量"
|
||||||
type="digit"></uni-easyinput>
|
type="digit"></uni-easyinput>
|
||||||
</view>
|
</view>
|
||||||
</uni-forms-item>
|
</uni-forms-item>
|
||||||
|
|
@ -118,11 +118,16 @@
|
||||||
$tbShopCategory,
|
$tbShopCategory,
|
||||||
$tbShopUnit
|
$tbShopUnit
|
||||||
} from '@/http/yskApi/goods.js'
|
} from '@/http/yskApi/goods.js'
|
||||||
|
import {
|
||||||
|
$temporaryDishes
|
||||||
|
} from '@/http/yskApi/Instead.js'
|
||||||
import {
|
import {
|
||||||
reactive,
|
reactive,
|
||||||
onMounted,
|
onMounted,
|
||||||
ref
|
ref,
|
||||||
|
onBeforeMount
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
import {onLoad} from '@dcloudio/uni-app'
|
||||||
const units = reactive({
|
const units = reactive({
|
||||||
list: [],
|
list: [],
|
||||||
current: ''
|
current: ''
|
||||||
|
|
@ -147,7 +152,7 @@
|
||||||
category: '',
|
category: '',
|
||||||
price: '',
|
price: '',
|
||||||
unit: '',
|
unit: '',
|
||||||
number: ''
|
num: ''
|
||||||
})
|
})
|
||||||
// 校验规则
|
// 校验规则
|
||||||
const rules = {
|
const rules = {
|
||||||
|
|
@ -163,7 +168,7 @@
|
||||||
errorMessage: '请选择菜品分类'
|
errorMessage: '请选择菜品分类'
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
price: {
|
num: {
|
||||||
rules: [{
|
rules: [{
|
||||||
required: true,
|
required: true,
|
||||||
errorMessage: '请输入价格'
|
errorMessage: '请输入价格'
|
||||||
|
|
@ -182,10 +187,30 @@
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
let timer=null
|
||||||
function submit() {
|
function submit() {
|
||||||
refform.value.validate(res => {
|
refform.value.validate(res => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
|
if(!res){
|
||||||
|
$temporaryDishes({
|
||||||
|
"useType": option.useType,
|
||||||
|
"masterId": option.masterId,
|
||||||
|
"tableId": option.tableId,
|
||||||
|
"name": form.name,
|
||||||
|
"categoryId": category[categoryCurrent.value].id,
|
||||||
|
"price": form.price,
|
||||||
|
"num": form.num,
|
||||||
|
unit:units.list[units.current].id,
|
||||||
|
"note": form.note,
|
||||||
|
"vipUserId": option.vipUserId
|
||||||
|
}).then(r=>{
|
||||||
|
uni.$emit('add:cashCai')
|
||||||
|
clearInterval(timer)
|
||||||
|
timer=setTimeout(()=>{
|
||||||
|
uni.navigateBack()
|
||||||
|
},500)
|
||||||
|
})
|
||||||
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
})
|
})
|
||||||
|
|
@ -204,16 +229,22 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
async function getCategory(){
|
async function getCategory() {
|
||||||
const res=await $tbShopCategory({
|
const res = await $tbShopCategory({
|
||||||
page: 0,
|
page: 0,
|
||||||
size: 600
|
size: 600
|
||||||
})
|
})
|
||||||
const arr=returnAllCategory(res.content).map(v=>{
|
const arr = returnAllCategory(res.content).map(v => {
|
||||||
return {...v,value:v.id}
|
return {
|
||||||
|
...v,
|
||||||
|
value: v.id
|
||||||
|
}
|
||||||
})
|
})
|
||||||
category.length=arr.length
|
category.length = arr.length
|
||||||
category = reactive(arr)
|
for (let i in arr) {
|
||||||
|
category[i] = arr[i]
|
||||||
|
}
|
||||||
|
console.log(category);
|
||||||
}
|
}
|
||||||
async function init() {
|
async function init() {
|
||||||
getTbShopUnit()
|
getTbShopUnit()
|
||||||
|
|
@ -222,6 +253,15 @@
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
init()
|
init()
|
||||||
})
|
})
|
||||||
|
onBeforeMount(()=>{
|
||||||
|
clearInterval(timer)
|
||||||
|
})
|
||||||
|
const option=reactive({
|
||||||
|
|
||||||
|
})
|
||||||
|
onLoad((opt)=>{
|
||||||
|
Object.assign(option,opt)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@
|
||||||
<view class="page-view u-p-l-24">
|
<view class="page-view u-p-l-24">
|
||||||
<view class="list-tight-top">
|
<view class="list-tight-top">
|
||||||
<template v-if="lingshi.show">
|
<template v-if="lingshi.show">
|
||||||
<view id="lingshi" class="lingshi" @tap="toLinshi">
|
<view id="lingshi" class="lingshi u-m-b-32" @tap="toLinshi">
|
||||||
<uni-icons type="plus-filled" size="24" :color="color.ColorMain"></uni-icons>
|
<uni-icons type="plus-filled" size="24" :color="color.ColorMain"></uni-icons>
|
||||||
<view class="u-m-t-24 color-main">临时菜</view>
|
<view class="u-m-t-24 color-main">临时菜</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -671,7 +671,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function toLinshi() {
|
function toLinshi() {
|
||||||
go.to('PAGES_ADD_TEMP_CUISINE')
|
go.to('PAGES_ADD_TEMP_CUISINE',{
|
||||||
|
masterId:data.masterId,
|
||||||
|
tableId:data.table.tableId,
|
||||||
|
vipUserId:option.vipUserId?option.vipUserId:'',
|
||||||
|
useType:uni.getStorageSync('useType')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const chooseGuigeModel = ref(null)
|
const chooseGuigeModel = ref(null)
|
||||||
|
|
@ -897,10 +902,13 @@
|
||||||
categoryId,
|
categoryId,
|
||||||
skuId
|
skuId
|
||||||
} = goods
|
} = goods
|
||||||
|
|
||||||
const cartId = goods.id
|
const cartId = goods.id
|
||||||
const tabbarIndex = data.tabbar.findIndex(v => v.id == categoryId)
|
const tabbarIndex = data.tabbar.findIndex(v => v.id == categoryId)
|
||||||
const $goods = data.tabbar[tabbarIndex].foods.find(v => v.id == productId)
|
//临时菜没有对应商品数据
|
||||||
const $sku = $goods.specList.find(v => v.id == skuId)
|
const $goods =!productId?undefined:data.tabbar[tabbarIndex].foods.find(v => v.id == productId)
|
||||||
|
//临时菜没有skuList
|
||||||
|
const $sku =!productId?{suit:1}:$goods.specList.find(v => v.id == skuId)
|
||||||
|
|
||||||
if (num === 0 || num < $sku.suit) {
|
if (num === 0 || num < $sku.suit) {
|
||||||
//移除
|
//移除
|
||||||
|
|
@ -1184,6 +1192,7 @@
|
||||||
function watchUpdate() {
|
function watchUpdate() {
|
||||||
uni.$off('update:createOrderIndex')
|
uni.$off('update:createOrderIndex')
|
||||||
uni.$off('get:table')
|
uni.$off('get:table')
|
||||||
|
uni.$off('add:cashCai')
|
||||||
uni.$on('update:createOrderIndex', () => {
|
uni.$on('update:createOrderIndex', () => {
|
||||||
// data.table = {
|
// data.table = {
|
||||||
// tableId: ""
|
// tableId: ""
|
||||||
|
|
@ -1192,6 +1201,15 @@
|
||||||
console.log('update:createOrderIndex');
|
console.log('update:createOrderIndex');
|
||||||
init()
|
init()
|
||||||
})
|
})
|
||||||
|
uni.$on('add:cashCai', async() => {
|
||||||
|
console.log('add:cashCai');
|
||||||
|
const cartRes = await getCart()
|
||||||
|
cars.length = 0
|
||||||
|
const cartArr = getNowCart(cartRes.records)
|
||||||
|
for (let i in cartArr) {
|
||||||
|
cars.push(cartArr[i])
|
||||||
|
}
|
||||||
|
})
|
||||||
uni.$on('get:table', () => {
|
uni.$on('get:table', () => {
|
||||||
console.log('get:table');
|
console.log('get:table');
|
||||||
if (data.table.tableId) {
|
if (data.table.tableId) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,10 @@ export function getNowCart(records) {
|
||||||
const arr = []
|
const arr = []
|
||||||
for (let i in Cart) {
|
for (let i in Cart) {
|
||||||
const item=Cart[i]
|
const item=Cart[i]
|
||||||
const key = item.productId + '_' + item.skuId
|
const productId=item.productId
|
||||||
|
const skuId=item.skuId
|
||||||
|
const isLinShiCai=!productId&&!skuId?true:false
|
||||||
|
const key =isLinShiCai?item.name: (item.productId + '_' + item.skuId)
|
||||||
if (goodsMap.hasOwnProperty(key)) {
|
if (goodsMap.hasOwnProperty(key)) {
|
||||||
const index = goodsMap[key]
|
const index = goodsMap[key]
|
||||||
arr[index].number = arr[index].number * 1 + item.number
|
arr[index].number = arr[index].number * 1 + item.number
|
||||||
|
|
|
||||||
|
|
@ -213,7 +213,8 @@
|
||||||
tableId: options.tableId || orderDetail.info.tableId,
|
tableId: options.tableId || orderDetail.info.tableId,
|
||||||
name: options.name || orderDetail.info.tableName,
|
name: options.name || orderDetail.info.tableName,
|
||||||
masterId:orderDetail.info.masterId,
|
masterId:orderDetail.info.masterId,
|
||||||
type: 'add'
|
type: 'add',
|
||||||
|
vipUserId:orderDetail.memberId?orderDetail.memberId:''
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue