lex 1 year ago
parent
commit
9765d4a58e
2 changed files with 92 additions and 37 deletions
  1. 91 36
      src/views/student-register/register-modal/index.tsx
  2. 1 1
      vite.config.ts

+ 91 - 36
src/views/student-register/register-modal/index.tsx

@@ -53,7 +53,7 @@ for (let i = 1; i <= 40; i++) {
 export default defineComponent({
   name: 'register-modal',
   setup() {
-    const studentDetails = sessionStorage.getItem('register-student');
+    // const studentDetails = sessionStorage.getItem('register-student');
     const countDownRef = ref();
     const route = useRoute();
     const router = useRouter();
@@ -174,16 +174,16 @@ export default defineComponent({
         });
 
         if (result.code !== 200) {
-          sessionStorage.setItem(
-            'register-student',
-            JSON.stringify({
-              ...res,
-              extra: JSON.stringify({
-                ...extra,
-                schoolId: forms.schoolId
-              })
-            })
-          );
+          // sessionStorage.setItem(
+          //   'register-student',
+          //   JSON.stringify({
+          //     ...res,
+          //     extra: JSON.stringify({
+          //       ...extra,
+          //       schoolId: forms.schoolId
+          //     })
+          //   })
+          // );
 
           if (result.code === 5436) {
             forms.showTips = true;
@@ -589,6 +589,57 @@ export default defineComponent({
       paymentContinue(); // 实名成功后自动支付
     };
 
+    //
+    const getUserInfos = async () => {
+      if (
+        studentInfo.password.length !== 6 ||
+        !checkPhone(studentInfo.username)
+      ) {
+        return;
+      }
+      try {
+        // 15907120131;
+        const { data } = await request.get(
+          `/edu-app/open/student/studentInfo?mobile=${studentInfo.username}&code=${studentInfo.password}&type=REGISTER`
+        );
+        if (data) {
+          if (!studentInfo.extra.nickname) {
+            studentInfo.extra.nickname = data.nickname;
+          }
+
+          if (!studentInfo.extra.currentGradeNum) {
+            studentInfo.extra.currentGradeNum = data.currentGradeNum;
+          }
+
+          if (!studentInfo.extra.currentClass) {
+            studentInfo.extra.currentClass = data.currentClass;
+          }
+          // if (!studentInfo.extra.gender) {
+          studentInfo.extra.gender =
+            studentInfo.extra.gender !== data.gender
+              ? data.gender
+              : studentInfo.extra.gender;
+
+          // studentInfo.username = data.nickname;
+
+          classList.forEach((i: any) => {
+            if (i.value === data.currentClass) {
+              forms.currentClassText = i.text;
+            }
+          });
+
+          const tempGrade: any = gradeList.value[0] || [];
+          tempGrade?.forEach((i: any) => {
+            if (i.value === data.currentGradeNum) {
+              forms.gradeNumText = i.text;
+            }
+          });
+        }
+      } catch {
+        //
+      }
+    };
+
     onMounted(async () => {
       try {
         // 获取支付类型
@@ -614,32 +665,32 @@ export default defineComponent({
         getRegisterGoods();
       } catch {}
       gradeList.value = getGradeList();
-      if (studentDetails) {
-        const studentJson = JSON.parse(studentDetails);
-        const extraJson = studentJson.extra
-          ? JSON.parse(studentJson.extra)
-          : {};
-        studentInfo.extra.nickname = extraJson.nickname;
-        studentInfo.extra.currentGradeNum = extraJson.currentGradeNum;
-        studentInfo.extra.currentClass = extraJson.currentClass;
-        studentInfo.extra.gender = extraJson.gender;
-        studentInfo.username = studentJson.username;
-
-        classList.forEach((i: any) => {
-          if (i.value === extraJson.currentClass) {
-            forms.currentClassText = i.text;
-          }
-        });
+      // if (studentDetails) {
+      //   const studentJson = JSON.parse(studentDetails);
+      //   const extraJson = studentJson.extra
+      //     ? JSON.parse(studentJson.extra)
+      //     : {};
+      //   studentInfo.extra.nickname = extraJson.nickname;
+      //   studentInfo.extra.currentGradeNum = extraJson.currentGradeNum;
+      //   studentInfo.extra.currentClass = extraJson.currentClass;
+      //   studentInfo.extra.gender = extraJson.gender;
+      //   studentInfo.username = studentJson.username;
 
-        const tempGrade: any = gradeList.value[0] || [];
-        tempGrade?.forEach((i: any) => {
-          if (i.value === extraJson.currentGradeNum) {
-            forms.gradeNumText = i.text;
-          }
-        });
+      //   classList.forEach((i: any) => {
+      //     if (i.value === extraJson.currentClass) {
+      //       forms.currentClassText = i.text;
+      //     }
+      //   });
 
-        sessionStorage.removeItem('register-student');
-      }
+      //   const tempGrade: any = gradeList.value[0] || [];
+      //   tempGrade?.forEach((i: any) => {
+      //     if (i.value === extraJson.currentGradeNum) {
+      //       forms.gradeNumText = i.text;
+      //     }
+      //   });
+
+      //   sessionStorage.removeItem('register-student');
+      // }
     });
 
     return () => (
@@ -686,7 +737,11 @@ export default defineComponent({
               autocomplete="off"
               type="number"
               v-model={studentInfo.password}
-              maxlength={6}>
+              maxlength={6}
+              onUpdate:modelValue={(val: any) => {
+                console.log(val, 'val');
+                getUserInfos();
+              }}>
               {{
                 button: () =>
                   forms.countDownStatus ? (

+ 1 - 1
vite.config.ts

@@ -16,7 +16,7 @@ function resolve(dir: string) {
 // const proxyUrl = 'https://test.lexiaoya.cn/';
 // const proxyUrl = 'https://kt.colexiu.com/';
 // const proxyUrl = 'http://192.168.3.143:7989/';
-const proxyUrl = 'https://test.kt.colexiu.com/';
+const proxyUrl = 'https://dev.kt.colexiu.com/';
 export default defineConfig({
   base: './',
   plugins: [