getLoginCode() : void{
// 返回的是string
const getWxCode : Promise<string> = new Promise((resolve,reject)=>{
uni.login({
provider: 'weixin',
success:(res : any)=> {
resolve(res.code);
},
})
})
const getWxInfo : Promise<object> = new Promise((resolve,reject)=>{
uni.getUserProfile({
desc:'登录',
success:(res : any)=> {
resolve(res.userInfo)
},
fail() {
Toast.error('授权失败')
}
})
})
Promise.all([getWxCode ,getWxInfo]).then((res : Array<any>)=>{
const first : string = res[0]
const sencend : object = res[1]
// 回调
quickLogin(
{
nickname: sencend['nickName'],
headPortrait: sencend['avatarUrl'],
code: first
}).then((data: any) => {
console.log('data',data);
})
})
},
console