【秒杀商品详情】

1. 接入收藏
pull/1/MERGE
YunaiV 2023-06-11 22:21:35 +08:00
parent 02aa4756fd
commit ddf9aa6d8a
1 changed files with 40 additions and 19 deletions

View File

@ -430,14 +430,14 @@
//
this.getGoodsDetails();
// TODO
// this.isFavoriteExists();
//
this.isFavoriteExists();
//
this.getProductReplyList();
this.getProductReplyCount();
app.globalData.openPages = '/pages/activity/goods_seckill_details/index?id=' + this.id
+ '&spread=' + this.uid;
app.globalData.openPages = '/pages/activity/goods_seckill_details/index?id='
+ this.id + '&spread=' + this.uid;
}).catch(err => {
that.$util.Tips({
title:err
@ -684,6 +684,41 @@
});
},
// ========== ==========
/**
* 获得是否收藏
*/
isFavoriteExists: function() {
if (!this.isLogin) {
return;
}
ProductFavoriteApi.isFavoriteExists(this.activity.spuId).then(res => {
this.userCollect = res.data;
});
},
/**
* 收藏 / 取消商品
*/
setCollect: function() {
if (!this.isLogin) {
toLogin();
return;
}
//
if (this.userCollect) {
ProductFavoriteApi.deleteFavorite(this.activity.spuId).then(res => {
this.$set(this, 'userCollect', false);
})
//
} else {
ProductFavoriteApi.createFavorite(this.activity.spuId).then(res => {
this.$set(this, 'userCollect', true);
})
}
},
// TODO
@ -766,21 +801,7 @@
});
}
},
/**
* 收藏商品
*/
setCollect: function() {
var that = this;
if (this.userCollect) {
collectDel(this.storeInfo.productId).then(res => {
that.userCollect = !that.userCollect
})
} else {
collectAdd(this.storeInfo.productId).then(res => {
that.userCollect = !that.userCollect
})
}
},
/**
* 分享打开
*