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,66 +122,78 @@ export default { ...@@ -115,66 +122,78 @@ 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;
122 if (!year) { 129 if (!year) {
123 return; 130 return;
124 } 131 }
125 let hkHolidayDefine = this.hkHolidayDefine; 132 let hkHolidayDefine = this.hkHolidayDefine;
126 for (let index = 0; index < hkHolidayDefine.gl.length; index++) {
127 let m = hkHolidayDefine.gl[index][0];
128 let d = hkHolidayDefine.gl[index][1];
129 133
130 // 如果是周六/周日,顺延到下周一
131 let date = Date.parse(`${year}.${m}.${d}`);
132 if (date.getDay() == 6) {
133 // 周六
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 134
141 let list = result[m]; 135 // 加入清明节
142 if (!list) { 136 if (hkHolidayDefine.qm[0].indexOf(year + "") >= 0) {
143 result[m] = []; 137 // 如果是周六/周日,顺延到下周一
144 list = result[m]; 138 let vals = this.checkWeeken(4, 4);
145 } 139 let m = vals[0];
146 list.push(d); 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
157 for (let index = 0; index < hkHolidayDefine.gl.length; index++) {
158 let m = hkHolidayDefine.gl[index][0];
159 let d = hkHolidayDefine.gl[index][1];
160
161 // 如果是周六/周日,顺延到下周一
162 let vals = this.checkWeeken(m, d);
163 m = vals[0];
164 d = vals[1];
165
166 let list = result[m];
167 if (!list) {
168 result[m] = [];
169 list = result[m];
147 } 170 }
171 list.push(d);
172 }
148 173
149 174
150 for (let index = 0; index < hkHolidayDefine.nl.length; index++) { 175 for (let index = 0; index < hkHolidayDefine.nl.length; index++) {
151 let m = hkHolidayDefine.nl[index][0]; 176 let m = hkHolidayDefine.nl[index][0];
152 let d = hkHolidayDefine.nl[index][1]; 177 let d = hkHolidayDefine.nl[index][1];
153 let gl = toSolar(year, m, d); 178 let gl = toSolar(year, m, d);
154 179
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) {
172 result[m] = []; 191 result[m] = [];
173 list = result[m]; 192 list = result[m];
174 }
175 list.push(d);
176 } 193 }
177 return result; 194 list.push(d);
195 }
196 return result;
178 }, 197 },
179 locale() { 198 locale() {
180 return this.$i18n.locale || 'tc'; 199 return this.$i18n.locale || 'tc';
...@@ -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
609 // 如果是周六/周日,顺延到下周一
610 let date = Date.parse(`${year}.${m}.${d}`);
611 if (date.getDay() == 6) {
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 617
620 let list = result[m]; 618 },
621 if (!list) { 619 checkWeeken(m, d) {
622 result[m] = []; 620 let year = this.year;
623 list = result[m]; 621 let date = Date.parse(`${year}.${m}.${d}`);
624 } 622 // if (date.getDay() == 6) {
625 list.push(d); 623 // // 周六
626 } 624 // date.addDays(2);
627 625 // } else
628 626 if (date.getDay() == 0) {
629 for (let index = 0; index < hkHolidayDefine.nl.length; index++) { 627 date.addDays(1);
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}`);
639
640 if (date.getDay() == 6) {
641 // 周六
642 date.addDays(2);
643 } else if (date.getDay() == 0) {
644 date.addDays(1);
645 }
646 m = date.getMonth() + 1;
647 d = date.getDate();
648
649 let list = result[m];
650 if (!list) {
651 result[m] = [];
652 list = result[m];
653 }
654 list.push(d);
655 } 628 }
656 629 m = date.getMonth() + 1;
657 this.holiday = result; 630 d = date.getDate();
658 console.log(JSON.stringify(this.holiday)); 631 return [m, d];
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("登出成功");
......