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([
...
@@ -64,9 +64,9 @@ const staticRoutes = Object.freeze([
}
}
},
},
{
{
name
:
'
Information
'
,
name
:
'
UserInfo
'
,
path
:
'/
information
'
,
path
:
'/
userInfo
'
,
component
:
()
=>
import
(
'views/home/
information
.vue'
),
component
:
()
=>
import
(
'views/home/
userInfo
.vue'
),
meta
:
{
meta
:
{
title
:
'我的信息'
,
title
:
'我的信息'
,
backgroundColor
:
'#fff'
backgroundColor
:
'#fff'
...
...
src/utils/axios.ts
View file @
61d810d
...
@@ -5,7 +5,7 @@ import router, { resetRoute } from '../router'
...
@@ -5,7 +5,7 @@ import router, { resetRoute } from '../router'
import
qs
from
'qs'
import
qs
from
'qs'
import
{
createSign
}
from
'./util'
import
{
createSign
}
from
'./util'
import
$mockConfig
from
'./config'
import
$mockConfig
from
'./config'
//
import { useUserStore } from '../store/user'
import
{
useUserStore
}
from
'../store/user'
// function getSession(key: string) {
// function getSession(key: string) {
// let json: any = window.sessionStorage.getItem(key)
// let json: any = window.sessionStorage.getItem(key)
// return JSON.parse(json)
// return JSON.parse(json)
...
@@ -85,6 +85,7 @@ service.interceptors.response.use(
...
@@ -85,6 +85,7 @@ service.interceptors.response.use(
console
.
log
(
2
)
console
.
log
(
2
)
localStorage
.
removeItem
(
'sessionId'
)
localStorage
.
removeItem
(
'sessionId'
)
router
.
push
(
'/logged'
)
router
.
push
(
'/logged'
)
console
.
log
(
'session失效,登出'
,
useUserStore
().
getSession
)
}
}
Toast
(
res
.
message
||
res
.
msg
||
'出错了,请联系管理员'
)
Toast
(
res
.
message
||
res
.
msg
||
'出错了,请联系管理员'
)
break
break
...
...
src/utils/request.ts
View file @
61d810d
import
axios
from
'./axios'
import
axios
from
'./axios'
import
{
useUserStore
}
from
'../store/user'
import
{
useUserStore
}
from
'../store/user'
const
PATH
=
'rop-scrm-renewal/router'
const
PATH
=
'rop-scrm-renewal/router'
let
sessionId
=
useUserStore
().
getSession
console
.
log
(
sessionId
)
const
req
:
any
=
(
url
:
string
,
data
:
any
=
{},
returnAll
=
false
,
method
=
'POST'
,
)
=>
{
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
if
(
sessionId
)
data
.
loginSessionId
=
sessionId
data
.
method
=
url
data
.
method
=
url
return
axios
({
return
axios
({
...
...
src/views/home/index.vue
View file @
61d810d
...
@@ -12,28 +12,28 @@
...
@@ -12,28 +12,28 @@
<img
class=
"user-avatar"
src=
"@/assets/images/avatar.png"
alt=
""
/>
<img
class=
"user-avatar"
src=
"@/assets/images/avatar.png"
alt=
""
/>
<div
class=
"userinfo"
>
<div
class=
"userinfo"
>
<div
class=
"user-top"
>
<div
class=
"user-top"
>
<span
class=
"username"
>
王美丽
</span>
<span
class=
"username"
>
{{
data
.
userInfo
.
name
}}
</span>
<img
class=
"auth"
src=
"@/assets/images/auth.png"
alt=
""
/>
<img
v-if=
"data.userInfo.authStatus == 1"
class=
"auth"
src=
"@/assets/images/auth.png"
alt=
""
/>
</div>
</div>
<div>
<div>
<span>
1369526347丨粤B75963
</span>
<span>
{{
data
.
userInfo
.
mobile
}}
丨
{{
data
.
userInfo
.
plateNo
}}
</span>
</div>
</div>
</div>
</div>
<div
class=
"logout"
@
click=
"logout"
>
退出登录
</div>
<div
class=
"logout"
@
click=
"logout"
>
退出登录
</div>
</div>
</div>
<div
class=
"user-btn"
>
<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=
""
/>
<img
class=
"nav-img"
src=
"@/assets/images/use-info.png"
alt=
""
/>
<div>
积分使用记录
</div>
<div>
积分使用记录
</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=
""
/>
<img
class=
"nav-img"
src=
"@/assets/images/my-info.png"
alt=
""
/>
<div>
我的信息
</div>
<div>
我的信息
</div>
</div>
</div>
</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"
>
<div
class=
"history-list-top"
>
<img
class=
"top-img"
src=
"@/assets/images/list-info.png"
alt=
""
/>
<img
class=
"top-img"
src=
"@/assets/images/list-info.png"
alt=
""
/>
</div>
</div>
...
@@ -78,7 +78,13 @@ type listStyle = {
...
@@ -78,7 +78,13 @@ type listStyle = {
const
userStore
=
useUserStore
()
const
userStore
=
useUserStore
()
const
router
=
useRouter
();
const
router
=
useRouter
();
const
data
=
reactive
({
const
data
=
reactive
({
innerHeight
:
window
.
innerHeight
// 获取可视区高度
innerHeight
:
window
.
innerHeight
,
// 获取可视区高度
userInfo
:
{
name
:
''
,
mobile
:
''
,
plateNo
:
''
,
authStatus
:
0
}
})
})
const
list
=
reactive
<
listStyle
>
([]);
const
list
=
reactive
<
listStyle
>
([]);
...
@@ -86,17 +92,15 @@ let id = ref<number>(0);
...
@@ -86,17 +92,15 @@ let id = ref<number>(0);
const
loading
=
ref
<
boolean
>
(
true
);
const
loading
=
ref
<
boolean
>
(
true
);
const
finished
=
ref
<
boolean
>
(
false
);
const
finished
=
ref
<
boolean
>
(
false
);
// 校验是否登录
const
getUserInfo
=
async
()
=>
{
const
hasSession
=
()
=>
{
const
res
=
await
req
(
'scrm.api.renewal.customer.h5.get'
)
console
.
log
(
userStore
.
getSession
)
data
.
userInfo
=
res
const
sessionId
=
userStore
.
getSession
}
// isLogin.value = !!sessionId
if
(
!
sessionId
)
logout
()
// 路由跳转,value:跳转页面路径
const
routerTo
=
(
value
:
string
)
=>
{
router
.
push
(
`/
${
value
}
`
)
}
}
// 跳到登录页面
const
toLogin
=
()
=>
{
router
.
push
(
"/login"
);
};
// 登出
// 登出
const
logout
=
()
=>
{
const
logout
=
()
=>
{
...
@@ -105,15 +109,6 @@ const logout = () => {
...
@@ -105,15 +109,6 @@ const logout = () => {
// isLogin.value = false;
// isLogin.value = false;
};
};
// 跳到积分使用记录页面
const
toUseList
=
()
=>
{
router
.
push
(
"/uselist"
);
};
// 跳转我的信息
const
toInformation
=
()
=>
{
router
.
push
(
"/information"
);
};
// 下拉加载数据
// 下拉加载数据
const
onLoad
=
():
void
=>
{
const
onLoad
=
():
void
=>
{
loading
.
value
=
true
;
loading
.
value
=
true
;
...
@@ -139,7 +134,7 @@ const onLoad = (): void => {
...
@@ -139,7 +134,7 @@ const onLoad = (): void => {
// 组件挂载完成
// 组件挂载完成
onBeforeMount
(()
=>
{
onBeforeMount
(()
=>
{
onLoad
()
onLoad
()
hasSession
()
getUserInfo
()
});
});
</
script
>
</
script
>
...
...
src/views/home/
information
.vue
→
src/views/home/
userInfo
.vue
View file @
61d810d
...
@@ -42,9 +42,7 @@ const getUserInfo = async() => {
...
@@ -42,9 +42,7 @@ const getUserInfo = async() => {
// const {mobile, plateNo, name, bankName, bankNo} = res
// const {mobile, plateNo, name, bankName, bankNo} = res
data
.
userInfo
=
res
data
.
userInfo
=
res
}
}
onBeforeMount
(()
=>
{
getUserInfo
()
getUserInfo
()
})
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.register
{
.register
{
...
...
src/views/login/index.vue
View file @
61d810d
...
@@ -31,7 +31,7 @@ import { ref, reactive, watch } from 'vue'
...
@@ -31,7 +31,7 @@ import { ref, reactive, watch } from 'vue'
import
{
useRouter
}
from
'vue-router'
import
{
useRouter
}
from
'vue-router'
import
{
useUserStore
}
from
'../../store/user'
import
{
useUserStore
}
from
'../../store/user'
import
req
from
"../../utils/request"
import
req
from
"../../utils/request"
import
{
Notify
,
Toast
}
from
'vant'
;
import
{
Toast
}
from
'vant'
;
import
{
isVehicleNumber
,
isTel
}
from
'../../utils/common'
import
{
isVehicleNumber
,
isTel
}
from
'../../utils/common'
const
router
=
useRouter
()
const
router
=
useRouter
()
const
userStore
=
useUserStore
()
const
userStore
=
useUserStore
()
...
@@ -42,7 +42,7 @@ const userForm = reactive({
...
@@ -42,7 +42,7 @@ const userForm = reactive({
})
})
let
timeout
:
number
|
undefined
=
undefined
let
timeout
:
number
|
undefined
=
undefined
const
time
=
ref
()
const
time
=
ref
()
console
.
log
(
userStore
.
getSession
)
watch
(
time
,
(
newVal
)
=>
{
watch
(
time
,
(
newVal
)
=>
{
if
(
newVal
==
0
)
{
if
(
newVal
==
0
)
{
clearInterval
(
timeout
)
clearInterval
(
timeout
)
...
@@ -82,6 +82,7 @@ const onSubmit = async (values: any) => {
...
@@ -82,6 +82,7 @@ const onSubmit = async (values: any) => {
const
sessionId
=
res
.
loginSessionId
const
sessionId
=
res
.
loginSessionId
userStore
.
updateSessionId
(
sessionId
)
userStore
.
updateSessionId
(
sessionId
)
router
.
push
(
'/'
)
router
.
push
(
'/'
)
console
.
log
(
'登录了'
,
userStore
.
getSession
)
}
}
}
}
</
script
>
</
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