收藏商品及取消收藏
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>
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -326,6 +326,13 @@ const apiService = {
|
||||
resolve(service.get(url))
|
||||
})
|
||||
},
|
||||
//修改个人信息
|
||||
getUser() {
|
||||
const url = `/center/userinfo`
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(service.get(url))
|
||||
})
|
||||
},
|
||||
// 获取首页分类Tag
|
||||
getTags(data) {
|
||||
const url = `/home/tags`
|
||||
|
||||
Reference in New Issue
Block a user