collect 8.7

This commit is contained in:
2020-08-07 11:59:08 +08:00
parent 71e984b2ed
commit a088c895d2
10 changed files with 76 additions and 30 deletions

View File

@@ -27,10 +27,10 @@
<text>{{ goodsInfo.goods_price }}</text>
<s>{{ goodsInfo.goods_marketprice }}</s>
</view>
<view class="collect">
<u-icon name="star" color="#474747" size="28" v-if="1"></u-icon>
<view class="collect" @click="switchCollect(goodsInfo.goods_collect)">
<u-icon name="star" color="#474747" size="28" v-if="!goodsInfo.goods_collect"></u-icon>
<u-icon name="star-fill" color="#FF7807" size="28" v-else></u-icon>
<text>收藏</text>
<text>{{ !goodsInfo.goods_collect ? '收藏' : '已收藏' }}</text>
</view>
</view>
</view>
@@ -227,9 +227,12 @@ export default {
onLoad(option) {
// this.init();
// console.log(option);
this.type = Number(option.type);
// this.type = Number(option.type);
// this.type = 1;
this.id = option.id;
this.setTitle();
// 先请求普通商品详情获取商品类型再渲染页面
this.ordinaryDetails(this.id);
},
onShow() {
this.debounce = true;
@@ -296,19 +299,15 @@ export default {
},
getGoodsDetails(id) {
switch (this.type) {
case 1:
this.ordinaryDetails(id);
break;
// case 1:
// this.ordinaryDetails(id);
// break;
case 2:
this.pinTuanDetails(id);
break;
case 3:
this.spikeGoodsDetails(id);
break;
case 4:
break;
default:
break;
}
@@ -322,7 +321,8 @@ export default {
this.storeInfo = res.data.store;
this.setSwiperList(res.data.goods_image);
this.glist = res.data.spec_list;
// console.log(this.goodsInfo.mobile_body);
this.type = res.data.view_type;
this.getGoodsDetails(this.type);
}
})
},
@@ -481,7 +481,32 @@ export default {
urls: arr,
current: arr[index]
})
}
},
switchCollect(status) {
if(status) {
this.removeFavorite();
} else {
this.addFavoriteGoods();
}
},
addFavoriteGoods() {
this.$u.api.addFavoriteGoods({ fid: this.id }).then(res => {
if(res.errCode == 0) {
this.getGoodsDetails(this.id);
} else {
this.$u.toast(res.message);
}
})
},
removeFavorite() {
this.$u.api.removeFavorite({ fid: this.id, type: 'goods' }).then(res => {
if(res.errCode == 0) {
this.getGoodsDetails(this.id);
} else {
this.$u.toast(res.message);
}
})
}
},
}
</script>