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 0a44d422
authored
Aug 16, 2022
by
胡悦
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
注册,退出登录,带参数跳转
1 parent
272dcbed
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
20 deletions
src/utils/http.ts
src/views/home/index.vue
src/views/login/index.vue
src/views/login/register.vue
src/views/login/registerSuccess.vue
src/utils/http.ts
View file @
0a44d42
...
@@ -72,7 +72,7 @@ service.interceptors.response.use((r) => {
...
@@ -72,7 +72,7 @@ service.interceptors.response.use((r) => {
default
:
default
:
if
(
errValue
&&
errValue
==
errId_logout_value
)
{
if
(
errValue
&&
errValue
==
errId_logout_value
)
{
localStorage
.
removeItem
(
'sessionId'
)
localStorage
.
removeItem
(
'sessionId'
)
router
.
push
(
'/login'
)
router
.
replace
(
'/login'
)
}
}
Toast
(
res
.
message
||
res
.
msg
||
'出错了,请联系管理员'
)
Toast
(
res
.
message
||
res
.
msg
||
'出错了,请联系管理员'
)
break
break
...
...
src/views/home/index.vue
View file @
0a44d42
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
</div>
</div>
</div>
</div>
<div>
<div>
<span
class=
"user-mobile"
>
{{
data
.
userInfo
.
mobile
}}
丨
{{
data
.
userInfo
.
plateNo
}}
</span>
<span
class=
"user-mobile"
>
{{
data
.
userInfo
.
mobile
}}
<span
v-if=
"data.userInfo.plateNo"
>
丨
</span>
{{
data
.
userInfo
.
plateNo
}}
</span>
</div>
</div>
</div>
</div>
<div
class=
"logout"
@
click=
"logout"
>
退出登录
</div>
<div
class=
"logout"
@
click=
"logout"
>
退出登录
</div>
...
@@ -179,7 +179,14 @@ const routerTo = (value: string) => {
...
@@ -179,7 +179,14 @@ const routerTo = (value: string) => {
// 登出
// 登出
const
logout
=
()
=>
{
const
logout
=
()
=>
{
userStore
.
logout
();
userStore
.
logout
();
router
.
push
(
"/login"
);
// router.replace("/login")
router
.
replace
({
path
:
'/login'
,
query
:
{
plateNo
:
data
.
userInfo
.
plateNo
,
mobile
:
data
.
userInfo
.
mobile
}
})
};
};
// 下拉加载积分历史明细数据
// 下拉加载积分历史明细数据
...
@@ -225,6 +232,7 @@ onBeforeMount(() => {
...
@@ -225,6 +232,7 @@ onBeforeMount(() => {
}
}
.wrapper
{
.wrapper
{
//
padding-bottom
:
28px
;
.login
{
.login
{
height
:
291px
;
height
:
291px
;
margin
:
98px
16px
0
;
margin
:
98px
16px
0
;
...
@@ -272,7 +280,7 @@ onBeforeMount(() => {
...
@@ -272,7 +280,7 @@ onBeforeMount(() => {
&
-history-list
{
&
-history-list
{
background-color
:
#fff
;
background-color
:
#fff
;
border-radius
:
4px
;
border-radius
:
4px
;
margin
:
0
16px
28px
;
margin
:
0
16px
;
width
:
calc
(
100%
-
32px
);
width
:
calc
(
100%
-
32px
);
//
overflow
:
auto
;
//
overflow
:
auto
;
...
@@ -393,6 +401,7 @@ onBeforeMount(() => {
...
@@ -393,6 +401,7 @@ onBeforeMount(() => {
position
:
relative
;
position
:
relative
;
display
:
flex
;
display
:
flex
;
justify-items
:
center
;
justify-items
:
center
;
align-items
:
flex-end
;
padding
:
20px
;
padding
:
20px
;
.user-top
{
.user-top
{
...
...
src/views/login/index.vue
View file @
0a44d42
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
{ validator: isTel, message: '请输入正确的手机号' },
{ validator: isTel, message: '请输入正确的手机号' },
]" />
]" />
<van-field
v-model=
"userForm.captcha"
type=
"number"
name=
"captcha"
maxlength=
"4"
placeholder=
"请输入验证码"
clearable
<van-field
v-model=
"userForm.captcha"
type=
"number"
name=
"captcha"
maxlength=
"4"
placeholder=
"请输入验证码"
clearable
:rules=
"[
{ required: true, message: '请输入验证码' }]">
:rules=
"[
{ required: true, message: '请输入验证码' }
,{validator: isNumber, message: '仅支持输入数字'}
]">
<template
#
button
>
<template
#
button
>
<span
v-if=
"!time"
class=
"code"
@
click=
"getCode(userForm.mobile)"
>
获取验证码
</span>
<span
v-if=
"!time"
class=
"code"
@
click=
"getCode(userForm.mobile)"
>
获取验证码
</span>
<span
class=
"gray-code"
v-else
>
{{
time
}}
秒后重发
</span>
<span
class=
"gray-code"
v-else
>
{{
time
}}
秒后重发
</span>
...
@@ -35,21 +35,22 @@
...
@@ -35,21 +35,22 @@
</template>
</template>
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
ref
,
reactive
,
watch
}
from
"vue"
;
import
{
ref
,
reactive
,
watch
,
onMounted
}
from
"vue"
;
import
{
useRouter
}
from
"vue-router"
;
import
{
useRouter
,
useRoute
}
from
"vue-router"
;
import
{
useUserStore
}
from
"../../store/user"
;
import
{
useUserStore
}
from
"../../store/user"
;
import
req
from
"../../utils/request"
;
import
req
from
"../../utils/request"
;
import
{
Toast
}
from
"vant"
;
import
{
Toast
}
from
"vant"
;
import
{
isVehicleNumber
,
isTel
}
from
"../../utils/common"
;
import
{
isVehicleNumber
,
isTel
,
isNumber
}
from
"../../utils/common"
;
const
router
=
useRouter
();
const
router
=
useRouter
();
const
route
=
useRoute
()
const
userStore
=
useUserStore
();
const
userStore
=
useUserStore
();
cons
t
userForm
=
reactive
({
le
t
userForm
=
reactive
({
plateNo
:
''
,
plateNo
:
''
,
mobile
:
''
,
mobile
:
''
,
captcha
:
''
captcha
:
''
// plateNo: "湘MM4500",
// plateNo: "湘MM4500",
// mobile: "1
8925261040
",
// mobile: "1
7307427218
",
// captcha: "
7177
",
// captcha: "
8888
",
});
});
let
timeout
:
number
|
undefined
=
undefined
;
let
timeout
:
number
|
undefined
=
undefined
;
const
time
=
ref
();
const
time
=
ref
();
...
@@ -59,7 +60,6 @@ watch(time, (newVal) => {
...
@@ -59,7 +60,6 @@ watch(time, (newVal) => {
clearInterval
(
timeout
);
clearInterval
(
timeout
);
}
}
});
});
/** 定义的方法 */
/** 定义的方法 */
// 获取验证码
// 获取验证码
const
getCode
=
async
(
value
:
string
)
=>
{
const
getCode
=
async
(
value
:
string
)
=>
{
...
@@ -99,10 +99,16 @@ const onSubmit = async (values: any) => {
...
@@ -99,10 +99,16 @@ const onSubmit = async (values: any) => {
if
(
res
)
{
if
(
res
)
{
const
sessionId
=
res
.
loginSessionId
;
const
sessionId
=
res
.
loginSessionId
;
userStore
.
updateSessionId
(
sessionId
);
userStore
.
updateSessionId
(
sessionId
);
router
.
push
(
"/"
);
router
.
replace
(
"/"
);
console
.
log
(
"登录了"
,
userStore
.
getSession
);
console
.
log
(
"登录了"
,
userStore
.
getSession
);
}
}
};
};
onMounted
(()
=>
{
console
.
log
(
route
.
query
)
if
(
route
.
query
)
{
userForm
=
Object
.
assign
(
userForm
,
route
.
query
)
}
})
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
...
...
src/views/login/register.vue
View file @
0a44d42
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<div
class=
"form-item"
>
<div
class=
"form-item"
>
<van-field
:size=
"registerData.formSize"
v-model=
"registerData.register.mobile"
name=
"mobile"
type=
"number"
maxlength=
"11"
label=
"手机号"
placeholder=
"手机号"
clearable
@
focus=
"onFocus('mobile')"
@
blur=
"onBlur('mobile')"
:rules=
"[
{ required: true, message: '请输入您的手机号' }, { validator: isTel, message: '请输入正确的手机号' }]" />
<van-field
:size=
"registerData.formSize"
v-model=
"registerData.register.mobile"
name=
"mobile"
type=
"number"
maxlength=
"11"
label=
"手机号"
placeholder=
"手机号"
clearable
@
focus=
"onFocus('mobile')"
@
blur=
"onBlur('mobile')"
:rules=
"[
{ required: true, message: '请输入您的手机号' }, { validator: isTel, message: '请输入正确的手机号' }]" />
<van-field
:size=
"registerData.formSize"
label=
" "
v-model=
"registerData.register.captcha"
type=
"number"
name=
"captcha"
maxlength=
"4"
clearable
<van-field
:size=
"registerData.formSize"
label=
" "
v-model=
"registerData.register.captcha"
type=
"number"
name=
"captcha"
maxlength=
"4"
clearable
placeholder=
"验证码"
:rules=
"[
{ required: true, message: '请输入您的验证码' }]">
<template
#
button
>
placeholder=
"验证码"
:rules=
"[
{ required: true, message: '请输入您的验证码' }
,{validator: isNumber, message: '仅支持输入数字'}
]">
<template
#
button
>
<span
v-if=
"!time"
class=
"code"
@
click=
"getCode(registerData.register.mobile)"
>
获取验证码
</span>
<span
v-if=
"!time"
class=
"code"
@
click=
"getCode(registerData.register.mobile)"
>
获取验证码
</span>
<span
class=
"gray-code"
v-else
>
{{
time
}}
秒后重发
</span>
<span
class=
"gray-code"
v-else
>
{{
time
}}
秒后重发
</span>
</
template
>
</
template
>
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
<div
class=
"form-explain"
v-show=
"registerData.tips.mobile"
>
请确保您输入的手机号是与客服人员协商好的权益关联手机号
</div>
<div
class=
"form-explain"
v-show=
"registerData.tips.mobile"
>
请确保您输入的手机号是与客服人员协商好的权益关联手机号
</div>
</div>
</div>
<div
class=
"form-item"
>
<div
class=
"form-item"
>
<van-field
:size=
"registerData.formSize"
v-model=
"registerData.register.plateNo"
name=
"plateNo"
label=
"车牌号"
placeholder=
"车牌号"
clearable
@
focus=
"onFocus('plateNo')"
@
blur=
"onBlur('plateNo')"
<van-field
:size=
"registerData.formSize"
v-model=
"registerData.register.plateNo"
name=
"plateNo"
label=
"车牌号"
:formatter=
"formatter"
placeholder=
"车牌号"
clearable
@
focus=
"onFocus('plateNo')"
@
blur=
"onBlur('plateNo')"
:rules=
"[{ required: true, message: '请输入您的车牌号' }, { validator: isVehicleNumber, message: '请输入正确的车牌号' }]"
/>
:rules=
"[{ required: true, message: '请输入您的车牌号' }, { validator: isVehicleNumber, message: '请输入正确的车牌号' }]"
/>
<div
class=
"form-explain"
v-show=
"registerData.tips.plateNo"
>
请确保您输入的车牌号是与客服人员协商好的权益关联车辆
</div>
<div
class=
"form-explain"
v-show=
"registerData.tips.plateNo"
>
请确保您输入的车牌号是与客服人员协商好的权益关联车辆
</div>
</div>
</div>
...
@@ -81,7 +81,8 @@ watch(time, (newVal) => {
...
@@ -81,7 +81,8 @@ watch(time, (newVal) => {
clearInterval
(
timeout
)
clearInterval
(
timeout
)
}
}
})
})
// 格式化车牌号
const
formatter
=
(
value
:
string
)
=>
value
.
toUpperCase
();
/** 定义的方法 */
/** 定义的方法 */
// 获取验证码
// 获取验证码
const
getCode
=
async
(
value
:
string
)
=>
{
const
getCode
=
async
(
value
:
string
)
=>
{
...
@@ -107,7 +108,7 @@ const getCode = async (value: string) => {
...
@@ -107,7 +108,7 @@ const getCode = async (value: string) => {
}
}
// 提交注册
// 提交注册
const
onRegister
=
async
(
values
:
object
)
=>
{
const
onRegister
=
async
(
values
:
object
)
=>
{
const
params
:{
cardName
?:
string
,
name
?:
string
}
=
{
...
values
}
const
params
:{
cardName
?:
string
,
name
?:
string
,
plateNo
?:
string
,
mobile
?:
string
}
=
{
...
values
}
params
.
cardName
=
params
.
name
params
.
cardName
=
params
.
name
console
.
log
(
params
)
console
.
log
(
params
)
const
res
=
await
req
(
'scrm.api.renewal.h5.customer.register'
,
params
,
true
)
const
res
=
await
req
(
'scrm.api.renewal.h5.customer.register'
,
params
,
true
)
...
@@ -119,7 +120,13 @@ const onRegister = async (values: object) => {
...
@@ -119,7 +120,13 @@ const onRegister = async (values: object) => {
}
else
if
(
code
==
0
)
{
}
else
if
(
code
==
0
)
{
if
(
data
)
{
if
(
data
)
{
Toast
(
'注册成功'
)
Toast
(
'注册成功'
)
router
.
push
(
'/registerSuccess'
)
router
.
push
({
path
:
'/registerSuccess'
,
query
:
{
plateNo
:
params
.
plateNo
,
mobile
:
params
.
mobile
}
})
}
else
{
}
else
{
Toast
(
message
)
Toast
(
message
)
}
}
...
...
src/views/login/registerSuccess.vue
View file @
0a44d42
...
@@ -6,10 +6,16 @@
...
@@ -6,10 +6,16 @@
</
template
>
</
template
>
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
useRouter
}
from
'vue-router'
import
{
useRouter
,
useRoute
}
from
'vue-router'
const
router
=
useRouter
()
const
router
=
useRouter
()
const
route
=
useRoute
()
console
.
log
(
route
.
query
)
const
toLogin
=
()
=>
{
const
toLogin
=
()
=>
{
router
.
go
(
-
3
)
// router.go(-3)
router
.
replace
({
path
:
'/login'
,
query
:
route
.
query
})
}
}
</
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