Commit b9bdd406 authored by limingzhe's avatar limingzhe

fix: 存储page改到store

parent 743f571c
...@@ -156,6 +156,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -156,6 +156,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if (aspect) { if (aspect) {
console.log('aspect : ', aspect); console.log('aspect : ', aspect);
this.initPageData(aspect); this.initPageData(aspect);
this.initStoreData(aspect);
} }
if (data && typeof data == 'object') { if (data && typeof data == 'object') {
...@@ -228,6 +229,49 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -228,6 +229,49 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
// 用于存储私有数据 当翻页时清空
storeData;
initStoreData(aspect) {
const storeDataStr = aspect?.user_aspect;
if (!storeDataStr) {
this.storeData = {};
} else {
this.storeData = JSON.parse(storeDataStr);
}
console.log('this.storeData: ', this.storeData);
}
setStoreData(key, value, isSend=true) {
if (this.storeData) {
console.log('this.storeData: ', this.storeData);
this.storeData[key] = value;
if (isSend) {
this.sendStoreData();
}
}
}
getStoreData(key) {
return this.storeData && this.storeData[key];
}
sendStoreData() {
const data = this.storeData;
if (window && window['courseware']) {
let storeAspect = window['courseware'].storeAspect;
if (storeAspect) {
storeAspect(data);
}
}
}
initDefaultData() { initDefaultData() {
...@@ -627,22 +671,27 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -627,22 +671,27 @@ export class PlayComponent implements OnInit, OnDestroy {
if (progress == '1') { if (progress == '1') {
const resultData = this.getPageData('resultData') const resultData = this.getStoreData('resultData')
if (resultData) { if (resultData) {
this.initResultView(resultData); this.initResultView(resultData);
return; return;
} }
const progressStore = this.getStoreData('progress')
if (progressStore == '2' || progressStore == '3') {
const submitCount = this.getStoreData('submitCount')
this.submitCount = submitCount;
this.checkShowSubTemplateOne();
return;
}
this.gameStart(); this.gameStart();
return; return;
} }
if (progress == '2' || progress == '3') {
const submitCount = this.getPageData('submitCount')
this.submitCount = submitCount;
this.checkShowSubTemplateOne();
return;
}
} }
...@@ -696,7 +745,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -696,7 +745,7 @@ export class PlayComponent implements OnInit, OnDestroy {
} else { } else {
const resultData = this.getResultData(); const resultData = this.getResultData();
this.sendResult(resultData); this.sendResult(resultData);
this.setPageData('resultData', resultData); this.setStoreData('resultData', resultData);
} }
...@@ -1615,10 +1664,10 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1615,10 +1664,10 @@ export class PlayComponent implements OnInit, OnDestroy {
// this.showSubTemplate(0); // this.showSubTemplate(0);
console.log(' in checkShowSubTemplateOne') console.log(' in checkShowSubTemplateOne')
const progress = this.getPageData('progress'); const progress = this.getStoreData('progress');
console.log(' progress: ', progress); console.log(' progress: ', progress);
if (progress == '2') { if (progress == '2') {
...@@ -1719,8 +1768,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1719,8 +1768,8 @@ export class PlayComponent implements OnInit, OnDestroy {
delayCall(0.3, ()=> { delayCall(0.3, ()=> {
this.initResultView(); this.initResultView();
this.setPageData('progress', '2', false); this.setStoreData('progress', '2', false);
this.setPageData('submitCount', this.submitCount); this.setStoreData('submitCount', this.submitCount);
this.serverSendAnswer('4-1', this.resultAnswerArr); this.serverSendAnswer('4-1', this.resultAnswerArr);
}) })
} }
...@@ -2133,11 +2182,11 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2133,11 +2182,11 @@ export class PlayComponent implements OnInit, OnDestroy {
this.serverSendAnswer(key, JSON.parse( msgData.data )); this.serverSendAnswer(key, JSON.parse( msgData.data ));
const progress = this.getPageData('progress'); const progress = this.getStoreData('progress');
if (progress == '2') { if (progress == '2') {
this.setPageData('progress', '3'); this.setStoreData('progress', '3');
} else { } else {
this.setPageData('progress', '4'); this.setStoreData('progress', '4');
} }
console.log('in temp_send_result __ msgData: ', msgData); console.log('in temp_send_result __ msgData: ', msgData);
} }
......
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