Commit 47e23185 authored by limingzhe's avatar limingzhe

fix: debug

parent a1db9c7b
......@@ -4639,7 +4639,7 @@
},
{
"__type__": "cc.Node",
"_name": "icon_present",
"_name": "icon",
"_objFlags": 0,
"_parent": {
"__id__": 95
......@@ -4733,7 +4733,7 @@
},
{
"__type__": "cc.Node",
"_name": "num",
"_name": "gold",
"_objFlags": 0,
"_parent": {
"__id__": 95
......@@ -7444,7 +7444,7 @@
},
{
"__type__": "cc.Node",
"_name": "phone_label",
"_name": "label",
"_objFlags": 0,
"_parent": {
"__id__": 152
......@@ -7736,7 +7736,7 @@
},
{
"__type__": "cc.Node",
"_name": "phone_label",
"_name": "label",
"_objFlags": 0,
"_parent": {
"__id__": 158
......@@ -9724,6 +9724,9 @@
"userPage": {
"__id__": 134
},
"topUserPanel": {
"__id__": 88
},
"CourseItem": {
"__id__": 119
},
......
......@@ -12,6 +12,9 @@ export default class NewClass extends cc.Component {
@property(cc.Node)
userPage: cc.Node = null;
@property(cc.Node)
topUserPanel: cc.Node = null;
@property(cc.Node)
CourseItem: cc.Node = null;
......@@ -30,8 +33,42 @@ export default class NewClass extends cc.Component {
handleClickUserCenter() {
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 {
// onLoad () {}
userInfo;
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 (!token) {
console.log('token not exist!');
if (!this.userInfo) {
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});
console.log("userInfo: ", resData);
return `${year}/${month}/${day}/加入`;
}
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;
async start () {
await this.getCourseList();
await this.getUserInfo();
this.initTopUserPanel();
this._canTouch = true;
this._inited = true;
......@@ -125,18 +204,13 @@ export default class NewClass extends cc.Component {
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() {
this._canTouch = false;
this.initTopUserPanel();
if(this._inited) {
await this.getCourseList();
// 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