收藏商品及取消收藏

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

@@ -31,7 +31,7 @@
</view>
<u-button v-if="type==1" type="success" text="移除" color="#0EBB5B" @click="deleteProduct(item)">
</u-button>
<u-button v-if="type==2" type="success" text="取消收藏" color="#0EBB5B" @click="deleteProduct(item)">
<u-button v-if="type==2" type="success" text="取消收藏" color="#0EBB5B" @click="cancelCollect(item)">
</u-button>
</u-grid-item>
</u-grid>
@@ -77,6 +77,7 @@
methods: {
//获取历史记录
getHistoryOrCollection() {
console.log(uni.getStorageSync('token'));
this.$apiServe.getHistoryOrCollection(this.type).then(res => {
let data = res.data.data
for (const item of data) {
@@ -85,7 +86,7 @@
item.tags = this.tagsArray[0]
item.create_time = dateFormatHistory(item.create_time)
}
// console.log('获取历史记录', data);
console.log('获取历史记录', data);
this.productList = data
}).finally(_ => {
@@ -96,21 +97,41 @@
var that = this
uni.showModal({
title: '提示',
content: '你确定要除吗',
content: '你确定要除吗',
success: function(res) {
if (res.confirm) {
that.$apiServe.deleteHistoryOrCollection(item.id).then(res => {
if (res.data.code == 1) {
that.$toast.warn('除成功')
that.$toast.warn('除成功')
}
that.getHistoryOrCollection()
}).finally(_ => {})
} else if (res.cancel) {
that.$toast.warn('取消除')
that.$toast.warn('取消除')
}
}
})
}
},
//取消收藏按钮
cancelCollect(item) {
var that = this
uni.showModal({
title: '提示',
content: '你确定要取消收藏吗',
success: function(res) {
if (res.confirm) {
that.$apiServe.deleteHistoryOrCollection(item.id).then(res => {
if (res.data.code == 1) {
that.$toast.warn('取消收藏成功')
}
that.getHistoryOrCollection()
}).finally(_ => {})
} else if (res.cancel) {
that.$toast.warn('取消操作')
}
}
})
},
}
}
</script>