Commit c69124d9 authored by 李维's avatar 李维

修改ToView方法,支持页面之间传参

parent e8f4db40
...@@ -45,7 +45,10 @@ export default class HomePageClass extends cc.Component { ...@@ -45,7 +45,10 @@ export default class HomePageClass extends cc.Component {
cc.sys.localStorage.setItem('phone', ""); cc.sys.localStorage.setItem('phone', "");
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LoginPage", "leftIn") vc.toView({
name: "LoginPage",
animation: "leftIn"
})
} }
userPagePanel; userPagePanel;
...@@ -84,7 +87,10 @@ export default class HomePageClass extends cc.Component { ...@@ -84,7 +87,10 @@ export default class HomePageClass extends cc.Component {
// 点击资源库 // 点击资源库
handleClickLibrary() { handleClickLibrary() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LibraryPage", "bottomIn") vc.toView({
name: "LibraryPage",
animation: "bottomIn"
})
} }
...@@ -93,7 +99,10 @@ export default class HomePageClass extends cc.Component { ...@@ -93,7 +99,10 @@ export default class HomePageClass extends cc.Component {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.unitPage.attr({syllabus_pid: pid}); vc.unitPage.attr({syllabus_pid: pid});
vc.unitPage.attr({pData: pData}); vc.unitPage.attr({pData: pData});
vc.toView("UnitPage", "rightIn"); vc.toView({
name: "UnitPage",
animation: "rightIn"
})
} }
// 获取课程清单 // 获取课程清单
......
...@@ -58,7 +58,7 @@ export default class LessonPreviewClass extends cc.Component { ...@@ -58,7 +58,7 @@ export default class LessonPreviewClass extends cc.Component {
getSprNodeByUrl(_data.image, (spr) => { getSprNodeByUrl(_data.image, (spr) => {
this.mask.addChild(spr.node); this.mask.addChild(spr.node);
spr.srcBlendFactor = cc.macro.BlendFactor.ONE spr.srcBlendFactor = cc.macro.BlendFactor.ONE
setSprNodeMaxLen(spr.node, this.mask.width, this.mask.height); setSprNodeMaxLen(spr.node, this.mask.width, this.mask.height, true);
}); });
this.pageLbl.string=`${this.curPageIndex+1}/${this.data.length}` this.pageLbl.string=`${this.curPageIndex+1}/${this.data.length}`
this.strItem.string=_data.text this.strItem.string=_data.text
......
...@@ -103,14 +103,14 @@ export default class LessonReportClass extends cc.Component { ...@@ -103,14 +103,14 @@ export default class LessonReportClass extends cc.Component {
let _data = this.data let _data = this.data
getSprNodeByUrl(_data.cover, (spr) => { getSprNodeByUrl(_data.cover, (spr) => {
this.mask.addChild(spr.node); this.mask.addChild(spr.node);
spr.srcBlendFactor = cc.macro.BlendFactor.ONE // spr.srcBlendFactor = cc.macro.BlendFactor.ONE
setSprNodeMaxLen(spr.node, this.mask.width, this.mask.height, true); setSprNodeMaxLen(spr.node, this.mask.width, this.mask.height, true);
}); });
const lastDate = _data.last_play ? new Date(_data.last_play) : null; const lastDate = _data.last_play ? new Date(_data.last_play) : null;
this.title.string = _data.name this.title.string = _data.name
this.unit.string = _data.unitName this.unit.string = _data.unitName
this.last_play.string = lastDate ? `${dateFormate("yyyy.MM.dd", lastDate)} 学习过` : "未学过1" this.last_play.string = lastDate ? `${dateFormate("yyyy.MM.dd", lastDate)} 学习过` : "未学过"
this.question_right_percent1.string = ""; // _data.question_right_percent // 正确率 - 白色描边 this.question_right_percent1.string = ""; // _data.question_right_percent // 正确率 - 白色描边
this.question_right_percent2.string = _data.question_right_percent // 正确率 - 主体红字 this.question_right_percent2.string = _data.question_right_percent // 正确率 - 主体红字
this.study_duration.string = _data.study_duration > 999 ? Math.floor(_data.study_duration / 60 * 10) / 10 : _data.study_duration // 学习时长 this.study_duration.string = _data.study_duration > 999 ? Math.floor(_data.study_duration / 60 * 10) / 10 : _data.study_duration // 学习时长
......
...@@ -21,7 +21,10 @@ export default class LibraryAudioPageClass extends cc.Component { ...@@ -21,7 +21,10 @@ export default class LibraryAudioPageClass extends cc.Component {
handleClickBackBtn() { handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LibraryPage", "leftIn") vc.toView({
name: "LibraryPage",
animation: "leftIn"
})
} }
// onLoad () {} // onLoad () {}
......
...@@ -23,7 +23,10 @@ export default class LibraryPageClass extends cc.Component { ...@@ -23,7 +23,10 @@ export default class LibraryPageClass extends cc.Component {
handleClickBackBtn() { handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("HomePage", "topIn"); vc.toView({
name: "HomePage",
animation: "topIn"
})
} }
handleClickReadBook(evt: cc.Event, data) { handleClickReadBook(evt: cc.Event, data) {
...@@ -35,7 +38,10 @@ export default class LibraryPageClass extends cc.Component { ...@@ -35,7 +38,10 @@ export default class LibraryPageClass extends cc.Component {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc[`library${data}Page`].attr({syllabus_pid: syllabusId, showMyWork:false}); vc[`library${data}Page`].attr({syllabus_pid: syllabusId, showMyWork:false});
vc[`library${data}Page`].attr({pData: this.libraryRows[0]}); vc[`library${data}Page`].attr({pData: this.libraryRows[0]});
vc.toView(`Library${data}Page`, "rightIn"); vc.toView({
name: `Library${data}Page`,
animation: "rightIn"
})
} }
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
...@@ -52,8 +58,6 @@ export default class LibraryPageClass extends cc.Component { ...@@ -52,8 +58,6 @@ export default class LibraryPageClass extends cc.Component {
async initView() { async initView() {
const resData = await asyncCallNetworkApiGet(`/api/kyxq/v1/library`, {}); const resData = await asyncCallNetworkApiGet(`/api/kyxq/v1/library`, {});
const {code, rows} = resData; const {code, rows} = resData;
console.log("resData: ", JSON.stringify(resData));
this.libraryRows = rows; this.libraryRows = rows;
this.btnReading[`syllabus_id`] = rows[0].id; this.btnReading[`syllabus_id`] = rows[0].id;
this.btnListening[`syllabus_id`] = rows[1].id; this.btnListening[`syllabus_id`] = rows[1].id;
......
...@@ -38,7 +38,10 @@ export default class LibraryReadDetailPageClass extends cc.Component { ...@@ -38,7 +38,10 @@ export default class LibraryReadDetailPageClass extends cc.Component {
handleClickBackBtn() { handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LibraryReadPage", "leftIn") vc.toView({
name: "LibraryReadPage",
animation: "leftIn"
})
} }
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
...@@ -214,15 +217,11 @@ export default class LibraryReadDetailPageClass extends cc.Component { ...@@ -214,15 +217,11 @@ export default class LibraryReadDetailPageClass extends cc.Component {
content.height = sv.node.height; content.height = sv.node.height;
content.removeAllChildren(); content.removeAllChildren();
console.log("content.width : " , content.width );
const tempW = content.width / col; const tempW = content.width / col;
const disX = tempW * 0.95 //1.05; const disX = tempW * 0.95 //1.05;
const baseX = -(col - 1) * 0.5 * disX; const baseX = -(col - 1) * 0.5 * disX;
let colCount = 0; let colCount = 0;
console.log("tempW : " , tempW );
if (itemArr.length<=0) return if (itemArr.length<=0) return
const disY = 80 // this._mapScaleMin; const disY = 80 // this._mapScaleMin;
......
...@@ -19,7 +19,10 @@ export default class LibraryReadPageClass extends cc.Component { ...@@ -19,7 +19,10 @@ export default class LibraryReadPageClass extends cc.Component {
handleClickBackBtn() { handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LibraryPage", "leftIn") vc.toView({
name: "LibraryPage",
animation: "leftIn"
})
} }
// onLoad () {} // onLoad () {}
...@@ -119,7 +122,10 @@ export default class LibraryReadPageClass extends cc.Component { ...@@ -119,7 +122,10 @@ export default class LibraryReadPageClass extends cc.Component {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.libraryReadDetailPage.attr({syllabus_pid: data.id}); vc.libraryReadDetailPage.attr({syllabus_pid: data.id});
vc.libraryReadDetailPage.attr({pData: data}); vc.libraryReadDetailPage.attr({pData: data});
vc.toView("LibraryReadDetailPage", "rightIn") vc.toView({
name: "LibraryReadDetailPage",
animation: "rightIn"
})
}) })
itemArr.push(itemNode); itemArr.push(itemNode);
......
...@@ -22,10 +22,16 @@ export default class LibraryVideoPageClass extends cc.Component { ...@@ -22,10 +22,16 @@ export default class LibraryVideoPageClass extends cc.Component {
handleClickBackBtn() { handleClickBackBtn() {
if (this.node['fromPage']) { if (this.node['fromPage']) {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView(this.node['fromPage'], "leftIn") vc.toView({
name: this.node['fromPage'],
animation: "leftIn"
})
} else { } else {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LibraryPage", "leftIn") vc.toView({
name: "LibraryPage",
animation: "leftIn"
})
} }
} }
...@@ -102,16 +108,9 @@ export default class LibraryVideoPageClass extends cc.Component { ...@@ -102,16 +108,9 @@ export default class LibraryVideoPageClass extends cc.Component {
itemArr[_index].y = 0 itemArr[_index].y = 0
} }
} }
// sv.content.height+=440
} }
console.log("qsj!!", sv.content.height)
sv.scrollToTop() sv.scrollToTop()
// this.initScrollViewItemRow(sv, itemArr, 4);
// sv.content.removeAllChildren()
} }
getItemArr(dataArr) { getItemArr(dataArr) {
......
...@@ -56,7 +56,6 @@ export default class LoginPageClass extends cc.Component { ...@@ -56,7 +56,6 @@ export default class LoginPageClass extends cc.Component {
initListener() { initListener() {
this.editBox.on('text-changed', (editBox) => { this.editBox.on('text-changed', (editBox) => {
// console.log('文本改变1:', editBox.string);
this.phoneNum = editBox.string; this.phoneNum = editBox.string;
if (this.phoneNum.length >= 11) { if (this.phoneNum.length >= 11) {
this.showYellowBtn(); this.showYellowBtn();
...@@ -253,7 +252,10 @@ export default class LoginPageClass extends cc.Component { ...@@ -253,7 +252,10 @@ export default class LoginPageClass extends cc.Component {
showHomePage() { showHomePage() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("HomePage", "rightIn") vc.toView({
name: "HomePage",
animation: "rightIn"
})
} }
onEnable(): void { onEnable(): void {
......
...@@ -48,7 +48,10 @@ export default class MissionPageClass extends cc.Component { ...@@ -48,7 +48,10 @@ export default class MissionPageClass extends cc.Component {
handleClickBackBtn() { handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("UnitPage", "leftIn") vc.toView({
name: "UnitPage",
animation: "leftIn"
})
} }
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
...@@ -70,7 +73,11 @@ export default class MissionPageClass extends cc.Component { ...@@ -70,7 +73,11 @@ export default class MissionPageClass extends cc.Component {
content.removeAllChildren(); content.removeAllChildren();
} }
async mounted() { async mounted(unitConfigData) {
// unitConfigData 是从Unit层传进来的config配置参数,如果是从模板返回到Mission层,这个配置文件是没有的
const customBgUrl = unitConfigData && unitConfigData.mission_bg_url ? unitConfigData.mission_bg_url : "";
this.initCustomBg(customBgUrl);
this.loading.active = true; this.loading.active = true;
this.scrollView.opacity = 0; this.scrollView.opacity = 0;
...@@ -124,7 +131,6 @@ export default class MissionPageClass extends cc.Component { ...@@ -124,7 +131,6 @@ export default class MissionPageClass extends cc.Component {
} }
} }
this.initCustomBg(bgImageUrl);
this.refreshConfig() this.refreshConfig()
// 数据汇报 // 数据汇报
......
...@@ -130,7 +130,17 @@ export default class PageViewerClass extends cc.Component { ...@@ -130,7 +130,17 @@ export default class PageViewerClass extends cc.Component {
_currentViewName = "" _currentViewName = ""
_currentViewNode = null _currentViewNode = null
async toView(viewName, aniType="fade-in-out") { async toView(param, data = {}) {
let viewName = "";
let animation = "";
if(typeof param == 'object') {
viewName = param.name ? param.name : "";
animation = param.animation ? param.animation : "";
} else if(typeof param == 'string') {
viewName = param;
animation = ""
}
if(viewName == this._currentViewName) { if(viewName == this._currentViewName) {
cc.log(`重复跳转页面: ${this._currentViewName}`); cc.log(`重复跳转页面: ${this._currentViewName}`);
return return
...@@ -144,11 +154,11 @@ export default class PageViewerClass extends cc.Component { ...@@ -144,11 +154,11 @@ export default class PageViewerClass extends cc.Component {
// 触发页面beforeMounted生命周期 // 触发页面beforeMounted生命周期
this[PageMap[viewName]].emit("beforeMounted"); this[PageMap[viewName]].emit("beforeMounted");
// 切换页面 // 切换页面
await this.switchView(this[PageMap[viewName]], this._currentViewNode, aniType); await this.switchView(this[PageMap[viewName]], this._currentViewNode, animation);
this._currentViewName = viewName; this._currentViewName = viewName;
this._currentViewNode = this[PageMap[viewName]]; this._currentViewNode = this[PageMap[viewName]];
// mounted // mounted
this._currentViewNode.emit("mounted") this._currentViewNode.emit("mounted", data)
} }
switchView(inPage, outPage, aniType) { switchView(inPage, outPage, aniType) {
......
...@@ -32,7 +32,10 @@ export default class UnitPageClass extends cc.Component { ...@@ -32,7 +32,10 @@ export default class UnitPageClass extends cc.Component {
handleClickBackBtn() { handleClickBackBtn() {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("HomePage", "leftIn") vc.toView({
name: "HomePage",
animation: "leftIn"
})
} }
// LIFE-CYCLE CALLBACKS: // LIFE-CYCLE CALLBACKS:
...@@ -179,8 +182,7 @@ export default class UnitPageClass extends cc.Component { ...@@ -179,8 +182,7 @@ export default class UnitPageClass extends cc.Component {
// 课程配置文件 // 课程配置文件
const _strData = (v.children && v.children[0] && v.children[0].template_name == "sn_config" && v.children[0].data) ? v.children && v.children[0] && v.children[0].data : "{}" const _strData = (v.children && v.children[0] && v.children[0].template_name == "sn_config" && v.children[0].data) ? v.children && v.children[0] && v.children[0].data : "{}"
this.configData = JSON.parse(_strData) this.configData = JSON.parse(_strData)
bgImageUrl = this.configData.bg_image_url bgImageUrl = this.configData.unit_bg_url;
} else { } else {
// 课程数据 // 课程数据
rows.push(v) rows.push(v)
...@@ -305,7 +307,10 @@ export default class UnitPageClass extends cc.Component { ...@@ -305,7 +307,10 @@ export default class UnitPageClass extends cc.Component {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.missionPage.attr({ syllabus_pid: subData.id }); vc.missionPage.attr({ syllabus_pid: subData.id });
vc.missionPage.attr({ pData: subData }); vc.missionPage.attr({ pData: subData });
vc.toView("MissionPage", "rightIn") vc.toView({
name: "MissionPage",
animation: "rightIn"
}, this.configData)
}) })
} }
...@@ -373,7 +378,10 @@ export default class UnitPageClass extends cc.Component { ...@@ -373,7 +378,10 @@ export default class UnitPageClass extends cc.Component {
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc[`libraryVideoPage`].attr({ syllabus_pid: this.node['syllabus_pid'], showMyWork: true }); vc[`libraryVideoPage`].attr({ syllabus_pid: this.node['syllabus_pid'], showMyWork: true });
vc[`libraryVideoPage`].attr({ fromPage: "UnitPage" }); vc[`libraryVideoPage`].attr({ fromPage: "UnitPage" });
vc.toView(`LibraryVideoPage`, "rightIn"); vc.toView({
name: "LibraryVideoPage",
animation: "rightIn"
})
} }
// update (dt) {} // update (dt) {}
} }
......
...@@ -72,7 +72,10 @@ export default class UserPageClass extends cc.Component { ...@@ -72,7 +72,10 @@ export default class UserPageClass extends cc.Component {
// 跳转登录页面 // 跳转登录页面
const vc = this.Viewer.getComponent("PageViewer"); const vc = this.Viewer.getComponent("PageViewer");
vc.toView("LoginPage", "leftIn") vc.toView({
name: "LoginPage",
animation: "leftIn"
})
} }
clickPopupAccountModal() { clickPopupAccountModal() {
......
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