【小程序】獲取微信 自帶的 收貨地址獲取和整理


1、wx.chooseAddress(OBJECT)

if(wx.chooseAddress){
 wx.chooseAddress({
  success: function (res) {
   console.log(JSON.stringify(res))
  },
  fail: function(err){
   console.log(JSON.stringify(err))
  }
 })
}else{
 console.log('當前微信版本不支持chooseAddress');
}

2、數據處理,僅供參考

  //用戶選擇收貨地址
  chooseAddress:function(){
    var that = this;
    if (wx.chooseAddress) {
      wx.chooseAddress({
        success: function (res) {
          console.log(JSON.stringify(res));
          console.log(res);
          that.setData({
            "add_userName": res.userName,
            "add_telNumber": res.telNumber,
            "add_provinceName": res.provinceName,
            "add_cityName": res.cityName,
            "add_countyName": res.countyName,
            "add_detailInfo": res.detailInfo,
            "add_postalCode": res.postalCode,
            //具體收貨地址顯示
            flag:false,

          })
        },
        fail: function (err) {
          console.log(JSON.stringify(err));
          console.info("收貨地址授權失敗");
          wx.showToast({
            title: '授權失敗,您將無法進行下單支付;重新授權請刪除小程序后再次進入',
            icon: 'success',
            duration: 20000
          })
        }
      })
    } else {
      console.log('當前微信版本不支持chooseAddress');
    }
  },

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM