VUE: press eject mobile terminal to confirm the deletion address (2)

  There is also an article written before the press and pop-up confirmation box functionality, tested no problem in the android machine, to find the back of the overall IOS Press this function to remove disappeared test,

Unless the press and let go, with the other hand Click OK to complete the operation, so this was revised, IOS and android effective pro-test oh ~

CSS:
<li v-for="(item,idx) in addressList" :key="idx" @touchstart="longPress" @touchend="removePress(item)" @click="chooseAddress(item)">
JS:
// delete the address, press Start 
longPress () {
   the this .touchstartTime = new new a Date (). The getTime () 
}, 
// delete the address, press End 
removePress (Item) {
   the this .touchendTime = new new a Date (). The getTime ( )
   the this .duration = the this .touchendTime - the this .touchstartTime
   IF ( the this .duration> = 800 ) { 
    MessageBox.confirm ( 'confirm delete it?') the then (RES =>. {
       the this .addressList.splice (Item, 1 ) 
toast ( 'successfully deleted ~') }).
the catch (() => { }) } }

 

Connect the back-end data when interfaces: JS
// delete the address, press Start 
longPress () {
   the this .touchstartTime = new new a Date (). The getTime () 
}, 
// delete the address, press End 
removePress (Item) {
   the this .touchendTime = new new a Date (). The getTime ( )
   the this .duration = the this .touchendTime - the this .touchstartTime
   IF ( the this .duration> = 800 ) { 
    MessageBox.confirm ( 'confirm delete it?') the then (RES =>. { 
      the let _formData = { 
        cusmallToken: getStore ( 'cusmallToken ' ), 
        AddressID: item.id 
      }
      commonDkApiFun(_formData, '/ttmb/api/member/delAddress').then(res => {
        if (res.data.ret === 0) {
          this.addressList.splice(item, 1)
          this.getAddressList()
          Toast('删除成功')
        }
      }).catch(err => {
        console.log(err)
      })
    }).catch(() => {
    })
  }
}

 

Guess you like

Origin www.cnblogs.com/Awen71815iou/p/11570747.html