Commit 47e23185 authored by limingzhe's avatar limingzhe

fix: debug

parent a1db9c7b
...@@ -4639,7 +4639,7 @@ ...@@ -4639,7 +4639,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "icon_present", "_name": "icon",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 95 "__id__": 95
...@@ -4733,7 +4733,7 @@ ...@@ -4733,7 +4733,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "num", "_name": "gold",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 95 "__id__": 95
...@@ -7444,7 +7444,7 @@ ...@@ -7444,7 +7444,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "phone_label", "_name": "label",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 152 "__id__": 152
...@@ -7736,7 +7736,7 @@ ...@@ -7736,7 +7736,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "phone_label", "_name": "label",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 158 "__id__": 158
...@@ -9724,6 +9724,9 @@ ...@@ -9724,6 +9724,9 @@
"userPage": { "userPage": {
"__id__": 134 "__id__": 134
}, },
"topUserPanel": {
"__id__": 88
},
"CourseItem": { "CourseItem": {
"__id__": 119 "__id__": 119
}, },
......
...@@ -12,6 +12,9 @@ export default class NewClass extends cc.Component { ...@@ -12,6 +12,9 @@ export default class NewClass extends cc.Component {
@property(cc.Node) @property(cc.Node)
userPage: cc.Node = null; userPage: cc.Node = null;
@property(cc.Node)
topUserPanel: cc.Node = null;
@property(cc.Node) @property(cc.Node)
CourseItem: cc.Node = null; CourseItem: cc.Node = null;
...@@ -30,8 +33,42 @@ export default class NewClass extends cc.Component { ...@@ -30,8 +33,42 @@ export default class NewClass extends cc.Component {
handleClickUserCenter() { handleClickUserCenter() {
this.userPage.active = true; this.userPage.active = true;
// const vc = this.Viewer.getComponent("PageViewer");
// vc.toView("UserPage", "topIn") this.refreshUserPage();
}
userPagePanel;
userPageName;
userPagePhone;
userPageGold;
userPageClass;
userPageTeacher;
userPageTime;
userPageVersion;
async refreshUserPage() {
if (!this.userPagePanel) {
this.userPagePanel = cc.find("user_info/panel", this.userPage);
this.userPageName = cc.find("left_part/name_label", this.userPagePanel).getComponent(cc.Label);
this.userPagePhone = cc.find("left_part/phone_bg/label", this.userPagePanel).getComponent(cc.Label);
this.userPageGold = cc.find("left_part/gold_bg/label", this.userPagePanel).getComponent(cc.Label);
this.userPageVersion = cc.find("left_part/version_label", this.userPagePanel).getComponent(cc.Label);
this.userPageClass = cc.find("right_part/class/label", this.userPagePanel).getComponent(cc.Label);
this.userPageTeacher = cc.find("right_part/teacher/label", this.userPagePanel).getComponent(cc.Label);
this.userPageTime = cc.find("right_part/time/label", this.userPagePanel).getComponent(cc.Label);
}
this.userPageName.string = this.userInfo.nick_name;
this.userPagePhone.string = this.userInfo.phone;
this.userPageGold.string = this.userInfo.golds;
this.userPageClass.string = this.userInfo.class_name || '--';
this.userPageTeacher.string = this.userInfo.tea_name || '--';
this.userPageTime.string = this.formatDate(new Date(this.userInfo.create_at));
const engineInfo = await global.middleLayer.getEngineInfo();
this.userPageVersion.string = 'v' + engineInfo.version;
} }
// 点击资源库 // 点击资源库
...@@ -97,27 +134,69 @@ export default class NewClass extends cc.Component { ...@@ -97,27 +134,69 @@ export default class NewClass extends cc.Component {
// onLoad () {} // onLoad () {}
userInfo;
async getUserInfo() { async getUserInfo() {
this.userInfo = await global.middleLayer.getUserInfo();
console.log("userInfo: ", this.userInfo);
this.initTopUserPanel();
// const token = cc.sys.localStorage.getItem('token');
// if (!token) {
// console.log('token not exist!');
// return;
// } else {
// console.log('token: ', token);
// }
// const resData = await asyncCallNetworkApiGet('/api/kyxq/v1/user/info', {token});
// console.log("userInfo: ", resData);
// this.userInfo = resData;
}
// const userInfo = await global.middleLayer.getUserInfo(); nameLabel;
goldLabel;
initTopUserPanel() {
const token = cc.sys.localStorage.getItem('token'); if (!this.userInfo) {
if (!token) {
console.log('token not exist!');
return; return;
} }
if (!this.nameLabel) {
const nameLabelNode = cc.find("userName", this.topUserPanel);
const goldLabelNode = cc.find("userPoints/gold", this.topUserPanel);
this.nameLabel = nameLabelNode.getComponent(cc.Label);
this.goldLabel = goldLabelNode.getComponent(cc.Label);
}
this.nameLabel.string = this.userInfo.nick_name;
this.goldLabel.string = this.userInfo.golds;
}
formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1并且补零
const day = String(date.getDate()).padStart(2, '0'); // 补零
const resData = await asyncCallNetworkApiGet('/api/kyxq/v1/user/info', {token}); return `${year}/${month}/${day}/加入`;
console.log("userInfo: ", resData); }
initBg() {
const canvas = cc.find("Canvas");
const bg = cc.find("bg/bg", this.node);
const sx = canvas.width / bg.width;
const sy = canvas.height / bg.height;
bg.scale = Math.max(sx, sy);
} }
_canTouch = false; _canTouch = false;
async start () { async start () {
await this.getCourseList(); await this.getCourseList();
await this.getUserInfo(); await this.getUserInfo();
this.initTopUserPanel();
this._canTouch = true; this._canTouch = true;
this._inited = true; this._inited = true;
...@@ -125,18 +204,13 @@ export default class NewClass extends cc.Component { ...@@ -125,18 +204,13 @@ export default class NewClass extends cc.Component {
this.initBg(); this.initBg();
} }
initBg() {
const canvas = cc.find("Canvas");
const bg = cc.find("bg/bg", this.node);
const sx = canvas.width / bg.width;
const sy = canvas.height / bg.height;
bg.scale = Math.max(sx, sy);
}
async onEnable() { async onEnable() {
this._canTouch = false; this._canTouch = false;
this.initTopUserPanel();
if(this._inited) { if(this._inited) {
await this.getCourseList(); await this.getCourseList();
// await this.getUserInfo(); // await this.getUserInfo();
......
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