Commit 48461b5c authored by liujiangnan's avatar liujiangnan

feat: 类型

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