Commit ff156406 authored by liujiangnan's avatar liujiangnan

feat: 列表出来了

parent 8bad1ccb
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -17,6 +17,9 @@ export default class NewClass extends cc.Component {
@property(cc.Node)
SvContent: cc.Node = null;
@property(cc.Node)
loading: cc.Node = null;
_inited = false;
// 点击用户中心
......@@ -27,7 +30,7 @@ export default class NewClass extends cc.Component {
// vc.toView("UserPage", "topIn")
}
// 点击用户中心
// 点击资源库
handleClickLibrary() {
const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LibraryPage", "bottomIn")
......@@ -41,29 +44,39 @@ export default class NewClass extends cc.Component {
}
// 获取课程清单
getCourseList() {
async getCourseList() {
this.SvContent.removeAllChildren();
for(let i=0; i<10; i++) {
this.loading.active = true;
const userInfo = await global.middleLayer.getUserInfo();
const {rows} = await asyncCallNetworkApiGet('/api/kyxq/v1/user/jclist', {
jc_arr: userInfo.jc_arr,
});
for(let i=0; i<rows.length; i++) {
const row = rows[i];
const ci = cc.instantiate(this.CourseItem)
ci.active = true;
ci.attr({syllabus_id: row.id});
ci.on("click", ()=>{
this.handleClickCourseItem()
this.handleClickCourseItem();
})
this.SvContent.addChild(ci)
this.SvContent.addChild(ci);
}
this.loading.active = false;
}
// onLoad () {}
_canTouch = false;
async start () {
await this.getCourseList();
this._canTouch = true;
this.getCourseList();
this._inited = true;
}
onEnable() {
async onEnable() {
this._canTouch = false;
if(this._inited) {
this.getCourseList();
await this.getCourseList();
this._canTouch = true;
}
}
// update (dt) {}
......
......@@ -79,13 +79,14 @@ export default class NewClass extends cc.Component {
const res = await asyncCallNetworkApiPost('/api/kyxq/v1/login', {
phone: phone,
});
console.log(res);
if (res.code != '200') {
global.middleLayer.showTips(res.msg);
this.showEnterFail();
return;
}
global.middleLayer.isLogin = true;
cc.sys.localStorage.setItem('token', res.token);
cc.sys.localStorage.setItem('token', res.data.token);
cc.sys.localStorage.setItem('phone', phone);
this.showEnterSuccess();
......
......@@ -36,13 +36,18 @@ export default class NewClass extends cc.Component {
// onLoad () {}
start () {
// this._currentViewNode = this.loginPage;
// this._currentViewName = "LoginPage"
async start () {
const userInfo = await global.middleLayer.getUserInfo();
if (!userInfo) {
this._currentViewNode = this.loginPage;
this._currentViewName = "LoginPage"
} else {
this._currentViewNode = this.homePage;
this._currentViewName = "HomePage";
}
this._currentViewNode = this.missionPage;
this._currentViewName = "MissionPage"
// this._currentViewNode = this.missionPage;
// this._currentViewName = "MissionPage"
this._currentViewNode.active = true;
}
......
......@@ -126,6 +126,13 @@ export default class NewClass extends middleLayerBase {
cc.director['_scene'].height = frameSize.height;
}
async getUserInfo() {
const { code, data } = await this.asyncCallNetworkApiGet("/api/kyxq/v1/user/info", null);
if (code == 200) {
return data;
}
return null;
}
initListener() {
const exitBtn = cc.find('middleLayer/ExitBtn');
......
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