Ver Fonte

获取用户个人信息

Xiao_123 há 1 ano atrás
pai
commit
931cde26bd

+ 1 - 1
.env.development

@@ -2,6 +2,6 @@ NODE_ENV = 'development'
 
 VITE_APP_TITLE = 门墩儿招聘
 
-VITE_BASE_URL = 'http://192.168.3.80/admin-api'
+VITE_BASE_URL = 'http://192.168.3.80'
 
 VITE_TENANTCODE = '155'

+ 4 - 4
src/api/common/index.js

@@ -2,20 +2,20 @@ import http from '@/utils/request'
 
 // 发送验证码
 export const sendSmsCode = (params) => {
-  return http.post('/menduner/system/auth/send-sms-code', params)
+  return http.post('/app-api/menduner/system/auth/send-sms-code', params)
 }
 
 // 验证码登录
 export const smsLogin = (params) => {
-  return http.post('/menduner/system/auth/sms-login', params)
+  return http.post('/app-api/menduner/system/auth/sms-login', params)
 }
 
 // 退出登录
 export const logout = () => {
-  return http.post('/menduner/system/auth/logout')
+  return http.post('/app-api/menduner/system/auth/logout')
 }
 
 // 重置密码
 export const resetPassword = (params) => {
-  return http.put('/menduner/system/mde-user/reset-password', params)
+  return http.put('/app-api/menduner/system/mde-user/reset-password', params)
 } 

+ 1 - 1
src/api/personal/user.js

@@ -2,5 +2,5 @@ import http from '@/utils/request'
 
 // 获取用户信息
 export const getUserInfo = (params) => {
-  return http.get('/menduner/system/mde-user/get', params)
+  return http.get('/app-api/menduner/system/mde-user/get', params)
 }

+ 2 - 1
src/layout/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="parent">
     <Headers></Headers>
-    <div class="pa-3" style="background-color: #f0f2f5;">
+    <div class="pa-3">
       <router-view></router-view>
     </div>
     <!-- <Footers class="footer"></Footers> -->
@@ -16,6 +16,7 @@ defineOptions({ name: 'layout-index' })
 
 <style lang="scss" scoped>
 .parent {
+  background-color: #eaf4fe;
   height: 100vh;
   position: relative;
 }

+ 7 - 7
src/layout/personal/navBar.vue

@@ -3,7 +3,7 @@
     <div
       class="banner"
       density="compact"
-      style="padding-left: 0px;background-color: #00897B;height: 50px;font-size: 14px;"
+      style="padding-left: 0px;background-color: #fff;height: 50px;font-size: 14px;"
     >
       <div class="innerBox">
         <div class="nav-logo">
@@ -11,25 +11,25 @@
         </div>
         <div class="nav-city">
           <p class="nav-city-box">
-            <v-icon color="#fff">mdi-map-marker</v-icon>
+            <v-icon color="#00897B">mdi-map-marker</v-icon>
             <span class="nav-city-selected">广州</span>
             <span class="switchover-city nav-city-selected">[切换城市]</span>
           </p>
         </div>
         <div class="nav">
           <ul>
-            <li v-for="k in list" :key="k.text" class="white--text mt-1">
+            <li v-for="k in list" :key="k.text" class="mt-1">
               <a href="" style="font-size: 14px;">{{ k.text }}</a>
             </li>
           </ul>
         </div>
-        <div class="user-nav white--text" v-if="!getToken()">
+        <div class="user-nav" v-if="!getToken()">
           <div class="btns">
             <span class="nav-resume-tools">
-              <a href="" class="link-sign-resume">我要找工作</a>
-              <a href="" class="link-scan">我要招聘</a>
+              <a href="">我要找工作</a>
+              <a href="">我要招聘</a>
             </span>
-            <v-btn rounded color="#fff" size="small" @click="handleLogin">登录/注册</v-btn>
+            <v-btn class="half-button" color="primary" size="small" @click="handleLogin">登录/注册</v-btn>
           </div>
         </div>
         <div v-else class="d-flex user-nav">

+ 17 - 3
src/store/user.js

@@ -3,10 +3,12 @@ import { reactive } from 'vue'
 import { setToken, deleteToken } from '@/utils/auth'
 import { smsLogin } from '@/api/common/index'
 import { logout } from '@/api/common/index'
+import { getUserInfo } from '@/api/personal/user'
 
 export const userLocaleStore = defineStore('user',
   () => {
-    let userInfo = reactive({})
+    let accountInfo = reactive({}) // 登录返回的信息
+    let userInfo = reactive({}) // 当前登录账号信息
     // 登录
     const handleLogin = async (data) => {
       return new Promise((resolve, reject) => {
@@ -14,18 +16,30 @@ export const userLocaleStore = defineStore('user',
           const { data } = res
           console.log(data, 'res-login')
           setToken(data.accessToken)
-          userInfo = data
-          localStorage.setItem('userInfo', JSON.stringify(data))
+          accountInfo = data
+          localStorage.setItem('accountInfo', JSON.stringify(data))
           localStorage.setItem('expiresTime', data.expiresTime) // token过期时间
+          getUserInfos() // 获取当前登录账户信息
           resolve()
         }).catch(err => { reject(err) })
       })
     }
+    const getUserInfos = async () => {
+      try {
+        const { data } = await getUserInfo({ id: accountInfo.userId })
+        userInfo = data
+        localStorage.setItem('userInfo', JSON.stringify(data))
+      } catch (error) {
+        console.log(error, 'get-user-info')
+        alert(error.msg)
+      }
+    }
     // 退出登录
     const userLogout = async () => {
       await logout()
       deleteToken()
       userInfo = {}
+      accountInfo = {}
       localStorage.clear()
     }
     return {

+ 6 - 124
src/styles/personal/navBar.css

@@ -17,107 +17,6 @@
   background: transparent;
 }
 
-.header-login-desc {
-  display: none;
-  position: absolute;
-  left: 50%;
-  top: 34px;
-  margin-left: -114px;
-  background: #ffffff;
-  box-shadow: 0px 16px 40px 0px rgba(153, 153, 153, 0.3), 0px 2px 10px 0px rgba(0, 0, 0, 0.08);
-  z-index: 2;
-  font-size: 14px;
-  text-align: left;
-  padding: 16px 18px;
-  border-radius: 8px;
-  box-sizing: border-box;
-  font-weight: normal;
-}
-
-.header-login-desc:before {
-  content: " ";
-  position: absolute;
-  left: 50%;
-  margin-left: -4px;
-  top: -8px;
-  width: 0;
-  height: 0;
-  border-top: 4px solid transparent;
-  border-left: 4px solid transparent;
-  border-right: 4px solid transparent;
-  border-bottom: 4px solid #fff;
-}
-
-.header-login-desc .login-desc-title {
-  font-weight: 500;
-  color: #333333;
-  line-height: 20px;
-  display: block;
-}
-
-.header-login-desc .login-desc-list {
-  margin-top: 4px;
-}
-
-.header-login-desc .login-desc-list li {
-  margin: 8px 0 0 0;
-  display: block;
-  font-size: 13px;
-  color: #333333;
-  text-align: left;
-  height: 26px;
-  line-height: 26px;
-}
-
-.header-login-desc .login-desc-list .login-desc-icon {
-  display: inline-block;
-  height: 26px;
-  width: 26px;
-  margin-right: 8px;
-  vertical-align: middle;
-  background: url(https://img.bosszhipin.com/static/file/2022/7rf2cut4bc1669274264900.png) 0 0/26px auto no-repeat;
-}
-
-.header-login-desc .login-desc-list .login-desc-icon.desc-icon-chat {
-  background-position: 0 0;
-}
-
-.header-login-desc .login-desc-list .login-desc-icon.desc-icon-match {
-  background-position: 0 -26px;
-}
-
-.header-login-desc .login-desc-list .login-desc-icon.desc-icon-info {
-  background-position: 0 -52px;
-}
-
-.header-resume-new .header-resume-tip {
-  z-index: 2;
-  display: none;
-}
-
-.header-resume-new a:hover .header-resume-tip {
-  display: none;
-}
-
-.header-nav-group {
-  margin: 0 5px;
-  float: none;
-}
-
-.header-nav-group li {
-  margin: 0;
-  position: relative;
-}
-
-.header-nav-group .header-nav-dot {
-  display: inline-block;
-  width: 2px;
-  height: 2px;
-  border-radius: 100%;
-  background: #fff;
-  vertical-align: middle;
-}
-
 .user-nav .header-login-btn {
   vertical-align: middle;
 }
@@ -130,7 +29,7 @@
 .user-nav .nav-resume-tools > a {
   display: inline-block;
   font-weight: 500;
-  color: #ffffff;
+  color: var(--v-primary-base);
   line-height: 20px;
   height: auto;
   padding: 3px 7px;
@@ -140,11 +39,6 @@
   border: 1px solid transparent;
 }
 
-.user-nav .nav-resume-tools > a:hover {
-  color: #fff;
-  background: rgba(255, 255, 255, 0.2);
-}
-
 .banner {
   z-index: var(--zIndex-nav) !important;
   color: #fff;
@@ -181,7 +75,7 @@
   cursor: pointer;
   height: 49px;
   line-height: 49px;
-  color: #fff;
+  color: var(--v-primary-base);
   margin-left: 50px;
 }
 
@@ -195,7 +89,7 @@
 }
 
 .switchover-city {
-  color: #fff;
+  color: var(--v-primary-base);
   margin-left: 10px;
 }
 
@@ -225,29 +119,17 @@
   padding: 0 5px;
   position: relative;
   text-decoration: none;
-  color: #fff;
+  color: var(--v-primary-base);
 }
 
 .user-nav {
   position: absolute;
   right: 0;
+  color: var(--v-primary-base);
   height: 49px;
   line-height: 49px;
 }
 
-.user-nav .nav-resume-tools > a {
-  display: inline-block;
-  font-weight: 500;
-  color: #fff;
-  line-height: 20px;
-  height: auto;
-  padding: 3px 7px;
-  vertical-align: middle;
-  border-radius: 4px;
-  margin-right: 8px;
-  border: 1px solid transparent;
-}
-
 .user-nav .btns .btn-outline {
   border-radius: 8px;
   text-align: center;
@@ -263,7 +145,7 @@
 .user-nav .btn {
   display: inline-block;
   box-sizing: content-box;
-  border: 1px solid #fff;
+  border: 1px solid #00897B;
   letter-spacing: 1px;
   cursor: pointer;
 }

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
src/styles/personal/navBar.min.css


+ 6 - 110
src/styles/personal/navBar.scss

@@ -14,95 +14,6 @@
   z-index: 1;
   background: transparent;
 }
-.header-login-desc {
-  display: none;
-  position: absolute;
-  left: 50%;
-  top: 34px;
-  margin-left: -114px;
-  background: #ffffff;
-  box-shadow: 0px 16px 40px 0px rgba(153, 153, 153, 0.3),
-    0px 2px 10px 0px rgba(0, 0, 0, 0.08);
-  z-index: 2;
-  font-size: 14px;
-  text-align: left;
-  padding: 16px 18px;
-  border-radius: 8px;
-  box-sizing: border-box;
-  font-weight: normal;
-}
-.header-login-desc:before {
-  content: " ";
-  position: absolute;
-  left: 50%;
-  margin-left: -4px;
-  top: -8px;
-  width: 0;
-  height: 0;
-  border-top: 4px solid transparent;
-  border-left: 4px solid transparent;
-  border-right: 4px solid transparent;
-  border-bottom: 4px solid #fff;
-}
-.header-login-desc .login-desc-title {
-  font-weight: 500;
-  color: #333333;
-  line-height: 20px;
-  display: block;
-}
-.header-login-desc .login-desc-list {
-  margin-top: 4px;
-}
-.header-login-desc .login-desc-list li {
-  margin: 8px 0 0 0;
-  display: block;
-  font-size: 13px;
-  color: #333333;
-  text-align: left;
-  height: 26px;
-  line-height: 26px;
-}
-.header-login-desc .login-desc-list .login-desc-icon {
-  display: inline-block;
-  height: 26px;
-  width: 26px;
-  margin-right: 8px;
-  vertical-align: middle;
-  background: url(https://img.bosszhipin.com/static/file/2022/7rf2cut4bc1669274264900.png)
-    0 0 / 26px auto no-repeat;
-}
-.header-login-desc .login-desc-list .login-desc-icon.desc-icon-chat {
-  background-position: 0 0;
-}
-.header-login-desc .login-desc-list .login-desc-icon.desc-icon-match {
-  background-position: 0 -26px;
-}
-.header-login-desc .login-desc-list .login-desc-icon.desc-icon-info {
-  background-position: 0 -52px;
-}
-.header-resume-new .header-resume-tip {
-  z-index: 2;
-  display: none;
-}
-.header-resume-new a:hover .header-resume-tip {
-  display: none;
-}
-.header-nav-group {
-  margin: 0 5px;
-  float: none;
-}
-.header-nav-group li {
-  margin: 0;
-  position: relative;
-}
-.header-nav-group .header-nav-dot {
-  display: inline-block;
-  width: 2px;
-  height: 2px;
-  border-radius: 100%;
-  background: #fff;
-  vertical-align: middle;
-}
 .user-nav .header-login-btn {
   vertical-align: middle;
 }
@@ -113,7 +24,7 @@
 .user-nav .nav-resume-tools > a {
   display: inline-block;
   font-weight: 500;
-  color: #ffffff;
+  color: var(--v-primary-base);
   line-height: 20px;
   height: auto;
   padding: 3px 7px;
@@ -122,10 +33,6 @@
   margin-right: 8px;
   border: 1px solid transparent;
 }
-.user-nav .nav-resume-tools > a:hover {
-  color: #fff;
-  background: rgba(255, 255, 255, 0.2);
-}
 .banner {
   z-index: var(--zIndex-nav) !important;
   color: #fff;
@@ -157,7 +64,7 @@
   cursor: pointer;
   height: 49px;
   line-height: 49px;
-  color: #fff;
+  color: var(--v-primary-base);
   margin-left: 50px;
 }
 .nav-city-selected {
@@ -170,7 +77,7 @@
 }
 .switchover-city {
   // font-size: 12px;
-  color: #fff;
+  color: var(--v-primary-base);
   margin-left: 10px;
 }
 .nav {
@@ -196,27 +103,16 @@
   padding: 0 5px;
   position: relative;
   text-decoration: none;
-  color: #fff;
+  color: var(--v-primary-base);
 }
 .user-nav {
   position: absolute;
   right: 0;
   // display: inline-block;
+  color: var(--v-primary-base);
   height: 49px;
   line-height: 49px;
 }
-.user-nav .nav-resume-tools > a {
-  display: inline-block;
-  font-weight: 500;
-  color: #fff;
-  line-height: 20px;
-  height: auto;
-  padding: 3px 7px;
-  vertical-align: middle;
-  border-radius: 4px;
-  margin-right: 8px;
-  border: 1px solid transparent;
-}
 .user-nav .btns .btn-outline {
   border-radius: 8px;
   text-align: center;
@@ -231,7 +127,7 @@
 .user-nav .btn {
   display: inline-block;
   box-sizing: content-box;
-  border: 1px solid #fff;
+  border: 1px solid #00897B;
   letter-spacing: 1px;
   cursor: pointer;
 }

+ 3 - 12
src/views/Home/personal/account/dynamic/editPassword.vue

@@ -3,7 +3,7 @@
     <h3>修改密码</h3>
     <v-divider class="mb-4"></v-divider>
     <div>
-      <div class="login-user">当前登录账号: <span style="color: #483d3d;">13229740091</span></div>
+      <div class="login-user">当前登录账号: <span style="color: #483d3d;">{{ userInfo.phone }}</span></div>
       <div class="error-tips mt-2 mb-1">检测到当前账号未设置密码,设置后可使用账号密码进行登录。</div>
     </div>
     <div style="width: 300px;">
@@ -44,7 +44,6 @@
 <script setup name="editPassword">
 import PhonePage from '@/components/VerificationCode'
 import { resetPassword } from '@/api/common/index'
-import { getUserInfo } from '@/api/personal/user'
 import { ref, reactive, computed } from 'vue'
 
 const phoneRef = ref()
@@ -60,16 +59,8 @@ const passwordCheck = computed(() => {
   return query.checkPassword === query.password || '两次密码输入不一致'
 })
 
-const getUserInfos = async () => {
-  const userInfo = JSON.parse(localStorage.getItem('userInfo'))
-  try {
-    const { data } = await getUserInfo({ id: userInfo.userId })
-    console.log(data, 'data')
-  } catch (error) {
-    console.log(error, 'error')
-  }
-}
-getUserInfos()
+// 当前登录的用户信息
+const userInfo = JSON.parse(localStorage.getItem('userInfo'))
 
 const handleSubmit = async () => {
   const { valid: phoneValid } = await phoneRef.value.phoneForm.validate()

+ 1 - 0
src/views/login/index.vue

@@ -90,6 +90,7 @@ const handleLogin = async () => {
     router.push({ path: '/home' })
   } catch (error) {
     console.log(error, 'error-login')
+    alert(error.msg)
   } finally {
     loginLoading.value = false
   }

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff