Commit fc615389 by 赵雅纹

点赞与取消点赞

parent d51177cd
...@@ -25,44 +25,13 @@ Component({ ...@@ -25,44 +25,13 @@ Component({
*/ */
methods: { methods: {
onTapLike(e){ onTapLike(e){
console.log(e)
const { memberId } = wx.getStorageSync('_baseUserInfo') const { memberId } = wx.getStorageSync('_baseUserInfo')
var params = { let params = {
contentId: e.currentTarget.dataset.id, contentId: e.currentTarget.dataset.id,
type: e.currentTarget.dataset.type, type: e.currentTarget.dataset.type,
userId: memberId userId: memberId
} }
if (!e.currentTarget.dataset.type){ this.triggerEvent('updataLike', params)
wxService.post(`/merchant/contentMobileTerminal/operationSave`, params).then(res => {
if (!res) return false
const { result, data } = res.data
if (result == 0) {
wx.showToast({
title: '点赞成功',
icon: 'none'
})
}
}).finally(() => {
})
}else{
wxService.post(`/merchant/contentMobileTerminal/operationDelete`, {
contentId: e.currentTarget.dataset.id,
userId: memberId
}).then(res => {
if (!res) return false
const { result, data } = res.data
if (result == 0) {
wx.showToast({
title: '取消点赞成功',
icon: 'none'
})
}
}).finally(() => {
})
}
}, },
//详情 //详情
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<view class="item-title">{{headline}}</view> <view class="item-title">{{headline}}</view>
</view> </view>
<view class="share-wrap"> <view class="share-wrap">
<view class="share-oprate" bindtap="onTapLike" data-id="{{id}}" data-type="{{type}}"> <view class="share-oprate" catchtap="onTapLike" data-id="{{id}}" data-type="{{type}}">
<image class="share-img" src="{{type ? '/assets/imgs/heart-primary.png' : '/assets/imgs/heart-default.png'}}"></image> <image class="share-img" src="{{type ? '/assets/imgs/heart-primary.png' : '/assets/imgs/heart-default.png'}}"></image>
<text class="share-number">{{enjoySum || 0}}</text> <text class="share-number">{{enjoySum || 0}}</text>
</view> <view class="share-oprate"> </view> <view class="share-oprate">
......
...@@ -150,7 +150,7 @@ wxService.page({ ...@@ -150,7 +150,7 @@ wxService.page({
currentTab:data[0].id currentTab:data[0].id
}) })
getContentList(data[0].id) this.getContentList(data[0].id)
} }
}).finally(() => { }).finally(() => {
...@@ -183,6 +183,45 @@ wxService.page({ ...@@ -183,6 +183,45 @@ wxService.page({
}) })
}, },
// 点赞
gotoLike(e){
console.log(e.detail)
let params = e.detail
if (!e.detail.type){
wxService.post(`/merchant/contentMobileTerminal/operationSave`, params).then(res => {
if (!res) return false
const { result, data } = res.data
if (result == 0) {
wx.showToast({
title: '点赞成功',
icon: 'none'
})
this.getContentList(this.data.currentTab)
}
}).finally(() => {
})
}else{
wxService.post(`/merchant/contentMobileTerminal/operationDelete`, {
contentId: e.detail.contentId,
userId: e.detail.userId
}).then(res => {
if (!res) return false
const { result, data } = res.data
if (result == 0) {
wx.showToast({
title: '取消点赞成功',
icon: 'none'
})
this.getContentList(this.data.currentTab)
}
}).finally(() => {
})
}
},
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
......
...@@ -8,10 +8,15 @@ ...@@ -8,10 +8,15 @@
</view> </view>
<scroll-view scroll-y > <scroll-view scroll-y >
<view class="main-content" wx:if="{{contentList.length > 0}}"> <view class="main-content" wx:if="{{contentList.length > 0}}">
<water-flow-layout image-data="{{contentList}}"/> <water-flow-layout image-data="{{contentList}}" bind:updataLike="gotoLike"/>
</view> </view>
<view class="empty" wx:if="{{!contentList || contentList.length < 1}}"> <view class="empty" wx:if="{{!contentList || contentList.length < 1}}">
暂无内容哦~ 暂无内容哦~
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
...@@ -12,7 +12,7 @@ wxService.page({ ...@@ -12,7 +12,7 @@ wxService.page({
contentInfo:[], contentInfo:[],
id:'', id:'',
pageNo:1, pageNo:1,
pageSize:30, pageSize:100,
proList:[] proList:[]
}, },
...@@ -55,17 +55,59 @@ wxService.page({ ...@@ -55,17 +55,59 @@ wxService.page({
var params = { var params = {
productIds: this.data.contentInfo.productIds productIds: this.data.contentInfo.productIds
} }
wxService.post(`/sale/product/buyer/listPageByCategoryId?pageNo=${this.data.pageNo}&pageSize=${this.data.pageSize}`, params).then(res => { wxService.post(`/sale/product/buyer/listPage?pageNo=${this.data.pageNo}&pageSize=${this.data.pageSize}`, params).then(res => {
if (!res) return false if (!res) return false
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0 && data.content) {
this.setData({ this.setData({
proList: data proList: data.content
})
}
}).finally(() => {
})
},
// 点赞
gotoLike(){
const { memberId } = wx.getStorageSync('_baseUserInfo')
let params = {
contentId: this.data.contentInfo.id,
type: this.data.contentInfo.currentType,
userId: memberId
}
if (!this.data.contentInfo.currentType) {
wxService.post(`/merchant/contentMobileTerminal/operationSave`, params).then(res => {
if (!res) return false
const { result, data } = res.data
if (result == 0) {
wx.showToast({
title: '点赞成功',
icon: 'none'
}) })
this.getContentList(this.data.currentTab)
} }
}).finally(() => { }).finally(() => {
}) })
} else {
wxService.post(`/merchant/contentMobileTerminal/operationDelete`, {
contentId: this.data.contentInfo.id,
userId: memberId
}).then(res => {
if (!res) return false
const { result, data } = res.data
if (result == 0) {
wx.showToast({
title: '取消点赞成功',
icon: 'none'
})
this.getContentList(this.data.currentTab)
}
}).finally(() => {
})
}
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<view class="buy-desc"> <view class="buy-desc">
<view>{{contentInfo.describe}}</view> <view>{{contentInfo.describe}}</view>
<view class="share-wrap"> <view class="share-wrap">
<view class="share-oprate"> <view class="share-oprate" bindtap="gotoLike">
<image class="share-img" src="{{contentInfo.currentType ? '/assets/imgs/heart-primary.png' : '/assets/imgs/heart-default.png'}}"></image> <image class="share-img" src="{{contentInfo.currentType ? '/assets/imgs/heart-primary.png' : '/assets/imgs/heart-default.png'}}"></image>
<text class="share-number">{{contentInfo.enjoySum || 0}}</text> <text class="share-number">{{contentInfo.enjoySum || 0}}</text>
</view> </view>
...@@ -20,34 +20,21 @@ ...@@ -20,34 +20,21 @@
</view> </view>
<view class="buy-product-wrap"> <view class="buy-product-wrap">
<view class="buy-product-content"> <view class="buy-product-content">
<view class="buy-list"> <view class="buy-list" wx:for="{{proList}}" wx:key="{{index}}">
<view class="prod-img">
<image src="/assets/imgs/avatar.png"></image>
</view>
<view class="prod-info">
<view class="prod-name">商品名称商品名称商品名称商品名称商品名称</view>
<view class="sale-btn">限时特价</view>
<view class="bottom-price">
<text class="price">¥299</text>
<text class="cost-price">¥456</text>
<view class="look-over">查看详情</view>
</view>
</view>
</view>
<view class="buy-list">
<view class="prod-img"> <view class="prod-img">
<image src="/assets/imgs/avatar.png"></image> <image src="{{item.indexUrl}}"></image>
</view> </view>
<view class="prod-info"> <view class="prod-info">
<view class="prod-name">商品名称商品名称商品名称商品名称商品名称</view> <view class="prod-name">{{item.productName}}</view>
<view class="sale-btn">限时特价</view> <!-- <view class="sale-btn">限时特价</view> -->
<view class="bottom-price"> <view class="bottom-price">
<text class="price">¥299</text> <text class="price">¥{{item.minSalePrice}}</text>
<text class="cost-price">¥456</text> <!-- <text class="cost-price">¥456</text> -->
<view class="look-over">查看详情</view> <view class="look-over">查看详情</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
</view> </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