最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序項(xiàng)目總結(jié)之點(diǎn)贊 刪除列表 分享功能

 更新時(shí)間:2018年06月25日 14:44:51   作者:Acitylion  
這篇文章主要介紹了微信小程序項(xiàng)目總結(jié)之點(diǎn)贊 刪除列表 分享功能,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

小程序點(diǎn)贊功能

思路:在后臺(tái)沒有給你接口自己模擬數(shù)據(jù)

data:{ 
 likes:{ 
 iszan:false, 
 num:0 
} 
} 

    1.遍歷評(píng)論列表 判斷點(diǎn)擊的id

    2.如果id相同 判斷是否點(diǎn)贊過 如果為true -1 如果為false +1

    3.更新數(shù)據(jù)

bindlike:function(e){ 
 var newData = this.data.release.map(function(item){ 
  if (item.id == e.currentTarget.dataset.id){ 
  console.log(item.id + e.currentTarget.dataset.id ) 
  if(item.likes.iszan){ 
   var obj = {} 
   obj.iszan = !item.likes.iszan; 
   obj.num = item.likes.num -1 ; 
   return Object.assign({},item,{likes:obj}) 
  }else { 
   var obj = {} 
   obj.iszan = !item.likes.iszan; 
   obj.num = item.likes.num + 1; 
   return Object.assign({}, item, { likes: obj }) 
  } 
  }else { 
  return item 
  } 
 }) 
 this.setData ({ 
  release:newData 
 }) 
 }, 

       2.點(diǎn)擊刪除列表功能

1.給撤銷按鈕綁定id 添加點(diǎn)擊事件

2.點(diǎn)擊刪除按鈕時(shí)提示是否刪除

3.如果用戶點(diǎn)擊確定 獲取到要?jiǎng)h除的id

4.刪除對(duì)應(yīng)的數(shù)組內(nèi)容

5.更新數(shù)據(jù)

//刪除評(píng)論 
 binddelete:function(e){ 
 var that = this; 
 wx.showModal({ 
  title: '提示', 
  content: '確認(rèn)撤回嗎?', 
 success:function(res){ 
  if(res.confirm){ 
 console.log('用戶點(diǎn)擊確定') 
 // 獲取要?jiǎng)h除數(shù)據(jù)的id 
 var dataid = e.currentTarget.dataset.id; 
 console.log(dataid) 
 // 刪除數(shù)組對(duì)應(yīng)的數(shù)據(jù)內(nèi)容 
 var release = that.data.release; 
 that.data.release.splice(dataid,1) 
 //判斷數(shù)據(jù)的長度 
 var len = that.data.release.length; 
 //通過判斷數(shù)組的長度來決定是否顯示隱藏的部分 
  that.setData ({ 
  release: that.data.release 
  }) 
  }else if(res.cancel){ 
  console.log('用戶點(diǎn)擊取消') 
  } 
 } 
 }) 
 }, 

3.點(diǎn)擊分享

點(diǎn)擊分享按鈕 要給button按鈕綁定個(gè) open-type ="share"屬性

通過給 button 組件設(shè)置屬性 open-type="share",可以在用戶點(diǎn)擊按鈕后觸發(fā) Page.onShareAppMessage() 事件,如果當(dāng)前頁面沒有定義此事件,則點(diǎn)擊后無效果。

Page({ 
 onShareAppMessage: function (res) { 
 if (res.from === 'button') { 
 // 來自頁面內(nèi)轉(zhuǎn)發(fā)按鈕 
 console.log(res.target) 
 } 
 return { 
 title: '自定義轉(zhuǎn)發(fā)標(biāo)題', 
 path: '/page/user?id=123' 
 } 
 } 
}) 

總結(jié)

以上所述是小編給大家介紹的微信小程序項(xiàng)目總結(jié)之點(diǎn)贊 刪除列表 分享功能,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論

银川市| 灵宝市| 昌乐县| 永平县| 乌兰察布市| 丰原市| 安康市| 章丘市| 宿松县| 夏邑县| 文水县| 邵武市| 卢龙县| 涡阳县| 阿尔山市| 航空| 绥阳县| 平顺县| 克东县| 顺平县| 山西省| 惠州市| 林芝县| 泾源县| 萍乡市| 仁化县| 子长县| 乌什县| 石景山区| 黄骅市| 井陉县| 微博| 保康县| 囊谦县| 儋州市| 新泰市| 那坡县| 长顺县| 华宁县| 通化市| 徐汇区|