Commit e8f4db40 authored by 李维's avatar 李维

修复正常用户登录左上角用户信息错误的问题

parent 7efb6e2d
......@@ -6395,7 +6395,7 @@
"__id__": 157
}
],
"_active": false,
"_active": true,
"_components": [
{
"__id__": 158
......@@ -6717,8 +6717,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "Delia",
"_N$string": "Delia",
"_string": "",
"_N$string": "",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
......@@ -6973,8 +6973,8 @@
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "123456",
"_N$string": "123456",
"_string": "",
"_N$string": "",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
......
......@@ -134,7 +134,6 @@ export default class HomePageClass extends cc.Component {
}
getSprNodeByUrl(row.cover, async(resSpr) => {
// getSpriteFrimeByUrl(row.cover, async (spriteFrame) => {
const coverNode = cc.find(`bg`, ci);
const spr = coverNode.getComponent(cc.Sprite);
......@@ -143,10 +142,6 @@ export default class HomePageClass extends cc.Component {
spr.spriteFrame = resSpr.spriteFrame;
// const sx = 476 / coverNode.width;
// const sy = 630 / coverNode.height;
// coverNode.scale = Math.max(sx, sy);
ci.active = true;
ci.attr({syllabus_id: row.id});
ci.on("click", ()=>{
......@@ -165,7 +160,6 @@ export default class HomePageClass extends cc.Component {
} else {
this.SvContent.x = -canvas.width / 2;
}
this.loading.active = false;
}
});
......@@ -176,28 +170,30 @@ export default class HomePageClass extends cc.Component {
ci.scale = scale;
this.SvContent.addChild(ci);
}
// this.loading.active = false;
}
// onLoad () {}
userInfo;
async getUserInfo() {
this.userInfo = null;
this.initTopUserPanel();
const userInfo = await this.Viewer.getComponent("PageViewer").getUserInfo();
this.userInfo = userInfo.detail;
// 如果是匿名登录 隐藏右上角头像按钮
cc.find("/UserInfo", this.node).active = this.userInfo.isAnonymous ? true : false;
cc.find("/UserLogin", this.node).active = this.userInfo.isAnonymous ? false : true;
cc.find("/UserInfo", this.node).active = userInfo.isAnonymous ? false : true;
cc.find("/UserLogin", this.node).active = userInfo.isAnonymous ? true : false;
this.initTopUserPanel();
}
nameLabel;
goldLabel;
initTopUserPanel() {
if (!this.userInfo) {
return;
let nameLabelString = "";
let goldLabelString = "";
if (this.userInfo) {
nameLabelString = this.userInfo.nick_name;
goldLabelString = this.userInfo.golds;
}
if (!this.nameLabel) {
......@@ -207,8 +203,8 @@ export default class HomePageClass extends cc.Component {
this.goldLabel = goldLabelNode.getComponent(cc.Label);
}
this.nameLabel.string = this.userInfo.nick_name;
this.goldLabel.string = this.userInfo.golds;
this.nameLabel.string = nameLabelString;
this.goldLabel.string = goldLabelString;
}
formatDate(date) {
......@@ -227,27 +223,26 @@ export default class HomePageClass extends cc.Component {
bg.scale = Math.max(sx, sy);
}
_canTouch = false;
async start () {
this.initBg();
// 注册PageViwer发来的beforeMounted事件 [页面即将被显示]
this.node.on("beforeMounted", this.beforeMounted.bind(this));
// 注册PageViwer发来的mounted事件 [页面已经切换完毕]
this.node.on("mounted", this.mounted.bind(this));
}
async beforeMounted() {
}
async mounted() {
await this.getUserInfo();
await this.getCourseList();
this.initTopUserPanel();
this._canTouch = true;
this._inited = true;
}
async onEnable() {
this._canTouch = false;
if(this._inited) {
// await this.getCourseList();
await this.getUserInfo();
await this.getCourseList();
this.initTopUserPanel();
this._canTouch = true;
}
}
// update (dt) {}
}
......@@ -213,7 +213,7 @@ export default class PageViewerClass extends cc.Component {
return new Promise((resovle, reject)=>{
setTimeout(()=>{
resovle(true)
}, 1)
}, 200)
})
}
}
......
......@@ -355,7 +355,6 @@ export default class UnitPageClass extends cc.Component {
rowCount = 0;
colCount++;
}
}
}
......
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