69f9df43 by simon

Merge branch 'master' of 120.27.44.69:dev/pingan-life-index-pro

2 parents 578e5180 9b0ee30e
...@@ -105,7 +105,14 @@ export default { ...@@ -105,7 +105,14 @@ export default {
105 // 公历假期,缺少复活节,缺少聖誕節後第一個周日 105 // 公历假期,缺少复活节,缺少聖誕節後第一個周日
106 gl: [[1, 1], [4, 10], [4, 11], [4, 30], [5, 1], [7, 1], [10, 1], [10, 2], [12, 25]], 106 gl: [[1, 1], [4, 10], [4, 11], [4, 30], [5, 1], [7, 1], [10, 1], [10, 2], [12, 25]],
107 // 农历假期,缺少清明节 107 // 农历假期,缺少清明节
108 nl: [[1, 1], [1, 2], [1, 3], [5, 5], [8, 15], [9, 9]] 108 nl: [[1, 1], [1, 2], [1, 3], [5, 5], [8, 15], [9, 9]],
109 // 清明节
110 qm: [
111 // 4月4号
112 ["2020", "2021", "2024", "2025", "2028", "2029", "2032", "2033", "2036", "2037"],
113 // 4月5号
114 ["2022", "2023", "2026", "2027", "2030", "2031", "2034", "2035", "2038", "2039"]
115 ]
109 }, 116 },
110 // 节假日,key是月份,value是日期列表 117 // 节假日,key是月份,value是日期列表
111 // holiday: { 118 // holiday: {
...@@ -115,7 +122,7 @@ export default { ...@@ -115,7 +122,7 @@ export default {
115 }, 122 },
116 components: {}, 123 components: {},
117 computed: { 124 computed: {
118 holiday(){ 125 holiday() {
119 // 计算新历 126 // 计算新历
120 let result = {}; 127 let result = {};
121 let year = this.year; 128 let year = this.year;
...@@ -123,20 +130,38 @@ export default { ...@@ -123,20 +130,38 @@ export default {
123 return; 130 return;
124 } 131 }
125 let hkHolidayDefine = this.hkHolidayDefine; 132 let hkHolidayDefine = this.hkHolidayDefine;
133
134
135 // 加入清明节
136 if (hkHolidayDefine.qm[0].indexOf(year + "") >= 0) {
137 // 如果是周六/周日,顺延到下周一
138 let vals = this.checkWeeken(4, 4);
139 let m = vals[0];
140 let d = vals[1];
141 result[m] = [d];
142 } else if (hkHolidayDefine.qm[1].indexOf(year + "") >= 0) {
143 // 如果是周六/周日,顺延到下周一
144 let vals = this.checkWeeken(4, 5);
145 let m = vals[0];
146 let d = vals[1];
147 result[m] = [d];
148 } else {
149 let mod = year % 4;
150 let d = mod == 0 || mod == 1 ? 4 : 5;
151 let vals = this.checkWeeken(4, d);
152 let m = vals[0];
153 d = vals[1];
154 result[m] = [d];
155 }
156
126 for (let index = 0; index < hkHolidayDefine.gl.length; index++) { 157 for (let index = 0; index < hkHolidayDefine.gl.length; index++) {
127 let m = hkHolidayDefine.gl[index][0]; 158 let m = hkHolidayDefine.gl[index][0];
128 let d = hkHolidayDefine.gl[index][1]; 159 let d = hkHolidayDefine.gl[index][1];
129 160
130 // 如果是周六/周日,顺延到下周一 161 // 如果是周六/周日,顺延到下周一
131 let date = Date.parse(`${year}.${m}.${d}`); 162 let vals = this.checkWeeken(m, d);
132 if (date.getDay() == 6) { 163 m = vals[0];
133 // 周六 164 d = vals[1];
134 date.addDays(2);
135 } else if (date.getDay() == 0) {
136 date.addDays(1);
137 }
138 m = date.getMonth() + 1;
139 d = date.getDate();
140 165
141 let list = result[m]; 166 let list = result[m];
142 if (!list) { 167 if (!list) {
...@@ -155,17 +180,11 @@ export default { ...@@ -155,17 +180,11 @@ export default {
155 m = gl[1]; 180 m = gl[1];
156 d = gl[2]; 181 d = gl[2];
157 182
158 // 如果是周六/周日,顺延到下周一
159 let date = Date.parse(`${year}.${m}.${d}`);
160 183
161 if (date.getDay() == 6) { 184 // 如果是周六/周日,顺延到下周一
162 // 周六 185 let vals = this.checkWeeken(m, d);
163 date.addDays(2); 186 m = vals[0];
164 } else if (date.getDay() == 0) { 187 d = vals[1];
165 date.addDays(1);
166 }
167 m = date.getMonth() + 1;
168 d = date.getDate();
169 188
170 let list = result[m]; 189 let list = result[m];
171 if (!list) { 190 if (!list) {
...@@ -278,7 +297,7 @@ export default { ...@@ -278,7 +297,7 @@ export default {
278 if (isWeekend) { 297 if (isWeekend) {
279 disable = true; 298 disable = true;
280 } else { 299 } else {
281 let holidayCandidates = this.holiday[month+""]; 300 let holidayCandidates = this.holiday[month + ""];
282 if (holidayCandidates && holidayCandidates.indexOf(date) != -1) { 301 if (holidayCandidates && holidayCandidates.indexOf(date) != -1) {
283 disable = true; 302 disable = true;
284 } 303 }
...@@ -595,68 +614,21 @@ export default { ...@@ -595,68 +614,21 @@ export default {
595 614
596 }, 615 },
597 calculateHolidays() { 616 calculateHolidays() {
598 // 计算新历
599 let result = {};
600 let year = this.year;
601 if (!year) {
602 return;
603 }
604 let hkHolidayDefine = this.hkHolidayDefine;
605 for (let index = 0; index < hkHolidayDefine.gl.length; index++) {
606 let m = hkHolidayDefine.gl[index][0];
607 let d = hkHolidayDefine.gl[index][1];
608 617
609 // 如果是周六/周日,顺延到下周一 618 },
610 let date = Date.parse(`${year}.${m}.${d}`); 619 checkWeeken(m, d) {
611 if (date.getDay() == 6) { 620 let year = this.year;
612 // 周六
613 date.addDays(2);
614 } else if (date.getDay() == 0) {
615 date.addDays(1);
616 }
617 m = date.getMonth() + 1;
618 d = date.getDate();
619
620 let list = result[m];
621 if (!list) {
622 result[m] = [];
623 list = result[m];
624 }
625 list.push(d);
626 }
627
628
629 for (let index = 0; index < hkHolidayDefine.nl.length; index++) {
630 let m = hkHolidayDefine.nl[index][0];
631 let d = hkHolidayDefine.nl[index][1];
632 let gl = toSolar(year, m, d);
633
634 m = gl[1];
635 d = gl[2];
636
637 // 如果是周六/周日,顺延到下周一
638 let date = Date.parse(`${year}.${m}.${d}`); 621 let date = Date.parse(`${year}.${m}.${d}`);
639 622 // if (date.getDay() == 6) {
640 if (date.getDay() == 6) { 623 // // 周六
641 // 周六 624 // date.addDays(2);
642 date.addDays(2); 625 // } else
643 } else if (date.getDay() == 0) { 626 if (date.getDay() == 0) {
644 date.addDays(1); 627 date.addDays(1);
645 } 628 }
646 m = date.getMonth() + 1; 629 m = date.getMonth() + 1;
647 d = date.getDate(); 630 d = date.getDate();
648 631 return [m, d];
649 let list = result[m];
650 if (!list) {
651 result[m] = [];
652 list = result[m];
653 }
654 list.push(d);
655 }
656
657 this.holiday = result;
658 console.log(JSON.stringify(this.holiday));
659
660 } 632 }
661 }, 633 },
662 mounted() { }, 634 mounted() { },
......
...@@ -141,6 +141,7 @@ export default { ...@@ -141,6 +141,7 @@ export default {
141 } 141 }
142 }, 142 },
143 logoutHandler() { 143 logoutHandler() {
144 this.clearCache();
144 httpPost({ 145 httpPost({
145 url: api.logout 146 url: api.logout
146 }).then(() => { 147 }).then(() => {
...@@ -148,6 +149,13 @@ export default { ...@@ -148,6 +149,13 @@ export default {
148 this.showLogoutTip(); 149 this.showLogoutTip();
149 }); 150 });
150 }, 151 },
152 clearCache() {
153 for (let index = 0; index < sessionStorage.length; index++) {
154 let key = sessionStorage.key(index);
155 console.log(key);
156 sessionStorage.removeItem(key);
157 }
158 },
151 showLogoutTip() { 159 showLogoutTip() {
152 // 登出后的提示 160 // 登出后的提示
153 // alert("登出成功"); 161 // alert("登出成功");
......