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 '}}})}