Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
html
/
poolin_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9a56b1d0
authored
Feb 11, 2018
by
jingjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jingjie
parent
cfc04940
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
427 additions
and
36 deletions
+427
-36
src/assets/less/style2.less
+31
-0
src/components/common/captcha.vue
+24
-14
src/components/reg/index.vue
+152
-20
src/config/index.js
+2
-2
src/plugins/axios.js
+48
-0
src/plugins/helpers.js
+170
-0
No files found.
src/assets/less/style2.less
View file @
9a56b1d0
...
@@ -236,3 +236,34 @@
...
@@ -236,3 +236,34 @@
}
}
}
}
}
}
.captcha-content{.clearfix;
.el-form-item{
.fl;width:60%;
}
.captcha{
.fr;width:40%;height:0.9rem;
img{width:100%;height:100%;}
}
}
.el-form-item {
margin-bottom: 15px;
}
.error-tip{
color: #f56c6c;
font-size: 12px;
line-height: 1;
}
src/components/common/captcha.vue
View file @
9a56b1d0
<
template
>
<
template
>
<div>
<div
class=
"captcha-content"
>
<input
v-model=
"captcha_input"
name=
"captcha"
/>
<!--
<el-form-item
prop=
"captcha"
:rules=
"[
{ required: true, message: '请输入验证码', trigger: 'blur' }]">-->
<img
:src=
"captchaUrl"
>
</div>
<el-form-item
prop=
"captcha"
>
<el-input
v-model=
"captchaComputed"
name=
"captcha"
placeholder=
"输入验证码"
></el-input>
</el-form-item>
<a
class=
"captcha"
>
<img
:src=
"captchaUrl"
@
click=
"newCaptcha"
>
</a>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
config
from
'@/config'
console
.
log
(
config
)
export
default
{
export
default
{
// beforeMount () {
props
:[
'errTipMsg'
],
// const captcha_img =;
// this.captchaUrl = captcha_img ;
// },
data
(){
data
(){
return
{
return
{
captcha_input
:
''
,
captcha
:
''
,
captchaUrl
:
'http://ucdev1212.blockin.com/captcha?'
+
new
Date
().
getTime
()
captchaUrl
:
'https://ucdev1212.blockin.com/captcha?'
+
new
Date
().
getTime
()
}
},
computed
:
{
captchaComputed
:
{
get
()
{
return
this
.
captcha
},
set
(
captcha
)
{
this
.
$emit
(
'dispatchCaptcha'
,
captcha
);
}
}
}
},
},
methods
:{
methods
:{
newCaptcha
:
function
()
{
newCaptcha
:
function
()
{
this
.
captchaUrl
=
'https://ucdev1212.blockin.com/captcha?'
+
new
Date
().
getTime
()
}
},
}
}
}
}
</
script
>
</
script
>
src/components/reg/index.vue
View file @
9a56b1d0
...
@@ -10,37 +10,65 @@
...
@@ -10,37 +10,65 @@
<h2
class=
"f-tac c-blue2 fs36 pt80 pb60"
>
使用邮箱地址注册
</h2>
<h2
class=
"f-tac c-blue2 fs36 pt80 pb60"
>
使用邮箱地址注册
</h2>
<div
class=
"form-content"
>
<div
class=
"form-content"
>
<el-form
:model=
"regForm"
ref=
"regForm"
label-width=
"0px"
>
<el-form
:model=
"regForm"
ref=
"regForm"
label-width=
"0px"
>
<el-form-item
prop=
"email"
label=
""
:rules=
"[
{ required: true, message: '请输入邮箱地址', trigger: 'blur' },{ type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur,change' }]">
<!--
<el-form-item
prop=
"email"
label=
""
:rules=
"[
{ required: true, message: '请输入邮箱地址', trigger: 'blur' },{ type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur,change' }]">-->
<el-form-item
prop=
"email"
label=
""
>
<el-input
v-model=
"regForm.email"
placeholder=
"输入邮箱"
><i
slot=
"prefix"
class=
"iconfont icon-email"
></i></el-input>
<el-input
v-model=
"regForm.email"
placeholder=
"输入邮箱"
><i
slot=
"prefix"
class=
"iconfont icon-email"
></i></el-input>
</el-form-item>
</el-form-item>
<captcha>
<captcha
v-show=
"showEmailCaptcha"
:captcha=
"regForm.captcha"
ref=
"captchaEmail"
@
dispatchCaptcha=
"getCaptchaValue"
></captcha>
<div
class=
"error-tip"
v-show=
"errTipMsg != ''"
>
{{
errTipMsg
}}
</div>
</captcha>
<el-form-item>
<el-form-item>
<div
class=
"btn-group full mt100"
>
<div
class=
"btn-group full mt100"
>
<el-button
type=
"primary"
round
@
click=
"submitForm('regForm')"
>
提交
</el-button>
<!--
<el-button
type=
"primary"
round
@
click=
"submitForm('regForm')"
>
提交
</el-button>
-->
<el-button
type=
"primary"
round
@
click=
"goStep2"
>
提交
</el-button>
</div>
</div>
<
!--
<
div
class=
"f-tac"
>
<div
class=
"f-tac"
>
<router-link
to=
""
class=
"c-blue1"
>
使用手机号注册>>
</router-link>
<router-link
to=
""
class=
"c-blue1"
>
使用手机号注册>>
</router-link>
</div>
-->
</div>
</el-form-item>
</el-form>
</div>
</div>
<div
v-if=
"step===2"
class=
"pt80"
>
<div
class=
"form-content"
>
<el-form
:model=
"regForm"
ref=
"regForm"
label-width=
"0px"
>
<el-form-item
prop=
"password"
label=
""
>
<el-input
type=
"password"
v-model=
"regForm.password"
placeholder=
"请输入不少于8位的密码"
></el-input>
</el-form-item>
<el-form-item
prop=
"passwordAgain"
label=
""
>
<el-input
type=
"password"
v-model=
"regForm.passwordAgain"
placeholder=
"确认密码"
></el-input>
</el-form-item>
</el-form-item>
</el-form>
</el-form>
<div
class=
"button-wrap"
>
<div
class=
"error-tip"
v-show=
"errTipMsg != ''"
>
{{
errTipMsg
}}
</div>
<div
class=
"btn-group full mt100"
>
<el-button
type=
"primary"
round
@
click=
"goEnd"
>
提交
</el-button>
</div>
</div>
</div>
</div>
</div>
</div>
<div
v-if=
"step===2"
>
123123
</div>
</div>
</div>
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
captcha
from
'@/components/common/captcha'
import
captcha
from
'@/components/common/captcha'
;
export
default
{
import
config
from
'@/config'
;
import
axios
from
'axios'
;
import
{
apiErrMap
,
isEmailAddress
,
isVerifyCode
}
from
'@/plugins/helpers'
;
export
default
{
name
:
'rega'
,
name
:
'rega'
,
data
()
{
data
()
{
return
{
return
{
regForm
:
{
regForm
:
{
email
:
''
email
:
''
,
captcha
:
''
,
password
:
''
,
passwordAgain
:
''
},
},
step
:
1
showLoading
:
false
,
showEmailCaptcha
:
false
,
step
:
1
,
errTipMsg
:
''
,
}
}
},
},
components
:{
components
:{
...
@@ -50,15 +78,119 @@ export default {
...
@@ -50,15 +78,119 @@ export default {
},
},
methods
:
{
methods
:
{
submitForm
(
formName
)
{
// submitForm(formName) {
this
.
$refs
[
formName
].
validate
((
valid
)
=>
{
// this.$refs[formName].validate((valid) => {
if
(
valid
)
{
// // console.log(this.$refs[formname]);
this
.
$router
.
replace
(
'/jump'
)
// if (valid) {
}
else
{
// this.$router.replace('/jump')
console
.
log
(
'error submit!!'
);
// } else {
return
false
;
// console.log('error submit!!');
// return false;
// }
// });
// },
getCaptchaValue
(
captcha
)
{
this
.
regForm
.
captcha
=
captcha
;
},
async
goStep2
(){
if
(
!
isEmailAddress
(
this
.
regForm
.
email
)
)
{
this
.
showErrorTip
(
-
1
,
'请输入正确的邮箱地址'
);
return
;
}
if
(
this
.
showEmailCaptcha
&&
!
isVerifyCode
(
this
.
regForm
.
captcha
)
)
{
this
.
showErrorTip
(
-
1
,
'请输入正确的验证码'
);
return
;
}
this
.
errTipMsg
=
''
;
this
.
showLoading
=
false
;
var
start
=
config
.
get_api
(
'post-register-email-start'
);
console
.
log
(
start
);
const
{
data
:
accountResponse
}
=
await
axios
.
post
(
start
,
{
captcha
:
this
.
regForm
.
captcha
,
email
:
this
.
regForm
.
email
});
// 错误id提示
if
(
accountResponse
.
err_no
)
{
// 邮箱注册 图形验证码一直激活
if
(
accountResponse
.
err_no
==
1000
&&
!
this
.
showEmailCaptcha
)
{
this
.
showErrorTip
(
-
1
,
''
);
this
.
showEmailCaptcha
=
true
;
this
.
regForm
.
password
=
''
;
this
.
regForm
.
passwordAgain
=
''
;
// this.$refs.email.focusCaptchaInput();
return
;
}
}
this
.
showErrorTip
(
accountResponse
.
err_no
,
accountResponse
.
err_msg
);
return
;
}
this
.
showLoading
=
false
;
this
.
step
=
2
;
this
.
errTipMsg
=
''
;
// setTimeout( () => {
// this.$refs.step2Focus.focus();
// }, 100);
// if(accountResponse.err_no==0){
// console.log('success')
// console.log((accountResponse))
//
// }else {
// console.log('error')
// console.log((accountResponse))
// }
},
async
goEnd
()
{
if
(
this
.
regForm
.
password
==
''
)
{
this
.
showErrorTip
(
-
1
,
'请输入密码'
);
return
;
}
if
(
this
.
regForm
.
password
.
length
<
8
)
{
this
.
showErrorTip
(
-
1
,
'请输入不少于8位的密码'
);
return
}
if
(
this
.
regForm
.
password
.
length
>
256
)
{
this
.
showErrorTip
(
-
1
,
'密码长度请小于256位'
);
return
}
if
(
this
.
regForm
.
password
!=
this
.
regForm
.
passwordAgain
)
{
this
.
showErrorTip
(
-
1
,
'两次输入的密码不一致'
);
return
;
}
this
.
showLoading
=
true
;
this
.
errTipMsg
=
''
;
// 根据用户信息创建密码
var
setPwd
=
config
.
get_api
(
'post-register-email-password'
);
const
{
data
:
passwordResponse
}
=
await
axios
.
post
(
setPwd
,
{
timezone
:
-
1
*
(
new
Date
().
getTimezoneOffset
()),
password
:
this
.
regForm
.
password
});
});
// 登录失败
if
(
passwordResponse
.
err_no
)
{
this
.
showErrorTip
(
passwordResponse
.
err_no
,
passwordResponse
.
err_msg
);
return
;
}
// 获取用户信息,直接登录
const
userinfo
=
await
this
.
$store
.
dispatch
(
"Auth/fetchUser"
);
this
.
showLoading
=
false
;
this
.
errTipMsg
=
''
;
// 跳转用户中心
this
.
$router
.
push
({
name
:
'jump'
});
},
showErrorTip
(
errNo
,
errMsg
)
{
this
.
showLoading
=
false
;
this
.
errTipMsg
=
apiErrMap
(
errNo
,
errMsg
).
errMsg
;
},
},
goBack
()
{
goBack
()
{
this
.
$router
.
go
(
-
1
)
this
.
$router
.
go
(
-
1
)
...
@@ -68,7 +200,7 @@ export default {
...
@@ -68,7 +200,7 @@ export default {
}
}
},
},
}
}
</
script
>
</
script
>
<
style
>
<
style
>
...
...
src/config/index.js
View file @
9a56b1d0
...
@@ -35,7 +35,8 @@ const api ={
...
@@ -35,7 +35,8 @@ const api ={
const
config
=
{
const
config
=
{
base
:{
base
:{
domain
:
'https://management.poolin.com'
,
// domain:'https://management.poolin.com',
domain
:
'https://ucdev1212.blockin.com'
},
},
get_api
:
function
(
key
)
{
get_api
:
function
(
key
)
{
// domain=window.config.baseUrl
// domain=window.config.baseUrl
...
@@ -43,5 +44,4 @@ const config = {
...
@@ -43,5 +44,4 @@ const config = {
return
this
.
base
.
domain
+
apiPrefix
+
api
.
api
[
key
]
return
this
.
base
.
domain
+
apiPrefix
+
api
.
api
[
key
]
}
}
}
}
export
default
config
;
export
default
config
;
src/plugins/axios.js
0 → 100644
View file @
9a56b1d0
import
axios
from
'axios'
import
store
from
'~/store'
import
router
from
'~/router'
// import swal from 'sweetalert2'
axios
.
interceptors
.
request
.
use
(
request
=>
{
const
token
=
store
.
getters
[
'Auth/token'
]
if
(
token
)
{
request
.
headers
.
common
[
'Authorization'
]
=
`Bearer
${
token
}
`
}
// request.headers['X-Socket-Id'] = Echo.socketId()
return
request
})
axios
.
interceptors
.
response
.
use
(
response
=>
response
,
error
=>
{
const
{
status
}
=
error
.
response
if
(
status
>=
500
)
{
// swal({
// type: 'error',
// title: swal.i18n.t('error_alert_title'),
// text: swal.i18n.t('error_alert_text')
// })
}
if
(
status
===
401
&&
store
.
getters
[
'Auth/check'
])
{
// swal({
// type: 'warning',
// title: swal.i18n.t('token_expired_alert_title'),
// text: swal.i18n.t('token_expired_alert_text')
// })
// .then(async() => {
// await store.dispatch('Auth/logout')
// router.push({
// name: 'login'
// })
// })
}
return
Promise
.
reject
(
error
)
})
\ No newline at end of file
src/plugins/helpers.js
0 → 100644
View file @
9a56b1d0
import
axios
from
'axios'
;
import
conf
from
'./../config'
;
let
helpers
=
{};
const
domainUrl
=
conf
.
domain_url
;
export
const
getBus
=
(
apiName
,
params
,
apiParams
=
{})
=>
{
let
url
=
conf
.
api
[
apiName
];
if
(
!
url
)
{
// 如果取不到
throw
new
Error
(
'get DataBus not match url'
);
}
for
(
let
_key
in
apiParams
)
{
let
value
=
apiParams
[
_key
];
let
regArr
=
[
'\{'
,
_key
,
'\}'
];
// let regExp = new RegExp(regArr.join(''), 'igm');
let
regExp
=
new
RegExp
(
'\{'
+
_key
+
'\}'
,
'igm'
);
url
=
url
.
replace
(
regExp
,
value
);
}
// 获取token
let
access_token
=
localStorage
.
getItem
(
'access_token'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
get
(
domainUrl
+
url
,
{
params
:
params
,
headers
:
{
// Authorization: 'Bearer ' + access_token
}
// withCredentials: true
}).
then
(
(
response
)
=>
{
resolve
(
response
.
data
);
}).
catch
(
(
error
)
=>
{
// 该error是个json。
let
errorMsg
=
'Network Error'
;
if
(
error
.
response
)
{
let
errorStatus
=
error
.
response
.
status
;
switch
(
errorStatus
)
{
case
401
:
// 未登录
errorMsg
=
'Please Login'
;
break
;
case
500
:
default
:
if
(
error
.
response
.
data
.
message
)
{
errorMsg
=
error
.
response
.
data
.
message
;
}
break
;
}
// console.log(error.response);
}
else
{
// console.log(error.message);
}
lolpool
&&
lolpool
.
$message
&&
lolpool
.
$message
.
error
(
errorMsg
,
5
);
});
});
};
export
const
postBus
=
(
apiName
,
params
,
apiParams
)
=>
{
let
url
=
conf
.
api
[
apiName
];
if
(
!
url
)
{
// 如果取不到url
throw
new
Error
(
'post DataBus not match url'
);
}
for
(
let
_key
in
apiParams
)
{
let
value
=
apiParams
[
_key
];
let
regArr
=
[
'\{'
,
_key
,
'\}'
];
let
regExp
=
new
RegExp
(
'\{'
+
_key
+
'\}'
,
'igm'
);
url
=
url
.
replace
(
regExp
,
value
);
}
// 获取token
let
access_token
=
localStorage
.
getItem
(
'access_token'
);
return
new
Promise
((
resolve
,
reject
)
=>
{
axios
.
post
(
domainUrl
+
url
,
params
,
{
headers
:
{
// 'Content-Type': 'application/x-www-form-urlencoded',
// Authorization: 'Bearer ' + access_token
}
// withCredentials: true
}).
then
(
(
response
)
=>
{
resolve
(
response
.
data
);
}).
catch
(
(
error
)
=>
{
let
errorMsg
=
'Network Error'
;
if
(
error
.
response
)
{
let
errorStatus
=
error
.
response
.
status
;
switch
(
errorStatus
)
{
case
401
:
// 未登录
errorMsg
=
'Please Login'
;
break
;
case
500
:
default
:
if
(
error
.
response
.
data
.
message
)
{
errorMsg
=
error
.
response
.
data
.
message
;
}
break
;
}
}
lolpool
&&
lolpool
.
$message
&&
lolpool
.
$message
.
error
(
errorMsg
,
5
);
});
});
}
export
const
renderFullUrl
=
(
api
,
apiParams
)
=>
{
for
(
let
_key
in
apiParams
)
{
let
value
=
apiParams
[
_key
];
let
regArr
=
[
'\{'
,
_key
,
'\}'
];
// let regExp = new RegExp(regArr.join(''), 'igm');
let
regExp
=
new
RegExp
(
'\{'
+
_key
+
'\}'
,
'igm'
);
api
=
api
.
replace
(
regExp
,
value
);
}
return
api
;
}
export
const
apiErrMap
=
(
errNo
,
errMsg
)
=>
{
if
(
errNo
==
0
)
{
return
{
errNo
:
0
,
errMsg
:
''
};
}
if
(
errNo
==
-
1
)
{
return
{
errNo
:
-
1
,
errMsg
};
}
// todo: 翻译
const
errMap
=
new
Map
()
.
set
(
100
,
'步骤不正确'
)
.
set
(
1000
,
'请输入验证码'
)
.
set
(
1001
,
'验证码错误'
)
.
set
(
1010
,
'用户已存在'
)
.
set
(
1011
,
'用户不存在'
)
.
set
(
1012
,
'用户被锁定'
)
.
set
(
1013
,
'登录次数过多'
)
.
set
(
1014
,
'密码错误'
)
.
set
(
1015
,
'invalid totp code'
)
.
set
(
1020
,
'验证码过多'
)
.
set
(
1021
,
'无效手机号'
)
.
set
(
1022
,
'邮箱地址无效'
)
.
set
(
1023
,
'电话号码不支持'
)
.
set
(
1024
,
'sms rate limited'
);
errMsg
=
errMap
.
get
(
errNo
);
if
(
errMsg
)
{
return
{
errNo
,
errMsg
}
}
return
{
errNo
,
errMsg
:
'网络错误'
}
}
export
const
isEmailAddress
=
(
str
)
=>
{
return
new
RegExp
(
'^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$'
).
test
(
str
);
}
export
const
isVerifyCode
=
(
str
)
=>
{
return
new
RegExp
(
'^[a-z0-9A-Z]{4}$'
).
test
(
str
);
}
export
const
getServices
=
(
serviceName
)
=>
{
}
\ No newline at end of file
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