Commit e8f4db40 authored by 李维's avatar 李维

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

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