律师小程序开发:小程序点赞收藏功能

来源:律品科技 发布时间:2018-09-12 浏览:204

一.收藏

focusFavoriteTab: function (e) {

var that = this;

var isFocus = that.data.isFocus;

console.log("isFocus", isFocus)

var itemId = that.data.itemId;

if (isFocus) {

favoriteService.cancel(that, itemId).then((res) => {

wx.showToast({

title: "取消收藏",

icon: 'success',

duration: 1000

});

that.setData({

isFocus: false,

});

})

} else {

favoriteService.add(that, itemId).then((res) => {

wx.showToast({

title: res.data == 1 ? "收藏成功" : "收藏失败",

icon: 'success',

duration: 1000

});

that.setData({

isFocus: true,

});

});

}

},

二.点赞

focuslikeTab: function (e) {

var that = this;

var isLike = that.data.isLike;

let itemDetail = this.data.itemDetail

var itemId = that.data.itemId;

if (isLike) {

itemService.cancellike(that, itemId).then((res) => {

wx.showToast({

title: "点赞取消",

icon: 'success',

duration: 1000

});

itemDetail.liked--;

that.setData({

itemDetail:itemDetail,

isLike: false

});

})

} else {

itemService.addlike(that, itemId).then((res) => {

wx.showToast({

title: res.data == 1 ? "点赞成功" : "点赞失败",

icon: 'success',

duration: 1000

});

itemDetail.liked++;

that.setData({

itemDetail: itemDetail,

isLike: true

});

});

}

},

联系方式

电话:152-0832-9147

邮箱:105991110@qq.com

Q Q:105991110

地址:成都市人民南路四段27号商鼎国际2栋1单元2705

蜀ICP备18025242号-1

微信联系我们