小程序获取用户信息
<button class="pay_type" bindgetuserinfo="go_to_canvas" open-type="getUserInfo">
<view class="surplus_num ">
<image class="qrcode" src="/images/person/qrcode.png" />
</view>
<view class="pay_way pay_way_qrcode">推广码</view>
</button>
获取用户信息之后,执行方法。
go_to_canvas: function (e) {
let { telphone } = this.data.user_data.user_result;
if (!telphone) {
wx.showModal({
title: '提示',
content: '请先绑定手机号'
});
return;
}
// 获取最新的用户信息
if (e.detail.errMsg == "getUserInfo:ok") {
console.log(e.detail);
let openid = app.globalData.openid || Storage.get().openid;
let nickname = e.detail.userInfo.nickName;
let avatarurl = e.detail.userInfo.avatarUrl;
request("userInit", { openid,nickname,avatarurl }).then(({ data }) => {
wx.navigateTo({
url: '/pages/mine/canvas'
})
});
}
}
绑定信息之后,进行操作。