Commit f1db089b authored by 范雪寒's avatar 范雪寒

feat: 有token跳菜单页,没token跳登录页

parent 6a29e645
...@@ -39,12 +39,20 @@ export default class NewClass extends middleLayerBase { ...@@ -39,12 +39,20 @@ export default class NewClass extends middleLayerBase {
} }
protected start(): void { async start() {
this.node.zIndex = 9999; this.node.zIndex = 9999;
cc.game.addPersistRootNode(this.node); cc.game.addPersistRootNode(this.node);
const token = cc.sys.localStorage.getItem('token');
const kidDataStr = await this.asyncCallNetworkApiGet('/api/oxford/v1/kid/info', {
token: token
});
const kidData = JSON.parse(kidDataStr);
if (kidData.code == 200) {
this.loadOnlineBundle('NJ_YouLeChang');
} else {
this.loadOnlineBundle('NJ_login'); this.loadOnlineBundle('NJ_login');
} }
}
role = 'student'; role = 'student';
protected onLoad(): void { protected onLoad(): void {
......
...@@ -65,14 +65,14 @@ export abstract class middleLayerBase extends cc.Component { ...@@ -65,14 +65,14 @@ export abstract class middleLayerBase extends cc.Component {
}); });
} }
} }
asyncCallNetworkApiGet(apiName, data) { asyncCallNetworkApiGet(apiName, data): Promise<any> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.callNetworkApiGet(apiName, data, (res => { this.callNetworkApiGet(apiName, data, (res => {
resolve(res); resolve(res);
})); }));
}); });
} }
asyncCallNetworkApiPost(uri, data) { asyncCallNetworkApiPost(uri, data): Promise<any> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.callNetworkApiPost(uri, data, (res) => { this.callNetworkApiPost(uri, data, (res) => {
resolve(res); resolve(res);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment