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
42f40dbb
authored
Feb 10, 2018
by
zhanghui1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
未完成错误版
parent
8e97b441
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
13 deletions
+97
-13
src/components/ucenter/helpers.js
+30
-1
src/components/ucenter/index.vue
+6
-6
src/store/index.js
+61
-6
No files found.
src/components/ucenter/helpers.js
View file @
42f40dbb
...
...
@@ -163,7 +163,36 @@ export const isEmailAddress = (str) => {
export
const
isVerifyCode
=
(
str
)
=>
{
return
new
RegExp
(
'^[a-z0-9A-Z]{4}$'
).
test
(
str
);
}
export
const
api
=
{
// 邮箱注册api
'post-register-email-start'
:
'/register/email/start'
,
'post-register-email-verify-code'
:
'/register/email/verify-code'
,
'post-register-email-password'
:
'/register/email/password'
,
// 手机注册api
'post-register-mobile-start'
:
'/register/mobile/start'
,
'post-register-mobile-verify-code'
:
'/register/mobile/verify-code'
,
'post-register-mobile-password'
:
'/register/mobile/password'
,
// 登录
'post-login-start'
:
'/login/start'
,
'post-login-mobile'
:
'/login/start/mobile'
,
'post-login-password'
:
'/login/password'
,
'post-login-totp'
:
'/login/totp'
,
'post-login-code'
:
'/login/code'
,
// 重置密码
'post-reset-start'
:
'/reset/start'
,
'post-reset-send-code'
:
'/reset/send-code'
,
'post-reset-verify'
:
'/reset/verify'
,
'post-reset-password'
:
'/reset/password'
,
// 登出
'get-logout-do'
:
'/logout/do'
,
// 获取用户信息
'get-userinfo'
:
'/userinfo'
,
}
// export const getServices = (serviceName) => {
// }
src/components/ucenter/index.vue
View file @
42f40dbb
...
...
@@ -41,7 +41,7 @@
import
{
mapState
}
from
'vuex'
import
countryInfo
from
'./country_info.json'
import
captcha
from
'./captcha.vue'
import
{
apiErrMap
,
isEmailAddress
,
isVerifyCode
}
from
'./helpers.js'
;
import
{
apiErrMap
,
isEmailAddress
,
isVerifyCode
,
api
}
from
'./helpers.js'
;
export
default
{
components
:
{
captcha
...
...
@@ -108,7 +108,7 @@ export default {
email
=
this
.
form
.
email
;
const
{
data
:
accountResponse
}
=
await
this
.
$axios
.
post
(
config
.
apiDomain
+
config
.
api
[
'post-login-start'
],
{
.
post
(
this
.
UC_BASEURL
+
'/auth/api'
+
api
[
'post-login-start'
],
{
captcha
:
this
.
showEmailCaptcha
?
this
.
form
.
captcha
:
''
,
// todo: 登录验证码
email
,
type
:
'email'
...
...
@@ -127,7 +127,7 @@ export default {
}
const
{
data
:
passwordResponse
}
=
await
this
.
$axios
.
post
(
config
.
apiDomain
+
config
.
api
[
'post-login-password'
],
{
.
post
(
this
.
UC_BASEURL
+
"/auth/api"
+
api
[
'post-login-password'
],
{
password
:
this
.
form
.
password
});
...
...
@@ -154,7 +154,7 @@ export default {
email
=
this
.
form
.
country
+
'|'
+
this
.
form
.
email
;
const
{
data
:
accountResponse
}
=
await
this
.
$axios
.
post
(
config
.
apiDomain
+
config
.
api
[
'post-login-start'
],
{
.
post
(
apiDomain
+
'/auth/api'
+
api
[
'post-login-start'
],
{
captcha
:
this
.
showMobileCaptcha
?
this
.
form
.
captcha
:
''
,
// todo: 登录验证码
email
,
type
:
'mobile'
...
...
@@ -174,7 +174,7 @@ export default {
}
const
{
data
:
passwordResponse
}
=
await
this
.
$axios
.
post
(
config
.
apiDomain
+
config
.
api
[
'post-login-password'
],
{
.
post
(
apiDomain
+
'/auth/api'
+
api
[
'post-login-password'
],
{
password
:
this
.
form
.
password
});
...
...
@@ -187,7 +187,7 @@ export default {
}
// 获取用户信息
const
userinfo
=
await
this
.
$store
.
dispatch
(
"
Auth/
fetchUser"
);
const
userinfo
=
await
this
.
$store
.
dispatch
(
"fetchUser"
);
this
.
showLoading
=
false
;
// 跳转用户中心
...
...
src/store/index.js
View file @
42f40dbb
import
Vue
from
'vue'
;
import
Vuex
from
'vuex'
;
import
{
api
}
from
'@/components/ucenter/helpers.js'
;
Vue
.
use
(
Vuex
);
import
dictionaries
from
'@/utils/dictionaries.js'
;
//字典
...
...
@@ -27,6 +28,7 @@ const state = {
tab_bar
:
0
,
UC_BASEURL
:
'https://ucdev1212.blockin.com'
,
user
:
null
,
}
const
mutations
=
{
setEnterPannel
(
state
,
v
)
{
...
...
@@ -57,18 +59,71 @@ const mutations = {
setLanguage
(
state
,
v
)
{
state
.
language
=
v
localStorage
.
setItem
(
"language"
,
v
);
},
FETCH_USER_SUCCESS
(
state
,
{
user
})
{
window
.
config
.
user
=
user
;
state
.
user
=
user
;
},
FETCH_USER_FAILURE
(
state
)
{},
LOGOUT
(
state
)
{
state
.
user
=
null
},
UPDATE_USER
(
state
,
{
user
})
{
state
.
user
=
user
}
}
const
getters
=
{
// count: function(state) {
// return state.count += 100;
// }
user
:
state
=>
{
return
state
.
user
},
check
:
state
=>
{
let
hasLogged
=
state
.
user
&&
Boolean
(
state
.
user
.
uid
);
if
(
!
hasLogged
)
{
hasLogged
=
Boolean
(
JSON
.
parse
(
window
.
config
.
register
));
}
return
hasLogged
;
}
}
const
actions
=
{
// addAction(context) {
// context.commit('add', 10)
// }
async
fetchUser
({
commit
})
{
try
{
const
{
data
}
=
await
axios
.
get
(
config
.
apiDomain
+
api
[
'get-userinfo'
]);
if
(
data
.
err_no
)
{
throw
new
Error
(
'get userinfo fail'
);
}
commit
(
'FETCH_USER_SUCCESS'
,
{
user
:
data
.
data
.
userinfo
});
return
data
.
data
.
userinfo
;
}
catch
(
e
)
{
commit
(
'FETCH_USER_FAILURE'
)
return
null
;
}
},
updateUser
({
commit
},
payload
)
{
commit
(
'UPDATE_USER'
,
payload
)
},
async
logout
({
commit
})
{
try
{
await
axios
.
get
(
'/logout'
)
}
catch
(
e
)
{}
commit
(
'LOGOUT'
)
}
}
export
default
new
Vuex
.
Store
({
state
,
...
...
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