|
@@ -824,8 +824,16 @@ export default {
|
|
|
},
|
|
|
});
|
|
|
} else {
|
|
|
- this.attrValue = this.skuArr[0].spceName
|
|
|
+ this.attrValue = item.spceName
|
|
|
+ this.storeInfo.obtainIntegral = item.obtainIntegral - 0
|
|
|
+ this.storeInfo.salePrice = item.salePrice - 0
|
|
|
+ this.attr.productSelect.totalStock = item.stock - 0
|
|
|
this.attr.attrValueId = item.id
|
|
|
+ if(!item.canSale){
|
|
|
+ this.availableCheck = false
|
|
|
+ }else{
|
|
|
+ this.availableCheck = true
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
@@ -857,6 +865,7 @@ export default {
|
|
|
*
|
|
|
*/
|
|
|
getGoodsDetails: function () {
|
|
|
+ uni.showLoading({ title: '商品信息加载中' });
|
|
|
let that = this;
|
|
|
getGoodsDetail({ id: that.id })
|
|
|
.then((res) => {
|
|
@@ -865,7 +874,7 @@ export default {
|
|
|
that.skuArr = storeInfo.goodsSpecList
|
|
|
that.$set(that, "storeInfo", storeInfo);
|
|
|
that.$set(that.attr, "productAttr", storeInfo.goodsSpecList);
|
|
|
- that.DefaultSelect();
|
|
|
+ that.getUserAddressByUserId()
|
|
|
setTimeout(function () {
|
|
|
that.infoScroll();
|
|
|
}, 500);
|
|
@@ -939,13 +948,7 @@ export default {
|
|
|
success: function () { },
|
|
|
});
|
|
|
},
|
|
|
- /**
|
|
|
- * 默认选中属性
|
|
|
- *
|
|
|
- */
|
|
|
- DefaultSelect: function () {
|
|
|
- this.attrValue = this.skuArr[0].spceName
|
|
|
- this.attr.attrValueId = this.skuArr[0].id
|
|
|
+ getUserAddressByUserId(){
|
|
|
getUserAddressByUserId({
|
|
|
userId: this.$store.state.app.uid,
|
|
|
type: 1
|
|
@@ -954,13 +957,44 @@ export default {
|
|
|
this.getAvailableCheck()
|
|
|
})
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 默认选中属性
|
|
|
+ *
|
|
|
+ */
|
|
|
+ DefaultSelect: function () {
|
|
|
+ //找到第一个可销售的规格
|
|
|
+ if(this.skuArr.length >= 0){
|
|
|
+ this.skuArr.every(value => {
|
|
|
+ if(value.canSale){
|
|
|
+ this.attrValue = value.spceName
|
|
|
+ this.storeInfo.obtainIntegral = value.obtainIntegral - 0
|
|
|
+ this.storeInfo.salePrice = value.salePrice - 0
|
|
|
+ this.attr.productSelect.totalStock = value.stock - 0
|
|
|
+ this.attr.attrValueId = value.id
|
|
|
+ this.availableCheck = true
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ uni.hideLoading();
|
|
|
+ },
|
|
|
// 可销售检测
|
|
|
getAvailableCheck(){
|
|
|
getAvailableCheck({
|
|
|
goodsInfoId: this.id,
|
|
|
userAddressId: this.attrAddrValue.id
|
|
|
}).then(res => {
|
|
|
- this.availableCheck = res.success
|
|
|
+ //处理缺货的规格
|
|
|
+ let ban = res.data.ban
|
|
|
+ if (ban !== undefined){
|
|
|
+ this.storeInfo.goodsSpecList.forEach((value,key) =>{
|
|
|
+ if(ban.includes(value.id-0) || ban.includes(value.optionId-0)){
|
|
|
+ this.storeInfo.goodsSpecList[key].canSale = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // this.availableCheck = res.success
|
|
|
+ this.DefaultSelect();
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
@@ -1147,7 +1181,7 @@ export default {
|
|
|
uni.navigateTo({
|
|
|
url: "/pages/goods/order_confirm/index?num=" + that.attr.productSelect.totalSales + "&productId=" +
|
|
|
that.attr.productSelect.id + "&addressId=" + that.attrAddrValue.id +
|
|
|
- "&goodsSpecId=" + that.attr.attrValueId,
|
|
|
+ "&goodsSpecId=" + that.attr.attrValueId+"&obtainIntegral="+that.storeInfo.obtainIntegral,
|
|
|
});
|
|
|
} else {
|
|
|
that.$util.Tips({
|