增加单品备注

This commit is contained in:
2024-10-09 17:40:52 +08:00
parent b37510e804
commit cf6dbab969
2 changed files with 57 additions and 27 deletions

View File

@@ -18,7 +18,9 @@
<view class="u-p-30"> <view class="u-p-30">
<view class="u-m-t-10"> <view class="u-m-t-10">
<my-button @tap="confirm" shape="circle" showShadow>确认</my-button> <my-button @tap="confirm" shape="circle" showShadow>确认</my-button>
<my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button> <view class="u-m-t-10">
<my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button>
</view>
</view> </view>
</view> </view>
</template> </template>
@@ -31,9 +33,6 @@
nextTick, nextTick,
ref ref
} from 'vue'; } from 'vue';
import myModel from '@/components/my-components/my-model.vue'
import myButton from '@/components/my-components/my-button.vue'
import myTabs from '@/components/my-components/my-tabs.vue'
const props = defineProps({ const props = defineProps({
title: { title: {
type: String, type: String,
@@ -47,7 +46,7 @@
function changeCauses(item) { function changeCauses(item) {
let prve=form.remark.length?',':'' let prve=form.remark?',':''
form.remark +=prve+item.name form.remark +=prve+item.name
} }
@@ -88,7 +87,8 @@
const model = ref(null) const model = ref(null)
function open() { function open(data) {
Object.assign(form,data)
model.value.open() model.value.open()
} }
@@ -100,11 +100,12 @@
function confirm() { function confirm() {
const {remark const {remark
} = form } = form
close()
emits('confirm', { emits('confirm', {
name, remark
price
}) })
console.log(remark);
close()
} }
defineExpose({ defineExpose({
open, open,

View File

@@ -13,7 +13,8 @@
</view> --> </view> -->
<view class="u-m-l-20">{{user.nickName}}</view> <view class="u-m-l-20">{{user.nickName}}</view>
<view class="color-main u-m-l-10 u-font-24">{{user.isVip?'会员':'' }}</view> <view class="color-main u-m-l-10 u-font-24">{{user.isVip?'会员':'' }}</view>
<view class="u-font-24 u-m-l-30"><text>余额</text><text class="color-main">{{user.amount}}</text> <view class="u-font-24 u-m-l-30"><text>余额</text><text
class="color-main">{{user.amount}}</text>
</view> </view>
<view class="u-font-24 u-m-l-30"><text>积分</text><text <view class="u-font-24 u-m-l-30"><text>积分</text><text
class="color-main">{{user.totalScore}}</text></view> class="color-main">{{user.totalScore}}</text></view>
@@ -33,7 +34,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class=" " @tap="chooseTable"> <view class=" " @tap="chooseTable">
<view>选择桌码</view> <view>选择桌码</view>
<view class="u-m-t-24 u-flex u-row-between "> <view class="u-m-t-24 u-flex u-row-between ">
@@ -44,9 +45,9 @@
<uni-icons type="right" color="#999" size="16"></uni-icons> <uni-icons type="right" color="#999" size="16"></uni-icons>
</view> </view>
</view> </view>
</view> </view>
<template v-if="user"> <template v-if="user">
<view class="block"> <view class="block">
<view class=""> <view class="">
@@ -80,7 +81,8 @@
<view class="block"> <view class="block">
<view class=" "> <view class=" ">
<view>用餐人数</view> <view>用餐人数</view>
<picker @change="userNumberChange" :value="userNumbers.defaultCateIndex" :range="userNumbers.list"> <picker @change="userNumberChange" :value="userNumbers.defaultCateIndex"
:range="userNumbers.list">
<view class="u-m-t-24 u-flex u-row-between "> <view class="u-m-t-24 u-flex u-row-between ">
<view class="color-333">{{userNumbers.defaultCateIndex||''}}</view> <view class="color-333">{{userNumbers.defaultCateIndex||''}}</view>
<uni-icons type="right" color="#999" size="16"></uni-icons> <uni-icons type="right" color="#999" size="16"></uni-icons>
@@ -147,7 +149,11 @@
<view class="color-999 u-text-right u-font-24 u-m-t-12">×{{item.number}}</view> <view class="color-999 u-text-right u-font-24 u-m-t-12">×{{item.number}}</view>
</view> </view>
</view> </view>
<template v-if="item.note">
<view class="u-p-20 bg-gray u-m-t-10">
{{item.note}}
</view>
</template>
<scroll-view scroll-x="true" v-if="index==goods.sel"> <scroll-view scroll-x="true" v-if="index==goods.sel">
<view class="u-m-t-32 u-flex no-wrap u-p-b-12"> <view class="u-m-t-32 u-flex no-wrap u-p-b-12">
<!-- <view class="u-flex u-m-r-20 u-m-b-20"> <!-- <view class="u-flex u-m-r-20 u-m-b-20">
@@ -167,7 +173,8 @@
@tap="toggleWait(item)">{{item.isWait?'取消等叫':'等叫'}}</button> @tap="toggleWait(item)">{{item.isWait?'取消等叫':'等叫'}}</button>
</view> --> </view> -->
<view class="u-flex u-m-r-20 u-m-b-20"> <view class="u-flex u-m-r-20 u-m-b-20">
<button class="tag" hover-class="hover-class" @tap="showModel('remark')">单品备注</button> <button class="tag" hover-class="hover-class"
@tap="showModel('remark',index)">单品备注</button>
</view> </view>
</view> </view>
</scroll-view> </scroll-view>
@@ -214,7 +221,7 @@
<model-discount title="菜品打折/减免" :ref="setModel" name="discount" :price="allPrice"></model-discount> <model-discount title="菜品打折/减免" :ref="setModel" name="discount" :price="allPrice"></model-discount>
<give-food title="赠菜" :ref="setModel" name="giveFood"></give-food> <give-food title="赠菜" :ref="setModel" name="giveFood"></give-food>
<my-remark title="单品备注" :ref="setModel" name="remark"></my-remark> <my-remark @confirm="goodsOneRemarkConfirm" title="单品备注" :ref="setModel" name="remark"></my-remark>
<edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount> <edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount>
</view> </view>
@@ -252,6 +259,10 @@
getNowCart getNowCart
} from '@/pagesCreateOrder/util.js' } from '@/pagesCreateOrder/util.js'
const models = new Map(); const models = new Map();
const modelData = reactive({
data: {},
selIndex: -1
})
//备注 //备注
let note = ref('') let note = ref('')
@@ -261,9 +272,11 @@
} }
} }
function showModel(key) { function showModel(key, index) {
modelData.data =goods.list[index]
modelData.selIndex =index
const model = models.get(key) const model = models.get(key)
model && model.open() model && model.open({remark:modelData.data.note})
} }
function formatPrice(n) { function formatPrice(n) {
@@ -401,7 +414,7 @@
}) })
} }
const goods = reactive({ const goods = reactive({
list: [], list: [],
sel: 0 sel: 0
@@ -468,7 +481,7 @@
console.log(res); console.log(res);
return res return res
} }
// 创建订单 // 创建订单
async function createOrder(par = { async function createOrder(par = {
masterId: option.masterId, masterId: option.masterId,
@@ -497,7 +510,9 @@
}) })
} else { } else {
//后付 //后付
uni.navigateBack({delta:2}) uni.navigateBack({
delta: 2
})
// return go.to('PAGES_ORDER_DETAIL', { // return go.to('PAGES_ORDER_DETAIL', {
// id: res.id // id: res.id
// }) // })
@@ -513,11 +528,25 @@
// }) // })
// }, 500) // }, 500)
} }
function init(){ //单品备注确认
async function goodsOneRemarkConfirm(e) {
const cart=goods.list[modelData.selIndex]
await Api.$updateCart({
cartId: cart.id,
productId: cart.productId,
skuId: cart.skuId,
tableId: option.tableId,
note: e.remark,
num: cart.number // 0会删除此商品
})
cart.note= e.remark
} }
function init() {
}
onLoad((opt) => { onLoad((opt) => {
console.log('opt'); console.log('opt');
console.log(opt); console.log(opt);
@@ -548,7 +577,7 @@
useType = `dine-in-${isPayAfter? "after" : "before"}`; useType = `dine-in-${isPayAfter? "after" : "before"}`;
uni.setStorageSync("useType", useType); uni.setStorageSync("useType", useType);
} }
const tableId = useType=='takeout'?undefined: table.value.tableId; const tableId = useType == 'takeout' ? undefined : table.value.tableId;
const res = await Api.$changeUseType({ const res = await Api.$changeUseType({
useType, useType,
tableId, tableId,