fix: request before getting token

mgy
Dawn1Ocean 2024-04-22 21:05:27 +08:00
parent fb9f4b4342
commit 8b2ed25109
7 changed files with 43 additions and 8 deletions

View File

@ -1,5 +1,6 @@
export default defineAppConfig({
pages: [
'pages/Loading/Loading',
'pages/index/index',
'pages/repair/repair',
'pages/user/user',

View File

@ -0,0 +1,3 @@
export default definePageConfig({
usingComponents: {},
});

View File

View File

@ -0,0 +1,24 @@
import { AtActivityIndicator } from 'taro-ui';
import { Component, ReactNode } from 'react';
import Taro from '@tarojs/taro';
import pt from '@/plain-text';
import { View } from '@tarojs/components';
import './Loading.scss';
export default class LoadingPage extends Component {
componentDidMount(): void {
Taro.setNavigationBarTitle({
title: pt.get().navBar.loading,
});
}
render(): ReactNode {
return (
<View>
<AtActivityIndicator
mode='center'
content={pt.get().actIndicator.loading}
></AtActivityIndicator>
</View>
);
}
}

View File

@ -1,5 +1,6 @@
export interface NavBarTitle {
notFound: string;
loading: string;
ticketDetail: string;
ticketList: string;
askLeave: string;
@ -16,6 +17,7 @@ export interface NavBarTitle {
export const navBarTitleZhCn: NavBarTitle = {
notFound: '连接失败',
loading: '加载中',
ticketDetail: '工单详情',
ticketList: '所有工单',
askLeave: '请假单填写',
@ -32,6 +34,7 @@ export const navBarTitleZhCn: NavBarTitle = {
export const navBarTitleEnUs: NavBarTitle = {
notFound: 'Failed',
loading: 'Loading',
ticketDetail: 'Ticket Detail',
ticketList: 'All Tickets',
askLeave: 'Ask for leave',

View File

@ -21,6 +21,9 @@ export function loginAte() {
data: data.token,
});
wechatUser.setToken(data.token);
Taro.reLaunch({
url: '/pages/index/index',
});
getLocaleData();
})
.catch((err) => {

View File

@ -13,14 +13,15 @@ export function pingAte() {
})
.then((res) => {
console.log(res.data);
checkLogin((success) => {
if (success) {
wechatUser.setToken(checkToken());
getInfo();
} else {
loginAte();
}
});
// checkLogin((success) => {
// if (success) {
// wechatUser.setToken(checkToken());
// getInfo();
// } else {
// loginAte();
// }
// });
loginAte();
})
.catch((err) => {
console.log(err.errMsg);