Ver Fonte

Merge branch 'v2.0' into debug

yujinwen há 5 dias atrás
pai
commit
a199287f19

+ 2 - 2
src/api/index.js

@@ -4,9 +4,9 @@ import router from "@/router";
 import {useRequestLoading} from '@/hooks/useRequestLoading'
 import { MessagePlugin } from 'tdesign-vue-next';
 import CryptoJS from '@/utils/crypto'
-import {useUserInfo} from '@/hooks/userInfo'
+import {useToken} from '@/hooks/useToken'
 
-const {token}=useUserInfo()
+const {token}=useToken()
 
 // Full config:  https://github.com/axios/axios#request-config
 // axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || '';

+ 4 - 0
src/api/system/common.js

@@ -20,5 +20,9 @@ export default{
     // 用户登录
     userLogin:params=>{
         return post('/user_login/login',params)
+    },
+    //获取用户信息
+    userInfo:()=>{
+        return get('/user/base_info',{})
     }
 }

+ 3 - 9
src/hooks/userInfo.js → src/hooks/useToken.js

@@ -1,21 +1,15 @@
-// 全局接口请求loading hook
+// 用户 hook
 import { ref } from "vue";
 
-const userInfo = ref(null);
 const token = ref(localStorage.getItem("token") || "");
 
-export function useUserInfo() {
+export function useToken() {
   function setToken(e){
     token.value=e
     localStorage.setItem('token',e)
   }
-
-  function getUserInfo() {
-
-  }
-
   return {
     token,
-    setToken
+    setToken,
   };
 }

+ 18 - 0
src/hooks/useUserInfo.js

@@ -0,0 +1,18 @@
+// 个人信息 hook
+import { ref } from "vue";
+import {apiSystemCommon} from '@/api/system'
+
+const userInfo = ref(null);
+
+export function useUserInfo() {
+  async function getUserInfo() {
+    const res=await apiSystemCommon.userInfo()
+    if(res.Ret!==200) return
+    userInfo.value=res.Data||null
+  }
+
+  return {
+    userInfo,
+    getUserInfo,
+  };
+}

+ 15 - 5
src/layout/Index.vue

@@ -1,4 +1,12 @@
 <script setup>
+import {useUserInfo} from '@/hooks/useUserInfo'
+import { useRouter } from 'vue-router';
+
+const {getUserInfo,userInfo}=useUserInfo()
+const router=useRouter()
+
+getUserInfo()
+
 
 async function handleLoginOut(){
 	await $confirmDialog({
@@ -6,6 +14,8 @@ async function handleLoginOut(){
     body: '是否确认退出当前账号',
 		confirmBtn:'确认退出'
   }); 
+	localStorage.removeItem('token')
+	router.replace('/login')
 }
 
 </script>
@@ -20,14 +30,14 @@ async function handleLoginOut(){
 						<div class="top-box">
 							<div class="label-text">账号信息</div>
 							<div class="flex">
-								<span>用户名</span>
+								<span>{{userInfo?.RealName}}</span>
 								<span>|</span>
-								<span>手机号</span>
+								<span>{{userInfo?.Mobile}}</span>
 							</div>
 							<div class="flex">
-								<span>所属机构</span>
+								<span>{{userInfo?.BusinessName}}</span>
 								<span>|</span>
-								<span>岗位</span>
+								<span>{{userInfo?.Position}}</span>
 							</div>
 						</div>
 						<div class="flex my-fav-box" @click="$router.push('/etaChart/favorite')">
@@ -43,7 +53,7 @@ async function handleLoginOut(){
 				</template>
 				<div class="userInfo-box">
 					<svg-icon name="user_avatar" style="font-size:20px;margin-right:3px"></svg-icon>
-					<span>账号吗</span>
+					<span>{{userInfo?.RealName}}</span>
 					<t-icon name="chevron-down" style="font-size:28px;margin-left:11px"></t-icon>
 				</div>
 			</t-popup>

+ 2 - 2
src/views/Login.vue

@@ -2,9 +2,9 @@
 import { useTemplateRef } from "vue"
 import {apiSystemCommon} from '@/api/system'
 import { useRouter } from "vue-router"
-import {useUserInfo} from '@/hooks/userInfo'
+import {useToken} from '@/hooks/useToken'
 
-const {setToken}=useUserInfo()
+const {setToken}=useToken()
 const router=useRouter()
 
 //图形验证码

+ 1 - 3
src/views/user/favorite/components/MoveChart.vue

@@ -52,7 +52,7 @@ async function getChartList(){
   const res=await apiETAChartUser.chartCollectList({
     CollectClassifyIds:selectClassify.value?selectClassify.value.join(','):'',
     Keyword:keyword.value,
-    PageSize:pagination.value.defaultPageSize,
+    PageSize:pagination.value.pageSize,
     CurrentIndex:pagination.value.current
   })
   if(res.Ret!==200) return
@@ -103,8 +103,6 @@ function handleClickCheckAll(check) {
     tableData.value.forEach(item=>{
       selectedRowKeys.value.push(item.ChartInfoId)
     })
-  }else{
-    selectedRowKeys.value=[]
   }
 }
 

+ 4 - 2
src/views/user/favorite/etaChart.vue

@@ -28,8 +28,9 @@ async function getChartList(){
   chartList.value=arr
 }
 
-function onPageChange(){
-
+function onPageChange(e){
+  page.value=e.current
+  getChartList()
 }
 function refreshList(){
   page.value=1
@@ -176,6 +177,7 @@ async function handleCancelCollect(item,index){
       }
       .chart-img{
         display: block;
+        width: 100%;
         height: 230px;
       }
       .time{