diff --git a/libs/routine.js b/libs/routine.js index 17a1b36a..620b91d3 100644 --- a/libs/routine.js +++ b/libs/routine.js @@ -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); } diff --git a/pages/users/login/index.vue b/pages/users/login/index.vue index 7d68acf5..228106be 100644 --- a/pages/users/login/index.vue +++ b/pages/users/login/index.vue @@ -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() diff --git a/pages/users/wechat_login/index.vue b/pages/users/wechat_login/index.vue index 638054e3..7acc99c9 100644 --- a/pages/users/wechat_login/index.vue +++ b/pages/users/wechat_login/index.vue @@ -21,7 +21,7 @@ - + @@ -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: '正在登录中'