小編給大家分享一下小程序中點贊和收藏功能怎么弄,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
創(chuàng)新互聯(lián)是一家專業(yè)從事網(wǎng)站制作、網(wǎng)站設(shè)計的網(wǎng)絡(luò)公司。作為專業(yè)網(wǎng)絡(luò)公司,創(chuàng)新互聯(lián)依托的技術(shù)實力、以及多年的網(wǎng)站運營經(jīng)驗,為您提供專業(yè)的成都網(wǎng)站建設(shè)、網(wǎng)絡(luò)營銷推廣及網(wǎng)站設(shè)計開發(fā)服務(wù)!收藏功能:
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 }); this.setData({ isFocus: false, }); }) } else { favoriteService.add(that, itemId).then((res) => { wx.showToast({ title: res.data == 1 ? "收藏成功" : "收藏失敗", icon: 'success', duration: 1000 }); this.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--; this.setData({ itemDetail:itemDetail }); this.setData({ isLike: false, }); }) } else { itemService.addlike(that, itemId).then((res) => { wx.showToast({ title: res.data == 1 ? "點贊成功" : "點贊失敗", icon: 'success', duration: 1000 }); itemDetail.liked++; this.setData({ itemDetail: itemDetail }); this.setData({ isLike: true, }); }); } },
看完了這篇文章,相信你對“小程序中點贊和收藏功能怎么弄”有了一定的了解,如果想了解更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!