You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
629 B

5 months ago
App({
globalData: {
uid: null,
userInfo: null
},
async onLaunch() {
try {
// 尝试获取用户信息
const res = await this.getUserAccount()
if (res.data.code === 200 && res.data.account?.id) {
this.globalData.uid = res.data.account.id
this.globalData.userInfo = res.data.profile
} else {
console.error('获取用户信息失败')
}
} catch (error) {
console.error('初始化用户信息失败:', error)
}
},
async getUserAccount() {
const musicApi = require('./api/music').default
return await musicApi.getUserAccount()
}
})