修复 getUserProfile

pull/1/MERGE
stivepeim 2021-05-06 10:04:18 +08:00
parent 5e6d4b5a77
commit 95031bc483
3 changed files with 24 additions and 12 deletions

View File

@ -24,8 +24,9 @@ class Routine
getUserInfo(){
let that = this , code = this.getUserCode();
return new Promise( (resolve,reject) => {
uni.getUserInfo({
uni.getUserProfile({
lang: 'zh_CN',
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success(user) {
if(code) user.code = code;
resolve({userInfo:user,islogin:false});
@ -118,15 +119,12 @@ class Routine
authUserInfo(code,data)
{
console.log('code:',code);
console.log('data:',data);
return new Promise((resolve, reject)=>{
login(code,data).then(res=>{
if(res.data.type==='login'){
// let time = res.data.expiresTime - Cache.time();
store.commit('UPDATE_USERINFO', res.data.user);
store.commit('LOGIN', {token:res.data.token});
store.commit('SETUID', res.data.user.uid);
// Cache.set(EXPIRES_TIME,res.data.expiresTime,time);
Cache.set(USER_INFO,res.data.user);
}

View File

@ -158,16 +158,12 @@
provider: 'apple',
timeout: 10000,
success(loginRes) {
console.log(loginRes, 'loginRes')
uni.getUserInfo({
uni.getUserProfile({
provider: 'apple',
success: function(infoRes) {
console.log(infoRes.userInfo, 'yyyy')
self.appleUserInfo = infoRes.userInfo
self.appleLoginApi()
console.log(self.$store);
console.log(infoRes.userInfo);
},
fail() {
uni.showToast({
@ -247,10 +243,9 @@
provider: 'weixin',
success: function(loginRes) {
//
uni.getUserInfo({
uni.getUserProfile({
provider: 'weixin',
success: function(infoRes) {
console.log(infoRes.userInfo, 'yyyy')
self.appUserInfo = infoRes.userInfo
self.wxLoginApi()

View File

@ -21,7 +21,7 @@
<button hover-class="none" @click="wechatLogin" class="bg-green btn1">微信登录</button>
<!-- #endif -->
<!-- #ifdef MP -->
<button hover-class="none" open-type="getUserInfo" @getuserinfo="setUserInfo" class="bg-green btn1">微信登录</button>
<button hover-class="none" @tap="getUserProfile" class="bg-green btn1">微信登录</button>
<!-- #endif -->
<!-- <button hover-class="none" @click="isUp = true" class="btn2">手机号登录</button> -->
</view>
@ -238,6 +238,25 @@
})
});
},
getUserProfile() {
let self = this;
uni.showLoading({
title: '正在登录中'
});
Routine.getUserProfile()
.then(res => {
Routine.getCode()
.then(code => {
self.getWxUser(code, res);
})
.catch(res => {
uni.hideLoading();
});
})
.catch(res => {
uni.hideLoading();
});
},
setUserInfo(e) {
uni.showLoading({
title: '正在登录中'