收藏商品及取消收藏

This commit is contained in:
clay
2023-01-19 16:37:14 +08:00
parent 7d0b6274f1
commit 133a0e77f4
3 changed files with 46 additions and 18 deletions

View File

@@ -5,10 +5,10 @@
</u-image>
<view class="collect" @click="starTap">
<view class="star">
<u-image v-if="detailList.type==0" src="/static/detail/xp_icon_wstar.png" width="28rpx"
<u-image v-if="detailList.is_fav==0" src="/static/detail/xp_icon_wstar.png" width="28rpx"
height="28rpx">
</u-image>
<u-image v-if="detailList.type==1" src="/static/detail/xp_icon_star.png" width="28rpx"
<u-image v-if="detailList.is_fav==1" src="/static/detail/xp_icon_star.png" width="28rpx"
height="28rpx">
</u-image>
</view>
@@ -100,6 +100,7 @@
methods: {
//获取详情信息
getProductDetail() {
console.log(this.id);
this.$apiServe.getProductDetail(this.id).then(res => {
console.log('产品详情页', res.data)
if (res.data.data.thumb) {
@@ -119,16 +120,15 @@
},
//收藏按钮
starTap() {
this.detailList.type = !this.detailList.type
// this.$apiServe.collect(this.id).then(res => {
// console.log('收藏成功', res.data)
// if (res.data.code == 1) {
// this.detailList.type = 1
// this.$toast.warn('收藏成功')
// } else {
// this.$toast.warn('收藏失败')
// }
// }).finally(_ => {})
this.$apiServe.collect(this.id).then(res => {
console.log('收藏成功', res.data)
if (res.data.code == 1) {
this.detailList.is_fav = 1
this.$toast.warn('收藏成功')
} else {
this.$toast.warn('收藏失败')
}
}).finally(_ => {})
},
//点赞按钮
heartTap() {