Commit d4403f15 by 李嘉林

商品列表收藏

parent e5434229
......@@ -34,4 +34,12 @@ export default {
batch_query_collect_count(data) {
return requestPOST(`${process.env.OLSHOP_URL}/product/batch_query_collect_count`, data)
},
// 收藏
collect_goods(data) {
return requestPOST(`${process.env.OLSHOP_URL}/product/collect_goods?productId=${data.productId}&terminalProductId=${data.terminalProductId}`)
},
// 取消收藏
uncollect_goods(data) {
return requestPOST(`${process.env.OLSHOP_URL}/product/uncollect_goods?productId=${data.productId}&terminalProductId=${data.terminalProductId}`, data)
},
};
......@@ -101,6 +101,36 @@ const componentOptions = {
link: linkVal
});
},
// 收藏
toStart(e) {
let {items} = this.data;
console.log(this.data.items,e,'----items')
let query = {
productId: items.productId,
terminalProductId: items.terminalProductId,
}
if (!items.collectFlag) {
// 收藏
goodsApi.collect_goods(query).then(res1 => {
let res = res1.data;
if(res.code == 200 && res.data) {
this.setData({
"items.collectFlag": !items.collectFlag
})
}
})
} else {
// 取消收藏
goodsApi.uncollect_goods(query).then(res1 => {
let res = res1.data;
if(res.code == 200 && res.data) {
this.setData({
"items.collectFlag": !items.collectFlag
})
}
})
}
},
onclickBuynow(e) {
let { btnType } = this.data.datas.componentData;
let _this = this;
......
......@@ -185,7 +185,7 @@
{{datas.componentData.btnTest}}
</view>
</view>
<view class="start" wx:if="{{datas.componentData['collectFlag']}}">
<view class="start" wx:if="{{datas.componentData['collectFlag']}}" catchtap="toStart">
<text style="color:{{datas.componentData.btnColor}}" class="buy-now-icon iconfont-common {{items.collectFlag?'common-iconaixin':'common-iconaixin1'}}"></text>
</view>
<!-- 底部展示标签列表 -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment