今天在写登陆页面的时候,由于需要的个人信息和手机号的授权,但是如果在页面上直接放2个按钮,岂不是很呆???
索性就写了一个mask层,去引导用户授权手机号。

1. 当我点击快捷登录的 微信登录时,首先触发的是 微信原生的 获取用户信息userInfo 的方法,再它的 success 回调里面去打开 mask 层.....

2. mask 层里面 有一个按钮,这个按钮是去触发 微信原生的 获取用户手机号的 getPhoneNumber 的方法,接下来就不用我多说了吧。。。。


直接甩代码
<button open-type="getUserInfo" @tap="getUserProfile">
<view class="item column center">
<image class="iconc" src="/static/img/share/wx.png"></image>
</view>
</button>
<view class="modal-mask" catchtouchmove="preventTouchMove" v-if="showModal"></view>
<view class="modal-dialog" v-if="showModal">
<view class="modal-content">
<view><image src='' class='show'></image></view>
<view >绑定手机号</view>
<view >请先绑定手机号在进行此操作</view>
<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
<image src='/static/img/share/wx.png' class='iconWx'></image>微信用户一键绑定
</button>
</view>
</view>
methods: {
getUserProfile(){
wx.getUserProfile({
desc: '用于完善会员资料',
success: (res) => {
this.showDialogBtn();
}
})
},
showDialogBtn: function () {
this.showModal = true
},
hideModal: function () {
this.showModal = false
},
getPhoneNumber (e) {
console,log(e.detael)
},
以上就是本次分享的全部内容啦,感谢大家的查阅,欢迎三连~~~~~~~~