wx.showModal({
title: '获取手机号',
content: '获取手机号用于注册账号',
complete: (res) => {
if (res.cancel) {
}
if (res.confirm) {
wx.getPhoneNumber({
isRealtime:false,
success: function(res) {
console.log(res.code); // 动态令牌
console.log(res.errMsg); // 回调信息(成功失败都会返回)
console.log(res.errno); // 错误码(失败时返回)
}, // [!] 这里必须用逗号分隔属性,而不是分号
fail: function(res) {
console.log(res.errMsg); // 错误码(失败时返回)
}
}); // [!] 这里需要分号结束方法调用
}
}
});