Applet List Delete Function _ applet address Delete

Source: Internet
Author: User
Address Book deletion, first gets the ID value of the current address part, and deletes the corresponding address part according to the ID value. Gets all the address information, defines an empty array newalldata, and uses to place the new address information. Removes the address information for the selected ID in all address information and generates a new address information into the defined empty array. Now the newalldata is to remove the remaining address information after the selected address information, and the information in the Newalldata is rendered on the page.

WML files:

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

JS file:

Deleteaddress (e) {Let so = 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 ': ' Confirm deletion of this address information. ', ' cancelcolor ': ' #0076FF ', ' confirmcolor ': ' #0076FF ', success:function (res) {if (Res.confir m) {console.log (' user clicks OK ') 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.mess Age, ' conFirmcolor ': ' #0076FF '}}}, function (Res2) {})} else if (Res.cancel) { Console.log (' User clicks Cancel '}}})}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.