diff --git a/config/app.js b/config/app.js index d94b1a2..479ac47 100644 --- a/config/app.js +++ b/config/app.js @@ -9,8 +9,8 @@ let httpApiThree let wsApi // 在打包之前请检查当前环境是否正确 -// const env = 'dev'; // 开发 -const env = 'prod'; // 生产 +const env = 'dev'; // 开发 +// const env = 'prod'; // 生产 // const env = 'prew'; // 预上线 switch (env) { diff --git a/pages/nongKe/supply_chain/shopping_trolley.vue b/pages/nongKe/supply_chain/shopping_trolley.vue index 83a2abc..3580d1c 100644 --- a/pages/nongKe/supply_chain/shopping_trolley.vue +++ b/pages/nongKe/supply_chain/shopping_trolley.vue @@ -37,7 +37,7 @@ - @@ -65,8 +65,10 @@ - - - {{goods.cart_num}} + - + + + + @@ -582,14 +584,21 @@ }, // 立即下单 subOrder: function(event) { - let selectValue = [] + let selectValue = []; + let stockFlag = false; this.cartList.valid.forEach(el => { el.list.forEach(goods => { if (goods.check) { selectValue.push(goods.cart_id) } + if (goods.cart_num > goods.attrValue[0].stock){ + stockFlag = true; + } }) }) + if(stockFlag){ + return Toast('库存不足!'); + } if (selectValue.length > 0) { uni.navigateTo({ url: `/pages/users/order_confirm/index?product_type=98&cartId=${selectValue.join(',')}&type_id=12` @@ -656,6 +665,7 @@ // 购物车递减 subCart(goods) { let status = false; + if ((goods.cart_num <= goods.product.once_min_count)) return Toast(`${goods.product.once_min_count}件起购哦`); if (goods.cart_num < 1) status = true; if (goods.cart_num <= 1) { goods.cart_num = 1; @@ -684,6 +694,65 @@ } } }, + inputNum(goods){ + let cart_num = Number(goods.cart_num); + if(cart_num>+goods.productAttr.stock) { + this.$nextTick(()=>{ + goods.cart_num = goods.productAttr.stock; + this.cartAllCheck('goodsCheck') + }) + } + else this.cartAllCheck('goodsCheck') + // if(cart_num<+goods.product.once_min_count||goods<1) { + // this.$nextTick(()=>{ + // goods.cart_num = goods.product.once_min_count; + // }) + // } + }, + // 输入框失去焦点 + inputCartNum(goods){ + let status = false; + if(!goods.cart_num){ + goods.product.once_min_count ? goods.cart_num = goods.product.once_min_count : goods.cart_num = 1; + return this.updateCartNum(goods); + } + if (goods.cart_num <= goods.product.once_min_count) { + goods.cart_num = goods.product.once_min_count; + this.updateCartNum(goods); + return Toast(`${goods.product.once_min_count}件起购哦`); + } + if (goods.cart_num < 1) status = true; + if (goods.cart_num <= 1) { + goods.cart_num = 1; + goods.numSub = true; + status = true; + } else { + if (false == status) { + this.updateCartNum(goods); + } + } + }, + updateCartNum(goods){ + changeCartNum(goods.cart_id, { + cart_num: goods.cart_num + }).then(res => { + goods.numSub = false; + goods.numAdd = false; + if (goods.cart_num <= 1) { + goods.numSub = true; + } + this.cartAllCheck('goodsCheck') + }).catch(error => { + this.$util.Tips({ + title: error + }); + this.$nextTick(()=>{ + goods.cart_num = goods.productAttr.stock; + goods.numAdd = true; + this.cartAllCheck('goodsCheck') + }) + }) + }, getCartNum: function() { let that = this; getCartCounts({ product_type: 98, source: 11 }).then(res => { @@ -781,7 +850,7 @@ }) }) this.cartCount = totalNum - this.selectCountPrice = totalMoney + this.selectCountPrice = totalMoney > 0 ? totalMoney : '0.00' // 全选 this.isAllSelect = allArr.length == this.cartList.valid.length ? true : false }, diff --git a/pages/nongKe/supply_chain/shopping_trolley_a.vue b/pages/nongKe/supply_chain/shopping_trolley_a.vue index 285b464..f64d975 100644 --- a/pages/nongKe/supply_chain/shopping_trolley_a.vue +++ b/pages/nongKe/supply_chain/shopping_trolley_a.vue @@ -59,8 +59,10 @@ - - - {{goods.cart_num}} + - + + + + @@ -650,7 +652,7 @@ // 购物车递减 subCart(goods) { let status = false; - if (goods.cart_num <= goods.product.once_min_count) return Toast(`${goods.product.once_min_count}件起购哦`); + if ((goods.cart_num <= goods.product.once_min_count)) return Toast(`${goods.product.once_min_count}件起购哦`); if (goods.cart_num < 1) status = true; if (goods.cart_num <= 1) { goods.cart_num = 1; @@ -679,6 +681,65 @@ } } }, + inputNum(goods){ + let cart_num = Number(goods.cart_num); + if(cart_num>+goods.productAttr.stock) { + this.$nextTick(()=>{ + goods.cart_num = goods.productAttr.stock; + this.cartAllCheck('goodsCheck') + }) + } + else this.cartAllCheck('goodsCheck') + // if(cart_num<+goods.product.once_min_count||goods<1) { + // this.$nextTick(()=>{ + // goods.cart_num = goods.product.once_min_count; + // }) + // } + }, + // 输入框失去焦点 + inputCartNum(goods){ + let status = false; + if(!goods.cart_num){ + goods.product.once_min_count ? goods.cart_num = goods.product.once_min_count : goods.cart_num = 1; + return this.updateCartNum(goods); + } + if (goods.cart_num <= goods.product.once_min_count) { + goods.cart_num = goods.product.once_min_count; + this.updateCartNum(goods); + return Toast(`${goods.product.once_min_count}件起购哦`); + } + if (goods.cart_num < 1) status = true; + if (goods.cart_num <= 1) { + goods.cart_num = 1; + goods.numSub = true; + status = true; + } else { + if (false == status) { + this.updateCartNum(goods); + } + } + }, + updateCartNum(goods){ + changeCartNum(goods.cart_id, { + cart_num: goods.cart_num + }).then(res => { + goods.numSub = false; + goods.numAdd = false; + if (goods.cart_num <= 1) { + goods.numSub = true; + } + this.cartAllCheck('goodsCheck') + }).catch(error => { + this.$util.Tips({ + title: error + }); + this.$nextTick(()=>{ + goods.cart_num = goods.productAttr.stock; + goods.numAdd = true; + this.cartAllCheck('goodsCheck') + }) + }) + }, getCartNum: function() { let that = this; getCartCounts({ product_type: 98, source: 11 }).then(res => { @@ -776,7 +837,7 @@ }) }) this.cartCount = totalNum - this.selectCountPrice = totalMoney + this.selectCountPrice = totalMoney > 0 ? totalMoney : '0.00' // 全选 this.isAllSelect = allArr.length == this.cartList.valid.length ? true : false }, diff --git a/pages/nongKe/supply_chain/shopping_trolley_other.vue b/pages/nongKe/supply_chain/shopping_trolley_other.vue index 04723c2..c308162 100644 --- a/pages/nongKe/supply_chain/shopping_trolley_other.vue +++ b/pages/nongKe/supply_chain/shopping_trolley_other.vue @@ -59,8 +59,10 @@ - - - {{goods.cart_num}} + - + + + + @@ -652,7 +654,7 @@ // 购物车递减 subCart(goods) { let status = false; - if (goods.cart_num <= goods.product.once_min_count) return Toast(`${goods.product.once_min_count}件起购哦`); + if ((goods.cart_num <= goods.product.once_min_count)) return Toast(`${goods.product.once_min_count}件起购哦`); if (goods.cart_num < 1) status = true; if (goods.cart_num <= 1) { goods.cart_num = 1; @@ -681,6 +683,65 @@ } } }, + inputNum(goods){ + let cart_num = Number(goods.cart_num); + if(cart_num>+goods.productAttr.stock) { + this.$nextTick(()=>{ + goods.cart_num = goods.productAttr.stock; + this.cartAllCheck('goodsCheck') + }) + } + else this.cartAllCheck('goodsCheck') + // if(cart_num<+goods.product.once_min_count||goods<1) { + // this.$nextTick(()=>{ + // goods.cart_num = goods.product.once_min_count; + // }) + // } + }, + // 输入框失去焦点 + inputCartNum(goods){ + let status = false; + if(!goods.cart_num){ + goods.product.once_min_count ? goods.cart_num = goods.product.once_min_count : goods.cart_num = 1; + return this.updateCartNum(goods); + } + if (goods.cart_num <= goods.product.once_min_count) { + goods.cart_num = goods.product.once_min_count; + this.updateCartNum(goods); + return Toast(`${goods.product.once_min_count}件起购哦`); + } + if (goods.cart_num < 1) status = true; + if (goods.cart_num <= 1) { + goods.cart_num = 1; + goods.numSub = true; + status = true; + } else { + if (false == status) { + this.updateCartNum(goods); + } + } + }, + updateCartNum(goods){ + changeCartNum(goods.cart_id, { + cart_num: goods.cart_num + }).then(res => { + goods.numSub = false; + goods.numAdd = false; + if (goods.cart_num <= 1) { + goods.numSub = true; + } + this.cartAllCheck('goodsCheck') + }).catch(error => { + this.$util.Tips({ + title: error + }); + this.$nextTick(()=>{ + goods.cart_num = goods.productAttr.stock; + goods.numAdd = true; + this.cartAllCheck('goodsCheck') + }) + }) + }, getCartNum: function() { let that = this; getCartCounts({ @@ -784,7 +845,7 @@ }) }) this.cartCount = totalNum - this.selectCountPrice = totalMoney + this.selectCountPrice = totalMoney > 0 ? totalMoney : '0.00' // 全选 this.isAllSelect = allArr.length == this.cartList.valid.length ? true : false }, diff --git a/pages/product/addGood/addGood.vue b/pages/product/addGood/addGood.vue index 3aee3ee..8d51d1e 100644 --- a/pages/product/addGood/addGood.vue +++ b/pages/product/addGood/addGood.vue @@ -150,6 +150,13 @@ placeholder="填写关键字" /> + + + 最少购买件数 + + + 送货方式 @@ -242,7 +249,8 @@ delivery_way: [1, 2], // 配送方式 1 到店核销 2 快递配送 delivery_free: '1', // 是否包邮 0不包邮 1包邮 temp_id: '', // 运费模板ID - tempName: '' // 运费模板名称 + tempName: '' ,// 运费模板名称 + once_min_count: '', //最少购买件数 }, platformClassificationData: [], // 平台分类数据 merchantClassification: [], // 店铺分类 @@ -382,7 +390,8 @@ delivery_way: [], // 配送方式 1 到店核销 2 快递配送 delivery_free: '0', // 是否包邮 0不包邮 1包邮 temp_id: '', // 运费模板ID - tempName: '' // 运费模板名称 + tempName: '' ,// 运费模板名称 + once_min_count: '', //最小购买数量 }; productDetail(this.merId, this.product_id).then(async (res) => { this.showCommodity = true; @@ -403,6 +412,7 @@ this.setFormData.brand_name = editGoodsDetils.brand ? editGoodsDetils.brand.brand_name : ''; if (res.data.content && typeof res.data.content == 'string') res.data.content = JSON.parse(res.data .content); + this.setFormData.once_min_count <= 0 ? this.setFormData.once_min_count = '' : null; //向组件注入数据 this.$nextTick(() => { this.$refs.commodityRef.setDatas({