From 7e994f84f0dfd342501b1cd90ec327abc26a1dea Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Thu, 21 Nov 2024 09:52:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E4=B8=B4=E6=97=B6=E8=8F=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- http/yskApi/Instead.js | 25 +++++++- .../add-temp-cuisine/add-temp-cuisine.vue | 64 +++++++++++++++---- pagesCreateOrder/index/index.vue | 28 ++++++-- pagesCreateOrder/util.js | 5 +- pagesOrder/detail/detail.vue | 3 +- 5 files changed, 105 insertions(+), 20 deletions(-) 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) + })