Authored by htoooth

调整代码

... ... @@ -9,16 +9,14 @@
const _ = require('lodash');
const helpers = global.yoho.helpers;
const PassportHelper = require('../models/passport-helper');
const BindService = require('../models/bind-api');
const loginService = require('../models/login-service');
const BindService = require('../models/bind-service');
const LoginService = require('../models/login-service');
const Sources = {
qq: 'QQ',
sina: '微博',
alipay: '支付宝',
wechat: '微信',
renren: '人人',
douban: '豆瓣'
wechat: '微信'
};
const DEFAULT_URL = 'http://img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100';
... ... @@ -173,7 +171,7 @@ const bind = {
let sourceType = req.body.sourceType;
if (mobile && openId && area && sourceType) {
BindService.bindCheck(mobile, openId, sourceType, area).then(result => {
BindService.bindCheckAsync(mobile, openId, sourceType, area).then(result => {
if (!result || !result.code) {
return {code: 400, message: '', data: ''};
} else if (result.code === 200 && result.data.is_register === 0) {
... ... @@ -210,7 +208,7 @@ const bind = {
let mobile = req.body.mobile;
let area = req.body.area;
BindService.sendBindMsg(area, mobile).then(result => {
BindService.sendBindMsgAsync(area, mobile).then(result => {
if (result && result.code) {
res.json(result);
} else {
... ... @@ -223,7 +221,7 @@ const bind = {
let area = req.body.area;
let code = req.body.code;
BindService.checkBindCode(area, mobile, code).then(result => {
BindService.checkBindCodeAsync(area, mobile, code).then(result => {
if (result && result.code) {
res.json(result);
} else {
... ... @@ -238,14 +236,14 @@ const bind = {
let sourceType = _.trim(req.body.sourceType);
let password = _.trim(req.body.password) || '';
BindService.bindMobile(openId, sourceType, mobile, area, password).then(result => {
BindService.bindMobileAsync(openId, sourceType, mobile, area, password).then(result => {
if (result && result.code) {
if (result.code === 200 && result.data && result.data.uid) {
let refer = helpers.urlFormat('/passport/thirdlogin/bindsuccess', {
sourceType: sourceType + '_bind'
});
return loginService.syncUserSession(result.data.uid, req, res).then(() => {
return LoginService.syncUserSession(result.data.uid, req, res).then(() => {
return {code: 200, message: result.message, data: {refer: refer}};
});
} else {
... ... @@ -264,14 +262,14 @@ const bind = {
let areaCode = req.body.areaCode || '86';
let sourceType = req.body.sourceType;
return BindService.relateMobile(openId, sourceType, mobile, areaCode).then(result => {
return BindService.relateMobileAsync(openId, sourceType, mobile, areaCode).then(result => {
if (result && result.code) {
if (result.code === 200 && result.data && result.data.uid) {
let refer = helpers.urlFormat('/passport/thirdlogin/relatesuccess', {
sourceType: sourceType + '_bind'
});
return loginService.syncUserSession(result.data.uid, req, res).then(() => {
return LoginService.syncUserSession(result.data.uid, req, res).then(() => {
return {code: 200, message: result.message, data: {refer: refer}};
});
} else {
... ...
... ... @@ -5,9 +5,9 @@
const _ = require('lodash');
const Promise = require('bluebird');
const passportHelper = require('../models/passport-helper');
const regService = require('../models/reg-api');
const userService = require('../models/user-service');
const loginService = require('../models/login-service');
const RegService = require('../models/reg-service');
const UserService = require('../models/user-service');
const LoginService = require('../models/login-service');
const config = require('../../../config/common');
let helpers = global.yoho.helpers;
... ... @@ -100,7 +100,7 @@ let checkMobile = (req, res, next) => {
}
// 判断用户是否存在
return userService.findByMobileAsync(area, mobile).then((user) => {
return UserService.findByMobileAsync(area, mobile).then((user) => {
if (!_.isEmpty(user)) {
data.message = '手机号码已经存在';
return res.json(data);
... ... @@ -156,7 +156,7 @@ let sendBindMsg = (req, res, next) => {
}
/* 向手机发送注册验证码 */
let result = yield regService.sendCodeToMobile(area, mobile);
let result = yield RegService.sendCodeToMobileAsync(area, mobile);
return cache.set(sendCodeKey, sendCodeTimes + 1, 3600).then(() => {
if (result.code) {
... ... @@ -182,7 +182,7 @@ let msgCaptcha = (req, res, next) => {
let mobile = req.body.mobile;
let code = req.body.code; // 短信验证码
regService.validMobileCode(area, mobile, code).then((result) => {
RegService.validMobileCodeAsync(area, mobile, code).then((result) => {
if (result.code) {
return res.json(result);
} else {
... ... @@ -232,7 +232,7 @@ let mobileRegister = (req, res, next) => {
let mobile = req.body.mobile;
let code = req.body.code; // 短信验证码
let password = req.body.password;
let result = yield regService.validMobileCode(area, mobile, code); // 验证注册的标识码是否有效
let result = yield RegService.validMobileCodeAsync(area, mobile, code); // 验证注册的标识码是否有效
if (!result.code || result.code !== 200) {
data.message = '验证码错误';
... ... @@ -240,14 +240,14 @@ let mobileRegister = (req, res, next) => {
}
/* 手机注册: 调用注册接口*/
let regResult = yield regService.regMobile(area, mobile, password, cookie.getShoppingKey(req));
let regResult = yield RegService.regMobileAsync(area, mobile, password, cookie.getShoppingKey(req));
if (!regResult.code || regResult.code !== 200) {
data.message = '注册失败';
return res.json(data);
}
return loginService.syncUserSession(regResult.data.uid, req, res).then(() => {
return LoginService.syncUserSession(regResult.data.uid, req, res).then(() => {
return res.json({
code: 200,
message: '注册成功',
... ... @@ -272,7 +272,7 @@ let success = (req, res) => {
title: '注册成功',
passport: {
goUrl: goUrl,
goShoppong: goShoppingUrl,
goShopping: goShoppingUrl,
mobile: mobile
}
});
... ...
... ... @@ -9,7 +9,7 @@
const api = global.yoho.API;
const bindCheck = (mobile, openId, sourceType, area) => {
const bindCheckAsync = (mobile, openId, sourceType, area) => {
let params = {
method: 'app.passport.signCheck',
area: area,
... ... @@ -21,7 +21,7 @@ const bindCheck = (mobile, openId, sourceType, area) => {
return api.get('', params);
};
const sendBindMsg = (area, mobile) => {
const sendBindMsgAsync = (area, mobile) => {
let params = {
method: 'app.passport.smsbind',
mobile: mobile,
... ... @@ -31,7 +31,7 @@ const sendBindMsg = (area, mobile) => {
return api.get('', params);
};
const checkBindCode = (area, mobile, code) => {
const checkBindCodeAsync = (area, mobile, code) => {
return api.get('', {
method: 'app.register.validRegCode',
mobile: mobile,
... ... @@ -40,7 +40,7 @@ const checkBindCode = (area, mobile, code) => {
});
};
const bindMobile = (openId, sourceType, mobile, area, password, nickname) => {
const bindMobileAsync = (openId, sourceType, mobile, area, password, nickname) => {
let params = {
method: 'app.passport.bind',
mobile: mobile,
... ... @@ -60,7 +60,7 @@ const bindMobile = (openId, sourceType, mobile, area, password, nickname) => {
return api.get('', params);
};
const relateMobile = (openId, sourceType, mobile, area) => {
const relateMobileAsync = (openId, sourceType, mobile, area) => {
return api.get('', {
method: 'app.passport.relatedMobile',
mobile: mobile,
... ... @@ -70,7 +70,7 @@ const relateMobile = (openId, sourceType, mobile, area) => {
});
};
const changeCheck = (mobile, area) => {
const changeCheckAsync = (mobile, area) => {
return api.get('', {
method: 'app.passport.changeCheck',
mobile: mobile,
... ... @@ -78,7 +78,7 @@ const changeCheck = (mobile, area) => {
});
};
const changeMobile = (uid, mobile, area, code) => {
const changeMobileAsync = (uid, mobile, area, code) => {
return api.get('', {
method: 'app.passport.changeMobile',
mobile: mobile,
... ... @@ -89,11 +89,11 @@ const changeMobile = (uid, mobile, area, code) => {
};
module.exports = {
bindCheck,
sendBindMsg,
checkBindCode,
bindMobile,
relateMobile,
changeCheck,
changeMobile
bindCheckAsync,
sendBindMsgAsync,
checkBindCodeAsync,
bindMobileAsync,
relateMobileAsync,
changeCheckAsync,
changeMobileAsync
};
... ...
/**
* Created by TaoHuang on 2016/7/26.
*/
'use strict';
const api = require('./bind-api');
module.exports = api;
... ...
... ... @@ -6,7 +6,7 @@
const api = global.yoho.API;
const signin = (area, profile, password, shoppingKey) => {
const signinAsnyc = (area, profile, password, shoppingKey) => {
let param = {
method: 'app.passport.signin',
area: area,
... ... @@ -21,7 +21,7 @@ const signin = (area, profile, password, shoppingKey) => {
return api.post('', param);
};
const signinByOtherOpenID = (nickname, openId, sourceType, shoppingKey) => {
const signinByOtherOpenIDAsync = (nickname, openId, sourceType, shoppingKey) => {
let param = {
nickname: nickname,
openId: openId,
... ... @@ -36,7 +36,7 @@ const signinByOtherOpenID = (nickname, openId, sourceType, shoppingKey) => {
return api.get('', param);
};
const signinByWechat = (nickname, openId, sourceType, shoppingKey, unionId) => {
const signinByWechatAsync = (nickname, openId, sourceType, shoppingKey, unionId) => {
let param = {
nickname: nickname,
openId: openId,
... ... @@ -53,7 +53,7 @@ const signinByWechat = (nickname, openId, sourceType, shoppingKey, unionId) => {
};
module.exports = {
signin,
signinByOtherOpenID,
signinByWechat
signinAsnyc,
signinByOtherOpenIDAsync,
signinByWechatAsync
};
... ...
... ... @@ -13,10 +13,10 @@ const config = global.yoho.config;
const api = require('./login-api');
const userService = require('./user-service');
const signinByOpenID = (nickname, openId, sourceType, shoppingKey, unionId) => {
const signinByOpenIDAsync = (nickname, openId, sourceType, shoppingKey, unionId) => {
let signinFunc = {
other: api.signinByOtherOpenID,
wechat: api.signinByWechat
other: api.signinByOtherOpenIDAsync,
wechat: api.signinByWechatAsync
};
// PC 的微信登录之前使用了 open_id, 所以需要特别的接口处理
... ... @@ -73,8 +73,8 @@ const rememberAccount = (accountInfo, req, res) => {
};
module.exports = {
signin: api.signin,
signinByOpenID,
signinAsync: api.signinAsync,
signinByOpenIDAsync,
syncUserSession,
rememberAccount
};
... ...
... ... @@ -48,7 +48,7 @@ function AlipayStrategy(options, verify) {
options = options || {};
passport.Strategy.call(this);
this.name = 'alipay';
this._verify = verify;
this._verify = verif
this._options = options;
}
... ...
... ... @@ -4,7 +4,7 @@
'use strict';
const api = global.yoho.API;
let sendCodeToMobile = (area, mobile) => {
let sendCodeToMobileAsync = (area, mobile) => {
let params = {
method: 'app.register.sendRegCodeToMobile',
area: area,
... ... @@ -14,7 +14,7 @@ let sendCodeToMobile = (area, mobile) => {
return api.post('', params);
};
let validMobileCode = (area, mobile, code) => {
let validMobileCodeAsync = (area, mobile, code) => {
let params = {
method: 'app.register.validRegCode',
area: area,
... ... @@ -25,7 +25,7 @@ let validMobileCode = (area, mobile, code) => {
return api.post('', params);
};
let regMobile = (area, mobile, password, shoppingKey)=> {
let regMobileAsync = (area, mobile, password, shoppingKey)=> {
let params = {
method: 'app.passport.register',
area: area,
... ... @@ -41,7 +41,7 @@ let regMobile = (area, mobile, password, shoppingKey)=> {
};
module.exports = {
sendCodeToMobile,
validMobileCode,
regMobile
sendCodeToMobileAsync,
validMobileCodeAsync,
regMobileAsync
};
... ...
/**
* Created by TaoHuang on 2016/7/26.
*/
'use strict';
const api = require('./reg-api');
module.exports = api;
... ...
... ... @@ -52,9 +52,7 @@
var count = 5,
countDown = document.getElementById('count-down');
console.log(countDown);
var timer = setInterval(function () {
setInterval(function () {
if (count > 1) {
count--;
countDown.innerHTML = count;
... ...
... ... @@ -9,7 +9,7 @@
<div>
尊敬的{{mobile}},恭喜您已经成为YOHO!BLK会员!即刻您可以开启时尚购物之旅!
</div>
<a class="btn btn-fixed-height success-btn" href="{{goShoppong}}" data-url="{{goUrl}}">开始购物</a>
<a class="btn btn-fixed-height success-btn" href="{{goShopping}}" data-url="{{goUrl}}">开始购物</a>
</div>
{{/ passport}}
</div>
... ...