Bläddra i källkod

session to local

zhuf 1 år sedan
förälder
incheckning
4bb8b5a935

+ 8 - 5
src/main.js

@@ -2,21 +2,24 @@ import { createApp } from 'vue'
 import user from '~/store/user'
 import 'default-passive-events'
 import 'virtual:windi.css';
+import VConsole from 'vconsole';
+
+if (window.debug) {
+  const vConsole = new VConsole();
+}
 
-// import VConsole from 'vconsole';
-// const vConsole = new VConsole();
 
 import App from './App.vue'
 import router from './router/index';
 
 router.beforeEach((to, from, next) => {
-    console.log(to);
+  console.log(to);
   if (to.meta?.loginRequest) { // 如果路由meta中loginRequest为true,进行拦截
     if (user.token) {
       next()
     } else {
-        window.location.href =
-          "https://nmlm.bozedu.net/login.html?redirect=" + to.fullPath;
+      window.location.href =
+        "https://nmlm.bozedu.net/login.html?redirect=" + to.fullPath;
     }
   } else {
     next() // 直接进入页面

+ 1 - 1
src/pages/_home/index.vue

@@ -120,7 +120,7 @@ function initData() {
   }).then((res) => {
     if (res.code == "1") {
       childrenList = res.data.info;
-      sessionStorage.setItem("children", JSON.stringify(res.data.info));
+      localStorage.setItem("children", JSON.stringify(res.data.info));
       // setChild(res.data.info[0]);
     }
   });

+ 1 - 1
src/pages/stxk/jz/index.vue

@@ -5,7 +5,7 @@ import { child } from '~/store/child';
 // import { children } from '~/store/children';
 import getTeamInfo from '~/store/team';
 
-const children = JSON.parse(sessionStorage.getItem('children'))
+const children = JSON.parse(localStorage.getItem('children'))
 console.log('children :>> ', children);
 
 function handleNavLeftClick() {

+ 5 - 3
src/pages/stxk/jz/kcxq.vue

@@ -11,7 +11,7 @@ const props = defineProps({
   },
 });
 let child = $ref(childInfo);
-const children = JSON.parse(sessionStorage.getItem('children'))
+const children = JSON.parse(localStorage.getItem('children'))
 let childrenCols = $ref([])
 const router = useRouter();
 function handleNavLeftClick() {
@@ -66,7 +66,9 @@ function handleSubmitbarClick() {
   console.log("handleSubmitbarClick", orderStatus, child);
   // const grades = (detailInfo.kk_grade_id).split(',').filter(item => item !== '')
   const grades = (detailInfo?.kk_grade_id)?.split(',')?.filter(item => item !== '') ?? []
-  if (grades.indexOf(child.cm_info[0].grade) === -1) {
+  console.log('grades : ', grades)
+  console.log('child.cm_info[0].grade : ', child.cm_info[0].grade)
+  if (child.cm_info[0].grade && grades.indexOf(child.cm_info[0].grade) === -1) {
     showFailToast('该学生不在可报名年级范围内')
     return
   }
@@ -97,7 +99,7 @@ function handleSubmitbarClick() {
         location.replace(
           `http://wx.bozedu.net/get-weixin-code.html?appid=${window.GLOBAL_CONFIG.appid}&redirect_uri=${_href}&state=1`
         );
-      }else{
+      } else {
         orderStatus = 2;
       }
     }

+ 1 - 1
src/pages/stxk/jz/wd/index.vue

@@ -1,6 +1,6 @@
 <script setup>
 import { child } from '~/store/child';
-const children = JSON.parse(sessionStorage.getItem('children'))
+const children = JSON.parse(localStorage.getItem('children'))
 
 const handleNavLeftClick = () => {
   router.back()

+ 2 - 2
src/store/children.js

@@ -5,7 +5,7 @@ await request({
   url: '/user/main/my_child',
 }).then(res => {
   if (res.code === '1') {
-    sessionStorage.setItem('children', JSON.stringify(res.data.info))
+    localStorage.setItem('children', JSON.stringify(res.data.info))
   }
 })
-export const children = JSON.parse(sessionStorage.getItem('children'))
+export const children = JSON.parse(localStorage.getItem('children'))