时间: 2020-08-31|tag:69次围观|0 条评论

 <button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">getPhoneNumber</button> 
uniapp获取手机号插图
image.png

open-type String 开放能力

注意

事件务必使用vue语法,比如下面的获取手机号示例

<button type="default" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">获取手机号</button>
uniapp获取手机号插图1
image.png
getPhoneNumber(e) {  if (!e.target.iv) {    uni.showModal({      content: '获取手机号失败!',      showCancel: false    })    return;  }  uni.checkSession({    success: _ => {      bindMobileApi({        ivdata: e.target.iv,        encrypdata: e.target.encryptedData,      }).then(res => {        this.$emit('callback',true);        store.dispatch('getInfo', false)        uni.showModal({          content: '登录成功',          showCancel: false        })      }).catch(err => {        store.dispatch('getInfo', false)      })    },    fail: res => {      store.dispatch('getInfo', false)      uni.showModal({        content: '获取手机号失败,请再次尝试!',        showCancel: false      })    }  })}

文章转载于:https://www.jianshu.com/p/b567233dddbb

原著是一个有趣的人,若有侵权,请通知删除

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《uniapp获取手机号
   

还没有人抢沙发呢~