修复代客下单起售数量问题

This commit is contained in:
YeMingfei666 2024-10-12 15:18:27 +08:00
parent 1bf3334127
commit 68c23e6e48
2 changed files with 20 additions and 6 deletions

View File

@ -52,8 +52,10 @@
import { import {
computed, computed,
reactive, reactive,
ref ref,
watch
} from 'vue'; } from 'vue';
import infobox from '@/commons/utils/infoBox.js'
import myModel from '@/components/my-components/my-model.vue' import myModel from '@/components/my-components/my-model.vue'
import myButton from '@/components/my-components/my-button.vue' import myButton from '@/components/my-components/my-button.vue'
const props = defineProps({ const props = defineProps({
@ -98,6 +100,10 @@
const goods=computed(()=>{ const goods=computed(()=>{
return props.skuMap[selSku.value] return props.skuMap[selSku.value]
}) })
watch(()=>goods.value,(newval)=>{
console.log(newval);
number.value=newval.suit||1
})
//使 //使
const isAllDisabled=computed(()=>{ const isAllDisabled=computed(()=>{
@ -142,7 +148,11 @@
if(isDisabled()){ if(isDisabled()){
return return
} }
const suit=goods.value.suit||1
const newval = number.value - 1 const newval = number.value - 1
if(newval<suit){
return infobox.showToast(suit+'个起售')
}
number.value = newval <= 1 ? 1 : newval number.value = newval <= 1 ? 1 : newval
} }

View File

@ -298,13 +298,14 @@
return Api.getGoodsLists(par) return Api.getGoodsLists(par)
} }
// //
function getCart(par = { async function getCart(par = {
page: 0, page: 0,
size: 300, size: 300,
masterId: data.masterId, masterId: data.masterId,
tableId: data.table.tableId tableId: data.table.tableId
}) { }) {
return Api.getCart(par) const res= await Api.getCart(par)
return res
} }
// //
function getMasterId() { function getMasterId() {
@ -742,7 +743,9 @@
const cartId = goods.id const cartId = goods.id
const tabbarIndex = data.tabbar.findIndex(v => v.id == categoryId) const tabbarIndex = data.tabbar.findIndex(v => v.id == categoryId)
const $goods = data.tabbar[tabbarIndex].foods.find(v => v.id == productId) const $goods = data.tabbar[tabbarIndex].foods.find(v => v.id == productId)
if (num === 0) { const $sku = $goods.specList.find(v => v.id == skuId)
if (num === 0||num<$sku.suit) {
// //
await removeCartGoods({ await removeCartGoods({
cartId cartId
@ -793,13 +796,14 @@
}); });
const productId = $goods.id const productId = $goods.id
const skuId = $goods.specList[0].id const skuId = $goods.specList[0].id
const suit=$goods.specList[0].suit||1
if (goodsInCarIndex !== -1) { if (goodsInCarIndex !== -1) {
// //
const carGoods = cars[goodsInCarIndex] const carGoods = cars[goodsInCarIndex]
const cartId = carGoods.id const cartId = carGoods.id
const step = isAdd ? 1 : -1 const step = isAdd ? 1 : -1
const num = carGoods.number * 1 + step const num = carGoods.number * 1 + step
if (num === 0) { if (num === 0||num<suit) {
// //
cars.splice(goodsInCarIndex, 1) cars.splice(goodsInCarIndex, 1)
$goods.chooseNumber = 0 $goods.chooseNumber = 0
@ -819,7 +823,7 @@
$goods.chooseNumber = number $goods.chooseNumber = number
} else { } else {
// //
const num = 1 const num = suit
const cartGoods = await addCart({ const cartGoods = await addCart({
num, num,
productId, productId,