Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
mongo-ui
Commits
bed6141d
Commit
bed6141d
authored
Jul 29, 2020
by
郭志伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 登录弹框封装完成
parent
cda1196e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
11 deletions
+34
-11
LoginModal.vue
src/components/LoginModal.vue
+20
-10
validation.js
src/service/validation.js
+6
-0
index.js
src/store/index.js
+8
-1
No files found.
src/components/LoginModal.vue
View file @
bed6141d
<
template
>
<
template
>
<modal
<modal
v-model=
"
show
"
v-model=
"
isShowLogin
"
title=
"您好
<br
/>
欢迎来到芒果保险"
title=
"您好
<br
/>
欢迎来到芒果保险"
:closeable="true"
:closeable="true"
cancel-btn
cancel-btn
confirm-btn="确定"
confirm-btn="确定"
@close="setLoginIsShow(false)"
@confirm="$refs.loginForm.submit()"
@confirm="$refs.loginForm.submit()"
>
>
<cr-form
<cr-form
class=
"login-form"
class=
"login-form"
ref=
"loginForm"
ref=
"loginForm"
validate-trigger=
"onBlur"
validate-trigger=
"onBlur"
@
submit=
"
onFormSubmit
"
@
submit=
"
login
"
@
failed=
"onFormFailed"
@
failed=
"onFormFailed"
>
>
<cr-field
<cr-field
...
@@ -40,9 +41,10 @@
...
@@ -40,9 +41,10 @@
</template>
</template>
<
script
>
<
script
>
import
{
mapState
,
mapActions
}
from
"
vuex
"
;
import
Modal
from
"
@/components/Modal
"
;
import
Modal
from
"
@/components/Modal
"
;
import
{
loginByPhone
,
getCaptchaSms
}
from
"
@/api/user
"
;
import
{
loginByPhone
,
getCaptchaSms
}
from
"
@/api/user
"
;
import
{
isPhone
}
from
"
@/service/validation
"
;
import
{
isPhone
,
isWeixinBrower
}
from
"
@/service/validation
"
;
export
default
{
export
default
{
name
:
"
LoginModal
"
,
name
:
"
LoginModal
"
,
components
:
{
components
:
{
...
@@ -61,31 +63,39 @@ export default {
...
@@ -61,31 +63,39 @@ export default {
validOptions
:
[
validOptions
:
[
[
[
{
require
:
true
,
message
:
"
请填写您的手机号
"
},
{
require
:
true
,
message
:
"
请填写您的手机号
"
},
{
validator
:
isPhone
,
message
:
"
手机号格式错误
"
}
{
validator
:
isPhone
,
message
:
"
请填写正确的手机号码
"
}
],
],
[{
require
:
true
,
message
:
"
请填写验证码
"
}]
[{
require
:
true
,
message
:
"
请填写验证码
"
}]
]
]
};
};
},
},
methods
:
{
computed
:
{
onFormSubmit
()
{
...
mapState
([
"
isShowLogin
"
])
this
.
login
();
},
},
methods
:
{
...
mapActions
([
"
setLoginIsShow
"
]),
onFormFailed
(
errorInfo
)
{
onFormFailed
(
errorInfo
)
{
const
{
errors
}
=
errorInfo
;
const
{
errors
}
=
errorInfo
;
this
.
$notify
({
type
:
"
warning
"
,
message
:
errors
[
0
].
message
});
this
.
$notify
({
type
:
"
warning
"
,
message
:
errors
[
0
].
message
});
},
},
async
login
()
{
async
login
()
{
this
.
formData
.
loginChannel
=
1
;
this
.
formData
.
loginChannel
=
isWeixinBrower
?
1
:
2
;
this
.
formData
.
openId
=
1
;
this
.
formData
.
openId
=
localStorage
.
getItem
(
"
openId
"
)
||
null
;
const
res
=
await
loginByPhone
(
this
.
formData
);
const
res
=
await
loginByPhone
(
this
.
formData
);
if
(
res
.
code
===
0
)
{
if
(
res
.
code
===
"
0
"
)
{
this
.
$notify
(
"
登录成功
"
);
this
.
$notify
(
"
登录成功
"
);
this
.
setLoginIsShow
(
false
);
localStorage
.
setItem
(
"
mongoToken
"
,
res
.
data
.
token
);
}
}
},
},
async
getCode
()
{
async
getCode
()
{
const
TIME_COUNT
=
60
;
const
TIME_COUNT
=
60
;
const
{
phoneNo
}
=
this
.
formData
;
const
{
phoneNo
}
=
this
.
formData
;
if
(
this
.
timer
)
return
;
if
(
!
isPhone
(
phoneNo
))
{
this
.
$notify
({
type
:
"
warning
"
,
message
:
"
请填写正确的手机号码
"
});
return
;
}
const
res
=
await
getCaptchaSms
({
phoneNo
});
const
res
=
await
getCaptchaSms
({
phoneNo
});
if
(
res
.
code
===
"
0
"
&&
!
this
.
timer
)
{
if
(
res
.
code
===
"
0
"
&&
!
this
.
timer
)
{
this
.
count
=
TIME_COUNT
;
this
.
count
=
TIME_COUNT
;
...
...
src/service/validation.js
View file @
bed6141d
...
@@ -248,3 +248,9 @@ export function isBankNumber(str) {
...
@@ -248,3 +248,9 @@ export function isBankNumber(str) {
}
}
return
false
;
return
false
;
}
}
// 判断微信环境
export
function
isWeixinBrower
()
{
const
ua
=
window
.
navigator
.
userAgent
.
toLowerCase
();
return
ua
.
match
(
/MicroMessenger/i
)
==
"
micromessenger
"
;
}
src/store/index.js
View file @
bed6141d
...
@@ -6,7 +6,8 @@ Vue.use(Vuex);
...
@@ -6,7 +6,8 @@ Vue.use(Vuex);
export
default
new
Vuex
.
Store
({
export
default
new
Vuex
.
Store
({
state
:
{
state
:
{
activeIdx
:
0
,
activeIdx
:
0
,
isLoading
:
false
isLoading
:
false
,
isShowLogin
:
false
},
},
mutations
:
{
mutations
:
{
setActiveIdx
(
state
,
value
)
{
setActiveIdx
(
state
,
value
)
{
...
@@ -14,6 +15,9 @@ export default new Vuex.Store({
...
@@ -14,6 +15,9 @@ export default new Vuex.Store({
},
},
setIsLoading
(
state
,
value
)
{
setIsLoading
(
state
,
value
)
{
state
.
isLoading
=
value
;
state
.
isLoading
=
value
;
},
setIsShowLogin
(
state
,
value
)
{
state
.
showLogin
=
value
;
}
}
},
},
actions
:
{
actions
:
{
...
@@ -22,6 +26,9 @@ export default new Vuex.Store({
...
@@ -22,6 +26,9 @@ export default new Vuex.Store({
},
},
setIsLoading
({
commit
},
args
)
{
setIsLoading
({
commit
},
args
)
{
commit
(
"
setIsLoading
"
,
args
);
commit
(
"
setIsLoading
"
,
args
);
},
setIsShowLogin
({
commit
},
args
)
{
commit
(
"
setIsShowLogin
"
,
args
);
}
}
},
},
modules
:
{}
modules
:
{}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment