微信小程序返回上一级页面

微信小程序返回上一级页面

      • wx.navigateBack({ delta: 1 //返回上一级页面})

wx.navigateBack({ delta: 1 //返回上一级页面})

html:

<view class="refusea_btn">
        <van-button type="primary" size="large" bind:tap="submit">保存</van-button>
</view>

js:

//提交
  submit(){
    let data = this.data;
    let params = data.AddressVo;
    if(params.name == ""){
      wx.showToast({
        icon: "none",
        title:"请输入发货人姓名"
      })
      return
    }
    if(params.mobile == ""){
      wx.showToast({
        icon: "none",
        title:"请填写手机号"
      })
      return
    }
    if(params.address == ""){
      wx.showToast({
        icon: "none",
        title:"请选择收货地址"
      })
      return
    }
    if(params.addressDetail == ""){
      wx.showToast({
        icon: "none",
        title:"请填写详细收货地址"
      })
      return
    }
    POST('/store/saveShipAddress', params).then(res => {
     if(res.code === 200){
       wx.showToast({
         icon:'success',
         title:'保存成功!'
       })
       setTimeout(item => {
         wx.navigateBack({
           delta: 1 //返回上一级页面
         })
       },2000)
     }else{
       wx.showToast({
         icon:'none',
         title:'保存失败'
       })
     }
    })
  },

你可能感兴趣的:(JavaScript,小程序)