手机号码登录开发

master
gongfuxiang 2023-12-16 12:08:27 +08:00
parent 9328929df6
commit a18922b266
1 changed files with 120 additions and 15 deletions

135
App.vue
View File

@ -336,21 +336,15 @@
//
self.user_login(object, method, params);
// #endif
// #ifdef H5 || APP
// h5app
uni.showModal({
title: '温馨提示',
content: '请先登录或注册',
confirmText: '确认',
cancelText: '暂不',
success: (result) => {
if (result.confirm) {
uni.navigateTo({
url: '/pages/login/login',
});
}
},
});
// #ifdef APP
// app
self.app_login_handle(self, object, method, params);
// #endif
// #ifdef H5
// h5
self.login_confirm_tips_modal();
// #endif
}
}
@ -360,6 +354,117 @@
return user;
},
// app
app_login_handle(self, object, method, params) {
//
uni.getProvider({
service: 'oauth',
success: function (res) {
if(res.provider.includes('univerify')) {
//
uni.preLogin({
provider: 'univerify',
success(res) {
//
var theme_color = self.get_theme_color();
var theme_color_light = self.get_theme_color(null, true);
uni.login({
provider: 'univerify',
univerifyStyle: {
authButton: {
// #3479f5
normalColor: theme_color,
// #2861c5ios
highlightColor: theme_color_light,
// #73aaf5ios
disabledColor: theme_color_light,
},
privacyTerms: {
// 2urltitle.
privacyItems: [
{
url: self.get_config('config.agreement_userregister_url'),
title: '服务协议'
},
{
url: self.get_config('config.agreement_userprivacy_url'),
title: '隐私权政策'
}
]
},
},
success(res) {
//
// {openid:'',access_token:' token'}
console.log(res.authResult, 'success');
// access_tokencallfunction
uniCloud.callFunction({
name: 'uni-id-cf',
data: {
access_token: res.authResult.access_token,
openid: res.authResult.openid
}
}).then(res => {
// res.result = {
// code: '',
// message: ''
// }
//
console.log(res, 'success')
}).catch(err=>{
//
console.log(err, 'error')
});
},
fail(res) {
//
if(res.errCode == 30002) {
//
uni.closeAuthView();
//
uni.navigateTo({
url: '/pages/login/login',
});
} else {
//
if(res.errCode != 30003) {
app.globalData.showToast(res.errMsg+'('+res.errCode+')');
}
}
}
});
},
fail(res) {
self.login_confirm_tips_modal();
}
});
} else {
self.login_confirm_tips_modal();
}
},
fail(res) {
self.login_confirm_tips_modal();
}
});
},
//
login_confirm_tips_modal() {
uni.showModal({
title: '温馨提示',
content: '请先登录或注册',
confirmText: '确认',
cancelText: '暂不',
success: (result) => {
if (result.confirm) {
uni.navigateTo({
url: '/pages/login/login',
});
}
},
});
},
/**
* 从缓存获取用户信息可指定key和默认值
* key 数据key