Commit 77236077 authored by 李维's avatar 李维

修复匿名登录仍然显示用户名的Bug

parent cae7f496
...@@ -174,17 +174,17 @@ export default class NewClass extends cc.Component { ...@@ -174,17 +174,17 @@ export default class NewClass extends cc.Component {
userInfo; userInfo;
async getUserInfo() { async getUserInfo() {
const userInfo = await this.Viewer.getComponent("PageViewer").getUserInfo(); const userInfo = await this.Viewer.getComponent("PageViewer").getUserInfo();
console.log(userInfo)
this.userInfo = userInfo.detail; this.userInfo = userInfo.detail;
// 如果是匿名登录 隐藏右上角头像按钮 // 如果是匿名登录 隐藏右上角头像按钮
cc.find("/UserInfo", this.node).active = this.userInfo.isAnonymous ? false : true; cc.find("/UserInfo", this.node).active = this.userInfo.isAnonymous ? true : false;
cc.find("/UserLogin", this.node).active = this.userInfo.isAnonymous ? true : false; cc.find("/UserLogin", this.node).active = this.userInfo.isAnonymous ? false : true;
this.initTopUserPanel(); this.initTopUserPanel();
} }
nameLabel; nameLabel;
goldLabel; goldLabel;
initTopUserPanel() { initTopUserPanel() {
if (!this.userInfo) { if (!this.userInfo) {
return; return;
} }
...@@ -192,21 +192,18 @@ export default class NewClass extends cc.Component { ...@@ -192,21 +192,18 @@ export default class NewClass extends cc.Component {
if (!this.nameLabel) { if (!this.nameLabel) {
const nameLabelNode = cc.find("userName", this.topUserPanel); const nameLabelNode = cc.find("userName", this.topUserPanel);
const goldLabelNode = cc.find("userPoints/gold", this.topUserPanel); const goldLabelNode = cc.find("userPoints/gold", this.topUserPanel);
this.nameLabel = nameLabelNode.getComponent(cc.Label); this.nameLabel = nameLabelNode.getComponent(cc.Label);
this.goldLabel = goldLabelNode.getComponent(cc.Label); this.goldLabel = goldLabelNode.getComponent(cc.Label);
} }
this.nameLabel.string = this.userInfo.nick_name; this.nameLabel.string = this.userInfo.nick_name;
this.goldLabel.string = this.userInfo.golds; this.goldLabel.string = this.userInfo.golds;
} }
formatDate(date) { formatDate(date) {
const year = date.getFullYear(); const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1并且补零 const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1并且补零
const day = String(date.getDate()).padStart(2, '0'); // 补零 const day = String(date.getDate()).padStart(2, '0'); // 补零
return `${year}/${month}/${day}/加入`; return `${year}/${month}/${day}/加入`;
} }
......
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