代客下单增加临时菜

This commit is contained in:
YeMingfei666 2024-11-21 09:52:17 +08:00
parent d8738f4e74
commit 7e994f84f0
5 changed files with 105 additions and 20 deletions

View File

@ -389,4 +389,27 @@ export function $calcDeDuctionPoints(data) {
...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
}
});
}

View File

@ -76,7 +76,7 @@
</picker>
</uni-forms-item>
<uni-forms-item required label="" name="price">
<uni-forms-item required label="" name="num">
<template #label>
<view class=" u-text-left">
<text class="color-333">下单数量</text>
@ -84,7 +84,7 @@
</view>
</template>
<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>
</view>
</uni-forms-item>
@ -118,11 +118,16 @@
$tbShopCategory,
$tbShopUnit
} from '@/http/yskApi/goods.js'
import {
$temporaryDishes
} from '@/http/yskApi/Instead.js'
import {
reactive,
onMounted,
ref
ref,
onBeforeMount
} from 'vue';
import {onLoad} from '@dcloudio/uni-app'
const units = reactive({
list: [],
current: ''
@ -147,7 +152,7 @@
category: '',
price: '',
unit: '',
number: ''
num: ''
})
//
const rules = {
@ -163,7 +168,7 @@
errorMessage: '请选择菜品分类'
}]
},
price: {
num: {
rules: [{
required: true,
errorMessage: '请输入价格'
@ -182,10 +187,30 @@
}]
},
}
let timer=null
function submit() {
refform.value.validate(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 => {
console.log(err);
})
@ -204,16 +229,22 @@
}
})
}
async function getCategory(){
const res=await $tbShopCategory({
async function getCategory() {
const res = await $tbShopCategory({
page: 0,
size: 600
})
const arr=returnAllCategory(res.content).map(v=>{
return {...v,value:v.id}
const arr = returnAllCategory(res.content).map(v => {
return {
...v,
value: v.id
}
})
category.length=arr.length
category = reactive(arr)
category.length = arr.length
for (let i in arr) {
category[i] = arr[i]
}
console.log(category);
}
async function init() {
getTbShopUnit()
@ -222,6 +253,15 @@
onMounted(() => {
init()
})
onBeforeMount(()=>{
clearInterval(timer)
})
const option=reactive({
})
onLoad((opt)=>{
Object.assign(option,opt)
})
</script>
<style lang="scss" scoped>

View File

@ -60,7 +60,7 @@
<view class="page-view u-p-l-24">
<view class="list-tight-top">
<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>
<view class="u-m-t-24 color-main">临时菜</view>
</view>
@ -671,7 +671,12 @@
}
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)
@ -897,10 +902,13 @@
categoryId,
skuId
} = goods
const cartId = goods.id
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) {
//
@ -1180,10 +1188,11 @@
setTabBar($category, $originGoods, cars)
}
onBeforeUnmount(() => {})
function watchUpdate() {
uni.$off('update:createOrderIndex')
uni.$off('get:table')
uni.$off('add:cashCai')
uni.$on('update:createOrderIndex', () => {
// data.table = {
// tableId: ""
@ -1192,6 +1201,15 @@
console.log('update:createOrderIndex');
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', () => {
console.log('get:table');
if (data.table.tableId) {

View File

@ -9,7 +9,10 @@ export function getNowCart(records) {
const arr = []
for (let i in Cart) {
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)) {
const index = goodsMap[key]
arr[index].number = arr[index].number * 1 + item.number

View File

@ -213,7 +213,8 @@
tableId: options.tableId || orderDetail.info.tableId,
name: options.name || orderDetail.info.tableName,
masterId:orderDetail.info.masterId,
type: 'add'
type: 'add',
vipUserId:orderDetail.memberId?orderDetail.memberId:''
})
}