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 4f6a1836
authored
Aug 18, 2022
by
匡雅琴
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'huy_v2.8.1' of
http://192.168.3.233:8090/h5/vite-integral
into huy_v2.8.1
2 parents
d26b45bf
be6f74c6
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
0 additions
and
25 deletions
src/router/index.ts
src/store/user.ts
src/utils/http.ts
src/utils/request.ts
src/views/home/index.vue
src/views/home/userInfo.vue
src/views/login/index.vue
src/router/index.ts
View file @
4f6a183
...
...
@@ -6,7 +6,6 @@ const routerHistory = createWebHashHistory()
// createWebHistory history 路由
// createMemoryHistory 带缓存history路由
console
.
log
(
routes
)
const
router
=
createRouter
({
history
:
routerHistory
,
routes
:
routes
...
...
src/store/user.ts
View file @
4f6a183
...
...
@@ -8,7 +8,6 @@ export const useUserStore = defineStore({
getters
:
{
getSession
:
state
=>
{
if
(
!
state
.
sessionId
)
{
console
.
log
(
state
.
sessionId
)
state
.
sessionId
=
localStorage
.
getItem
(
'sessionId'
)
||
''
}
return
state
.
sessionId
...
...
src/utils/http.ts
View file @
4f6a183
...
...
@@ -32,10 +32,8 @@ const service: AxiosInstance = axios.create({
// 添加请求拦截器
service
.
interceptors
.
request
.
use
((
config
:
AxiosRequestConfig
)
=>
{
console
.
log
(
config
)
let
{
data
=
{}
}
=
config
data
=
createSign
(
Object
.
assign
({},
sign
,
data
),
secret
)
// console.log(config)
if
(
config
.
method
)
{
const
method
=
config
.
method
.
toLowerCase
()
if
(
method
==
'get'
)
{
...
...
@@ -51,7 +49,6 @@ service.interceptors.request.use((config: AxiosRequestConfig) => {
// 添加响应拦截器
service
.
interceptors
.
response
.
use
((
r
)
=>
{
console
.
log
(
r
)
const
{
data
:
res
,
config
:
{
returnAll
}
}
=
r
const
{
code_key
,
code_success_value
,
data_key
=
'data'
,
errId_logout_value
}
=
response
const
errId
=
'errId'
...
...
@@ -61,7 +58,6 @@ service.interceptors.response.use((r) => {
let
codekey
=
Array
.
isArray
(
code_key
)
?
code_key
.
find
(
key
=>
res
.
hasOwnProperty
(
key
))
:
code_key
let
code
=
res
[
codekey
]
let
errValue
=
res
[
errId
]
console
.
log
(
code
,
errValue
)
// 特殊的code处理,可以增加
switch
(
code
+
''
)
{
case
code_success_value
+
''
:
...
...
@@ -69,7 +65,6 @@ service.interceptors.response.use((r) => {
case
errId_logout_value
+
''
:
localStorage
.
removeItem
(
'sessionId'
)
router
.
push
(
'/login'
)
console
.
log
(
'退出登录'
)
break
default
:
if
(
errValue
&&
errValue
==
errId_logout_value
)
{
...
...
src/utils/request.ts
View file @
4f6a183
...
...
@@ -3,9 +3,7 @@ import { useUserStore } from '../store/user'
const
PATH
=
'rop-scrm-renewal/router'
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
http
({
...
...
src/views/home/index.vue
View file @
4f6a183
...
...
@@ -178,11 +178,7 @@ let total = ref<number>(1);
// 校验是否登录
const
hasSession
=
()
=>
{
console
.
log
(
"123"
);
const
sessionId
=
userStore
.
getSession
;
console
.
log
(
sessionId
,
"12333"
);
if
(
sessionId
)
{
onLoad
();
getUserInfo
();
...
...
@@ -191,9 +187,6 @@ const hasSession = () => {
Toast
(
"请先登录"
);
logout
();
}
// if (!sessionId) Toast("请先登录");
// // onLoad
// sessionId ? getUserInfo() : logout();
};
// 获取用户信息
const
getUserInfo
=
async
()
=>
{
...
...
@@ -215,7 +208,6 @@ const routerTo = (value: string) => {
// 登出
const
logout
=
()
=>
{
userStore
.
logout
();
// router.replace("/login")
router
.
replace
({
path
:
"/login"
,
query
:
{
...
...
@@ -227,7 +219,6 @@ const logout = () => {
// 下拉加载积分历史明细数据
const
onLoad
=
async
()
=>
{
console
.
log
(
"456"
);
loading
.
value
=
true
;
let
params
:
{
pageNum
?:
number
;
...
...
@@ -252,7 +243,6 @@ const onLoad = async () => {
// 组件挂载完成
onBeforeMount
(()
=>
{
hasSession
();
// onLoad();
});
</
script
>
...
...
src/views/home/userInfo.vue
View file @
4f6a183
...
...
@@ -47,12 +47,10 @@ const router = useRouter()
// 获取个人信息
const
getUserInfo
=
async
()
=>
{
const
res
=
await
req
(
'scrm.api.renewal.h5.customer.get'
)
console
.
log
(
res
)
userData
.
userInfo
=
res
}
// 修改个人信息
const
update
=
async
(
values
:
object
)
=>
{
console
.
log
(
values
,
userData
.
userInfo
)
const
params
:
{
cardName
?:
string
,
id
?:
string
,
authStatus
?:
number
}
=
{...
values
}
const
{
id
,
name
,
authStatus
}
=
userData
.
userInfo
params
.
cardName
=
name
...
...
@@ -60,7 +58,6 @@ const update = async(values: object) => {
params
.
authStatus
=
authStatus
const
res
=
await
req
(
'scrm.api.renewal.h5.customer.update'
,
params
,
true
)
const
{
code
,
data
,
message
}
=
res
console
.
log
(
res
)
if
(
code
==
0
)
{
Toast
(
'修改成功'
)
router
.
go
(
-
1
)
...
...
src/views/login/index.vue
View file @
4f6a183
...
...
@@ -54,7 +54,6 @@ let userForm = reactive({
});
let
timeout
:
number
|
undefined
=
undefined
;
const
time
=
ref
();
console
.
log
(
userStore
.
getSession
);
watch
(
time
,
(
newVal
)
=>
{
if
(
newVal
==
0
)
{
clearInterval
(
timeout
);
...
...
@@ -95,7 +94,6 @@ const register = () => {
// 登录
const
onSubmit
=
async
(
values
:
any
)
=>
{
const
res
=
await
req
(
"scrm.api.renewal.h5.customer.login"
,
values
);
console
.
log
(
res
);
if
(
res
)
{
const
sessionId
=
res
.
loginSessionId
;
userStore
.
updateSessionId
(
sessionId
);
...
...
@@ -104,7 +102,6 @@ const onSubmit = async (values: any) => {
}
};
onMounted
(()
=>
{
console
.
log
(
route
.
query
)
if
(
route
.
query
)
{
userForm
=
Object
.
assign
(
userForm
,
route
.
query
)
}
...
...
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