49 lines
1023 B
JavaScript
49 lines
1023 B
JavaScript
import {url} from '../request'
|
|
Page({
|
|
data:{
|
|
authCode:'',
|
|
},
|
|
Login(){
|
|
my.getAuthCode({
|
|
scopes: 'auth_user',
|
|
success: res => {
|
|
const authCode = res.authCode;
|
|
console.log(typeof authCode);
|
|
console.log(authCode)
|
|
my.request({
|
|
url: url+'/api/Alipay/parseCode',
|
|
data: {
|
|
authCode,
|
|
},
|
|
success(res){
|
|
const { username, avatarUrl } = res.data.data;
|
|
my.setStorageSync({
|
|
key: 'user_info',
|
|
data: {
|
|
username:username,
|
|
avatarUrl:avatarUrl,
|
|
},
|
|
});
|
|
console.log(res)
|
|
console.log(username,avatarUrl)
|
|
my.alert({
|
|
title: '登录成功',
|
|
});
|
|
my.switchTab({
|
|
url:'/pages/wode/wode'
|
|
})
|
|
|
|
},
|
|
fail(res){
|
|
console.log("失败");
|
|
}
|
|
})
|
|
|
|
}
|
|
})
|
|
},
|
|
|
|
});
|
|
|
|
|