欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

小程序?qū)崿F(xiàn)列表刪除功能

 更新時間:2018年10月30日 10:23:26   作者:紫雪璇雨  
這篇文章主要為大家詳細(xì)介紹了小程序?qū)崿F(xiàn)列表刪除功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了小程序列表刪除功能的具體代碼,供大家參考,具體內(nèi)容如下

  • 地址簿刪除,先獲取當(dāng)前地址部分的id值,根據(jù)id值來刪除對應(yīng)的地址部分。
  • 獲取全部的地址信息,定義一個空的數(shù)組newallData,用來放置新的地址信息。
  • 在全部地址信息中刪除選中的id的地址信息,生成新的地址信息放入定義的空數(shù)組中。
  • 現(xiàn)在newallData就是刪除選中地址信息以后剩下的地址信息,在newallData中的信息渲染在頁面。

wml文件:

<!-- 刪除 -->
<view class="delete" bindtap="deleteaddress" data-id="{{ item.id }}">刪除</view>

js文件:

deleteaddress(e){
  let that = this;
  console.log(e);
  let deldeid = e.currentTarget.dataset.id;
  let allDatas = that.data.allData;
  let newallData = [];
  for (var i in allDatas) {
   var item = allDatas[i];
   if (item.id != deldeid) {
    newallData.push(item);
   }
  } 
  console.log(newallData)
  wx.showModal({
   'content': '確認(rèn)刪除該地址信息嗎?',
   'cancelColor': '#0076FF',
   'confirmColor': '#0076FF',
   success: function (res) {
    if (res.confirm) {
     console.log('用戶點擊確定')
     let url = getApp().Api_url + '/receiver/delete';
     requestd._post(url, { receiverId: e.currentTarget.dataset.id }, function (res2) {
      console.log(res2);
      if( res2.data.status == 1 ){
       that.setData({
        allData: newallData
       });
      }else{
       wx.showModal({
        'showCancel': false,
        'content': res2.data.message,
        'confirmColor': '#0076FF'
       })
      }
     }, function (res2) { })
    } else if (res.cancel) {
     console.log('用戶點擊取消')
    }
   }
  })

}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論