Merge branch 'test' of https://e.coding.net/g-cphe0354/cashier_front/cashier_admin_app into wwz
This commit is contained in:
commit
3a5460894b
|
|
@ -39,6 +39,10 @@
|
|||
</up-radio-group>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<uni-forms-item required name="name" label="商品名称" showRequired>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.name" placeholder="请输入商品名称" />
|
||||
</uni-forms-item>
|
||||
<uni-forms-item ref="fileItem" label="图片" required showRequired>
|
||||
<my-upload-file ref="refFile" :images="FormData.images"
|
||||
:imageStyles="imageStyles"></my-upload-file>
|
||||
|
|
@ -55,33 +59,27 @@
|
|||
</up-checkbox-group>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<template v-if="FormData.type!='package'">
|
||||
<uni-forms-item required name="name" label="商品名称" showRequired>
|
||||
<uni-easyinput :paddingNone="inputPaddingNone" :placeholderStyle="placeholderStyle"
|
||||
:inputBorder="inputBorder" v-model="FormData.name" placeholder="请输入商品名称" />
|
||||
<view class="u-relative">
|
||||
<uni-forms-item label="商品分类" required showRequired name="categoryId">
|
||||
<uni-data-picker :clear-icon="false" :map="{text:'name',value:'id'}"
|
||||
placeholder="请选择商品分类" popup-title="请选择商品分类" :localdata="pageData.category"
|
||||
v-model="FormData.categoryId">
|
||||
</uni-data-picker>
|
||||
</uni-forms-item>
|
||||
<view class="u-relative">
|
||||
<uni-forms-item label="商品分类" required showRequired name="categoryId">
|
||||
<uni-data-picker :clear-icon="false" :map="{text:'name',value:'id'}"
|
||||
placeholder="请选择商品分类" popup-title="请选择商品分类" :localdata="pageData.category"
|
||||
v-model="FormData.categoryId">
|
||||
</uni-data-picker>
|
||||
</uni-forms-item>
|
||||
<view class="zhezhao u-absolute position-all" @click="canEditGoodsCategory(true)"
|
||||
v-if="option.type=='edit'&&disabledChangeCategory">
|
||||
|
||||
</view>
|
||||
<view class="zhezhao u-absolute position-all" @click="canEditGoodsCategory(true)"
|
||||
v-if="option.type=='edit'&&disabledChangeCategory">
|
||||
|
||||
</view>
|
||||
<view class="border-top-0">
|
||||
<uni-forms-item label="单位" required showRequired name="units">
|
||||
|
||||
<uni-data-picker :clear-icon="false" @change="unitIdChange"
|
||||
:map="{text:'name',value:'id'}" placeholder="请选择单位" popup-title="请选择单位"
|
||||
:localdata="pageData.units" v-model="FormData.unitId">
|
||||
</uni-data-picker>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
</template>
|
||||
</view>
|
||||
<view class="">
|
||||
<uni-forms-item label="单位" required showRequired name="units">
|
||||
|
||||
<uni-data-picker :clear-icon="false" @change="unitIdChange"
|
||||
:map="{text:'name',value:'id'}" placeholder="请选择单位" popup-title="请选择单位"
|
||||
:localdata="pageData.units" v-model="FormData.unitId">
|
||||
</uni-data-picker>
|
||||
</uni-forms-item>
|
||||
</view>
|
||||
<template v-if="FormData.type==='package'">
|
||||
<!-- <view class="block border-top-0">
|
||||
<uni-forms-item label="选择规格" required name="categoryId">
|
||||
|
|
@ -92,7 +90,8 @@
|
|||
</uni-data-picker>
|
||||
</uni-forms-item>
|
||||
</view> -->
|
||||
<view class="border-top" >
|
||||
|
||||
<view class="border-top" v-if="FormData.proGroupVo">
|
||||
<view class=""
|
||||
v-if=" (FormData.groupType==1&&FormData.proGroupVo.length)||(FormData.groupType==0&&FormData.proGroupVo.length&&FormData.proGroupVo[0].goods.length) ">
|
||||
<view class="border-bottom u-p-b-32"
|
||||
|
|
@ -512,7 +511,7 @@
|
|||
</view>
|
||||
</template>
|
||||
|
||||
<template v-if="FormData.type=='weight'">
|
||||
<template v-if="FormData.type=='weigh'">
|
||||
<view class="block u-p-t-32 u-p-b-32">
|
||||
<view class="font-bold">
|
||||
<text class="color-red">*</text>
|
||||
|
|
@ -544,7 +543,7 @@
|
|||
<view class="border-top-0">
|
||||
<view class="u-flex u-row-between u-p-b-24 u-p-t-20">
|
||||
<view class="label-title">是否允许临时改价</view>
|
||||
<my-switch disabled :openDisabledClass="false"
|
||||
<my-switch
|
||||
v-model="FormData.isTempPrice"></my-switch>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -1239,7 +1238,7 @@
|
|||
singleOrderLimit:0,
|
||||
singlePeopleLimit:0,
|
||||
type: 'normal',
|
||||
showType: 'table',
|
||||
showType: ['table'],
|
||||
specsInfoName: '',
|
||||
id: "",
|
||||
typeEnum: "normal",
|
||||
|
|
@ -1686,8 +1685,9 @@
|
|||
}
|
||||
}
|
||||
if (type == 'package') {
|
||||
if (groupType == 0) {
|
||||
if (groupType == 0&& FormData.proGroupVo[0].goods.length<=0) {
|
||||
// 固定套餐
|
||||
return infoBox.showToast('套餐组合至少需要包含一种商品,请添加商品')
|
||||
}
|
||||
if (groupType == 1) {
|
||||
let ispase = FormData.proGroupVo.length > 0 ? true : false
|
||||
|
|
@ -1711,7 +1711,7 @@
|
|||
// 可选套餐
|
||||
}
|
||||
}
|
||||
if (type == 'weight') {
|
||||
if (type == 'weigh') {
|
||||
if (!FormData.weight) {
|
||||
return infoBox.showToast('请输入重量')
|
||||
}
|
||||
|
|
@ -1937,6 +1937,9 @@
|
|||
initDefaultProGroupVo()
|
||||
}
|
||||
}
|
||||
if(FormData.groupType==null){
|
||||
FormData.groupType=0
|
||||
}
|
||||
} else {
|
||||
if (newval == 'package') {
|
||||
initDefaultProGroupVo()
|
||||
|
|
|
|||
|
|
@ -638,7 +638,7 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"pageId": "PAGES_ADD_TEMP_CUISINE",
|
||||
"pageId": "PAGES_CHOOSE_ADD_TEMP_CUISINE",
|
||||
"path": "add-temp-cuisine/add-temp-cuisine",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加临时菜"
|
||||
|
|
|
|||
|
|
@ -125,9 +125,12 @@
|
|||
reactive,
|
||||
onMounted,
|
||||
ref,
|
||||
onBeforeMount
|
||||
onBeforeMount,
|
||||
} from 'vue';
|
||||
import {onLoad} from '@dcloudio/uni-app'
|
||||
import {
|
||||
onLoad,
|
||||
onShow
|
||||
} from '@dcloudio/uni-app'
|
||||
const units = reactive({
|
||||
list: [],
|
||||
current: ''
|
||||
|
|
@ -187,11 +190,12 @@
|
|||
}]
|
||||
},
|
||||
}
|
||||
let timer=null
|
||||
let timer = null
|
||||
|
||||
function submit() {
|
||||
refform.value.validate(res => {
|
||||
console.log(res)
|
||||
if(!res){
|
||||
if (!res) {
|
||||
$temporaryDishes({
|
||||
"useType": option.useType,
|
||||
"masterId": option.masterId,
|
||||
|
|
@ -200,15 +204,15 @@
|
|||
"categoryId": category[categoryCurrent.value].id,
|
||||
"price": form.price,
|
||||
"num": form.num,
|
||||
unit:units.list[units.current].id,
|
||||
unit: units.list[units.current].id,
|
||||
"note": form.note,
|
||||
"vipUserId": option.vipUserId
|
||||
}).then(r=>{
|
||||
}).then(r => {
|
||||
uni.$emit('add:cashCai')
|
||||
clearInterval(timer)
|
||||
timer=setTimeout(()=>{
|
||||
timer = setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
},500)
|
||||
}, 500)
|
||||
})
|
||||
}
|
||||
}).catch(err => {
|
||||
|
|
@ -234,7 +238,7 @@
|
|||
page: 0,
|
||||
size: 600
|
||||
})
|
||||
const arr = returnAllCategory(res.content).map(v => {
|
||||
const arr = forList(res.content).map(v => {
|
||||
return {
|
||||
...v,
|
||||
value: v.id
|
||||
|
|
@ -244,23 +248,39 @@
|
|||
for (let i in arr) {
|
||||
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() {
|
||||
getTbShopUnit()
|
||||
getCategory()
|
||||
}
|
||||
onMounted(() => {
|
||||
init()
|
||||
// onMounted(() => {
|
||||
// init()
|
||||
// })
|
||||
onLoad((opt) => {
|
||||
Object.assign(option, opt)
|
||||
setTimeout(() => {
|
||||
init()
|
||||
}, 600)
|
||||
})
|
||||
onBeforeMount(()=>{
|
||||
|
||||
onBeforeMount(() => {
|
||||
clearInterval(timer)
|
||||
})
|
||||
const option=reactive({
|
||||
|
||||
})
|
||||
onLoad((opt)=>{
|
||||
Object.assign(option,opt)
|
||||
const option = reactive({
|
||||
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<template>
|
||||
<my-model ref="model" :title="title" iconColor="#000" @close="resetForm">
|
||||
<template #desc>
|
||||
<view class="u-m-t-48 tab">
|
||||
<!-- <view class="u-m-t-48 tab">
|
||||
<my-tabs :list="tabs" @change="tabsChange"></my-tabs>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="u-text-left u-p-30 ">
|
||||
<template v-if="!current">
|
||||
<view>
|
||||
|
|
@ -34,7 +34,6 @@
|
|||
<view class="u-flex-1">
|
||||
<input @input="discountMoneyInput" v-model="form.discountMoney" type="digit"
|
||||
placeholder-class="placeholder-class" placeholder="减8.55元请输入8.55" />
|
||||
|
||||
</view>
|
||||
<view class="color-999 u-p-l-48 u-p-r-48 u-flex u-row-center u-col-center">
|
||||
<view>元</view>
|
||||
|
|
@ -46,19 +45,22 @@
|
|||
</view>
|
||||
</template>
|
||||
<view class="u-m-t-48">
|
||||
<view class="u-font-24">
|
||||
<text class="color-999">打折原因</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
<view class="u-font-24">
|
||||
<text class="color-999">当前单品价格:{{price}}</text>
|
||||
</view>
|
||||
<view class="u-font-24">
|
||||
<text class="color-999">打折原因</text>
|
||||
<text class="color-red">*</text>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-24">
|
||||
<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>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<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>
|
||||
|
|
@ -67,7 +69,10 @@
|
|||
<view class="u-p-30">
|
||||
<view class="u-m-t-10">
|
||||
<my-button @tap="confirm" shape="circle" showShadow>确认</my-button>
|
||||
<my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button>
|
||||
<view style="height: 20rpx;">
|
||||
|
||||
</view>
|
||||
<!-- <my-button type="cancel" bgColor="#fff" @tap="confirm">取消</my-button> -->
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
|
@ -86,7 +91,7 @@
|
|||
import myTabs from '@/components/my-components/my-tabs.vue'
|
||||
const props = defineProps({
|
||||
price: {
|
||||
type: [Number,String],
|
||||
type: [Number, String],
|
||||
default: 0
|
||||
},
|
||||
title: {
|
||||
|
|
@ -98,12 +103,10 @@
|
|||
default: []
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
function changeCauses(item) {
|
||||
item.checked = !item.checked
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const discounts = [95, 90, 85, 80]
|
||||
const causes = reactive([{
|
||||
|
|
@ -120,6 +123,11 @@
|
|||
}
|
||||
])
|
||||
|
||||
function changeCauses(item, index) {
|
||||
item.checked = !item.checked
|
||||
form.notes = causes
|
||||
}
|
||||
|
||||
function discountInput(e) {
|
||||
if (e.detail.value >= 100) {
|
||||
nextTick(() => {
|
||||
|
|
@ -127,8 +135,9 @@
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
function discountMoneyInput(e) {
|
||||
const max=100
|
||||
const max = 100
|
||||
if (e.detail.value >= max) {
|
||||
nextTick(() => {
|
||||
form.discountMoney = 100
|
||||
|
|
@ -142,7 +151,7 @@
|
|||
|
||||
|
||||
const tabs = ['打折', '减免']
|
||||
let current = ref(0)
|
||||
let current = ref(1)
|
||||
|
||||
function tabsChange(i) {
|
||||
console.log(i);
|
||||
|
|
@ -158,11 +167,12 @@
|
|||
const form = reactive({
|
||||
...$form
|
||||
})
|
||||
watch(()=>props.price,(newval)=>{
|
||||
watch(() => props.price, (newval) => {
|
||||
console.log(newval);
|
||||
form.price=newval
|
||||
form.currentPrice=newval
|
||||
form.price = newval
|
||||
form.currentPrice = newval
|
||||
})
|
||||
|
||||
function resetForm() {
|
||||
Object.assign(form, {
|
||||
...$form
|
||||
|
|
@ -182,22 +192,23 @@
|
|||
|
||||
function confirm() {
|
||||
const {
|
||||
discount,discountMoney
|
||||
discount,
|
||||
discountMoney
|
||||
} = form
|
||||
if (current.value===0&& discount==='') {
|
||||
if (current.value === 0 && discount === '') {
|
||||
return uni.showToast({
|
||||
icon: 'none',
|
||||
title: '请输入有效折扣!'
|
||||
})
|
||||
}
|
||||
if (current.value===1&& discountMoney==='') {
|
||||
if (current.value === 1 && discountMoney === '') {
|
||||
return uni.showToast({
|
||||
icon: 'none',
|
||||
title: '请输入有效减免价格!'
|
||||
})
|
||||
}
|
||||
close()
|
||||
emits('confirm', form)
|
||||
close()
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
|
|
|
|||
|
|
@ -136,10 +136,15 @@
|
|||
:key="index">
|
||||
<view class="u-flex u-row-between ">
|
||||
<view class="u-flex">
|
||||
<image class="img" :src="item.coverImg" mode=""></image>
|
||||
<image class="img" v-if="item.coverImg" :src="item.coverImg" mode=""></image>
|
||||
<view
|
||||
style="background-color: #3f9eff; width: 84rpx;height: 84rpx;line-height: 84rpx;text-align: center;color: #fff;"
|
||||
v-else>
|
||||
临时菜
|
||||
</view>
|
||||
<view class="u-m-l-32">
|
||||
<view class="u-flex">
|
||||
<view class="u-flex u-m-r-20" v-if="item.isWait">
|
||||
<view class="u-flex u-m-r-20" v-if="item.isWaitCall">
|
||||
<uni-tag text="等叫"
|
||||
custom-style="background-color: #FFF0DF; border-color: #FFF0DF; color: #FF9F2E;">
|
||||
</uni-tag>
|
||||
|
|
@ -154,6 +159,11 @@
|
|||
custom-style="background-color: #E6F0FF; border-color: #E6F0FF; color: #318AFE;"
|
||||
size="small" text="打包" inverted type="success" />
|
||||
</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>
|
||||
{{item.name}}
|
||||
</view>
|
||||
|
|
@ -174,7 +184,8 @@
|
|||
<text
|
||||
class="line-th color-999">¥{{formatPrice(item.salePrice*item.number) }}</text>
|
||||
<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>
|
||||
</template>
|
||||
<template v-else>
|
||||
|
|
@ -196,9 +207,10 @@
|
|||
</template>
|
||||
<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 u-m-r-20 u-m-b-20">
|
||||
<button class="tag" hover-class="hover-class" @tap="showModel('discount')">单品打折</button>
|
||||
</view> -->
|
||||
<view class="u-flex u-m-r-20 " v-if="!item.isGift">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="showModel('discount',index)">单品打折</button>
|
||||
</view>
|
||||
<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"
|
||||
|
|
@ -208,10 +220,14 @@
|
|||
<button class="tag" hover-class="hover-class"
|
||||
@tap="toggleGoodsItemKey(item,index,'isPack')">{{item.isPack?'取消打包':'打包'}}</button>
|
||||
</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"
|
||||
@tap="toggleWait(item)">{{item.isWait?'取消等叫':'等叫'}}</button>
|
||||
</view> -->
|
||||
@tap="toggleWait(item)">{{item.isWaitCall?'取消等叫':'等叫'}}</button>
|
||||
</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 ">
|
||||
<button class="tag" hover-class="hover-class"
|
||||
@tap="showModel('remark',index)">单品备注</button>
|
||||
|
|
@ -251,7 +267,7 @@
|
|||
<view class="font-bold u-font-32">¥{{formatPrice(youhui) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="u-flex price u-m-l-32">
|
||||
<view class="">实收金额</view>
|
||||
<view class="font-bold u-font-32">¥{{formatPrice(allPrice) }}</view>
|
||||
|
|
@ -278,8 +294,8 @@
|
|||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<model-discount title="菜品打折/减免" :ref="setModel" name="discount" :price="allPrice"></model-discount>
|
||||
<model-discount title="菜品减免" :ref="setModel" name="discount" :price="modelData.data.salePrice"
|
||||
@confirm="discountconfirm"></model-discount>
|
||||
<give-food title="赠菜" :ref="setModel" name="giveFood"></give-food>
|
||||
<one-remark @confirm="goodsOneRemarkConfirm" title="单品备注" :ref="setModel" name="remark"></one-remark>
|
||||
<edit-discount title="优惠金额" :ref="setModel" name="editMoney" :price="allPrice"></edit-discount>
|
||||
|
|
@ -351,7 +367,26 @@
|
|||
return Number(n).toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
// 单品打折
|
||||
async function discountconfirm(form) {
|
||||
if (form.discountMoney != '.') {
|
||||
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)
|
||||
getCart()
|
||||
}
|
||||
}
|
||||
|
||||
//用餐人数
|
||||
const userNumbers = reactive({
|
||||
|
|
@ -416,18 +451,46 @@
|
|||
skuId
|
||||
}
|
||||
par[key] = !item[key]
|
||||
|
||||
|
||||
const res = await Api.$updateCart(par)
|
||||
goods.list[index][key] = returnBoolean(res[key])
|
||||
if (key == 'isPack') {
|
||||
getCart()
|
||||
}
|
||||
getCart()
|
||||
}
|
||||
//等叫
|
||||
function toggleWait(item) {
|
||||
item.isWait = !item.isWait
|
||||
async function toggleWait(item) {
|
||||
item.isWaitCall = !item.isWaitCall
|
||||
let obj = {
|
||||
cartId: item.id,
|
||||
isGift: item.isGift,
|
||||
isPack: item.isPack,
|
||||
isPrint: item.isPrint,
|
||||
isWaitCall: item.isWaitCall,
|
||||
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.isWaitCall,
|
||||
masterId: option.masterId,
|
||||
num: item.number, // 0会删除此商品
|
||||
productId: item.productId,
|
||||
skuId: item.skuId,
|
||||
vipUserId: '',
|
||||
}
|
||||
let res = await Api.$updateCart(obj)
|
||||
}
|
||||
|
||||
|
||||
|
||||
const eatTypes = reactive({
|
||||
list: [{
|
||||
|
|
@ -479,7 +542,6 @@
|
|||
function watchChooseuser() {
|
||||
uni.$off('choose-user')
|
||||
uni.$on('choose-user', (data) => {
|
||||
console.log(data);
|
||||
user.value = data
|
||||
setUser()
|
||||
})
|
||||
|
|
@ -520,20 +582,25 @@
|
|||
totalNumber: 0,
|
||||
totalAmount: 0,
|
||||
})
|
||||
const isVip=computed(()=>{
|
||||
return $shop.value.isMemberPrice&& user.value&&user.value.id&&user.value.isVip
|
||||
const isVip = computed(() => {
|
||||
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 goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
const memberPrice=cur.memberPrice?cur.memberPrice:cur.salePrice
|
||||
const tPrice = (isVip.value? memberPrice:cur.salePrice) * cur.number
|
||||
const memberPrice = cur.memberPrice ? cur.memberPrice : cur.salePrice
|
||||
const tPrice = (isVip.value ? memberPrice : cur.salePrice) * cur.number
|
||||
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
|
||||
return prve + (cur.isGift ? 0 : tPrice) + tpackFee
|
||||
}, 0)
|
||||
return (goodsTotalPrice || 0).toFixed(2)
|
||||
return ((goodsTotalPrice - discountSaleAmount.value) || 0).toFixed(2)
|
||||
})
|
||||
const allPrice = computed(() => {
|
||||
console.log(goodsPrice.value);
|
||||
const n = goodsPrice.value * 1 + $seatFee.totalAmount
|
||||
return n.toFixed(2)
|
||||
// const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
|
|
@ -541,18 +608,21 @@
|
|||
// }, 0)
|
||||
// return (goodsTotalPrice + ($seatFee.totalAmount || 0)).toFixed(2)
|
||||
})
|
||||
const youhui=computed(()=>{
|
||||
if(user.value&&user.value.id&&user.value.isVip){
|
||||
const goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
const youhui = computed(() => {
|
||||
let goodsTotalPrice = 0
|
||||
if (user.value && user.value.id && user.value.isVip) {
|
||||
goodsTotalPrice = goods.list.reduce((prve, cur) => {
|
||||
const tPrice = cur.salePrice * cur.number
|
||||
const tpackFee = cur.isPack ? cur.packFee * 1 : 0
|
||||
return prve + tPrice + tpackFee
|
||||
}, 0)
|
||||
return goodsTotalPrice-allPrice.value
|
||||
}else{
|
||||
return 0
|
||||
return goodsTotalPrice - allPrice.value
|
||||
} else {
|
||||
console.log(discountSaleAmount.value,'优惠金额')
|
||||
return (discountSaleAmount.value)
|
||||
}
|
||||
return goodsTotalPrice
|
||||
console.log(discountSaleAmount.value,'优惠金额1')
|
||||
return (goodsTotalPrice + discountSaleAmount.value * 1).toFixed(2)
|
||||
})
|
||||
|
||||
function setGoodsItem(key, val) {
|
||||
|
|
@ -573,16 +643,16 @@
|
|||
records,
|
||||
seatFee
|
||||
} = await Api.getCart(par)
|
||||
let useType=''
|
||||
let useType = ''
|
||||
if (seatFee && seatFee.useType) {
|
||||
useType=seatFee.useType
|
||||
useType = seatFee.useType
|
||||
$storageManage.useType(useType)
|
||||
}else{
|
||||
useType=records[0].info[0].useType
|
||||
} else {
|
||||
useType = records[0].info[0].useType
|
||||
$storageManage.useType(useType)
|
||||
}
|
||||
console.log(useType);
|
||||
eatTypes.active =useType == 'takeout' ? useType : useType.replace(
|
||||
eatTypes.active = useType == 'takeout' ? useType : useType.replace(
|
||||
/-after|-before/g, '');
|
||||
goods.list = getNowCart(records)
|
||||
if (seatFee && seatFee.totalNumber) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<view class="u-absolute goods bg-fff">
|
||||
<view
|
||||
class="u-p-t-32 color-666 border-bottom bg-fff u-absolute total u-p-r-28 u-p-b-32 u-p-l-28 u-flex u-row-between">
|
||||
<view>已添加{{goodsNumber}}件商品</view>
|
||||
<view>已添加{{goodsNumber.toFixed(0)}}件商品</view>
|
||||
<view class="color-666">
|
||||
<uni-icons color="#666" type="trash"></uni-icons>
|
||||
<text class="u-m-l-10" @tap="setModalShow('clear',true)">清空</text>
|
||||
|
|
|
|||
|
|
@ -3,10 +3,11 @@
|
|||
|
||||
<up-image :src="data.coverImg" mode="aspectFill" :width="img.width" :height="img.height"></up-image>
|
||||
<!-- <image lazy-load class="img" :src="data.coverImg" mode="aspectFill" :style="computedImgStyle()"></image> -->
|
||||
<view class="info u-flex u-row-between u-col-top u-flex-col" @tap="emitEvent('add')">
|
||||
<view class="info u-flex u-row-between u-col-top u-flex-col" >
|
||||
<view>
|
||||
<view>
|
||||
<text class="u-line-2">{{data.name}}</text>
|
||||
<text class="u-line-2">{{data.name}}
|
||||
</text>
|
||||
</view>
|
||||
<view class="u-font-32 font-bold u-m-t-16">
|
||||
¥{{data.price}}
|
||||
|
|
@ -14,7 +15,7 @@
|
|||
</view>
|
||||
<view class="u-flex">
|
||||
<template v-if="!isSellout">
|
||||
<template v-if="!data.isDan">
|
||||
<template v-if="!data.isDan||data.groupType==1">
|
||||
<button class="btn" hover-class="btn-hover-class" @tap="emitEvent('chooseGuige')">选规格</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,174 @@
|
|||
<template>
|
||||
<my-model ref="model" borderRadius="12" :title="datas.title">
|
||||
<template #desc>
|
||||
<scroll-view scroll-y="true" style="height: 50vh;" class="u-p-30 guigeModel">
|
||||
<view class="u-m-b-40" v-for="(item,index) in datas.skus" :key="index">
|
||||
<view class="u-text-left">
|
||||
<view class="color-333">{{item.title}} <text
|
||||
style="color:#999">({{item.count}}选{{item.number}})</text> </view>
|
||||
</view>
|
||||
<view class="u-flex u-m-t-20 u-flex-wrap">
|
||||
<view class="item" @tap="chooseSkd(skd,item.number)" :class="{active:skd.select==true}"
|
||||
v-for="(skd,skdIndex) in item.goods" :key="skdIndex">
|
||||
{{skd.proName}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</template>
|
||||
<template #btn>
|
||||
<view class="u-p-30 border-top ">
|
||||
<view class="u-flex u-p-b-30 u-row-between">
|
||||
<view class="price">
|
||||
<text>¥</text>
|
||||
<text>{{datas.price}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="u-m-t-10">
|
||||
<my-button @tap="confirm">添加</my-button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
</my-model>
|
||||
<uni-popup ref="popup" type="message">
|
||||
<uni-popup-message type="info" message="请选择套餐" :duration="2000"></uni-popup-message>
|
||||
</uni-popup>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
getCurrentInstance,
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import util from '../util.js';
|
||||
import infobox from '@/commons/utils/infoBox.js'
|
||||
import myModel from '@/components/my-components/my-model.vue'
|
||||
import myButton from '@/components/my-components/my-button.vue'
|
||||
import {
|
||||
onShow,
|
||||
} from '@dcloudio/uni-app';
|
||||
const props = defineProps({
|
||||
goodsData: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
})
|
||||
|
||||
let datas = reactive({
|
||||
item: "",
|
||||
title: "",
|
||||
price: "",
|
||||
skus: [],
|
||||
selectData: [],
|
||||
// 几选几,的和
|
||||
selectNumber: 0,
|
||||
})
|
||||
|
||||
|
||||
// const selSku = computed(() => {
|
||||
// return props.skus.reduce((prve, cur) => {
|
||||
// prve.push(cur.sel)
|
||||
// return prve
|
||||
// }, []).join()
|
||||
// })
|
||||
|
||||
|
||||
// const goods = computed(() => {
|
||||
// return props.skuMap[selSku.value]
|
||||
// })
|
||||
watch(() => props.goodsData, (newval) => {
|
||||
datas.item = newval
|
||||
datas.title = newval.name
|
||||
datas.price = newval.price
|
||||
datas.skus = newval.proGroupVo
|
||||
datas.skus.forEach(ele => {
|
||||
datas.selectNumber += ele.number
|
||||
})
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm', 'updateSku'])
|
||||
let number = ref(1)
|
||||
|
||||
function chooseSkd(skd, number) {
|
||||
if (datas.selectData.includes(skd.proId)) {
|
||||
skd.select = false
|
||||
let indexs = datas.selectData.indexOf(skd.proId)
|
||||
datas.selectData.splice(indexs, 1)
|
||||
} else {
|
||||
if (datas.selectData.length < number) {
|
||||
skd.select = true
|
||||
datas.selectData.push(skd.proId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
const instance = getCurrentInstance();
|
||||
|
||||
function confirm() {
|
||||
console.log(datas.selectData.length)
|
||||
console.log(datas.selectNumber,'调试1111')
|
||||
if (datas.selectData.length == datas.selectNumber) {
|
||||
emits('confirm', datas.selectData,datas.item)
|
||||
close()
|
||||
} else {
|
||||
instance.ctx.$refs.popup.open()
|
||||
}
|
||||
}
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.border-top {}
|
||||
|
||||
.icon {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
|
||||
.guigeModel {
|
||||
.item {
|
||||
color: #666;
|
||||
font-size: 24rpx;
|
||||
padding: 4rpx 28rpx;
|
||||
border: 1px solid #E5E5E5;
|
||||
border-radius: 8rpx;
|
||||
margin-right: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
transition: all .2s ease-in-out;
|
||||
|
||||
&.active {
|
||||
border-color: $my-main-color;
|
||||
color: $my-main-color;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
color: #ccc;
|
||||
border-color: #eee;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.price {
|
||||
color: #EB4F4F;
|
||||
}
|
||||
|
||||
.border-top {
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -105,7 +105,6 @@
|
|||
@add="searchGoodsUpdate(goodsItem,goodsIndex,true)"
|
||||
@reduce="searchGoodsUpdate(goodsItem,goodsIndex,false)"
|
||||
:index="goodsItem.goodsIndex" :data="goodsItem"></list-goods-item>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
<my-img-empty v-if="!searchResult.length" tips="未搜索到相关商品"></my-img-empty>
|
||||
|
|
@ -120,7 +119,8 @@
|
|||
<my-car :isCreateOrderToDetail="isCreateOrderToDetail" @updateNumber="carsNumberChange" :user="data.vipUser"
|
||||
:masterId="data.masterId" :table="data.table" :data="cars" @clear="onClearCart"></my-car>
|
||||
</view>
|
||||
|
||||
<!-- 套餐选择规格 -->
|
||||
<taocanModel ref="taocanModelRef" @confirm="taocanConfirm" :goodsData="selGoods"></taocanModel>
|
||||
<!-- 选择规格 -->
|
||||
<guige-model @update-sku="updateSkuSel" @confirm="guigeConfirm" ref="chooseGuigeModel" :goodsData="selGoods"
|
||||
:title="guigeModelData.title" :sku-map="guigeModelData.chooseGoods.skuMap"
|
||||
|
|
@ -150,6 +150,7 @@
|
|||
import util from './util.js';
|
||||
import color from '@/commons/color.js';
|
||||
import guigeModel from './components/guige'
|
||||
import taocanModel from './components/taocanModel.vue'
|
||||
import listGoodsItem from './components/list-goods-item.vue'
|
||||
import mySurcharge from './components/surcharge'
|
||||
import {
|
||||
|
|
@ -277,6 +278,26 @@
|
|||
}
|
||||
return obj
|
||||
}
|
||||
// 添加套餐
|
||||
async function taocanConfirm(d, item) {
|
||||
const cartGoods = await addCart({
|
||||
num: 1,
|
||||
groupProductIdList: d,
|
||||
productId: item.id,
|
||||
skuId: item.specList[0].id
|
||||
})
|
||||
infoBox.showToast('添加成功')
|
||||
// guigeConfirm(item, 1)
|
||||
// updateCartGoods({
|
||||
// productId: item.id,
|
||||
// skuId: item.specList[0].id,
|
||||
// cartId: cartGoods.id
|
||||
// })
|
||||
cars.push({
|
||||
...cartGoods,
|
||||
specSnap: item.specSnap
|
||||
})
|
||||
}
|
||||
|
||||
function scanCode() {
|
||||
// 只允许通过相机扫码
|
||||
|
|
@ -671,11 +692,11 @@
|
|||
}
|
||||
|
||||
function toLinshi() {
|
||||
go.to('PAGES_ADD_TEMP_CUISINE',{
|
||||
masterId:data.masterId,
|
||||
tableId:data.table.tableId,
|
||||
vipUserId:option.vipUserId?option.vipUserId:'',
|
||||
useType:uni.getStorageSync('useType')
|
||||
go.to('PAGES_CHOOSE_ADD_TEMP_CUISINE', {
|
||||
masterId: data.masterId,
|
||||
tableId: data.table.tableId,
|
||||
vipUserId: option.vipUserId ? option.vipUserId : '',
|
||||
useType: uni.getStorageSync('useType')
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -833,7 +854,7 @@
|
|||
}
|
||||
|
||||
|
||||
let selGoods = ref({})
|
||||
let selGoods = ref({});
|
||||
|
||||
function chooseGuige(foodsindex, index) {
|
||||
if (!canAddGoods()) {
|
||||
|
|
@ -843,13 +864,19 @@
|
|||
}
|
||||
const $goods = data.tabbar[index].foods[foodsindex]
|
||||
selGoods.value = $goods
|
||||
guigeModelData.title = $goods.name
|
||||
const specList = $goods.specList;
|
||||
const tagSnap = JSON.parse($goods.skuResult.tagSnap)
|
||||
const skuMap = returnSelGoodsSkuMap(specList)
|
||||
const skuList = returnSelGoodsSkuList(tagSnap)
|
||||
setSkugoodsDefaultInit($goods, skuList, skuMap, specList)
|
||||
chooseGuigeModel.value.open()
|
||||
if ($goods.groupType == 1) {
|
||||
instance.ctx.$refs.taocanModelRef.open()
|
||||
} else {
|
||||
guigeModelData.title = $goods.name
|
||||
const specList = $goods.specList;
|
||||
const skuMap = returnSelGoodsSkuMap(specList)
|
||||
// 多规格,和套餐规格区分.groupType=1 套餐多规格
|
||||
let tagSnap = JSON.parse($goods.skuResult.tagSnap)
|
||||
const skuList = returnSelGoodsSkuList(tagSnap)
|
||||
setSkugoodsDefaultInit($goods, skuList, skuMap, specList)
|
||||
chooseGuigeModel.value.open()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function guigeConfirm(sku, num) {
|
||||
|
|
@ -902,13 +929,15 @@
|
|||
categoryId,
|
||||
skuId
|
||||
} = goods
|
||||
|
||||
|
||||
const cartId = goods.id
|
||||
const tabbarIndex = data.tabbar.findIndex(v => v.id == categoryId)
|
||||
//临时菜没有对应商品数据
|
||||
const $goods =!productId?undefined:data.tabbar[tabbarIndex].foods.find(v => v.id == productId)
|
||||
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)
|
||||
const $sku = !productId ? {
|
||||
suit: 1
|
||||
} : $goods.specList.find(v => v.id == skuId)
|
||||
|
||||
if (num === 0 || num < $sku.suit) {
|
||||
//移除
|
||||
|
|
@ -1000,16 +1029,19 @@
|
|||
$goods.chooseNumber = number
|
||||
setSearchGoods(searchGoodsIndex, number)
|
||||
} else {
|
||||
//增加
|
||||
const num = suit
|
||||
const cartGoods = await addCart({
|
||||
num,
|
||||
productId,
|
||||
skuId
|
||||
})
|
||||
infoBox.showToast('添加成功')
|
||||
$goods.chooseNumber = num
|
||||
cars.push(cartGoods)
|
||||
// 套餐和单规格
|
||||
if ($goods.groupType != 1) {
|
||||
//增加
|
||||
const num = suit
|
||||
const cartGoods = await addCart({
|
||||
num,
|
||||
productId,
|
||||
skuId
|
||||
})
|
||||
infoBox.showToast('添加成功')
|
||||
$goods.chooseNumber = num
|
||||
cars.push(cartGoods)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -1188,7 +1220,7 @@
|
|||
setTabBar($category, $originGoods, cars)
|
||||
}
|
||||
onBeforeUnmount(() => {})
|
||||
|
||||
|
||||
function watchUpdate() {
|
||||
uni.$off('update:createOrderIndex')
|
||||
uni.$off('get:table')
|
||||
|
|
@ -1201,7 +1233,7 @@
|
|||
console.log('update:createOrderIndex');
|
||||
init()
|
||||
})
|
||||
uni.$on('add:cashCai', async() => {
|
||||
uni.$on('add:cashCai', async () => {
|
||||
console.log('add:cashCai');
|
||||
const cartRes = await getCart()
|
||||
cars.length = 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue