单品改价
This commit is contained in:
@@ -639,7 +639,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pageId": "PAGES_ADD_TEMP_CUISINE",
|
"pageId": "PAGES_CHOOSE_ADD_TEMP_CUISINE",
|
||||||
"path": "add-temp-cuisine/add-temp-cuisine",
|
"path": "add-temp-cuisine/add-temp-cuisine",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "添加临时菜"
|
"navigationBarTitleText": "添加临时菜"
|
||||||
|
|||||||
@@ -125,9 +125,12 @@
|
|||||||
reactive,
|
reactive,
|
||||||
onMounted,
|
onMounted,
|
||||||
ref,
|
ref,
|
||||||
onBeforeMount
|
onBeforeMount,
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import {onLoad} from '@dcloudio/uni-app'
|
import {
|
||||||
|
onLoad,
|
||||||
|
onShow
|
||||||
|
} from '@dcloudio/uni-app'
|
||||||
const units = reactive({
|
const units = reactive({
|
||||||
list: [],
|
list: [],
|
||||||
current: ''
|
current: ''
|
||||||
@@ -188,6 +191,7 @@
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
let timer = null
|
let timer = null
|
||||||
|
|
||||||
function submit() {
|
function submit() {
|
||||||
refform.value.validate(res => {
|
refform.value.validate(res => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
@@ -234,7 +238,7 @@
|
|||||||
page: 0,
|
page: 0,
|
||||||
size: 600
|
size: 600
|
||||||
})
|
})
|
||||||
const arr = returnAllCategory(res.content).map(v => {
|
const arr = forList(res.content).map(v => {
|
||||||
return {
|
return {
|
||||||
...v,
|
...v,
|
||||||
value: v.id
|
value: v.id
|
||||||
@@ -244,24 +248,40 @@
|
|||||||
for (let i in arr) {
|
for (let i in arr) {
|
||||||
category[i] = arr[i]
|
category[i] = arr[i]
|
||||||
}
|
}
|
||||||
console.log(category);
|
}
|
||||||
|
|
||||||
|
function forList(arr) {
|
||||||
|
let arrs = []
|
||||||
|
arr.forEach(ele => {
|
||||||
|
arrs.push(ele)
|
||||||
|
if (ele.childrenList.length) {
|
||||||
|
ele.childrenList.forEach(res => {
|
||||||
|
arrs.push(res)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return arrs
|
||||||
}
|
}
|
||||||
async function init() {
|
async function init() {
|
||||||
getTbShopUnit()
|
getTbShopUnit()
|
||||||
getCategory()
|
getCategory()
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
// onMounted(() => {
|
||||||
|
// init()
|
||||||
|
// })
|
||||||
|
onLoad((opt) => {
|
||||||
|
Object.assign(option, opt)
|
||||||
|
setTimeout(() => {
|
||||||
init()
|
init()
|
||||||
|
}, 600)
|
||||||
})
|
})
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
})
|
})
|
||||||
const option = reactive({
|
const option = reactive({
|
||||||
|
|
||||||
})
|
})
|
||||||
onLoad((opt)=>{
|
|
||||||
Object.assign(option,opt)
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||||
<template #desc>
|
<template #desc>
|
||||||
<view class="u-m-t-48 tab">
|
<!-- <view class="u-m-t-48 tab">
|
||||||
<my-tabs :list="tabs" @change="tabsChange"></my-tabs>
|
<my-tabs :list="tabs" @change="tabsChange"></my-tabs>
|
||||||
</view>
|
</view> -->
|
||||||
<view class="u-text-left u-p-30 ">
|
<view class="u-text-left u-p-30 ">
|
||||||
<template v-if="!current">
|
<template v-if="!current">
|
||||||
<view>
|
<view>
|
||||||
@@ -46,19 +46,22 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<view class="u-m-t-48">
|
<view class="u-m-t-48">
|
||||||
|
<view class="u-font-24">
|
||||||
|
<text class="color-999">当前单品价格:{{price}}</text>
|
||||||
|
</view>
|
||||||
<view class="u-font-24">
|
<view class="u-font-24">
|
||||||
<text class="color-999">打折原因</text>
|
<text class="color-999">打折原因</text>
|
||||||
<text class="color-red">*</text>
|
<text class="color-red">*</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-flex u-m-t-24">
|
<view class="u-flex u-m-t-24">
|
||||||
<view class="u-flex" v-for="(item,index) in causes" :key="index">
|
<view class="u-flex" v-for="(item,index) in causes" :key="index">
|
||||||
<button @tap="changeCauses(item)" class="tag u-m-r-20"
|
<button @tap="changeCauses(item,index)" class="tag u-m-r-20"
|
||||||
:class="{active:item.checked}">{{item.name}}</button>
|
:class="{active:item.checked}">{{item.name}}</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-m-t-32 u-flex ">
|
<view class="u-m-t-32 u-flex ">
|
||||||
<uni-easyinput type="textarea" v-model="value" placeholder="自定义内容"></uni-easyinput>
|
<uni-easyinput type="textarea" v-model="form.note" placeholder="自定义内容"></uni-easyinput>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
@@ -101,9 +104,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function changeCauses(item) {
|
|
||||||
item.checked = !item.checked
|
|
||||||
}
|
|
||||||
|
|
||||||
const discounts = [95, 90, 85, 80]
|
const discounts = [95, 90, 85, 80]
|
||||||
const causes = reactive([{
|
const causes = reactive([{
|
||||||
@@ -120,6 +121,11 @@
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
function changeCauses(item, index) {
|
||||||
|
item.checked = !item.checked
|
||||||
|
form.notes = causes
|
||||||
|
}
|
||||||
|
|
||||||
function discountInput(e) {
|
function discountInput(e) {
|
||||||
if (e.detail.value >= 100) {
|
if (e.detail.value >= 100) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
@@ -127,6 +133,7 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function discountMoneyInput(e) {
|
function discountMoneyInput(e) {
|
||||||
const max = 100
|
const max = 100
|
||||||
if (e.detail.value >= max) {
|
if (e.detail.value >= max) {
|
||||||
@@ -142,7 +149,7 @@
|
|||||||
|
|
||||||
|
|
||||||
const tabs = ['打折', '减免']
|
const tabs = ['打折', '减免']
|
||||||
let current = ref(0)
|
let current = ref(1)
|
||||||
|
|
||||||
function tabsChange(i) {
|
function tabsChange(i) {
|
||||||
console.log(i);
|
console.log(i);
|
||||||
@@ -163,6 +170,7 @@
|
|||||||
form.price = newval
|
form.price = newval
|
||||||
form.currentPrice = newval
|
form.currentPrice = newval
|
||||||
})
|
})
|
||||||
|
|
||||||
function resetForm() {
|
function resetForm() {
|
||||||
Object.assign(form, {
|
Object.assign(form, {
|
||||||
...$form
|
...$form
|
||||||
@@ -182,7 +190,8 @@
|
|||||||
|
|
||||||
function confirm() {
|
function confirm() {
|
||||||
const {
|
const {
|
||||||
discount,discountMoney
|
discount,
|
||||||
|
discountMoney
|
||||||
} = form
|
} = form
|
||||||
if (current.value === 0 && discount === '') {
|
if (current.value === 0 && discount === '') {
|
||||||
return uni.showToast({
|
return uni.showToast({
|
||||||
@@ -196,8 +205,8 @@
|
|||||||
title: '请输入有效减免价格!'
|
title: '请输入有效减免价格!'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
close()
|
|
||||||
emits('confirm', form)
|
emits('confirm', form)
|
||||||
|
close()
|
||||||
}
|
}
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open,
|
open,
|
||||||
|
|||||||
@@ -154,6 +154,11 @@
|
|||||||
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
|
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
|
||||||
size="small" text="打包" inverted type="success" />
|
size="small" text="打包" inverted type="success" />
|
||||||
</view>
|
</view>
|
||||||
|
<view class="u-m-r-20 u-flex" v-if="item.isPrint">
|
||||||
|
<uni-tag
|
||||||
|
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
|
||||||
|
size="small" text="打印" inverted type="success" />
|
||||||
|
</view>
|
||||||
<view>
|
<view>
|
||||||
{{item.name}}
|
{{item.name}}
|
||||||
</view>
|
</view>
|
||||||
@@ -174,7 +179,8 @@
|
|||||||
<text
|
<text
|
||||||
class="line-th color-999">¥{{formatPrice(item.salePrice*item.number) }}</text>
|
class="line-th color-999">¥{{formatPrice(item.salePrice*item.number) }}</text>
|
||||||
<view class="u-absolute" style="right: 0;bottom: 100%;">
|
<view class="u-absolute" style="right: 0;bottom: 100%;">
|
||||||
<text class="font-bold">¥{{formatPrice(item.memberPrice*item.number) }}</text>
|
<text
|
||||||
|
class="font-bold">¥{{formatPrice(item.memberPrice*item.number) }}</text>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@@ -196,9 +202,10 @@
|
|||||||
</template>
|
</template>
|
||||||
<scroll-view class="u-m-t-32" scroll-x="true" v-if="index==goods.sel">
|
<scroll-view class="u-m-t-32" scroll-x="true" v-if="index==goods.sel">
|
||||||
<view class=" u-flex no-wrap ">
|
<view class=" u-flex no-wrap ">
|
||||||
<!-- <view class="u-flex u-m-r-20 u-m-b-20">
|
<view class="u-flex u-m-r-20 ">
|
||||||
<button class="tag" hover-class="hover-class" @tap="showModel('discount')">单品打折</button>
|
<button class="tag" hover-class="hover-class"
|
||||||
</view> -->
|
@tap="showModel('discount',index)">单品打折</button>
|
||||||
|
</view>
|
||||||
<view class="u-flex u-m-r-20 ">
|
<view class="u-flex u-m-r-20 ">
|
||||||
<!-- <button class="tag" hover-class="hover-class" @tap="showModel('giveFood')">赠菜</button> -->
|
<!-- <button class="tag" hover-class="hover-class" @tap="showModel('giveFood')">赠菜</button> -->
|
||||||
<button class="tag" hover-class="hover-class"
|
<button class="tag" hover-class="hover-class"
|
||||||
@@ -208,10 +215,14 @@
|
|||||||
<button class="tag" hover-class="hover-class"
|
<button class="tag" hover-class="hover-class"
|
||||||
@tap="toggleGoodsItemKey(item,index,'isPack')">{{item.isPack?'取消打包':'打包'}}</button>
|
@tap="toggleGoodsItemKey(item,index,'isPack')">{{item.isPack?'取消打包':'打包'}}</button>
|
||||||
</view>
|
</view>
|
||||||
<!-- <view class="u-flex u-m-r-20 u-m-b-20">
|
<view class="u-flex u-m-r-20 ">
|
||||||
<button class="tag" hover-class="hover-class"
|
<button class="tag" hover-class="hover-class"
|
||||||
@tap="toggleWait(item)">{{item.isWait?'取消等叫':'等叫'}}</button>
|
@tap="toggleWait(item)">{{item.isWait?'取消等叫':'等叫'}}</button>
|
||||||
</view> -->
|
</view>
|
||||||
|
<view class="u-flex u-m-r-20 ">
|
||||||
|
<button class="tag" hover-class="hover-class"
|
||||||
|
@tap="toggisPrint(item)">{{item.isPrint?'免厨打':'打印'}}</button>
|
||||||
|
</view>
|
||||||
<view class="u-flex u-m-r-20 ">
|
<view class="u-flex u-m-r-20 ">
|
||||||
<button class="tag" hover-class="hover-class"
|
<button class="tag" hover-class="hover-class"
|
||||||
@tap="showModel('remark',index)">单品备注</button>
|
@tap="showModel('remark',index)">单品备注</button>
|
||||||
@@ -278,8 +289,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
|
<model-discount title="菜品减免" :ref="setModel" name="discount" :price="modelData.data.salePrice" @confirm="discountconfirm"></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>
|
||||||
<one-remark @confirm="goodsOneRemarkConfirm" title="单品备注" :ref="setModel" name="remark"></one-remark>
|
<one-remark @confirm="goodsOneRemarkConfirm" title="单品备注" :ref="setModel" name="remark"></one-remark>
|
||||||
<edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount>
|
<edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount>
|
||||||
@@ -351,7 +361,24 @@
|
|||||||
return Number(n).toFixed(2)
|
return Number(n).toFixed(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 单品打折
|
||||||
|
async function discountconfirm(form) {
|
||||||
|
console.log(form, '调试111111')
|
||||||
|
let str = ''
|
||||||
|
if (form.notes) {
|
||||||
|
form.notes.forEach(ele => {
|
||||||
|
if (ele.checked) {
|
||||||
|
str = str + ele.name + ','
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
let obj = {
|
||||||
|
saleAmount: form.discountMoney,
|
||||||
|
note: str + form.note,
|
||||||
|
cartId: modelData.data.id
|
||||||
|
}
|
||||||
|
const res = await Api.$updatePrice(obj)
|
||||||
|
}
|
||||||
|
|
||||||
//用餐人数
|
//用餐人数
|
||||||
const userNumbers = reactive({
|
const userNumbers = reactive({
|
||||||
@@ -423,11 +450,40 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//等叫
|
//等叫
|
||||||
function toggleWait(item) {
|
async function toggleWait(item) {
|
||||||
item.isWait = !item.isWait
|
item.isWait = !item.isWait
|
||||||
|
let obj = {
|
||||||
|
cartId: item.id,
|
||||||
|
isGift: item.isGift,
|
||||||
|
isPack: item.isPack,
|
||||||
|
isPrint: item.isPrint,
|
||||||
|
isWaitCall: item.isWait,
|
||||||
|
masterId: option.masterId,
|
||||||
|
num: item.number, // 0会删除此商品
|
||||||
|
productId: item.productId,
|
||||||
|
skuId: item.skuId,
|
||||||
|
vipUserId: '',
|
||||||
}
|
}
|
||||||
|
let res = await Api.$updateCart(obj)
|
||||||
|
}
|
||||||
|
// 打印
|
||||||
|
|
||||||
|
async function toggisPrint(item) {
|
||||||
|
item.isPrint = !item.isPrint
|
||||||
|
let obj = {
|
||||||
|
cartId: item.id,
|
||||||
|
isGift: item.isGift,
|
||||||
|
isPack: item.isPack,
|
||||||
|
isPrint: item.isPrint,
|
||||||
|
isWaitCall: item.isWait,
|
||||||
|
masterId: option.masterId,
|
||||||
|
num: item.number, // 0会删除此商品
|
||||||
|
productId: item.productId,
|
||||||
|
skuId: item.skuId,
|
||||||
|
vipUserId: '',
|
||||||
|
}
|
||||||
|
let res = await Api.$updateCart(obj)
|
||||||
|
}
|
||||||
|
|
||||||
const eatTypes = reactive({
|
const eatTypes = reactive({
|
||||||
list: [{
|
list: [{
|
||||||
@@ -479,7 +535,6 @@
|
|||||||
function watchChooseuser() {
|
function watchChooseuser() {
|
||||||
uni.$off('choose-user')
|
uni.$off('choose-user')
|
||||||
uni.$on('choose-user', (data) => {
|
uni.$on('choose-user', (data) => {
|
||||||
console.log(data);
|
|
||||||
user.value = data
|
user.value = data
|
||||||
setUser()
|
setUser()
|
||||||
})
|
})
|
||||||
@@ -523,6 +578,12 @@
|
|||||||
const isVip = computed(() => {
|
const isVip = computed(() => {
|
||||||
return $shop.value.isMemberPrice && user.value && user.value.id && user.value.isVip
|
return $shop.value.isMemberPrice && user.value && user.value.id && user.value.isVip
|
||||||
})
|
})
|
||||||
|
const discountSaleAmount=computed(()=>{
|
||||||
|
return goods.list.filter((v) => v.discountSaleAmount && v.discountSaleAmount > 0)
|
||||||
|
.reduce((a, b) => {
|
||||||
|
return a + b.number * b.discountSaleAmount;
|
||||||
|
}, 0);
|
||||||
|
})
|
||||||
const goodsPrice = computed(() => {
|
const goodsPrice = computed(() => {
|
||||||
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||||
const memberPrice = cur.memberPrice ? cur.memberPrice : cur.salePrice
|
const memberPrice = cur.memberPrice ? cur.memberPrice : cur.salePrice
|
||||||
@@ -530,10 +591,10 @@
|
|||||||
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
|
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
|
||||||
return prve + (cur.isGift ? 0 : tPrice) + tpackFee
|
return prve + (cur.isGift ? 0 : tPrice) + tpackFee
|
||||||
}, 0)
|
}, 0)
|
||||||
return (goodsTotalPrice || 0).toFixed(2)
|
return ((goodsTotalPrice-discountSaleAmount.value) || 0).toFixed(2)
|
||||||
})
|
})
|
||||||
const allPrice = computed(() => {
|
const allPrice = computed(() => {
|
||||||
console.log(goodsPrice.value);
|
console.log(goodsPrice.value,'调试2121');
|
||||||
const n = goodsPrice.value * 1 + $seatFee.totalAmount
|
const n = goodsPrice.value * 1 + $seatFee.totalAmount
|
||||||
return n.toFixed(2)
|
return n.toFixed(2)
|
||||||
// const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
// const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||||
@@ -542,17 +603,18 @@
|
|||||||
// return (goodsTotalPrice + ($seatFee.totalAmount || 0)).toFixed(2)
|
// return (goodsTotalPrice + ($seatFee.totalAmount || 0)).toFixed(2)
|
||||||
})
|
})
|
||||||
const youhui = computed(() => {
|
const youhui = computed(() => {
|
||||||
|
let goodsTotalPrice=0
|
||||||
if (user.value && user.value.id && user.value.isVip) {
|
if (user.value && user.value.id && user.value.isVip) {
|
||||||
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||||
const tPrice = cur.salePrice * cur.number
|
const tPrice = cur.salePrice * cur.number
|
||||||
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
|
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
|
||||||
return prve + tPrice + tpackFee
|
return prve + tPrice + tpackFee
|
||||||
}, 0)
|
}, 0)
|
||||||
return goodsTotalPrice - allPrice.value
|
return goodsTotalPrice - allPrice.value
|
||||||
} else {
|
} else {
|
||||||
return 0
|
return (discountSaleAmount.value)
|
||||||
}
|
}
|
||||||
return goodsTotalPrice
|
return (goodsTotalPrice+discountSaleAmount.value*1).toFixed(2)
|
||||||
})
|
})
|
||||||
|
|
||||||
function setGoodsItem(key, val) {
|
function setGoodsItem(key, val) {
|
||||||
|
|||||||
@@ -671,7 +671,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toLinshi() {
|
function toLinshi() {
|
||||||
go.to('PAGES_ADD_TEMP_CUISINE',{
|
go.to('PAGES_CHOOSE_ADD_TEMP_CUISINE',{
|
||||||
masterId:data.masterId,
|
masterId:data.masterId,
|
||||||
tableId:data.table.tableId,
|
tableId:data.table.tableId,
|
||||||
vipUserId:option.vipUserId?option.vipUserId:'',
|
vipUserId:option.vipUserId?option.vipUserId:'',
|
||||||
|
|||||||
Reference in New Issue
Block a user