代码更新
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
<!-- 占位 -->
|
||||
<view class="u-p-t-32 color-666 border-bottom u-p-r-28 u-p-b-32 u-p-l-28 u-flex u-row-between"
|
||||
style="opacity: 0;">
|
||||
<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">清空</text>
|
||||
@@ -30,13 +30,13 @@
|
||||
<view class="u-m-t-10 u-font-24 color-666 u-line-1">{{item.specSnap||''}}</view>
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<view class="font-bold red u-m-r-32">¥{{formatPrice(item.salePrice*item.number) }}</view>
|
||||
<view class="font-bold red u-m-r-32">¥{{formatPrice(item.lowPrice*item.number) }}</view>
|
||||
<view class="u-flex" @tap="updateNumber(false,index,item)">
|
||||
<image src="/pagesCreateOrder/static/images/icon-reduce-black.svg" class="icon" mode="">
|
||||
</image>
|
||||
</view>
|
||||
<view class="u-m-l-30 u-m-r-30 color-333">
|
||||
{{(item.number).toFixed(2)}}
|
||||
{{item.number.toFixed(2)}}
|
||||
</view>
|
||||
<view class="u-flex" @tap="updateNumber(true,index,item)">
|
||||
<image src="/pagesCreateOrder/static/images/icon-add-black.svg" class="icon" mode="">
|
||||
@@ -107,10 +107,6 @@
|
||||
tableId: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
masterId: {
|
||||
type: [String, Number],
|
||||
default: ''
|
||||
}
|
||||
})
|
||||
const modal = reactive({
|
||||
@@ -125,9 +121,9 @@
|
||||
}
|
||||
|
||||
function setModalShow(key = 'show', show = true) {
|
||||
if (key == 'clear' && show && props.data.length <= 0) {
|
||||
return infoBox.showToast('购物车是空的!')
|
||||
}
|
||||
// if (key == 'clear' && show && props.data.length <= 0) {
|
||||
// return infoBox.showToast('购物车是空的!')
|
||||
// }
|
||||
modal.key = key
|
||||
modal[key] = show
|
||||
console.log(modal);
|
||||
@@ -153,38 +149,36 @@
|
||||
}
|
||||
|
||||
function toConfimOrder() {
|
||||
console.log(props.user);
|
||||
console.log(props.table);
|
||||
if (props.data.length <= 0) {
|
||||
return infoBox.showToast('还没有选择商品')
|
||||
}
|
||||
const {
|
||||
tableId,
|
||||
name,
|
||||
maxCapacity,
|
||||
status,
|
||||
type
|
||||
} = props.table
|
||||
if (props.table.tableId == '') {
|
||||
|
||||
if (props.table.id == '') {
|
||||
go.to('PAGES_CONFIRM_ORDER', {
|
||||
masterId: props.masterId,
|
||||
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
|
||||
})
|
||||
return
|
||||
}
|
||||
go.to('PAGES_CONFIRM_ORDER', {
|
||||
masterId: props.masterId,
|
||||
type,
|
||||
tableId,
|
||||
name,
|
||||
maxCapacity,
|
||||
status,
|
||||
type: type,
|
||||
tableId: props.table.id,
|
||||
name:name,
|
||||
maxCapacity:maxCapacity,
|
||||
status:status,
|
||||
isCreateOrderToDetail: props.isCreateOrderToDetail ? 1 : 0
|
||||
})
|
||||
}
|
||||
|
||||
const allPrice = computed(() => {
|
||||
return props.data.reduce((prve, cur) => {
|
||||
return prve + cur.salePrice * cur.number
|
||||
return prve + cur.lowPrice * cur.number
|
||||
}, 0).toFixed(2)
|
||||
})
|
||||
|
||||
@@ -193,6 +187,7 @@
|
||||
result = props.data.reduce((prve, cur) => {
|
||||
return prve + cur.number
|
||||
}, 0)
|
||||
// console.log(result)
|
||||
return result >= 99 ? 99 : result
|
||||
})
|
||||
|
||||
|
||||
@@ -51,12 +51,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import { computed, 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'
|
||||
@@ -82,20 +77,15 @@
|
||||
return []
|
||||
}
|
||||
},
|
||||
defaultIndex: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm', 'updateSku'])
|
||||
const model = ref(null)
|
||||
let number = ref(1)
|
||||
function to2(number) {
|
||||
return Number(number).toFixed(2)
|
||||
}
|
||||
|
||||
|
||||
|
||||
const selSku = computed(() => {
|
||||
return props.skus.reduce((prve, cur) => {
|
||||
prve.push(cur.sel)
|
||||
@@ -103,16 +93,13 @@
|
||||
}, []).join()
|
||||
})
|
||||
|
||||
|
||||
const goods = computed(() => {
|
||||
return props.skuMap[selSku.value]
|
||||
})
|
||||
watch(() => goods.value, (newval) => {
|
||||
console.log(props.goodsData.isStock);
|
||||
number.value = newval.suit || 1
|
||||
number.value = newval.suitNum || 1
|
||||
})
|
||||
|
||||
|
||||
const isCanBuy = computed(() => {
|
||||
if (!goods.value) {
|
||||
return false
|
||||
@@ -124,23 +111,22 @@
|
||||
|
||||
})
|
||||
|
||||
//全部规格是否都无法使用
|
||||
/**
|
||||
* 全部规格是否都无法使用
|
||||
*/
|
||||
const isAllDisabled = computed(() => {
|
||||
console.log(props.skus);
|
||||
return props.skus.reduce((prve, cur) => {
|
||||
return prve && cur.values.filter(v => v.disabled).length === cur.values.length
|
||||
}, true)
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm', 'updateSku'])
|
||||
let number = ref(1)
|
||||
|
||||
|
||||
/**
|
||||
* 规格选择
|
||||
* @param {Object} skusIndex
|
||||
* @param {Object} skd
|
||||
*/
|
||||
function chooseSkd(skusIndex, skd) {
|
||||
const {
|
||||
name,
|
||||
disabled
|
||||
} = skd
|
||||
const { name, disabled } = skd
|
||||
if (disabled) {
|
||||
return
|
||||
}
|
||||
@@ -148,50 +134,42 @@
|
||||
emits('updateSku', skusIndex, name)
|
||||
}
|
||||
}
|
||||
const defaultIndex = reactive(new Array(props.skus.length).fill(''))
|
||||
for (let i in props.defaultIndex) {
|
||||
defaultIndex[i] = props.defaultIndex[i]
|
||||
}
|
||||
const activeArr = defaultIndex
|
||||
|
||||
console.log(activeArr);
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁止操作
|
||||
*/
|
||||
const isDisabled = computed(() => {
|
||||
return isAllDisabled.value || !isCanBuy.value
|
||||
})
|
||||
|
||||
|
||||
/**
|
||||
* 数量减少
|
||||
*/
|
||||
function reduce() {
|
||||
if (isDisabled.value) {
|
||||
return
|
||||
}
|
||||
const suit = goods.value.suit || 1
|
||||
const suitNum = goods.value.suitNum || 1
|
||||
const newval = number.value - 1
|
||||
if (newval < suit) {
|
||||
return infobox.showToast(suit + '个起售')
|
||||
if (newval < suitNum) {
|
||||
return infobox.showToast(suitNum + '个起售')
|
||||
}
|
||||
number.value = newval <= 1 ? 1 : newval
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 数量增加
|
||||
*/
|
||||
function add() {
|
||||
if (isDisabled.value) {
|
||||
return
|
||||
}
|
||||
const newval = number.value + 1
|
||||
number.value = newval
|
||||
number.value = number.value + 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 都规格选择确认
|
||||
*/
|
||||
function confirm() {
|
||||
close()
|
||||
if (isDisabled.value) {
|
||||
@@ -199,6 +177,15 @@
|
||||
}
|
||||
emits('confirm', goods.value, number.value)
|
||||
}
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
|
||||
function close() {
|
||||
model.value.close()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
<view class="u-relative u-flex item">
|
||||
|
||||
<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">
|
||||
<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}}
|
||||
¥{{data.lowPrice}}
|
||||
</view>
|
||||
<template v-if="data.type=='weigh'">
|
||||
<view class="btnweigh">称重</view>
|
||||
@@ -18,7 +16,7 @@
|
||||
</view>
|
||||
<view class="u-flex">
|
||||
<template v-if="!isSellout">
|
||||
<template v-if="!data.isDan||data.groupType==1">
|
||||
<template v-if="data.type == 'sku'||data.groupType==1">
|
||||
<button class="btn" hover-class="btn-hover-class" @tap="emitEvent('chooseGuige')">选规格</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -84,27 +82,23 @@
|
||||
}
|
||||
})
|
||||
|
||||
function computedImgStyle() {
|
||||
return {
|
||||
width: props.img.width,
|
||||
height: props.img.height
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否是菜品
|
||||
/**
|
||||
* 判断是否是菜品
|
||||
*/
|
||||
function isGoods() {
|
||||
return props.data.hasOwnProperty('id')
|
||||
}
|
||||
|
||||
//判断商品是否售尽
|
||||
/**
|
||||
* 判断商品是否售尽
|
||||
*/
|
||||
const isSellout = computed(() => {
|
||||
const item = props.data
|
||||
if (!isGoods()) {
|
||||
return false
|
||||
}
|
||||
return (
|
||||
item.isPauseSale ||
|
||||
(item.typeEnum !== "sku" && item.isStock == 1 && item.stockNumber <= 0)
|
||||
item.isPauseSale || (item.type !== "sku" && item.isStock == 1 && item.stockNumber <= 0)
|
||||
);
|
||||
})
|
||||
|
||||
|
||||
@@ -36,27 +36,18 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
computed,
|
||||
getCurrentInstance,
|
||||
reactive,
|
||||
ref,
|
||||
watch
|
||||
} from 'vue';
|
||||
import util from '../util.js';
|
||||
import { computed, getCurrentInstance, reactive, ref, watch } from 'vue';
|
||||
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';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
const props = defineProps({
|
||||
goodsData: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
})
|
||||
|
||||
const model = ref(null)
|
||||
let datas = reactive({
|
||||
item: "",
|
||||
title: "",
|
||||
@@ -65,34 +56,60 @@
|
||||
// 几选几,的和
|
||||
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) => {
|
||||
newval.proGroupVo.forEach(ele => {
|
||||
newval.groupSnap.forEach(ele => {
|
||||
ele.selectData = []
|
||||
})
|
||||
datas.item = newval
|
||||
datas.title = newval.name
|
||||
datas.price = newval.price
|
||||
datas.skus = newval.proGroupVo
|
||||
datas.skus.forEach(ele => {
|
||||
datas.skus = newval.groupSnap
|
||||
})
|
||||
|
||||
const selectNumber = computed(() => {
|
||||
return datas.skus.reduce((prve, cur) => {
|
||||
console.log(prve)
|
||||
return 0 + cur.number
|
||||
}, 0)
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm', 'updateSku'])
|
||||
const instance = getCurrentInstance();
|
||||
|
||||
function confirm() {
|
||||
// 将数据保存进对应的值
|
||||
let arr = []
|
||||
let arrlength = 0
|
||||
datas.skus.map(ele => {
|
||||
let group = {
|
||||
...ele,
|
||||
goods: [],
|
||||
}
|
||||
if(ele.goods&&ele.goods.length>0){
|
||||
ele.goods.map(item=>{
|
||||
if(item.select){
|
||||
group.goods.push(item)
|
||||
arrlength++
|
||||
}
|
||||
})
|
||||
}
|
||||
arr.push(group)
|
||||
datas.selectNumber += ele.number
|
||||
})
|
||||
})
|
||||
|
||||
const emits = defineEmits(['confirm', 'updateSku'])
|
||||
|
||||
if (arrlength == datas.selectNumber) {
|
||||
emits('confirm', arr, datas.item)
|
||||
close()
|
||||
} else {
|
||||
instance.ctx.$refs.popup.open()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 套餐选择处理
|
||||
* @param {Object} skd
|
||||
* @param {Object} item
|
||||
*/
|
||||
function chooseSkd(skd, item) {
|
||||
if (item.selectData.includes(skd.proId)) {
|
||||
skd.select = false
|
||||
@@ -107,10 +124,6 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const model = ref(null)
|
||||
|
||||
function open() {
|
||||
model.value.open()
|
||||
}
|
||||
@@ -119,21 +132,7 @@
|
||||
datas.selectNumber = 0
|
||||
model.value.close()
|
||||
}
|
||||
const instance = getCurrentInstance();
|
||||
|
||||
function confirm() {
|
||||
// 将数据保存进对应的值
|
||||
let arr = []
|
||||
datas.item.proGroupVo.forEach(ele => {
|
||||
arr.push(...ele.selectData)
|
||||
})
|
||||
if (arr.length == datas.selectNumber) {
|
||||
emits('confirm', arr, datas.item)
|
||||
close()
|
||||
} else {
|
||||
instance.ctx.$refs.popup.open()
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
close
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="">
|
||||
<up-overlay :show="overlayshow" @click="overlayshow = false">
|
||||
<view class="boxoverlay">
|
||||
<view class="boxoverlay" v-if="form&&form.goods">
|
||||
<view class="rect" @tap.stop>
|
||||
<view class="title">
|
||||
<view>
|
||||
@@ -43,19 +43,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
onLoad,
|
||||
onShow,
|
||||
onReachBottom
|
||||
} from '@dcloudio/uni-app';
|
||||
import {
|
||||
computed,
|
||||
reactive,
|
||||
ref,
|
||||
watch,
|
||||
defineExpose,
|
||||
defineEmits
|
||||
} from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { reactive, ref, watch, defineExpose, defineEmits } from 'vue';
|
||||
|
||||
const emit = defineEmits(['refresh'])
|
||||
const currentInput = ref('');
|
||||
|
||||
@@ -82,6 +72,7 @@
|
||||
currentInput.value = currentInput.value.slice(0, -1);
|
||||
}
|
||||
};
|
||||
|
||||
const deleteLast = () => {
|
||||
currentInput.value = currentInput.value.slice(0, -1);
|
||||
};
|
||||
@@ -102,6 +93,7 @@
|
||||
const overlayshow = ref(false);
|
||||
const form = reactive({})
|
||||
const open = (foodsindex, index, goods) => {
|
||||
console.log("222",goods)
|
||||
currentInput.value = ''
|
||||
Object.assign(form, {
|
||||
foodsindex,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user