代码优化
This commit is contained in:
parent
01cdc5581c
commit
884d05a8ff
22
src/App.vue
22
src/App.vue
|
|
@ -1,20 +1,12 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { loginNewApi } from 'http/api/home/index'
|
import { loginNewApi } from 'http/api/home/index'
|
||||||
|
import { getUserInfoAPI } from 'http/api/login/index'
|
||||||
onMounted(async () => {
|
import { mainStore } from 'store/main'
|
||||||
const origin = window.location.href
|
import { useStore } from 'store/user'
|
||||||
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
console.log(origin.split('ticket=')[1], 'origin')
|
const userStore = mainStore()
|
||||||
|
const store = useStore()
|
||||||
if (origin.indexOf('ticket') != -1) {
|
const router = useRouter()
|
||||||
// console.log('origin.split爱玩送ticket')
|
|
||||||
const res = await loginNewApi({
|
|
||||||
ticket: origin.split('ticket=')[1].split('#/')[0],
|
|
||||||
sysType: 0,
|
|
||||||
})
|
|
||||||
console.log(res, '登录结果')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ const handlerLogout = () => {
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
router.push('/login')
|
// router.push('/login')
|
||||||
store.cleanUpToken('')
|
store.cleanUpToken('')
|
||||||
store.clearUserInfo('')
|
store.clearUserInfo('')
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
|
|
@ -65,6 +65,12 @@ const handlerLogout = () => {
|
||||||
message: '已退出登录',
|
message: '已退出登录',
|
||||||
duration: 1000,
|
duration: 1000,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.replace(
|
||||||
|
'http://sgwpdm.ah.sgcc.com.cn/iws/cas/login?appId=3874dcb953f184dc75450e33d6d6d4fa&service=http://sgwpdm.ah.sgcc.com.cn/iws/mall-view/',
|
||||||
|
)
|
||||||
|
}, 500)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
|
|
@ -287,7 +293,7 @@ onMounted(() => {
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class="header-item">
|
<div class="header-item">
|
||||||
<a
|
<!-- <a
|
||||||
v-if="!isShowLogout"
|
v-if="!isShowLogout"
|
||||||
class="a-border-none"
|
class="a-border-none"
|
||||||
@click="$router.push('/login')"
|
@click="$router.push('/login')"
|
||||||
|
|
@ -298,9 +304,10 @@ onMounted(() => {
|
||||||
v-if="!isShowLogout"
|
v-if="!isShowLogout"
|
||||||
style="padding: 0 20px 0 0"
|
style="padding: 0 20px 0 0"
|
||||||
@click="$router.push('/register')"
|
@click="$router.push('/register')"
|
||||||
>注册</a
|
|
||||||
>
|
>
|
||||||
<a v-else @click="handlerLogout">退出登录</a>
|
注册
|
||||||
|
</a> -->
|
||||||
|
<a @click="handlerLogout">退出登录</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ const VITE_token = import.meta.env.VITE_token
|
||||||
const VITE_LocalFlag = import.meta.env.VITE_LocalFlag
|
const VITE_LocalFlag = import.meta.env.VITE_LocalFlag
|
||||||
|
|
||||||
const VITE_ENV = import.meta.env.VITE_ENV
|
const VITE_ENV = import.meta.env.VITE_ENV
|
||||||
|
const iwsData: any = sessionStorage.getItem('data') || null
|
||||||
|
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
baseURL: baseUrl,
|
baseURL: baseUrl,
|
||||||
|
|
@ -40,10 +41,17 @@ service.interceptors.response.use(
|
||||||
return data
|
return data
|
||||||
} else if (data.code == '403') {
|
} else if (data.code == '403') {
|
||||||
ElMessage.error('请重新登录')
|
ElMessage.error('请重新登录')
|
||||||
router.push('/login')
|
setTimeout(() => {
|
||||||
|
window.location.replace('http://sgwpdm.ah.sgcc.com.cn/iws/cas/login?appId=3874dcb953f184dc75450e33d6d6d4fa&service=http://sgwpdm.ah.sgcc.com.cn/iws/mall-view/')
|
||||||
|
}, 500)
|
||||||
|
// router.push('/login')
|
||||||
|
|
||||||
} else if (data.code == '401') {
|
} else if (data.code == '401') {
|
||||||
ElMessage.error(data.msg)
|
ElMessage.error('请登录')
|
||||||
router.push('/login')
|
// router.push('/login')
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.replace('http://sgwpdm.ah.sgcc.com.cn/iws/cas/login?appId=3874dcb953f184dc75450e33d6d6d4fa&service=http://sgwpdm.ah.sgcc.com.cn/iws/mall-view/')
|
||||||
|
}, 500)
|
||||||
} else if (data.code == '500') {
|
} else if (data.code == '500') {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
|
|
@ -62,6 +70,16 @@ service.interceptors.response.use(
|
||||||
)
|
)
|
||||||
|
|
||||||
export function get(url: string, params: any) {
|
export function get(url: string, params: any) {
|
||||||
|
if (iwsData) {
|
||||||
|
service.get(`http://sgwpdm.ah.sgcc.com.cn/iws/cas/api/validate/sk?sessionKey=${iwsData.sessionKey}`).then((res: any) => {
|
||||||
|
console.log(res, '请求结果')
|
||||||
|
if (res.code != 200) {
|
||||||
|
window.location.replace('http://sgwpdm.ah.sgcc.com.cn/iws/cas/login?appId=3874dcb953f184dc75450e33d6d6d4fa&service=http://sgwpdm.ah.sgcc.com.cn/iws/mall-view/')
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// NProgress.start()
|
// NProgress.start()
|
||||||
service
|
service
|
||||||
|
|
@ -81,6 +99,18 @@ export function get(url: string, params: any) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
export function post(url: string, params: any) {
|
export function post(url: string, params: any) {
|
||||||
|
if (iwsData) {
|
||||||
|
service.get(`http://sgwpdm.ah.sgcc.com.cn/iws/cas/api/validate/sk?sessionKey=${iwsData.sessionKey}`).then((res: any) => {
|
||||||
|
console.log(res, '请求结果')
|
||||||
|
|
||||||
|
if (res.code != 200) {
|
||||||
|
window.location.replace('http://sgwpdm.ah.sgcc.com.cn/iws/cas/login?appId=3874dcb953f184dc75450e33d6d6d4fa&service=http://sgwpdm.ah.sgcc.com.cn/iws/mall-view/')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// NProgress.start()
|
// NProgress.start()
|
||||||
service
|
service
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { mainStore } from 'store/main'
|
||||||
import { useStore } from 'store/user'
|
import { useStore } from 'store/user'
|
||||||
import { cartStore } from 'store/cart'
|
import { cartStore } from 'store/cart'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { getHotSearchListApi, getBookCarDetailsApi } from 'http/api/home/index'
|
import { getHotSearchListApi, getBookCarDetailsApi, getCompanyListApi } from 'http/api/home/index'
|
||||||
import userClass from '../hooks/userClass'
|
import userClass from '../hooks/userClass'
|
||||||
import {
|
import {
|
||||||
getUserInfo, //用户信息
|
getUserInfo, //用户信息
|
||||||
|
|
@ -30,6 +30,8 @@ const isAdmin = ref(false)
|
||||||
const roles = store.userInfo.roles
|
const roles = store.userInfo.roles
|
||||||
const activeLoginCompanyName = ref('')
|
const activeLoginCompanyName = ref('')
|
||||||
const searchCheckVisible = ref(false)
|
const searchCheckVisible = ref(false)
|
||||||
|
import { storeToRefs } from 'pinia'
|
||||||
|
const { userInfo, token }: any = storeToRefs(store)
|
||||||
if (roles?.length > 0) {
|
if (roles?.length > 0) {
|
||||||
isAdmin.value = roles.some((e: any) => e.roleKey == 'admin')
|
isAdmin.value = roles.some((e: any) => e.roleKey == 'admin')
|
||||||
}
|
}
|
||||||
|
|
@ -39,22 +41,37 @@ const isShowLogout = computed(() => {
|
||||||
return store.token
|
return store.token
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(userInfo, (newValue, oldCount) => {
|
||||||
|
if (newValue.companyId) {
|
||||||
|
getCompanyListApi().then((res: any) => {
|
||||||
|
res.data.filter((e: any) => {
|
||||||
|
if (e.companyId == newValue.companyId) {
|
||||||
|
activeLoginCompanyName.value = e.companyName
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
watch(token, (newValue, oldCount) => {
|
||||||
|
if (newValue) {
|
||||||
|
getUserListData()
|
||||||
|
getBookCarDetailsData()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const setActiveCompanyName = () => {
|
const setActiveCompanyName = () => {
|
||||||
const companyList = userStore.companyList
|
// const companyList = userStore.companyList
|
||||||
const activeCompany: any = companyList.filter(
|
// const activeCompany: any = companyList.filter(
|
||||||
(e: any) => e.companyId == store.userInfo.companyId,
|
// (e: any) => e.companyId == store.userInfo.companyId,
|
||||||
)
|
// )
|
||||||
activeLoginCompanyName.value = activeCompany[0]?.companyName
|
// activeLoginCompanyName.value = activeCompany[0]?.companyName
|
||||||
localStorage.setItem('currentCompanyName', activeLoginCompanyName.value)
|
// localStorage.setItem('currentCompanyName', activeLoginCompanyName.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userStore.companyList.length === 0) {
|
// if (userStore.companyList.length === 0) {
|
||||||
getCompanyList().then((res) => {
|
// } else {
|
||||||
setActiveCompanyName()
|
// setActiveCompanyName()
|
||||||
})
|
// }
|
||||||
} else {
|
|
||||||
setActiveCompanyName()
|
|
||||||
}
|
|
||||||
|
|
||||||
const placeholderText = ref('搜索设备关键词')
|
const placeholderText = ref('搜索设备关键词')
|
||||||
|
|
||||||
|
|
@ -66,7 +83,7 @@ const handlerLogout = () => {
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
router.push('/login')
|
// router.push('/login')
|
||||||
store.cleanUpToken('')
|
store.cleanUpToken('')
|
||||||
store.clearUserInfo('')
|
store.clearUserInfo('')
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
|
|
@ -75,6 +92,9 @@ const handlerLogout = () => {
|
||||||
type: 'success',
|
type: 'success',
|
||||||
message: '已退出登录',
|
message: '已退出登录',
|
||||||
})
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.replace('http://sgwpdm.ah.sgcc.com.cn/iws/mall-view/')
|
||||||
|
}, 500)
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
|
|
@ -226,7 +246,6 @@ const getBookCarDetailsData = async () => {
|
||||||
})
|
})
|
||||||
cart.SET_CART_NUM(amountNum)
|
cart.SET_CART_NUM(amountNum)
|
||||||
}
|
}
|
||||||
getBookCarDetailsData()
|
|
||||||
const cartNum = computed(() => {
|
const cartNum = computed(() => {
|
||||||
return cart.cartNum
|
return cart.cartNum
|
||||||
|
|
||||||
|
|
@ -245,6 +264,10 @@ const onCarts = () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const nickNameNew = computed(() => {
|
||||||
|
return store.userInfo.nickName
|
||||||
|
})
|
||||||
|
|
||||||
const onJumpUser = () => {
|
const onJumpUser = () => {
|
||||||
const isType: any = localStorage.getItem('rolesType')
|
const isType: any = localStorage.getItem('rolesType')
|
||||||
if (isType == 3) {
|
if (isType == 3) {
|
||||||
|
|
@ -275,6 +298,12 @@ const onJumpUser = () => {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onClickLogin = () => {
|
||||||
|
window.location.replace(
|
||||||
|
'http://sgwpdm.ah.sgcc.com.cn/iws/cas/login?appId=3874dcb953f184dc75450e33d6d6d4fa&service=http://sgwpdm.ah.sgcc.com.cn/iws/mall-view/',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// 查看消息
|
// 查看消息
|
||||||
const onJumpMessage = () => {
|
const onJumpMessage = () => {
|
||||||
router.push({
|
router.push({
|
||||||
|
|
@ -292,12 +321,16 @@ const form: any = ref({
|
||||||
deptId: '',
|
deptId: '',
|
||||||
})
|
})
|
||||||
const dialogUserInfoVisible = ref(false)
|
const dialogUserInfoVisible = ref(false)
|
||||||
const circleUrl = ref('https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg')
|
// const circleUrl = ref('https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg')
|
||||||
|
|
||||||
|
const circleUrl = computed(() => {
|
||||||
|
return store.userInfo.avatar
|
||||||
|
})
|
||||||
const onAccountManage = () => {
|
const onAccountManage = () => {
|
||||||
dialogUserInfoVisible.value = true
|
dialogUserInfoVisible.value = true
|
||||||
}
|
}
|
||||||
const getUserListData = async () => {
|
const getUserListData = async () => {
|
||||||
let res = await getUserInfo()
|
let res: any = await getUserInfo()
|
||||||
form.value = res.data
|
form.value = res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -335,10 +368,9 @@ const resetPhone = async () => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
// onMounted(() => {
|
||||||
getUserListData()
|
// circleUrl.value = store.userInfo.avatar
|
||||||
circleUrl.value = store.userInfo.avatar
|
// })
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -348,18 +380,16 @@ onMounted(() => {
|
||||||
<div class="header-box">
|
<div class="header-box">
|
||||||
<div class="header-item" v-if="isShowLogout">
|
<div class="header-item" v-if="isShowLogout">
|
||||||
<a class="user-name">
|
<a class="user-name">
|
||||||
<span class="name">
|
<span class="name"> {{ activeLoginCompanyName }} / {{ nickNameNew }} </span>
|
||||||
{{ activeLoginCompanyName }} / {{ store.userInfo.nickName }}
|
|
||||||
</span>
|
|
||||||
<el-icon style="margin-left: 4px">
|
<el-icon style="margin-left: 4px">
|
||||||
<ArrowDown />
|
<ArrowDown />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
|
|
||||||
<div class="user-center">
|
<div class="user-center">
|
||||||
<div style="text-align: right">
|
<div style="text-align: right">
|
||||||
<el-button size="small" @click="onAccountManage"
|
<el-button size="small" @click="onAccountManage">
|
||||||
>账号管理</el-button
|
账号管理
|
||||||
>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="user-container">
|
<div class="user-container">
|
||||||
<el-avatar :size="50" :src="circleUrl" />
|
<el-avatar :size="50" :src="circleUrl" />
|
||||||
|
|
@ -373,25 +403,27 @@ onMounted(() => {
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="header-item">
|
<div class="header-item" v-if="isShowLogout">
|
||||||
<a @click="onJumpMessage">消息</a>
|
<a @click="onJumpMessage">消息</a>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-item">
|
<div class="header-item" v-if="isShowLogout">
|
||||||
<a @click="onJumpUser">个人中心</a>
|
<a @click="onJumpUser">个人中心</a>
|
||||||
<div class="line"></div>
|
<div class="line"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-item">
|
<div class="header-item">
|
||||||
<a v-if="!isShowLogout" class="a-border-none" @click="$router.push('/login')"
|
<!-- <a v-if="!isShowLogout" class="a-border-none" @click="$router.push('/login')">
|
||||||
>登录</a
|
登录
|
||||||
>
|
</a> -->
|
||||||
<span v-if="!isShowLogout" style="margin: 0 3px">/</span>
|
<a v-if="!isShowLogout" @click="onClickLogin"> 登录 </a>
|
||||||
|
<!-- <span v-if="!isShowLogout" style="margin: 0 3px">/</span>
|
||||||
<a
|
<a
|
||||||
v-if="!isShowLogout"
|
v-if="!isShowLogout"
|
||||||
style="padding: 0 20px 0 0"
|
style="padding: 0 20px 0 0"
|
||||||
@click="$router.push('/register')"
|
@click="$router.push('/register')"
|
||||||
>注册</a
|
|
||||||
>
|
>
|
||||||
|
注册
|
||||||
|
</a> -->
|
||||||
<a v-else @click="handlerLogout">退出登录</a>
|
<a v-else @click="handlerLogout">退出登录</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -464,10 +496,10 @@ onMounted(() => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="dialogUserInfoVisible"
|
|
||||||
title="账户管理"
|
|
||||||
width="50%"
|
width="50%"
|
||||||
|
title="账户管理"
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
|
v-model="dialogUserInfoVisible"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:before-close="
|
:before-close="
|
||||||
() => {
|
() => {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { loginApi, getUserInfoAPI } from 'http/api/login/index'
|
import { loginApi, getUserInfoAPI } from 'http/api/login/index'
|
||||||
|
import { loginNewApi } from 'http/api/home/index'
|
||||||
import { getCompanyListApi } from 'http/api/home/index'
|
import { getCompanyListApi } from 'http/api/home/index'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { User, Lock } from '@element-plus/icons-vue'
|
import { User, Lock } from '@element-plus/icons-vue'
|
||||||
|
|
@ -82,6 +83,39 @@ const handlerLogin = async () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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: any = await loginNewApi({
|
||||||
|
ticket: origin.split('ticket=')[1].split('#/')[0],
|
||||||
|
sysType: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
userStore.setToken(res.data.access_token)
|
||||||
|
|
||||||
|
localStorage.setItem('tokenNew', res.data.access_token)
|
||||||
|
const result: any = await getUserInfoAPI()
|
||||||
|
userStore.setUserInfo(result.user)
|
||||||
|
const roles = result.roles
|
||||||
|
const isAdmin = roles.some((e: any) => e == 'admin')
|
||||||
|
|
||||||
|
if (isAdmin) {
|
||||||
|
localStorage.setItem('rolesType', '3')
|
||||||
|
} else {
|
||||||
|
localStorage.setItem('rolesType', '1')
|
||||||
|
}
|
||||||
|
store.editcurrentMenuItem('goodsManagement')
|
||||||
|
// 跳转登录页面
|
||||||
|
router.push({
|
||||||
|
name: 'home',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -138,8 +172,8 @@ const handlerLogin = async () => {
|
||||||
class="primary-lease"
|
class="primary-lease"
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="handlerLogin"
|
@click="handlerLogin"
|
||||||
>立 即 登 录</el-button
|
>立 即 登 录
|
||||||
>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <el-form-item class="forget-password">
|
<!-- <el-form-item class="forget-password">
|
||||||
<a href=""></a>
|
<a href=""></a>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ import { useStore } from 'store/user'
|
||||||
import { mainStore } from 'store/main'
|
import { mainStore } from 'store/main'
|
||||||
import { getHotList } from 'http/api/equip'
|
import { getHotList } from 'http/api/equip'
|
||||||
import userClass from '../../hooks/userClass'
|
import userClass from '../../hooks/userClass'
|
||||||
|
import { loginNewApi } from 'http/api/home/index'
|
||||||
|
import { getUserInfoAPI } from 'http/api/login/index'
|
||||||
|
|
||||||
import imgSrc from '../../assets/img/home/nw.png'
|
import imgSrc from '../../assets/img/home/nw.png'
|
||||||
import swiper_1 from '../../assets/img/home/swiper01.png'
|
import swiper_1 from '../../assets/img/home/swiper01.png'
|
||||||
|
|
@ -115,7 +117,7 @@ const getHotDeviceList = async () => {
|
||||||
hotDeviceList.value = res.data
|
hotDeviceList.value = res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
getHotDeviceList()
|
// getHotDeviceList()
|
||||||
|
|
||||||
/* 热搜卡片点击跳转至详情页 */
|
/* 热搜卡片点击跳转至详情页 */
|
||||||
const onClick = (val: any) => {
|
const onClick = (val: any) => {
|
||||||
|
|
@ -162,6 +164,37 @@ const onClickSwiper = (item: any) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
getSwiperListData()
|
getSwiperListData()
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (!store.token) {
|
||||||
|
const origin = window.location.href
|
||||||
|
|
||||||
|
console.log(origin.split('ticket=')[1], 'origin')
|
||||||
|
|
||||||
|
if (origin.indexOf('ticket') != -1) {
|
||||||
|
// console.log('origin.split爱玩送ticket')
|
||||||
|
const res: any = await loginNewApi({
|
||||||
|
ticket: origin.split('ticket=')[1].split('#/')[0],
|
||||||
|
sysType: 0,
|
||||||
|
})
|
||||||
|
|
||||||
|
store.setToken(res.data.access_token)
|
||||||
|
localStorage.setItem('tokenNew', res.data.access_token)
|
||||||
|
const result: any = await getUserInfoAPI()
|
||||||
|
store.setUserInfo(result.user)
|
||||||
|
const roles = result.roles
|
||||||
|
const isAdmin = roles.some((e: any) => e == 'admin')
|
||||||
|
|
||||||
|
if (isAdmin) {
|
||||||
|
localStorage.setItem('rolesType', '3')
|
||||||
|
} else {
|
||||||
|
localStorage.setItem('rolesType', '1')
|
||||||
|
}
|
||||||
|
userStore.editcurrentMenuItem('goodsManagement')
|
||||||
|
// 跳转登录页面
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue