Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
vite-integral
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 61d810d3
authored
Aug 10, 2022
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改
1 parent
09767b60
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
38 deletions
src/router/routes.ts
src/utils/axios.ts
src/utils/request.ts
src/views/home/index.vue
src/views/home/information.vue → src/views/home/userInfo.vue
src/views/login/index.vue
src/router/routes.ts
View file @
61d810d
...
...
@@ -64,9 +64,9 @@ const staticRoutes = Object.freeze([
}
},
{
name
:
'
Information
'
,
path
:
'/
information
'
,
component
:
()
=>
import
(
'views/home/
information
.vue'
),
name
:
'
UserInfo
'
,
path
:
'/
userInfo
'
,
component
:
()
=>
import
(
'views/home/
userInfo
.vue'
),
meta
:
{
title
:
'我的信息'
,
backgroundColor
:
'#fff'
...
...
src/utils/axios.ts
View file @
61d810d
...
...
@@ -5,7 +5,7 @@ import router, { resetRoute } from '../router'
import
qs
from
'qs'
import
{
createSign
}
from
'./util'
import
$mockConfig
from
'./config'
//
import { useUserStore } from '../store/user'
import
{
useUserStore
}
from
'../store/user'
// function getSession(key: string) {
// let json: any = window.sessionStorage.getItem(key)
// return JSON.parse(json)
...
...
@@ -85,6 +85,7 @@ service.interceptors.response.use(
console
.
log
(
2
)
localStorage
.
removeItem
(
'sessionId'
)
router
.
push
(
'/logged'
)
console
.
log
(
'session失效,登出'
,
useUserStore
().
getSession
)
}
Toast
(
res
.
message
||
res
.
msg
||
'出错了,请联系管理员'
)
break
...
...
src/utils/request.ts
View file @
61d810d
import
axios
from
'./axios'
import
{
useUserStore
}
from
'../store/user'
const
PATH
=
'rop-scrm-renewal/router'
let
sessionId
=
useUserStore
().
getSession
console
.
log
(
sessionId
)
const
req
:
any
=
(
url
:
string
,
data
:
any
=
{},
returnAll
=
false
,
method
=
'POST'
,
)
=>
{
console
.
log
(
useUserStore
().
getSession
,
'---'
)
let
sessionId
=
useUserStore
().
getSession
console
.
log
(
'调用接口前'
,
sessionId
)
if
(
sessionId
)
data
.
loginSessionId
=
sessionId
data
.
method
=
url
return
axios
({
...
...
src/views/home/index.vue
View file @
61d810d
...
...
@@ -12,28 +12,28 @@
<img
class=
"user-avatar"
src=
"@/assets/images/avatar.png"
alt=
""
/>
<div
class=
"userinfo"
>
<div
class=
"user-top"
>
<span
class=
"username"
>
王美丽
</span>
<img
class=
"auth"
src=
"@/assets/images/auth.png"
alt=
""
/>
<span
class=
"username"
>
{{
data
.
userInfo
.
name
}}
</span>
<img
v-if=
"data.userInfo.authStatus == 1"
class=
"auth"
src=
"@/assets/images/auth.png"
alt=
""
/>
</div>
<div>
<span>
1369526347丨粤B75963
</span>
<span>
{{
data
.
userInfo
.
mobile
}}
丨
{{
data
.
userInfo
.
plateNo
}}
</span>
</div>
</div>
<div
class=
"logout"
@
click=
"logout"
>
退出登录
</div>
</div>
<div
class=
"user-btn"
>
<div
class=
"user-btn-content"
@
click=
"
toUseList
"
>
<div
class=
"user-btn-content"
@
click=
"
routerTo('uselist')
"
>
<img
class=
"nav-img"
src=
"@/assets/images/use-info.png"
alt=
""
/>
<div>
积分使用记录
</div>
</div>
<div
class=
"user-btn-content"
@
click=
"
toInformation
"
>
<div
class=
"user-btn-content"
@
click=
"
routerTo('userInfo')
"
>
<img
class=
"nav-img"
src=
"@/assets/images/my-info.png"
alt=
""
/>
<div>
我的信息
</div>
</div>
</div>
</div>
</div>
<div
class=
"wrapper-history-list"
:style=
"
{ height: data.innerHeight - (280 + 10 + 28) + 'px' }"
>
<div
class=
"wrapper-history-list"
>
<div
class=
"history-list-top"
>
<img
class=
"top-img"
src=
"@/assets/images/list-info.png"
alt=
""
/>
</div>
...
...
@@ -78,7 +78,13 @@ type listStyle = {
const
userStore
=
useUserStore
()
const
router
=
useRouter
();
const
data
=
reactive
({
innerHeight
:
window
.
innerHeight
// 获取可视区高度
innerHeight
:
window
.
innerHeight
,
// 获取可视区高度
userInfo
:
{
name
:
''
,
mobile
:
''
,
plateNo
:
''
,
authStatus
:
0
}
})
const
list
=
reactive
<
listStyle
>
([]);
...
...
@@ -86,17 +92,15 @@ let id = ref<number>(0);
const
loading
=
ref
<
boolean
>
(
true
);
const
finished
=
ref
<
boolean
>
(
false
);
// 校验是否登录
const
hasSession
=
()
=>
{
console
.
log
(
userStore
.
getSession
)
const
sessionId
=
userStore
.
getSession
// isLogin.value = !!sessionId
if
(
!
sessionId
)
logout
()
const
getUserInfo
=
async
()
=>
{
const
res
=
await
req
(
'scrm.api.renewal.customer.h5.get'
)
data
.
userInfo
=
res
}
// 路由跳转,value:跳转页面路径
const
routerTo
=
(
value
:
string
)
=>
{
router
.
push
(
`/
${
value
}
`
)
}
// 跳到登录页面
const
toLogin
=
()
=>
{
router
.
push
(
"/login"
);
};
// 登出
const
logout
=
()
=>
{
...
...
@@ -105,15 +109,6 @@ const logout = () => {
// isLogin.value = false;
};
// 跳到积分使用记录页面
const
toUseList
=
()
=>
{
router
.
push
(
"/uselist"
);
};
// 跳转我的信息
const
toInformation
=
()
=>
{
router
.
push
(
"/information"
);
};
// 下拉加载数据
const
onLoad
=
():
void
=>
{
loading
.
value
=
true
;
...
...
@@ -139,7 +134,7 @@ const onLoad = (): void => {
// 组件挂载完成
onBeforeMount
(()
=>
{
onLoad
()
hasSession
()
getUserInfo
()
});
</
script
>
...
...
src/views/home/
information
.vue
→
src/views/home/
userInfo
.vue
View file @
61d810d
...
...
@@ -42,9 +42,7 @@ const getUserInfo = async() => {
// const {mobile, plateNo, name, bankName, bankNo} = res
data
.
userInfo
=
res
}
onBeforeMount
(()
=>
{
getUserInfo
()
})
getUserInfo
()
</
script
>
<
style
lang=
"scss"
scoped
>
.register
{
...
...
src/views/login/index.vue
View file @
61d810d
...
...
@@ -31,7 +31,7 @@ import { ref, reactive, watch } from 'vue'
import
{
useRouter
}
from
'vue-router'
import
{
useUserStore
}
from
'../../store/user'
import
req
from
"../../utils/request"
import
{
Notify
,
Toast
}
from
'vant'
;
import
{
Toast
}
from
'vant'
;
import
{
isVehicleNumber
,
isTel
}
from
'../../utils/common'
const
router
=
useRouter
()
const
userStore
=
useUserStore
()
...
...
@@ -42,7 +42,7 @@ const userForm = reactive({
})
let
timeout
:
number
|
undefined
=
undefined
const
time
=
ref
()
console
.
log
(
userStore
.
getSession
)
watch
(
time
,
(
newVal
)
=>
{
if
(
newVal
==
0
)
{
clearInterval
(
timeout
)
...
...
@@ -82,6 +82,7 @@ const onSubmit = async (values: any) => {
const
sessionId
=
res
.
loginSessionId
userStore
.
updateSessionId
(
sessionId
)
router
.
push
(
'/'
)
console
.
log
(
'登录了'
,
userStore
.
getSession
)
}
}
</
script
>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment