feat: 任务和社区页面
This commit is contained in:
@@ -1,7 +1,29 @@
|
||||
// app.js
|
||||
import request from './utils/request';
|
||||
|
||||
App({
|
||||
onLaunch() {
|
||||
console.log('App Launch');
|
||||
// Login
|
||||
wx.login({
|
||||
success: res => {
|
||||
// Send res.code to backend to swap for openId, sessionKey, unionId
|
||||
if (res.code) {
|
||||
request.get('/auth/miniLogin', { code: res.code }).then(data => {
|
||||
// Assuming the token is in data.token or data itself
|
||||
const token = data.token || data;
|
||||
if (token && typeof token === 'string') {
|
||||
wx.setStorageSync('token', token);
|
||||
console.log('Login successful, token stored');
|
||||
} else {
|
||||
console.warn('Login response did not contain a valid token string', data);
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('Login failed', err);
|
||||
});
|
||||
} else {
|
||||
console.error('wx.login failed: ' + res.errMsg);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
globalData: {
|
||||
userInfo: null
|
||||
|
||||
Reference in New Issue
Block a user