抖音授权手机号登录
官方给的方法: 必须是
open-type="getPhoneNumber" @getphonenumber="getPhoneNumberHandler"
<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumberHandler" >授权手机号一键注册/登录</button>
getPhoneNumberHandler: function(e){
var encryptedData = e.detail.encryptedData;
var iv = e.detail.iv;
let postData = {
code: this.code,//当没有session时使用code和接口获取session,
iv: iv,
encryptedData: encryptedData
};
},
是否判断session过期,重新登录,获取用户信息
shouquan: function() {
let that = this;
// uni.checkSession({
// success(res) {
// that.setData({
// session: res.session
// })
// console.log("未过期",res);
// },
// fail() {
uni.login({
force:true,
success(res) {
var code = res.code;
that.setData({
code:res.code
})
// uni.getUserInfo({
// withCredentials: true,
// success:function(ress) {
// var encryptedData = ress.encryptedData;
// var iv = ress.iv;
// let postData = {
// code: code,
// iv: iv,
// encryptedData: encryptedData
// };
// }
// })
},
fail(res) {
console.log(res);
}
})
// }
// })
},