优化限购、库存的返回结果
parent
a89d014836
commit
cf23ffbbfe
|
@ -13,7 +13,7 @@
|
|||
<view class="money font-color">
|
||||
¥<text class="num">{{ fen2yuan(attr.productSelect.price) }}</text>
|
||||
<text class="stock" v-if='isShow'>库存: {{ attr.productSelect.stock }}</text>
|
||||
<text class='stock' v-if="limitNum">限量: {{ attr.productSelect.quota }}</text>
|
||||
<text class='stock' v-if="attr.productSelect.limitCount > 0">限购: {{ attr.productSelect.limitCount }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="iconfont icon-guanbi" @click="close"></view>
|
||||
|
@ -48,8 +48,7 @@
|
|||
+
|
||||
</view>
|
||||
<view v-else class='item plus'
|
||||
:class='(attr.productSelect.cart_num >= attr.productSelect.quota)
|
||||
|| (attr.productSelect.cart_num >= attr.productSelect.stock)
|
||||
:class='(attr.productSelect.cart_num >= attr.productSelect.stock)
|
||||
|| (attr.productSelect.cart_num >= attr.productSelect.limitCount)
|
||||
? "on":""'
|
||||
@click='CartNumAdd'>+</view>
|
||||
|
@ -57,10 +56,10 @@
|
|||
</view>
|
||||
</view>
|
||||
<!-- TODO 芋艿:拼团 -->
|
||||
<view class="joinBnt bg-color" v-if="iSbnt && attr.productSelect.stock > 0 && attr.productSelect.quota > 0"
|
||||
<view class="joinBnt bg-color" v-if="iSbnt && attr.productSelect.stock > 0"
|
||||
@click="goCat">我要参团</view>
|
||||
<view class="joinBnt on"
|
||||
v-else-if="(iSbnt && attr.productSelect.quota<=0)||(iSbnt &&attr.productSelect.stock<=0)">已售罄</view>
|
||||
v-else-if="iSbnt && attr.productSelect.stock <= 0">已售罄</view>
|
||||
<!-- TODO 芋艿:购物车 -->
|
||||
<view class="joinBnt bg-color" v-if="iScart && attr.productSelect.stock"
|
||||
@click="goCat">确定</view>
|
||||
|
@ -79,10 +78,6 @@
|
|||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
limitNum: { // 是否展示限售
|
||||
type: Number,
|
||||
value: 0
|
||||
},
|
||||
isShow: { // 是否展示库存
|
||||
type: Number,
|
||||
value: 0
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
</view>
|
||||
</view>
|
||||
<!-- 待拼列表 -->
|
||||
<view v-if='attr.productSelect.quota > 0' class='assemble mb30 borRadius14'>
|
||||
<view v-if='attr.productSelect.stock > 0' class='assemble mb30 borRadius14'>
|
||||
<view class='item acea-row row-between-wrapper' v-for='(item,index) in runningRecords'
|
||||
:key='index' v-if="index < AllIndex">
|
||||
<view class='pictxt acea-row row-between-wrapper'>
|
||||
|
@ -176,11 +176,11 @@
|
|||
<view class="joinCart bnts" @tap="openAlone">单独购买</view>
|
||||
<view class="buy bnts bg-color-hui">未开始</view>
|
||||
</view>
|
||||
<view class="bnt acea-row" v-else-if="status === 2 && attr.productSelect.quota > 0">
|
||||
<view class="bnt acea-row" v-else-if="status === 2 && attr.productSelect.stock > 0">
|
||||
<view class="joinCart bnts" @tap="openAlone">单独购买</view>
|
||||
<view class="buy bnts" @tap="goBuy">立即购买</view>
|
||||
</view>
|
||||
<view class="bnt acea-row" v-else-if="status === 2 && (attr.productSelect.quota <= 0)">
|
||||
<view class="bnt acea-row" v-else-if="status === 2 && (attr.productSelect.stock <= 0)">
|
||||
<view class="joinCart bnts" @tap="openAlone">单独购买</view>
|
||||
<view class="buy bnts bg-color-hui">已售罄</view>
|
||||
</view>
|
||||
|
@ -197,7 +197,6 @@
|
|||
<!-- SKU 弹窗 -->
|
||||
<product-window
|
||||
:attr='attr'
|
||||
:limitNum='1'
|
||||
@ChangeAttr="ChangeAttr"
|
||||
@ChangeCartNum="ChangeCartNum"
|
||||
@iptCartNum="iptCartNum"
|
||||
|
@ -380,7 +379,6 @@
|
|||
deep: true
|
||||
},
|
||||
},
|
||||
//#endif
|
||||
onLoad(options) {
|
||||
this.$store.commit("PRODUCT_TYPE", 'normal');
|
||||
// 设置商品列表高度
|
||||
|
@ -529,11 +527,16 @@
|
|||
const product = this.activity.products.find(product => product.skuId === sku.id);
|
||||
if (product) {
|
||||
sku.price = product.combinationPrice;
|
||||
sku.quota = product.quota;
|
||||
sku.limitCount = product.limitCount;
|
||||
} else { // 找不到可能是没配置,则不能发起拼团
|
||||
sku.quota = 0;
|
||||
sku.limitCount = 0;
|
||||
sku.stock = 0;
|
||||
}
|
||||
// 设置限购数量
|
||||
if (this.activity.totalLimitCount > 0 && this.activity.singleLimitCount > 0) {
|
||||
sku.limitCount = Math.min(this.activity.totalLimitCount, this.activity.singleLimitCount);
|
||||
} else if (this.activity.totalLimitCount > 0) {
|
||||
sku.limitCount = this.activity.totalLimitCount;
|
||||
} else if (this.activity.singleLimitCount > 0) {
|
||||
sku.limitCount = this.activity.singleLimitCount;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -598,9 +601,7 @@
|
|||
this.$set(this.attr.productSelect, "price", sku.price);
|
||||
this.$set(this.attr.productSelect, "stock", sku.stock);
|
||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
||||
// 拼团活动特有字段
|
||||
this.$set(this.attr.productSelect, "quota", sku.quota);
|
||||
this.$set(this.attr.productSelect, "limitCount", sku.limitCount);
|
||||
this.$set(this.attr.productSelect, "limitCount", sku.limitCount); // 拼团活动特有字段
|
||||
this.$set(this, "attrValue", skuKey.join(","));
|
||||
},
|
||||
/**
|
||||
|
@ -632,7 +633,6 @@
|
|||
this.$set(this.attr.productSelect, "picUrl", sku.picUrl);
|
||||
this.$set(this.attr.productSelect, "price", sku.price);
|
||||
this.$set(this.attr.productSelect, "stock", sku.stock);
|
||||
this.$set(this.attr.productSelect, "quota", sku.quota);
|
||||
this.$set(this.attr.productSelect, "limitCount", sku.limitCount);
|
||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
||||
// SKU 关联属性
|
||||
|
@ -654,17 +654,16 @@
|
|||
|
||||
// 设置数量
|
||||
let stock = sku.stock || 0;
|
||||
let quota = sku.quota || 0;
|
||||
let limitCount = sku.limitCount;
|
||||
if (changeValue) {
|
||||
sku.cart_num++;
|
||||
if (limitCount !== undefined && sku.cart_num > limitCount) {
|
||||
if (limitCount > 0 && sku.cart_num > limitCount) {
|
||||
this.$set(this.attr.productSelect, "cart_num", limitCount);
|
||||
this.$util.Tips({
|
||||
title: `该商品每次限购 ${sku.limitCount} ${this.spu.unitName}`
|
||||
});
|
||||
} else if (sku.cart_num > stock || sku.cart_num > quota) {
|
||||
this.$set(this.attr.productSelect, "cart_num", Math.min(stock, quota));
|
||||
} else if (sku.cart_num > stock) {
|
||||
this.$set(this.attr.productSelect, "cart_num", stock);
|
||||
}
|
||||
} else {
|
||||
sku.cart_num--;
|
||||
|
@ -682,7 +681,7 @@
|
|||
// 判断是否超限购
|
||||
let sku = this.attr.productSelect;
|
||||
let limitCount = sku.limitCount;
|
||||
if (limitCount !== undefined && number > limitCount) {
|
||||
if (limitCount > 0 && number > limitCount) {
|
||||
this.$set(this.attr.productSelect, "cart_num", limitCount);
|
||||
this.$util.Tips({
|
||||
title: `该商品每次限购 ${sku.limitCount} ${this.spu.unitName}`
|
||||
|
@ -1076,7 +1075,7 @@
|
|||
const query = wx.createSelectorQuery().in(this);
|
||||
const idView = "#past" + i;
|
||||
query.select(idView).boundingClientRect();
|
||||
query.exec(function(res) {
|
||||
query.exec(res => {
|
||||
const top = res[0].top;
|
||||
const height = res[0].height;
|
||||
topArr.push(top);
|
||||
|
|
|
@ -111,7 +111,6 @@
|
|||
<!-- SKU 选择 -->
|
||||
<product-window
|
||||
:attr="attr"
|
||||
:limitNum="1"
|
||||
:iSbnt="1"
|
||||
@ChangeAttr="ChangeAttr"
|
||||
@ChangeCartNum="ChangeCartNum"
|
||||
|
@ -346,11 +345,16 @@
|
|||
const product = this.activity.products.find(product => product.skuId === sku.id);
|
||||
if (product) {
|
||||
sku.price = product.combinationPrice;
|
||||
sku.quota = product.quota;
|
||||
sku.limitCount = product.limitCount;
|
||||
} else { // 找不到可能是没配置,则不能发起拼团
|
||||
sku.quota = 0;
|
||||
sku.limitCount = 0;
|
||||
sku.stock = 0;
|
||||
}
|
||||
// 设置限购数量
|
||||
if (this.activity.totalLimitCount > 0 && this.activity.singleLimitCount > 0) {
|
||||
sku.limitCount = Math.min(this.activity.totalLimitCount, this.activity.singleLimitCount);
|
||||
} else if (this.activity.totalLimitCount > 0) {
|
||||
sku.limitCount = this.activity.totalLimitCount;
|
||||
} else if (this.activity.singleLimitCount > 0) {
|
||||
sku.limitCount = this.activity.singleLimitCount;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -402,9 +406,7 @@
|
|||
this.$set(this.attr.productSelect, "price", sku.price);
|
||||
this.$set(this.attr.productSelect, "stock", sku.stock);
|
||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
||||
// 拼团活动特有字段
|
||||
this.$set(this.attr.productSelect, "quota", sku.quota);
|
||||
this.$set(this.attr.productSelect, "limitCount", sku.limitCount);
|
||||
this.$set(this.attr.productSelect, "limitCount", sku.limitCount); // 拼团活动特有字段
|
||||
this.$set(this, "attrValue", skuKey.join(","));
|
||||
},
|
||||
/**
|
||||
|
@ -436,7 +438,6 @@
|
|||
this.$set(this.attr.productSelect, "picUrl", sku.picUrl);
|
||||
this.$set(this.attr.productSelect, "price", sku.price);
|
||||
this.$set(this.attr.productSelect, "stock", sku.stock);
|
||||
this.$set(this.attr.productSelect, "quota", sku.quota);
|
||||
this.$set(this.attr.productSelect, "limitCount", sku.limitCount);
|
||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
||||
// SKU 关联属性
|
||||
|
@ -458,17 +459,16 @@
|
|||
|
||||
// 设置数量
|
||||
let stock = sku.stock || 0;
|
||||
let quota = sku.quota || 0;
|
||||
let limitCount = sku.limitCount;
|
||||
if (changeValue) {
|
||||
sku.cart_num++;
|
||||
if (limitCount !== undefined && sku.cart_num > limitCount) {
|
||||
if (limitCount > 0 && sku.cart_num > limitCount) {
|
||||
this.$set(this.attr.productSelect, "cart_num", limitCount);
|
||||
this.$util.Tips({
|
||||
title: `该商品每次限购 ${sku.limitCount} ${this.spu.unitName}`
|
||||
});
|
||||
} else if (sku.cart_num > stock || sku.cart_num > quota) {
|
||||
this.$set(this.attr.productSelect, "cart_num", Math.min(stock, quota));
|
||||
} else if (sku.cart_num > stock) {
|
||||
this.$set(this.attr.productSelect, "cart_num", stock);
|
||||
}
|
||||
} else {
|
||||
sku.cart_num--;
|
||||
|
@ -487,7 +487,7 @@
|
|||
// 判断是否超限购
|
||||
let sku = this.attr.productSelect;
|
||||
let limitCount = sku.limitCount;
|
||||
if (limitCount !== undefined && number > limitCount) {
|
||||
if (limitCount > 0 && number > limitCount) {
|
||||
this.$set(this.attr.productSelect, "cart_num", limitCount);
|
||||
this.$util.Tips({
|
||||
title: `该商品每次限购 ${sku.limitCount} ${this.spu.unitName}`
|
||||
|
|
|
@ -183,7 +183,6 @@
|
|||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
page {
|
||||
background-color: #F5F5F5 !important;
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
</view>
|
||||
<view class='label acea-row row-middle'>
|
||||
<view class='stock'>累计销售:{{ spu.salesCount}} {{ spu.unitName }}</view>
|
||||
<view>限量: {{ activity.quota ? activity.quota : 0 }} {{ spu.unitName }}</view>
|
||||
<view>限量: {{ activity.stock || 0 }} {{ spu.unitName }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- SKU 选择 -->
|
||||
|
@ -108,11 +108,11 @@
|
|||
<view class="joinCart bnts" @tap="openAlone">单独购买</view>
|
||||
<view class="buy bnts bg-color-hui">未开始</view>
|
||||
</view>
|
||||
<view class="bnt acea-row" v-else-if="status === 2 && attr.productSelect.quota > 0">
|
||||
<view class="bnt acea-row" v-else-if="status === 2 && attr.productSelect.stock > 0">
|
||||
<view class="joinCart bnts" @tap="openAlone">单独购买</view>
|
||||
<view class="buy bnts" @tap="goBuy">立即购买</view>
|
||||
</view>
|
||||
<view class="bnt acea-row" v-else-if="status === 2 && (attr.productSelect.quota <= 0)">
|
||||
<view class="bnt acea-row" v-else-if="status === 2 && (attr.productSelect.stock <= 0)">
|
||||
<view class="joinCart bnts" @tap="openAlone">单独购买</view>
|
||||
<view class="buy bnts bg-color-hui">已售罄</view>
|
||||
</view>
|
||||
|
@ -129,7 +129,6 @@
|
|||
<!-- SKU 弹窗 -->
|
||||
<product-window
|
||||
:attr='attr'
|
||||
:limitNum='1'
|
||||
@ChangeAttr="ChangeAttr"
|
||||
@ChangeCartNum="ChangeCartNum"
|
||||
@iptCartNum="iptCartNum"
|
||||
|
@ -375,10 +374,6 @@
|
|||
getSeckillDetail: function() {
|
||||
SeckillActivityApi.getSeckillActivity(this.id).then(res => {
|
||||
this.activity = res.data;
|
||||
// 计算总的 quota 数量
|
||||
this.activity.quota = this.activity.products.reduce((accumulator, product) => {
|
||||
return accumulator + product.quota;
|
||||
}, 0);
|
||||
// 计算活动状态
|
||||
const now = new Date().getTime();
|
||||
if (this.activity.status !== 0) {
|
||||
|
@ -431,11 +426,17 @@
|
|||
const product = this.activity.products.find(product => product.skuId === sku.id);
|
||||
if (product) {
|
||||
sku.price = product.seckillPrice;
|
||||
sku.quota = product.quota;
|
||||
sku.limitCount = product.limitCount;
|
||||
sku.stock = Math.min(sku.stock, product.stock);
|
||||
} else { // 找不到可能是没配置,则不能发起秒杀
|
||||
sku.quota = 0;
|
||||
sku.limitCount = 0;
|
||||
sku.stock = 0;
|
||||
}
|
||||
// 设置限购数量
|
||||
if (this.activity.totalLimitCount > 0 && this.activity.singleLimitCount > 0) {
|
||||
sku.limitCount = Math.min(this.activity.totalLimitCount, this.activity.singleLimitCount);
|
||||
} else if (this.activity.totalLimitCount > 0) {
|
||||
sku.limitCount = this.activity.totalLimitCount;
|
||||
} else if (this.activity.singleLimitCount > 0) {
|
||||
sku.limitCount = this.activity.singleLimitCount;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -500,9 +501,7 @@
|
|||
this.$set(this.attr.productSelect, "price", sku.price);
|
||||
this.$set(this.attr.productSelect, "stock", sku.stock);
|
||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
||||
// 秒杀活动特有字段
|
||||
this.$set(this.attr.productSelect, "quota", sku.quota);
|
||||
this.$set(this.attr.productSelect, "limitCount", sku.limitCount);
|
||||
this.$set(this.attr.productSelect, "limitCount", sku.limitCount); // 秒杀活动特有字段
|
||||
this.$set(this, "attrValue", skuKey.join(","));
|
||||
},
|
||||
/**
|
||||
|
@ -534,7 +533,6 @@
|
|||
this.$set(this.attr.productSelect, "picUrl", sku.picUrl);
|
||||
this.$set(this.attr.productSelect, "price", sku.price);
|
||||
this.$set(this.attr.productSelect, "stock", sku.stock);
|
||||
this.$set(this.attr.productSelect, "quota", sku.quota);
|
||||
this.$set(this.attr.productSelect, "limitCount", sku.limitCount);
|
||||
this.$set(this.attr.productSelect, "cart_num", 1);
|
||||
// SKU 关联属性
|
||||
|
@ -556,17 +554,16 @@
|
|||
|
||||
// 设置数量
|
||||
let stock = sku.stock || 0;
|
||||
let quota = sku.quota || 0;
|
||||
let limitCount = sku.limitCount;
|
||||
if (changeValue) {
|
||||
sku.cart_num++;
|
||||
if (limitCount !== undefined && sku.cart_num > limitCount) {
|
||||
if (limitCount > 0 && sku.cart_num > limitCount) {
|
||||
this.$set(this.attr.productSelect, "cart_num", limitCount);
|
||||
this.$util.Tips({
|
||||
title: `该商品每次限购 ${sku.limitCount} ${this.spu.unitName}`
|
||||
});
|
||||
} else if (sku.cart_num > stock || sku.cart_num > quota) {
|
||||
this.$set(this.attr.productSelect, "cart_num", Math.min(stock, quota));
|
||||
} else if (sku.cart_num > stock) {
|
||||
this.$set(this.attr.productSelect, "cart_num", stock);
|
||||
}
|
||||
} else {
|
||||
sku.cart_num--;
|
||||
|
@ -967,7 +964,7 @@
|
|||
const query = wx.createSelectorQuery().in(this);
|
||||
const idView = "#past" + i;
|
||||
query.select(idView).boundingClientRect();
|
||||
query.exec(function(res) {
|
||||
query.exec(res => {
|
||||
const top = res[0].top;
|
||||
const height = res[0].height;
|
||||
topArr.push(top);
|
||||
|
|
Loading…
Reference in New Issue