Authored by 郭成尧

throttling

@@ -54,6 +54,9 @@ class GradeDetailPage extends Page { @@ -54,6 +54,9 @@ class GradeDetailPage extends Page {
54 this.noListData = false; 54 this.noListData = false;
55 this.graphData = {}; 55 this.graphData = {};
56 56
  57 + this.timer = null;
  58 + this.cacheMouthDetailResult = [];
  59 +
57 this.graphRender(); 60 this.graphRender();
58 this.monthDetailRender(true); 61 this.monthDetailRender(true);
59 62
@@ -81,6 +84,11 @@ class GradeDetailPage extends Page { @@ -81,6 +84,11 @@ class GradeDetailPage extends Page {
81 * 滑动事件处理 84 * 滑动事件处理
82 */ 85 */
83 dataZoomEvent() { 86 dataZoomEvent() {
  87 + if (this.timer) {
  88 + clearTimeout(this.timer);
  89 + }
  90 +
  91 + this.timer = setTimeout(() => {
84 let optionData = this.eGradeGraph.getOption(); 92 let optionData = this.eGradeGraph.getOption();
85 let endIndex = optionData.dataZoom[0].endValue; 93 let endIndex = optionData.dataZoom[0].endValue;
86 94
@@ -105,6 +113,7 @@ class GradeDetailPage extends Page { @@ -105,6 +113,7 @@ class GradeDetailPage extends Page {
105 }) 113 })
106 }, true); 114 }, true);
107 } 115 }
  116 + }, 200);
108 } 117 }
109 118
110 /** 119 /**
@@ -208,6 +217,19 @@ class GradeDetailPage extends Page { @@ -208,6 +217,19 @@ class GradeDetailPage extends Page {
208 217
209 this.page++; 218 this.page++;
210 this.requesting = true; 219 this.requesting = true;
  220 +
  221 + let cacheResult = this.cacheMouthDetailResult[`${this.year}:${this.month}:${this.page}`];
  222 +
  223 + if (cacheResult) {
  224 + if (isInit) {
  225 + this.view.gradeBillList.html(cacheResult);
  226 + } else {
  227 + this.view.gradeBillList.append(cacheResult);
  228 + }
  229 + this.requesting = false;
  230 + return;
  231 + }
  232 +
211 this.ajax({ 233 this.ajax({
212 url: '/activity/grade/monthDetail', 234 url: '/activity/grade/monthDetail',
213 data: { 235 data: {
@@ -225,6 +247,7 @@ class GradeDetailPage extends Page { @@ -225,6 +247,7 @@ class GradeDetailPage extends Page {
225 this.view.gradeBillList.append(monthDetailPage); 247 this.view.gradeBillList.append(monthDetailPage);
226 } 248 }
227 249
  250 + this.cacheMouthDetailResult[`${this.year}:${this.month}:${this.page}`] = monthDetailPage;
228 return; 251 return;
229 } 252 }
230 253