Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
htoooth
9 years ago
Commit
56838b1d934eb46b267c207742246ba3390d755c
2 parents
b454a604
e584b330
Merge remote-tracking branch 'origin/feature/passport' into feature/passport
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
19 deletions
apps/passport/controllers/reg.js
apps/passport/models/user-api.js
apps/passport/router.js
config/common.js
public/js/passport/reg.page.js
public/js/passport/reg/reg.js
public/scss/product/_filter-box.css
apps/passport/controllers/reg.js
View file @
56838b1
...
...
@@ -2,11 +2,14 @@
* 注册控制器
*/
'use strict'
;
const
_
=
require
(
'lodash'
);
const
passportHelper
=
require
(
'../models/passport-helper'
);
const
regService
=
require
(
'../models/reg-service'
);
const
userService
=
require
(
'../models/user-service'
);
const
config
=
require
(
'../../../config/common'
);
let
helpers
=
global
.
yoho
.
helpers
;
let
cache
=
global
.
yoho
.
cache
;
let
index
=
(
req
,
res
,
next
)
=>
{
// 设置注册有效时间30分钟, 防机器刷
...
...
@@ -36,6 +39,43 @@ let index = (req, res, next) => {
}).
catch
(
next
);
};
let
checkMobile
=
(
req
,
res
,
next
)
=>
{
let
data
=
{
code
:
400
};
let
mobile
=
+
req
.
body
.
mobile
;
let
area
=
+
req
.
body
.
area
;
if
(
!
_
.
isNumber
(
mobile
)
||
!
_
.
isNumber
(
area
))
{
data
.
message
=
'手机号码格式不正确'
;
return
res
.
json
(
data
);
}
// 判断手机号是否检查超过指定次数
let
key
=
'checkmobilenum_'
+
passportHelper
.
makeAreaMobile
(
area
,
mobile
);
cache
.
get
(
key
).
then
((
checkNum
)
=>
{
checkNum
=
+
(
checkNum
||
0
);
cache
.
set
(
key
,
++
checkNum
).
catch
(
next
);
if
(
checkNum
>
500
)
{
data
.
message
=
'检查次数太多'
;
return
res
.
json
(
data
);
}
// 判断用户是否存在
return
userService
.
findByMobileAsync
(
area
,
mobile
).
then
((
user
)
=>
{
if
(
!
_
.
isEmpty
(
user
))
{
data
.
message
=
'手机号码已经存在'
;
return
res
.
json
(
data
);
}
data
.
code
=
200
;
return
res
.
json
(
data
);
});
}).
catch
(
next
);
};
let
success
=
(
req
,
res
,
next
)
=>
{
let
goUrl
=
req
.
query
.
next
||
config
.
siteUrl
;
let
goShoppingUrl
=
req
.
query
.
goShoppingUrl
||
config
.
siteUrl
;
...
...
@@ -55,5 +95,6 @@ let success = (req, res, next) => {
module
.
exports
=
{
index
,
success
success
,
checkMobile
};
...
...
apps/passport/models/user-api.js
View file @
56838b1
...
...
@@ -16,18 +16,15 @@ const findByMobileAsync = (area, mobile) => {
mobile
:
mobile
,
area
:
area
,
method
:
'app.passport.getProfileByMobile'
})
.
then
(
result
=>
{
if
(
!
result
.
code
||
result
.
code
!==
200
||
!
result
.
data
||
_
.
isEmpty
(
result
.
data
))
{
return
EMPTY
;
}
return
result
.
data
;
})
.
catch
(()
=>
{
}).
then
(
result
=>
{
if
(
!
result
.
code
||
result
.
code
!==
200
||
!
result
.
data
||
_
.
isEmpty
(
result
.
data
))
{
return
EMPTY
;
});
}
return
result
.
data
;
}).
catch
(()
=>
{
return
EMPTY
;
});
};
/**
...
...
apps/passport/router.js
View file @
56838b1
...
...
@@ -23,7 +23,7 @@ router.get('/login/wechat/callback', login.wechat.callback);
* 注册页面路由
*/
router
.
get
(
'/reg/index'
,
reg
.
index
);
router
.
post
(
'/reg/checkmobile'
,
reg
.
checkMobile
);
router
.
get
(
'/reg/success'
,
reg
.
success
);
/**
...
...
config/common.js
View file @
56838b1
...
...
@@ -21,9 +21,9 @@ module.exports = {
useOneapm
:
false
,
useCache
:
false
,
memcache
:
{
master
:
[
'192.168.102.163:11213'
],
slave
:
[
'192.168.102.163:11213'
],
session
:
[
'192.168.102.161:11213'
],
master
:
[
'192.168.102.222:11213'
],
slave
:
[
'192.168.102.222:11213'
],
session
:
[
'192.168.102.222:11213'
],
timeout
:
1000
,
retries
:
0
},
...
...
public/js/passport/reg.page.js
View file @
56838b1
var
reg
=
require
(
'./reg/reg'
);
reg
.
init
();
reg
.
init
(
'reg'
);
...
...
public/js/passport/reg/reg.js
View file @
56838b1
...
...
@@ -116,7 +116,7 @@ function phoneAjaxFn(page, callback) {
data
;
if
(
page
===
'reg'
)
{
url
=
'/passport/reg
ister
/checkmobile'
;
url
=
'/passport/reg/checkmobile'
;
data
=
{
mobile
:
$pn
.
val
(),
area
:
$region
.
text
().
split
(
'+'
)[
1
]
...
...
public/scss/product/_filter-box.css
View file @
56838b1
...
...
@@ -447,7 +447,7 @@
}
/* 高级选项箭头位置IE11Hack */
_
:-ms-fullscreen
,
_
:-ms-fullscreen
,
/* stylelint-disable-line */
:root
.senior-up-icon
{
top
:
1px
;
}
...
...
Please
register
or
login
to post a comment