diff --git a/http/yskApi/Instead.js b/http/yskApi/Instead.js index d964201..9839f3b 100644 --- a/http/yskApi/Instead.js +++ b/http/yskApi/Instead.js @@ -389,4 +389,27 @@ export function $calcDeDuctionPoints(data) { ...data } }); -} \ No newline at end of file +} + +//购物车-临时菜添加 +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 + } + }); +} diff --git a/pagesCreateOrder/add-temp-cuisine/add-temp-cuisine.vue b/pagesCreateOrder/add-temp-cuisine/add-temp-cuisine.vue index 9de3219..0ef2d25 100644 --- a/pagesCreateOrder/add-temp-cuisine/add-temp-cuisine.vue +++ b/pagesCreateOrder/add-temp-cuisine/add-temp-cuisine.vue @@ -76,7 +76,7 @@ - + - @@ -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) + })