|
@@ -42,7 +42,7 @@
|
|
|
<button class="show_car" data-eventsync="true" @click="showSpecPopup(2)" >加入购物车</button>
|
|
|
</view>
|
|
|
<view class="to_bottom"> --- 到底了 --- </view>
|
|
|
- <uni-popup ref="specPopup" :show="true" type="bottom" class="popup" background-color="#FFFFFF" @change="popupChange" >
|
|
|
+ <uni-popup ref="specPopup" :show="true" type="bottom" class="popup" background-color="#FFFFFF" @change="popupChange" @maskClick="onSpecPopupClose">
|
|
|
<view class="order_info">
|
|
|
<view class="custom_addr" v-if="specBtnType==1" @click="showAddrPopup()">
|
|
|
<view class="contact_user">
|
|
@@ -321,9 +321,6 @@
|
|
|
if(this.productInfo.product_sku.length === 1){
|
|
|
this.defaultSkuStatus();
|
|
|
}
|
|
|
- //重置上一次规格全部选中
|
|
|
- this.hasValidSpecSelected = false;
|
|
|
-
|
|
|
//如果当前商品没有规格,可以直接加入购物车
|
|
|
if(this.productInfo.product_attr.length === 0){
|
|
|
this.hasValidSpecSelected = true;
|
|
@@ -394,7 +391,7 @@
|
|
|
})
|
|
|
return;
|
|
|
}
|
|
|
- //规格选中
|
|
|
+ //规格没有选中全
|
|
|
if(!this.hasValidSpecSelected){
|
|
|
uni.showToast({
|
|
|
title:"请选择所有规格",
|
|
@@ -457,7 +454,7 @@
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ //规格没有选中全
|
|
|
if(!this.hasValidSpecSelected){
|
|
|
uni.showToast({
|
|
|
title:"请选择所有规格",
|
|
@@ -807,46 +804,46 @@
|
|
|
// 是否有对应的SKU
|
|
|
let haveSku = false;
|
|
|
// 先检查colorAttridsStr和sizeAttridsStr是否都已正确生成
|
|
|
- if (colorAttridsStr && colorAttridsStr.length > 0 && sizeAttridsStr && sizeAttridsStr.length > 0) {
|
|
|
- // 循环sku
|
|
|
- for (let i in this.productInfo.product_sku) {
|
|
|
- // 如果sku不匹配
|
|
|
- if( this.productInfo.product_sku[i].attr_ids != colorAttridsStr + "," + sizeAttridsStr ) continue;
|
|
|
- // 设置有SKU
|
|
|
- haveSku = 1;
|
|
|
- // 获取当前匹配到的SKU的状态
|
|
|
- currentSKUStatus = this.productInfo.product_sku[i].status;
|
|
|
- // 如果商品已经下架(status等于1),则恢复当前规格下所有属性原来的active状态
|
|
|
- if(currentSKUStatus === 1){
|
|
|
- uni.showToast({title:"该规格已下架",icon:"none"});
|
|
|
- for (let k in originalActiveStates) {
|
|
|
- this.productInfo.product_attr[spec_index].attr_list[k].active = originalActiveStates[k];
|
|
|
+ if (colorAttridsStr && colorAttridsStr.length > 0 && sizeAttridsStr && sizeAttridsStr.length > 0) {
|
|
|
+ // 循环sku
|
|
|
+ for (let i in this.productInfo.product_sku) {
|
|
|
+ // 如果sku不匹配
|
|
|
+ if( this.productInfo.product_sku[i].attr_ids != colorAttridsStr + "," + sizeAttridsStr ) continue;
|
|
|
+ // 设置有SKU
|
|
|
+ haveSku = 1;
|
|
|
+ // 获取当前匹配到的SKU的状态
|
|
|
+ currentSKUStatus = this.productInfo.product_sku[i].status;
|
|
|
+ // 如果商品已经下架(status等于1),则恢复当前规格下所有属性原来的active状态
|
|
|
+ if(currentSKUStatus === 1){
|
|
|
+ uni.showToast({title:"该规格已下架",icon:"none"});
|
|
|
+ for (let k in originalActiveStates) {
|
|
|
+ this.productInfo.product_attr[spec_index].attr_list[k].active = originalActiveStates[k];
|
|
|
+ }
|
|
|
+ continue;
|
|
|
}
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 如果商品没有库存
|
|
|
- if( this.productInfo.product_sku[i].stock <= 0 ){
|
|
|
- uni.showToast({title:"该规格库存不足",icon:"none"});
|
|
|
- for (let k in originalActiveStates) {
|
|
|
- this.productInfo.product_attr[spec_index].attr_list[k].active = originalActiveStates[k];
|
|
|
+ // 如果商品没有库存
|
|
|
+ if( this.productInfo.product_sku[i].stock <= 0 ){
|
|
|
+ uni.showToast({title:"该规格库存不足",icon:"none"});
|
|
|
+ for (let k in originalActiveStates) {
|
|
|
+ this.productInfo.product_attr[spec_index].attr_list[k].active = originalActiveStates[k];
|
|
|
+ }
|
|
|
+ continue;
|
|
|
}
|
|
|
- continue;
|
|
|
+ // console.log("我怎么没有执行?");
|
|
|
+ // 产品价格修改
|
|
|
+ this.productInfo.price = this.productInfo.product_sku[i].price;
|
|
|
+ // 产品规格修改
|
|
|
+ this.productInfo.spec = this.productInfo.product_sku[i].attr_names;
|
|
|
+ // 产品库存
|
|
|
+ this.productInfo.stock = this.productInfo.product_sku[i].stock;
|
|
|
+ // 产品SKU
|
|
|
+ this.sku_id = this.productInfo.product_sku[i].id;
|
|
|
+ // 计算价格
|
|
|
+ this.priceHandler();
|
|
|
+ // 优惠券是否可用
|
|
|
+ this.checkCoupon();
|
|
|
}
|
|
|
- // console.log("我怎么没有执行?");
|
|
|
- // 产品价格修改
|
|
|
- this.productInfo.price = this.productInfo.product_sku[i].price;
|
|
|
- // 产品规格修改
|
|
|
- this.productInfo.spec = this.productInfo.product_sku[i].attr_names;
|
|
|
- // 产品库存
|
|
|
- this.productInfo.stock = this.productInfo.product_sku[i].stock;
|
|
|
- // 产品SKU
|
|
|
- this.sku_id = this.productInfo.product_sku[i].id;
|
|
|
- // 计算价格
|
|
|
- this.priceHandler();
|
|
|
- // 优惠券是否可用
|
|
|
- this.checkCoupon();
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
// 如果没有对应的SKU
|
|
|
if( !haveSku && isSelectionComplete ){
|
|
|
uni.showToast({title:"该规格已下架",icon:"none"});
|
|
@@ -856,6 +853,22 @@
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ //specPopup关闭时重置数据
|
|
|
+ onSpecPopupClose(){
|
|
|
+ let colorSpecAttrList = this.productInfo.product_attr.find((spec) => spec.spec_id === 1).attr_list;
|
|
|
+ let sizeSpecAttrList = this.productInfo.product_attr.find((spec) => spec.spec_id === 2).attr_list;
|
|
|
+ //重置上一次规格全部选中
|
|
|
+ this.hasValidSpecSelected = false;
|
|
|
+ // 恢复颜色分类规格下属性的原始active状态
|
|
|
+ for (let i in colorSpecAttrList) {
|
|
|
+ colorSpecAttrList[i].active = 0;
|
|
|
+ }
|
|
|
+ // 恢复尺寸规格下属性的原始active状态
|
|
|
+ for (let i in sizeSpecAttrList) {
|
|
|
+ sizeSpecAttrList[i].active = 0;
|
|
|
+ }
|
|
|
+ this.$refs.specPopup.close()
|
|
|
+ },
|
|
|
//只有一组sku默认规格是否已下架
|
|
|
defaultSkuStatus(){
|
|
|
if(this.productInfo.product_sku.length){
|