Commit b9bdd406 authored by limingzhe's avatar limingzhe

fix: 存储page改到store

parent 743f571c
......@@ -156,6 +156,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if (aspect) {
console.log('aspect : ', aspect);
this.initPageData(aspect);
this.initStoreData(aspect);
}
if (data && typeof data == 'object') {
......@@ -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() {
......@@ -627,23 +671,28 @@ export class PlayComponent implements OnInit, OnDestroy {
if (progress == '1') {
const resultData = this.getPageData('resultData')
const resultData = this.getStoreData('resultData')
if (resultData) {
this.initResultView(resultData);
return;
}
this.gameStart();
const progressStore = this.getStoreData('progress')
if (progressStore == '2' || progressStore == '3') {
const submitCount = this.getStoreData('submitCount')
this.submitCount = submitCount;
this.checkShowSubTemplateOne();
return;
}
if (progress == '2' || progress == '3') {
const submitCount = this.getPageData('submitCount')
this.submitCount = submitCount;
this.checkShowSubTemplateOne();
this.gameStart();
return;
}
}
......@@ -696,7 +745,7 @@ export class PlayComponent implements OnInit, OnDestroy {
} else {
const resultData = this.getResultData();
this.sendResult(resultData);
this.setPageData('resultData', resultData);
this.setStoreData('resultData', resultData);
}
......@@ -1615,7 +1664,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// this.showSubTemplate(0);
console.log(' in checkShowSubTemplateOne')
const progress = this.getPageData('progress');
const progress = this.getStoreData('progress');
console.log(' progress: ', progress);
......@@ -1719,8 +1768,8 @@ export class PlayComponent implements OnInit, OnDestroy {
delayCall(0.3, ()=> {
this.initResultView();
this.setPageData('progress', '2', false);
this.setPageData('submitCount', this.submitCount);
this.setStoreData('progress', '2', false);
this.setStoreData('submitCount', this.submitCount);
this.serverSendAnswer('4-1', this.resultAnswerArr);
})
}
......@@ -2133,11 +2182,11 @@ export class PlayComponent implements OnInit, OnDestroy {
this.serverSendAnswer(key, JSON.parse( msgData.data ));
const progress = this.getPageData('progress');
const progress = this.getStoreData('progress');
if (progress == '2') {
this.setPageData('progress', '3');
this.setStoreData('progress', '3');
} else {
this.setPageData('progress', '4');
this.setStoreData('progress', '4');
}
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