最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序如何獲取用戶(hù)收貨地址

 更新時(shí)間:2018年11月27日 17:20:10   作者:a_靖  
這篇文章主要為大家詳細(xì)介紹了微信小程序獲取用戶(hù)收貨地址的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

獲取用戶(hù)收貨地址需要用戶(hù)點(diǎn)擊授權(quán),所以有兩種情況,確認(rèn)授權(quán)、取消授權(quán)。

情況一,用戶(hù)第一次訪(fǎng)問(wèn)用戶(hù)地址授權(quán),并且點(diǎn)擊確定授權(quán)。

情況二,用戶(hù)點(diǎn)擊取消授權(quán)后,再次獲取授權(quán)

流程: (代碼邏輯整理)

1.點(diǎn)擊事件觸發(fā)函數(shù),獲取用戶(hù)當(dāng)前設(shè)置

2.根據(jù)用戶(hù)當(dāng)前設(shè)置中的用戶(hù)授權(quán)結(jié)果,判斷是否包含收貨地址授權(quán)

3.如果包含收貨地址授權(quán)并且沒(méi)有取消過(guò)收貨地址授權(quán),直接調(diào)用wx.chooseAddress(),獲取用戶(hù)收貨地址。

4.取消過(guò)收貨地址授權(quán),調(diào)用wx.openSetting(),調(diào)起客戶(hù)端小程序設(shè)置界面讓用戶(hù)去打開(kāi)授權(quán)

4.1:用戶(hù)當(dāng)前設(shè)置包含收貨地址授權(quán)但是用戶(hù)點(diǎn)擊取消授權(quán),調(diào)用wx.openSetting(),調(diào)起客戶(hù)端小程序設(shè)置界面讓用戶(hù)去打開(kāi)授權(quán)

4.2:用戶(hù)當(dāng)前設(shè)置不包含收貨地址授權(quán)(說(shuō)明是第一次打開(kāi)獲取用戶(hù)收貨地址信息的授權(quán)),調(diào)用wx.chooseAddress(),獲取用戶(hù)收貨地址。

完整代碼:

<button bindtap='aaaaaaa'>獲取地址</button>
 aaaaaaa() {
 wx.getSetting({
 success(res) {
 console.log("vres.authSetting['scope.address']:",res.authSetting['scope.address'])
 if (res.authSetting['scope.address']) {
  console.log("111")
  wx.chooseAddress({
  success(res) {
  console.log(res.userName)
  console.log(res.postalCode)
  console.log(res.provinceName)
  console.log(res.cityName)
  console.log(res.countyName)
  console.log(res.detailInfo)
  console.log(res.nationalCode)
  console.log(res.telNumber)
  }
  })
  // 用戶(hù)已經(jīng)同意小程序使用錄音功能,后續(xù)調(diào)用 wx.startRecord 接口不會(huì)彈窗詢(xún)問(wèn)
  
 } else {
  if (res.authSetting['scope.address'] == false) {
  console.log("222")
  wx.openSetting({
  success(res) {
  console.log(res.authSetting)
  
  }
  })
  } else {
  console.log("eee")
  wx.chooseAddress({
  success(res) {
  console.log(res.userName)
  console.log(res.postalCode)
  console.log(res.provinceName)
  console.log(res.cityName)
  console.log(res.countyName)
  console.log(res.detailInfo)
  console.log(res.nationalCode)
  console.log(res.telNumber)
  }
  })
  }
 }
 }
 })
},

為大家推薦現(xiàn)在關(guān)注度比較高的微信小程序教程一篇:《微信小程序開(kāi)發(fā)教程》小編為大家精心整理的,希望喜歡。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

屏东县| 西畴县| 大埔区| 鄂州市| 长治市| 中西区| 巴楚县| 梁山县| 遂溪县| 固原市| 江华| 工布江达县| 呈贡县| 奉贤区| 巫溪县| 邵阳市| 中西区| 铜梁县| 吴堡县| 乌鲁木齐市| 商河县| 瓮安县| 太谷县| 探索| 乡宁县| 邻水| 宜兰市| 肇东市| 东兰县| 朝阳县| 松桃| 西畴县| 寿阳县| 明光市| 成都市| 化德县| 余干县| 安义县| 阿合奇县| 金山区| 恩平市|