统一登录问题调试

This commit is contained in:
BianLzhaoMin 2024-12-25 08:52:58 +08:00
parent ac72bc580f
commit 022c394b3b
11 changed files with 73 additions and 10 deletions

11
components.d.ts vendored
View File

@ -9,15 +9,19 @@ declare module 'vue' {
export interface GlobalComponents {
Breadcrumb: typeof import('./src/components/Breadcrumb/index.vue')['default']
EditorModel: typeof import('./src/components/EditorModel/index.vue')['default']
ElAvatar: typeof import('element-plus/es')['ElAvatar']
ElBadge: typeof import('element-plus/es')['ElBadge']
ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb']
ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem']
ElButton: typeof import('element-plus/es')['ElButton']
ElCard: typeof import('element-plus/es')['ElCard']
ElCarousel: typeof import('element-plus/es')['ElCarousel']
ElCarouselItem: typeof import('element-plus/es')['ElCarouselItem']
ElCascader: typeof import('element-plus/es')['ElCascader']
ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
ElCol: typeof import('element-plus/es')['ElCol']
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
ElCountdown: typeof import('element-plus/es')['ElCountdown']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
@ -25,18 +29,25 @@ declare module 'vue' {
ElEmpty: typeof import('element-plus/es')['ElEmpty']
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElImage: typeof import('element-plus/es')['ElImage']
ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
ElMenu: typeof import('element-plus/es')['ElMenu']
ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
ElOption: typeof import('element-plus/es')['ElOption']
ElPageHeader: typeof import('element-plus/es')['ElPageHeader']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm']
ElProgress: typeof import('element-plus/es')['ElProgress']
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElRow: typeof import('element-plus/es')['ElRow']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElStep: typeof import('element-plus/es')['ElStep']
ElSteps: typeof import('element-plus/es')['ElSteps']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTag: typeof import('element-plus/es')['ElTag']

4
env/.env.dev vendored
View File

@ -9,8 +9,8 @@ VITE_API_URL = '/proxyApi'
# VITE_proxyTarget = 'http://192.168.2.246:28080' # 马帅
# VITE_proxyTarget = 'http://192.168.2.127:28080' # 梁超
# VITE_proxyTarget = 'http://36.33.26.201:17788/proxyApi' # 测试服务
VITE_proxyTarget = 'http://192.168.0.244:28580' # 测试服务
VITE_proxyTarget = 'http://36.33.26.201:17788/proxyApi' # 测试服务
# VITE_proxyTarget = 'http://192.168.0.244:28580' # 测试服务
# VITE_proxyTarget = 'http://192.168.2.75:28080' # 盛旭
# VITE_proxyTarget = 'http://10.40.92.185:9206' # 赵福海 ( 设备类型)

View File

@ -1,4 +1,19 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { loginNewApi } from 'http/api/home/index'
onMounted(async () => {
const origin = window.location.href
console.log(origin.split('ticket=')[1], 'origin')
if (origin.indexOf('ticket') != -1) {
console.log('origin.split爱玩送ticket')
const res = await loginNewApi({ ticket: origin.split('ticket=')[1] })
console.log(res, '登录结果')
}
})
</script>
<template>
<RouterView />
</template>

16
src/hooks/login.ts Normal file
View File

@ -0,0 +1,16 @@
import { loginByIwsApi } from 'http/api/login/index'
export default function () {
const getLoginIwsInfo = async (data: any) => {
const res: any = await loginByIwsApi(data)
console.log(res)
}
return {
getLoginIwsInfo,
}
}

View File

@ -29,3 +29,8 @@ export const setAcceptByIdApi = (data: any = {}) => {
export const apiGetCollect = (params = {}) => {
return post('/zlpt-equip/dev/userCollectList', params)
}
// I 皖送登录
export const loginNewApi = (data: any) => {
return post('/auth/iwsLogin', data)
}

View File

@ -4,6 +4,7 @@ import { get, post } from '../../index'
export const loginApi = (data: any) => {
return post('/auth/login', data)
}
// 获取用户信息
export const getUserInfoAPI = () => {
return get('/system/user/getInfo', {})

View File

@ -2,11 +2,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import axios from 'axios'
import NProgress from 'nprogress'
import { mainStore } from 'store/main'
// import { mainStore } from 'store/main'
import { ElMessage } from "element-plus";
import { saveAs } from 'file-saver'
import router from "@/router"
const store = mainStore()
// const store = mainStore()
// const CancelToken = axios.CancelToken
// const source = CancelToken.source()
const baseUrl = import.meta.env.VITE_API_URL
@ -20,9 +21,10 @@ const service = axios.create({
timeout: 60000
})
service.interceptors.request.use(
(config) => {
config.headers['Authorization'] = store.token
config.headers['Authorization'] = localStorage.getItem('tokenNew')
return config
},
(error) => {

View File

@ -691,7 +691,7 @@ const onJumpUser = () => {
right: 0;
width: 100px;
height: 43px;
transform: translate(-10px, 5px);
transform: translate(-5px, 5px);
border-radius: 43px;
background: linear-gradient(132deg, #22ab9b 0%, #0d7462 100%);
box-shadow: 0px 2px 4px 0px rgba(20, 175, 255, 0.5);

View File

@ -1,9 +1,12 @@
import { createRouter, RouteRecordRaw, createWebHistory } from 'vue-router'
import test from './module/test'
import myInfo from './module/myInfo'
// import login from '../hooks/login'
// const { getLoginIwsInfo } = login()
import { mainStore } from 'store/main'
import { el } from 'element-plus/es/locale'
// import { el } from 'element-plus/es/locale'
@ -757,6 +760,12 @@ const router = createRouter({
const white = ['/qr-code']
// 使页面跳转后滚动条恢复至顶部
router.beforeEach((to, from, next) => {
// const origin = window.location.href
// if (origin.indexOf('ticket') != -1) {
// console.log(origin.split('ticket=')[1], 'origin.split爱玩送ticket')
// // getLoginIwsInfo({ ticket: 996 })
// }
const store = mainStore()
if (to.meta.isLogin && !to.meta.AuthFlag) {
if (store.token) {

View File

@ -31,6 +31,8 @@ const handlerLogin = async () => {
console.log('登录成功**', res)
if (res.code === 200) {
userStore.setToken(res.data.access_token)
localStorage.setItem('tokenNew', res.data.access_token)
const result: any = await getUserInfoAPI()
ElMessage({
showClose: true,
@ -153,7 +155,7 @@ const handlerLogin = async () => {
background-size: cover;
.login-form {
width: 500px;
width: 580px;
// height: 360px;
display: flex;
flex-direction: column;

View File

@ -410,12 +410,13 @@ const onSelectItem = (type: number) => {
.left-filter {
margin-top: 10px;
padding: 8px 0;
padding: 16px 0;
position: relative;
display: flex;
align-content: center;
justify-content: center;
color: #38b2a4;
font-size: 22px;
// height: 46px;
// line-height: 46px;
// text-align: center;
@ -466,6 +467,7 @@ const onSelectItem = (type: number) => {
height: 32px;
line-height: 32px;
text-align: center;
padding: 2px 20px;
// font-size: 16px !important;
&:hover {