Commit 48461b5c authored by liujiangnan's avatar liujiangnan

feat: 类型

parent 34cb16d7
......@@ -7,6 +7,13 @@ const levels = {
ydjyz: [],
};
let reportType = "pdtd";
const reportObj = {
"pdtd": "拼读天地",
"qwqd": "趣问趣答",
"ydjyz": "阅读加油站",
};
@ccclass
export default class NewClass extends cc.Component {
......@@ -42,12 +49,7 @@ export default class NewClass extends cc.Component {
return rows;
}
reportType = "pdtd";
reportObj = {
"pdtd": "拼读天地",
"qwqd": "趣问趣答",
"ydjyz": "阅读加油站",
};
userInfo = null;
// 查看拼读天地详情
async onClickView(evt, type) {
......@@ -58,17 +60,17 @@ export default class NewClass extends cc.Component {
return;
}
this.userInfo = JSON.parse(userInfo);
this.reportType = type;
reportType = type;
this.showLoading();
cc.find("Canvas/learnreport").active = true;
cc.find("Canvas/usercenter").active = false;
cc.find("Canvas/learnreport/avatar").getComponent(cc.Sprite).spriteFrame = cc.find(`Canvas/avatars/${this.userInfo.avatar_url||1}`).getComponent(cc.Sprite).spriteFrame;
await this.loadSyllabusTree();
if(this.reportType === 'pdtd') {
if(reportType === 'pdtd') {
await this.drawPagePdtd();
}
if(this.reportType === 'ydjyz') {
if(reportType === 'ydjyz') {
await this.drawPageYdjyz();
}
this.hideLoading();
......@@ -89,10 +91,10 @@ export default class NewClass extends cc.Component {
async drawPagePdtd() {
const node = cc.find("Canvas/learnreport");
cc.find("typeLabel", node).getComponent(cc.Label).string = this.reportObj[this.reportType];
cc.find("typeLabel", node).getComponent(cc.Label).string = reportObj[reportType];
// 设置每个级别激活状态(是否显示锁头)
const levelIds = levels[this.reportType].map(item => item.id);
const levelIds = levels[reportType].map(item => item.id);
const unLocks = this.getUnlockSyllabuses();
for (let i = 1; i < 5; i++) {
const id = levelIds[i];
......@@ -108,11 +110,11 @@ export default class NewClass extends cc.Component {
async drawPageYdjyz() {
const node = cc.find("Canvas/learnreport");
cc.find("typeLabel", node).getComponent(cc.Label).string = this.reportObj[this.reportType];
cc.find("typeLabel", node).getComponent(cc.Label).string = reportObj[reportType];
// 设置每个级别激活状态(是否显示锁头)
for (let i = 1; i < 5; i++) {
cc.find(`level${i+1}/lock_1`, node).active = false;
cc.find(`level${i+1}/lock_1`, node).active = (i >= 3);
}
// 激活索引为0的Level
await this.drawPageItems(0);
......@@ -132,15 +134,15 @@ export default class NewClass extends cc.Component {
const node = cc.find("Canvas/learnreport");
this.activeLevelIndex(index);
let rows = [];
if (levels[this.reportType][index]) {
rows = await this.loadData(levels[this.reportType][index].id);
if (levels[reportType][index]) {
rows = await this.loadData(levels[reportType][index].id);
rows = rows.filter(item => item.name.trim() !=='more games');
}
let unLocks = [];
if (this.reportType === 'pdtd') {
if (reportType === 'pdtd') {
unLocks = this.getUnlockSyllabuses();
}
if (this.reportType === 'ydjyz') {
if (reportType === 'ydjyz') {
// 全都解锁(没有解锁逻辑)
unLocks = rows.map(item => item.id);
}
......@@ -485,7 +487,7 @@ export default class NewClass extends cc.Component {
// 返回用户中心
async onClickBackToUserCenter() {
this.reportType = null;
reportType = null;
this.clearnContent();
cc.find("Canvas/usercenter").active = true;
cc.find("Canvas/learnreport").active = false;
......
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