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

  • 2018-09-12
  • 3634

一.收藏

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

});

});

}

},

相关阅读

律师小程序开发:在小程序wxml文件中编写js代码

律师小程序开发:微信小程序语音识别、合成

律师小程序开发:微信小程序富文本解析rich-text 组件

律师小程序开发:可实时改变转速的css3旋转动画

律师小程序开发:JS导出和导入

成都律品科技有限公司专注律师互联网营销技术服务,创始人员2009年开始从事律师行业互联网技术开发、营销运营工作已十年,2018年公司正式成立,不断探索律师行业服务需求,致力于为律师行业提供透明、优质的服务,现已为全国多家律师事务所、律师团队提供互联网技术及营销支持。

在线咨询
  • 152-0832-9147

  • 105991110

全时在线,如未回复请留下联系方式

微信咨询