jyk
2021-05-14 2c32f7300c24968e353edc4d395c2e7020a8c4d1
commit | author | age
11827a 1 <template>
62e06e 2   <div id="app">
D 3     <keep-alive>
4       <router-view v-if="$route.meta.keepAlive && isRouterAlive" />
5     </keep-alive>
6     <router-view v-if="!$route.meta.keepAlive && isRouterAlive" />
7     <el-dialog
8       title="提示"
9       :visible.sync="netTimeOut"
10       :close-on-click-modal="false"
11       :show-close="false"
12       width="30%"
13     >
14       <span>当前网络开小差了,请刷新重试~</span>
15       <span slot="footer" class="dialog-footer">
16         <el-button @click="close">取 消</el-button>
17         <el-button type="primary" @click="fresh">刷新</el-button>
18       </span>
19     </el-dialog>
20   </div>
11827a 21 </template>
C 22 <script>
62e06e 23 import { mapActions, mapState } from "vuex";
D 24 import { Utils } from "./assets/js/utils";
25 let utils = new Utils();
26 import cookie from "js-cookie";
27 import { axios } from "./assets/js/axios";
28 import { classPayorderDelayList } from "@/apis/teachCenter/grade";
29 export default {
30   name: "App",
31   data() {
32     return {
33       isLoading: true,
34       isRouterAlive: true,
35       noifdata: "",
36     };
37   },
38   computed: {
39     ...mapState("common", {
40       netTimeOut: (state) => state.netTimeOut,
41       menus: (state) => state.menus,
42       user: (state) => JSON.parse(state.user),
43     }),
44   },
45   watch: {
46     isLoading: {
47       handler(val, oldVal) {
48         if (!val) {
49           // 获取缓存课程
50           if (localStorage.getItem("annieUser")) {
51             let decodeData = utils.decrypt(localStorage.getItem("annieUser"));
feecaf 52
62e06e 53             localStorage.getItem("systemId")
D 54               ? this.setSystemId(localStorage.getItem("systemId"))
55               : this.setSystemId(JSON.parse(decodeData).orgMap[0].orgId);
56             let obj = JSON.parse(decodeData);
57             obj.orgId = this.$store.state.common.systemId;
58             decodeData = JSON.stringify(obj);
579157 59
62e06e 60             this.setUser(decodeData);
D 61             this.setMenus(JSON.parse(decodeData).orgMap);
62           }
63           // 通用错误页面文字
64           if (sessionStorage.getItem("errorText")) {
65             this.setError(sessionStorage.getItem("errorText"));
66           }
67         }
68       },
69       deep: true,
70     },
71     $route: {
72       handler: function (val, old) {
73         var that = this;
74         if (localStorage.getItem("annieUser")) {
75           let decodeData = utils.decrypt(localStorage.getItem("annieUser"));
76           let selected = utils.getCurrentTab(
77             this.menus,
78             val.path,
79             this.$store.state.common.systemId
80           );
81           this.setTab(JSON.stringify(selected));
82           if (val.path != "/login") {
83             var mmst = null;
84             this.menus.forEach((item) => {
85               if (this.user.orgId == item.orgId) {
86                 mmst = item;
87               }
88             });
89             if (this.user.orgId == "43") {
90               if (cookie.get("janniekids") != "ok") {
91                 this.classPayorderDelayList();
92               }
93             } else {
94               if (mmst.roleMap[0].RoleId == 2026) {
95                 if (cookie.get("janniekids") != "ok") {
96                   this.classPayorderDelayList();
97                 }
98               }
99             }
100             let hasCookie = cookie.get("ANNIEKIDSUSS");
101             if (!localStorage.getItem("annieUser") && hasCookie) {
102               axios
103                 .post("/api/checkPermissions", {
104                   SystemType: 2,
105                 })
106                 .then((res) => {
107                   let { code, data } = res;
108                   if (code == 1) {
109                     localStorage.setItem("annieUser", data);
110                   } else {
111                     if (cookie.get("ANNIEKIDSUSS")) {
112                       cookie.remove("ANNIEKIDSUSS");
113                     }
114                     this.$router.push("/login");
115                   }
116                 })
117                 .catch((err) => {});
118             }
119           }
120         }
121       },
122       deep: true,
123     },
124   },
125   methods: {
126     ...mapActions("common", {
127       setNetTimeOut: "setNetTimeOut",
128       setUser: "setUser",
129       setMenus: "setMenus",
130       setTab: "setTab",
131       setError: "setError",
132       setSystemId: "setSystemId",
133     }),
134     close() {
135       this.setNetTimeOut(false);
136     },
137     fresh() {
138       this.setNetTimeOut(false);
139       this.isRouterAlive = false;
140       this.$nextTick(() => {
141         this.isRouterAlive = true;
142       });
143     },
144     async classPayorderDelayList() {
145       let params = {
146         orgId: this.user.orgId,
147       };
148       var newifno = 0;
149       var newifno1 = 0;
150       let res = await classPayorderDelayList(params);
151       if (res.code == 1) {
152         this.noifdata = res.data;
153         res.data.forEach((item) => {
154           if (item.delaystatus == 1) {
155             newifno++;
156           }
157           if (item.delaystatus == 2) {
158             newifno1++;
159           }
160         });
161         if (newifno == 1 && newifno1 >= 1) {
162           this.zopen(newifno, newifno1);
163         } else {
164           if (newifno == 1) {
165             res.data.forEach((item) => {
166               if (item.delaystatus == 1) {
167                 this.zzopenr(item);
168                 console.log("111");
169               }
170             });
171           } else if (newifno > 1) {
172             this.zzzopen();
173           }
174           if (newifno1 > 1) {
175             this.zopen();
176           }
177         }
178       }
179     },
180     zopen(newifno22, newifno33) {
181       this.$alert("温馨提示:您有延迟结算班级,延迟即将到期", "", {
182         confirmButtonText: "查看详情",
183         callback: (action) => {
184           console.log(action);
185           if (action != "cancel") {
186             this.$router.push({
187               path: "/teachCenter/grade/delayList",
188             });
189             if (newifno22 == 1) {
190               this.noifdata.forEach((item) => {
191                 if (item.delaystatus == 1) {
192                   this.zzopenr(item);
193                 }
194               });
195             }
196           }
197           var x = new Date(
198             new Date(new Date().toLocaleDateString()).getTime() +
199               24 * 60 * 60 * 1000 -
200               1
201           );
202           cookie.set("janniekids", "ok", {
203             expires: x,
204           });
205         },
206       });
207     },
208     zzopenr(a) {
209       this.$alert(
210         "您申请的延迟结算已到期(申请" +
211           a.delayHour +
212           "课时以后,进行结算),请您及时结算",
213         "",
214         {
215           confirmButtonText: "去结算",
216           callback: (action) => {
217             if (action != "cancel") {
218               this.$router.push({
219                 path: "/teachCenter/grade/gradeCheck",
220                 query: {
221                   id: a.id,
222                   classMode: a.classCode,
223                   classCode: a.classCode,
224                   coursestageId: a.coursestageId,
225                 },
226               });
227             }
228             var x = new Date(
229               new Date(new Date().toLocaleDateString()).getTime() +
230                 24 * 60 * 60 * 1000 -
231                 1
232             );
233             cookie.set("janniekids", "ok", {
234               expires: x,
235             });
236           },
237         }
238       );
239     },
240     zzzopen() {
241       this.$alert("您有延迟结算班级待结算,请及时处理", "", {
242         confirmButtonText: "查看详情",
243         callback: (action) => {
244           if (action != "cancel") {
245             this.$router.push({
246               path: "/teachCenter/grade/delayList",
247             });
248           }
249           var x = new Date(
250             new Date(new Date().toLocaleDateString()).getTime() +
251               24 * 60 * 60 * 1000 -
252               1
253           );
254           cookie.set("janniekids", "ok", {
255             expires: x,
256           });
257         },
258       });
259     },
260   },
261   mounted() {
262     this.isLoading = false;
263   },
264 };
11827a 265 </script>
C 266 <style lang="less">
62e06e 267 #app {
D 268   width: 100%;
269   height: 100%;
270   box-sizing: border-box;
271 }
11827a 272 </style>