jiaqingjiayi-xiaochengxu/甲情_甲意/miniprogram/pages/denglu/denglu.js

49 lines
1023 B
JavaScript
Raw Normal View History

2024-11-15 03:51:28 +00:00
import {url} from '../request'
2024-11-10 07:01:22 +00:00
Page({
data:{
2024-11-15 03:51:28 +00:00
authCode:'',
2024-11-10 07:01:22 +00:00
},
2024-11-15 03:51:28 +00:00
Login(){
2024-11-10 07:01:22 +00:00
my.getAuthCode({
2024-11-15 03:51:28 +00:00
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("失败");
}
})
2024-11-10 07:01:22 +00:00
}
2024-11-15 03:51:28 +00:00
})
},
2024-11-10 07:01:22 +00:00
});