From cc26637f18b8ed178420122d7335b3f89be92ada Mon Sep 17 00:00:00 2001
From: litian <2804272236@qq.com>
Date: 星期四, 23 五月 2024 10:34:44 +0800
Subject: [PATCH] shujia

---
 src/views/login.vue |  188 ++++++++++++++++++++++++++++++++++------------
 1 files changed, 139 insertions(+), 49 deletions(-)

diff --git a/src/views/login.vue b/src/views/login.vue
index f602796..302d11f 100644
--- a/src/views/login.vue
+++ b/src/views/login.vue
@@ -1,40 +1,55 @@
 <template>
   <div class="loginPage">
-    <div class="loginForm">
-      <p>鏁板瓧鏁欐潗闃呰鍣�</p>
-      <el-form ref="ruleFormRef" :model="loginData" :rules="rules" label-width="80px">
-        <el-form-item label="鐢ㄦ埛鍚嶏細" prop="username">
-          <el-input v-model="loginData.username"></el-input>
-        </el-form-item>
-        <el-form-item label="瀵嗙爜锛�" prop="password">
-          <el-input type="password" v-model="loginData.password"></el-input>
-        </el-form-item>
-        <div class="btnBox">
-          <el-button
-            style="width: 120px"
-            type="primary"
-            @click="submitForm(ruleFormRef)"
-            :loading="loading"
-            >鐧� 褰�</el-button
-          >
+    <div class="loginBox">
+      <div class="loginForm">
+        <div class="singUpPhone">
+          <h2>瀵嗙爜鐧诲綍</h2>
+          <el-form ref="ruleFormRef" :model="loginData" :rules="rules" class="">
+            <el-form-item prop="username">
+              <!-- <el-input v-model="loginData.username"></el-input> -->
+              <el-input v-model="loginData.username" placeholder="璇疯緭鍏ユ墜鏈哄彿" size="large">
+              <template #prepend>
+                <el-select
+                  v-model="select"
+                  placeholder="Select"
+                  class="selectPhone"
+                >
+                  <el-option label="涓浗+86" value="86" />
+                </el-select>
+              </template>
+            </el-input>
+            </el-form-item>
+            <el-form-item prop="password">
+              <el-input type="password" v-model="loginData.password" placeholder="璇疯緭鍏ュ瘑鐮�"></el-input>
+            </el-form-item>
+            <div class="btnBox">
+              <el-button
+                class="logInBtn"
+                type="primary"
+                @click="submitForm(ruleFormRef)"
+                :loading="loading"
+                >鐧� 褰�</el-button
+              >
+            </div>
+          </el-form>
         </div>
-      </el-form>
+      </div>
+      <el-image :src="dialogRightImg" class="rightImg" />
     </div>
   </div>
 </template>
 
 <script setup lang="ts">
-import { ref, reactive, inject } from 'vue'
+import { ref, reactive, inject, onBeforeMount } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import { ElMessage } from 'element-plus'
-
+import dialogRightImg from '@/assets/images/content/dialogRightImg.png'
+const MG: any = inject('MG')
 const route = useRoute()
 const router = useRouter()
-
 const request = inject('request')
-
 const ruleFormRef = ref()
-
+const select = ref<string>('涓浗+86')
 const loginData = ref({
   username: '',
   password: ''
@@ -52,24 +67,22 @@
   await formEl.validate((valid, fields) => {
     if (valid) {
       loading.value = true
-      request({
-        url: '/identity/api/LoginByPassword',
-        method: 'post',
-        data: {
+      MG.identity
+        .loginByPassword({
           appRefCode: 'jingshieke',
           loginName: loginData.value.username,
           password: loginData.value.password,
           platform: 'string'
-        }
-      })
+        })
         .then((res) => {
           console.log(res)
           if (res.token != null) {
             localStorage.setItem('token', res.token)
+            getUserInfo()
             if (route.query.redirect) {
               router.push(route.query.redirect)
             } else {
-              router.push('/')
+              router.push('/home')
             }
           } else if (res.data.isError) {
             ElMessage.error(res.data.errorDescription)
@@ -83,6 +96,37 @@
     }
   })
 }
+
+const getUserInfo = () => {
+  MG.identity.getCurrentAppUser().then((res) => {
+    console.log(res, '鐢ㄦ埛淇℃伅')
+    if (res) {
+      let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher')
+      let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo')
+      let phoneInfo = res.secretList.find((item) => item.type == 'MobilePhone')
+      let nameAndPassword = res.secretList.find((item) => item.type == 'LoginNameAndPassword')
+
+      if (nameAndPassword) {
+        let userInfo = {
+          name: nameAndPassword.credential
+        }
+        localStorage.setItem('userInfo', JSON.stringify(userInfo))
+      } else if (teacherRole && teacherInfos) {
+        let userInfo = {
+          name: teacherInfos.name,
+          role: 'Teacher',
+          roleId: teacherRole.role.id
+        }
+        localStorage.setItem('userInfo', JSON.stringify(userInfo))
+      } else if (phoneInfo) {
+        let userInfo = {
+          name: phoneInfo.credential
+        }
+        localStorage.setItem('userInfo', JSON.stringify(userInfo))
+      }
+    }
+  })
+}
 </script>
 
 <style lang="less">
@@ -90,27 +134,73 @@
   width: 100%;
   height: 100%;
   position: relative;
-  .loginForm {
-    width: 400px;
-    height: 300px;
-    position: absolute;
-    top: 50%;
-    left: 50%;
-    margin-top: -150px;
-    margin-left: -200px;
-    border: 1px solid #ccc;
-    border-radius: 10px;
-    padding: 20px;
-    p {
-      font-size: 20px;
-      font-weight: bold;
-      text-align: center;
-      margin-bottom: 50px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  .loginBox {
+    width: 800px;
+    height: 540px;
+    border-radius: 20px;
+    overflow:hidden;
+    display: flex;
+    background: #FFFFFF;
+    box-shadow: 0px 6px 9px 1px rgba(0,0,0,0.06);
+    .loginForm {
+      width: 410px;
+      padding:40px;
+      height: 100%;
+      display: flex;
+      flex-direction: column;
+      justify-content: space-around;
+      .singUpPhone {
+        height: 400px;
+        display: flex;
+        flex-direction: column;
+        align-items: center;
+
+        h2 {
+          padding-top: 35px;
+          font-size: 20px;
+          color: #000;
+          font-weight: 700;
+          text-align: center;
+        }
+        .el-form {
+          margin-top: 26px;
+        }
+        .selectPhone {
+          background: #fff;
+        }
+      }
     }
-    .btnBox {
-      text-align: center;
-      margin-top: 50px;
+    .leftImg {
+      box-sizing: border-box;
+      width: 403px;
     }
+    .el-input{
+      height: 40px;
+    }
+    .el-select {
+        width: 100px;
+        height: 40px;
+        .el-select__wrapper {
+          height: 100% !important;
+          .el-input--suffix {
+            height: 100% !important;
+            background-color: #fff;
+          }
+        }
+      }
+
+      .logInBtn {
+        width: 304px;
+        height: 40px;
+        margin-top: 10px;
+        margin-bottom: 20px;
+        border-radius: 3px;
+        color: #fff;
+        font-size: 14px;
+      }
   }
 }
 </style>

--
Gitblit v1.9.1