收藏商品及取消收藏
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user