Authored by yyq

Merge branch 'release/1.0' of git.yoho.cn:fe/yohobuywap-node into release/1.0

... ... @@ -17,6 +17,7 @@ const path = require('path');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const favicon = require('serve-favicon');
const yohoLib = require('yoho-node-lib');
const session = require('express-session');
const memcached = require('connect-memcached');
const hbs = require('express-handlebars');
... ... @@ -29,12 +30,13 @@ const MemcachedStore = memcached(session);
app.locals.devEnv = app.get('env') === 'development';
app.locals.version = pkg.version;
// 全局注册library
yohoLib.global(config);
// 指定libray目录
global.library = path.resolve('./library/');
global.middleware = path.resolve('./doraemon/middleware');
global.utils = path.resolve('./utils');
const logger = require(global.library + '/logger');
const logger = global.yoho.logger;
app.set('view engine', '.hbs');
app.set('views', './doraemon/views');
... ... @@ -43,7 +45,7 @@ app.engine('.hbs', hbs({
defaultLayout: 'layout',
layoutsDir: './doraemon/views',
partialsDir: './doraemon/views/partial',
helpers: require(`${global.library}/helpers`)
helpers: global.yoho.helpers
}));
app.use(favicon(path.join(__dirname, '/public/favicon.ico')));
... ... @@ -98,6 +100,7 @@ try {
// YOHO 后置中间件
app.use(errorHanlder.serverError());
} catch (err) {
console.error(err);
logger.error(err);
}
... ...
... ... @@ -23,7 +23,7 @@ app.engine('.hbs', hbs({
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: ['./views/partial', `${doraemon}/partial`],
helpers: require(`${global.library}/helpers`)
helpers: global.yoho.helpers
}));
// router
... ...
var API = require('../../../library/api').API;
var api = new API();
const library = '../../../library';
const sign = require(`${library}/sign`);
/**
* 分享页面基础参数
... ... @@ -10,6 +8,7 @@ const sign = require(`${library}/sign`);
*/
const getPageInfo = (pageInfo) => {
var dest = {};
dest.shareTitle = pageInfo.data.shareTitle;
dest.shareDesc = pageInfo.data.shareContent;
dest.shareImg = pageInfo.data.shareImgUrl;
... ... @@ -73,13 +72,11 @@ const getUserStatus = (param) => {
*/
exports.getPageInfo = (data) => {
var defaultParam = {
method: 'app.activity.getInfoOfOrderShare'
},
infoData = Object.assign(defaultParam, data); // 处理完成后,发给后端
// 处理完成后,发给后端
infoData = Object.assign(defaultParam, data);
return api.get('', sign.apiSign(infoData)).then(result => {
return api.get('', infoData).then(result => {
return getPageInfo(result);
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
};
... ... @@ -95,7 +92,7 @@ exports.getCoupon = (data) => {
// 处理完成后,发给后端
phoneData = Object.assign(defaultParam, data);
return api.get('', sign.apiSign(phoneData)).then(result => {
return api.get('', phoneData).then(result => {
return getUserStatus(result);
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
};
... ... @@ -112,7 +109,7 @@ exports.registerAndSendCoupon = (data) => {
// 处理完成后,发给后端
verifyData = Object.assign(defaultParam, data);
return api.get('', sign.apiSign(verifyData)).then(result => {
return api.get('', verifyData).then(result => {
return getUserStatus(result);
}); // 所有数据返回一个 Promise,方便 Promise.all 调用
};
... ...
... ... @@ -4,10 +4,10 @@
* @date: 2016/05/09
*/
'use strict';
const library = '../../../library';
const _ = require('lodash');
const channelModel = require('../models/channel');
const helpers = require(`${library}/helpers`);
const helpers = global.yoho.helpers;
let _renderData = {
module: 'channel',
... ...
... ... @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: require(`${global.library}/helpers`)
helpers: global.yoho.helpers
}));
// router
... ...
... ... @@ -4,17 +4,14 @@
* @date: 2016/05/09
*/
'use strict';
const library = '../../../library';
const utils = '../../../utils';
const contentCodeConfig = require('../../../config/content-code');
const _ = require('lodash');
const ServiceAPI = require(`${library}/api`).ServiceAPI;
const camelCase = require(`${library}/camel-case`);
const logger = require(`${library}/logger`);
const api = global.yoho.ServiceAPI;
const camelCase = global.yoho.camelCase;
const logger = global.yoho.logger;
const resourcesProcess = require(`${utils}/resources-process`);
const api = new ServiceAPI();
/**
* 性别数据
... ...
{{# content}}
{{! 头部banner}}
{{#if focus}}
{{> resources/banner-top}}
{{/if}}
{{! 图标入口}}
{{#if appIconList}}
{{> resources/icons-enter}}
{{/if}}
{{! 中间banner}}
{{#if singleImage}}
{{> resources/banner}}
{{/if}}
{{! 两个小图}}
{{#if smallPic}}
{{> resources/thumb-row}}
{{/if}}
{{! 热门品类}}
{{#if recommendContentFive}}
{{> resources/hot-category}}
{{/if}}
{{! 热门品牌}}
{{#if appHotBrands}}
{{> resources/hot-brands-list}}
{{/if}}
{{! 热门品牌可滑动}}
{{#if customBrands}}
{{> resources/hot-brands-swipe}}
{{/if}}
{{! 潮人搭配}}
{{#if trendsetterCollocation}}
{{> resources/trendsetter-collocation}}
{{/if}}
{{! 潮流话题}}
{{#if trendgoodsTopic}}
{{> resources/trend-topics}}
{{/if}}
{{! 潮流时装/经典裤裙/时尚靴履/潮人配饰/潮流上装}}
{{#if recommendContentOne}}
{{> resources/goods-category}}
{{/if}}
{{! 新入住品牌/品味生活/创意生活}}
{{#if recommendContentTwo}}
{{> resources/creative-life}}
{{/if}}
{{! PLUS}}
{{#if singleNameImage}}
{{> resources/plus-star}}
{{/if}}
{{! 新人专享}}
{{#if newUserFloor}}
{{> resources/fresh-only}}
{{/if}}
{{/ content}}
... ... @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: require(`${global.library}/helpers`)
helpers: global.yoho.helpers
}));
// router
... ...
... ... @@ -4,19 +4,15 @@
* @date: 2016/05/30
*/
'use strict';
const library = '../../../library';
const utils = '../../../utils';
const contentCodeConfig = require('../../../config/content-code');
const resourcesProcess = require(`${utils}/resources-process`);
const ServiceAPI = require(`${library}/api`).ServiceAPI;
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const logger = require(`${library}/logger`);
const camelCase = require(`${library}/camel-case`);
const helpers = require(`${library}/helpers`);
const logger = global.yoho.logger;
const camelCase = global.yoho.camelCase;
const helpers = global.yoho.helpers;
const _ = require('lodash');
const serviceAPI = new ServiceAPI();
const api = new API();
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const contentCode = contentCodeConfig.guang;
... ... @@ -26,10 +22,10 @@ const contentCode = contentCodeConfig.guang;
* @return {[array]}
*/
const _getResources = (page) => {
return serviceAPI.get('operations/api/v5/resource/get', sign.apiSign({
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: contentCode[page],
client_type: 'iphone'
})).then((result) => {
}).then((result) => {
if (result && result.code === 200) {
return resourcesProcess(result.data);
} else {
... ... @@ -164,11 +160,11 @@ const _processCollocationData = (list) => {
* 星潮首页
*/
const getIndexData = (uid) => {
return api.get('', sign.apiSign({
return api.get('', {
method: 'app.starClass.index',
code: '8adc27fcf5676f356602889afcfd2a8e',
client_type: 'iphone'
})).then((result) => {
}).then((result) => {
if (result && result.code === 200) {
return _processIndexData(result.data, uid);
} else {
... ... @@ -182,13 +178,13 @@ const getIndexData = (uid) => {
* 明星专题
*/
const getDetailData = (params) => {
return api.get('', sign.apiSign({
return api.get('', {
method: 'app.starClass.lastTagArticle',
tag: params.tag,
page: params.page || 1,
size: 10,
client_type: 'iphone'
})).then((result) => {
}).then((result) => {
if (result && result.code === 200) {
if (params.page > result.data.totalPage) {
return '';
... ... @@ -232,10 +228,10 @@ const getSpecialData = () => {
*/
const getCollocationListData = (params, uid) => {
return serviceAPI.get('guang/api/v5/article/getStarClassroomArticleList', sign.apiSign(Object.assign({
return serviceAPI.get('guang/api/v5/article/getStarClassroomArticleList', Object.assign({
limit: '20',
uid: uid
}, params))).then((result) => {
}, params)).then((result) => {
if (result && result.code === 200) {
return _processCollocationData(result.data.list.artList);
} else {
... ... @@ -253,12 +249,12 @@ const setFavorite = (params, uid) => {
});
}
return api.get('', sign.apiSign({
return api.get('', {
method: params.type === 'del' ? 'app.sns.cancelFavorBackCount' : 'app.sns.setFavorBackCount',
client_type: 'h5',
article_id: params.articleId,
uid: uid
}));
});
};
module.exports = {
... ...
... ... @@ -16,10 +16,10 @@ const AlipayStrategy = require('./models/passport-alipay').Strategy;
const _ = require('lodash');
const md5 = require('md5');
const config = require('../../config/common');
const logger = require(global.library + '/logger');
const helpers = require(global.library + '/helpers');
const cookie = require(global.library + '/cookie');
const config = global.yoho.config;
const logger = global.yoho.logger;
const helpers = global.yoho.helpers;
const cookie = global.yoho.cookie;
const AuthHelper = require('./models/auth-helper');
... ...
... ... @@ -7,84 +7,85 @@
const _ = require('lodash');
const library = '../../../library';
const helpers = require(`${library}/helpers`);
const helpers = global.yoho.helpers;
const service = require('../models/back-service');
const SIGN_IN_URL = helpers.urlFormat('/signin.html');
const SIGN_IN = helpers.urlFormat('/passport/login');
/**
* 通过邮箱找回密码页面
*/
module.exports.indexByEmailPage = (req, res) => {
let data = {
backUrl: SIGN_IN_URL,
headerText: '找回密码',
isPassportPage: true,
backEmail: true
};
res.render('back/email', Object.assign({
module: 'passport',
page: 'back-email',
title: '找回密码-通过邮箱'
}, data));
const indexEmailPage = (req, res) => {
res.render('back/email', Object.assign(
{
module: 'passport',
page: 'back-email',
title: '找回密码-通过邮箱'
}, {
backUrl: SIGN_IN,
headerText: '找回密码',
isPassportPage: true,
backEmail: true
}
));
};
/**
* 发送验证码到邮箱
*/
module.exports.sendCodeToEmailAPI = (req, res) => {
const sendCodeToEmailAPI = (req, res) => {
let email = req.body.email || '';
let error = {
const ERR = {
code: 400,
message: '邮箱格式不正确,请重新输入',
data: ''
};
if (!helpers.verifyEmail(email)) {
res.json(error);
res.json(ERR);
return;
}
service.sendCodeToEmailAsync(email).then(result => {
if (result.code === 200) {
result.data = helpers.urlFormat('/passport/back/success.html', {email: email});
}
service.sendCodeToEmailAsync(email)
.then(result => {
if (result.code === 200) {
result.data = helpers.urlFormat('/passport/back/success', { email: email });
}
res.json(result);
}).catch(() => {
res.json(error);
});
res.json(result);
})
.catch(() => {
res.json(ERR);
});
};
/**
* 重新发送验证码到邮箱
*/
module.exports.resendCodeToEmailAPI = (req, res) => {
const resendCodeToEmailAPI = (req, res) => {
let email = req.query.email || '';
service.sendCodeToEmailAsync(email).then(result => {
if (_.isEmpty(result)) {
return Promise.rejected('重新发邮件失败');
}
service.sendCodeToEmailAsync(email)
.then(result => {
if (_.isEmpty(result)) {
return Promise.rejected('重新发邮件失败');
}
res.json(result);
}).catch(err => {
res.json({
code: 400,
message: err
res.json(result);
})
.catch(err => {
res.json({
code: 400,
message: err
});
});
});
};
/**
* 邮箱找回密码-返回成功页面
*/
module.exports.backSuccessByEmailPage = (req, res) => {
const backSuccessByEmailPage = (req, res) => {
let email = req.query.email || '';
if (!helpers.verifyEmail(email)) {
... ... @@ -92,55 +93,51 @@ module.exports.backSuccessByEmailPage = (req, res) => {
}
let domain = email.split('@')[1];
let emailUrl = `http://${domain === 'gmail.com' ? 'mail.google.com' : 'mail.'}${domain}`;
res.render('back/email-success', Object.assign({
module: 'passport',
page: 'back-email-success',
title: '找回密码-通过邮箱'
}, {
backUrl: helpers.urlFormat('/passport/back/email.html'),
backUrl: helpers.urlFormat('/passport/back/email'),
headerText: '找回密码',
isPassportPage: true,
backEmailSuccess: true,
goEmail: emailUrl,
resendUrl: helpers.urlFormat('/passport/back/resendemail', {email: email})
resendUrl: helpers.urlFormat('/passport/back/resendemail', { email: email })
}));
};
/**
* 根据邮箱修改密码
*/
module.exports.setNewPasswordByEmailAPI = (req, res) => {
const setNewPasswordByEmailAPI = (req, res) => {
let pwd = req.body.password || '';
let code = req.body.code || '';
let data = {
code: 200,
data: SIGN_IN_URL
data: SIGN_IN
};
service.modifyPasswordByEmailAsync(pwd, code).then(result => {
if (result.includes('history.back')) {
data.code = 400;
data.message = '修改失败';
}
service.modifyPasswordByEmailAsync(pwd, code)
.then(result => {
if (result.includes('history.back')) {
data.code = 400;
data.message = '修改失败';
}
res.json(data);
}).catch(() => {
res.json(data);
});
res.json(data);
})
.catch(() => {
res.json(data);
});
};
/**
* 找回密码页面-通过手机号
*/
module.exports.indexByMobilePage = (req, res, next) => {
const indexMobilePage = (req, res, next) => {
service.getAreaDataAsync()
.then(result => {
res.render('back/mobile', Object.assign({
... ... @@ -148,63 +145,57 @@ module.exports.indexByMobilePage = (req, res, next) => {
page: 'back-mobile',
title: '找回密码-通过手机号'
}, {
backUrl: SIGN_IN_URL,
backUrl: SIGN_IN,
headerText: '找回密码',
isPassportPage: true,
backMobile: true,
countrys: result.data,
areaCode: '+86'
}));
}).catch(next);
})
.catch(next);
};
/**
* 发送手机验证码
*/
module.exports.sendCodeToMobileAPI = (req, res) => {
let result = {
code: 400,
message: '密码只能使用数字、字母和半角标点符号,请重新输入',
data: ''
};
const sendCodeToMobileAPI = (req, res, next) => {
let phoneNum = req.body.phoneNum || '';
let areaCode = req.body.areaCode || '86';
let ERR = {
code: 400,
message: '输入手机号码出错'
};
if (!helpers.verifyMobile(phoneNum)) {
res.json(result);
return;
return res.json(ERR);
}
service.sendCodeToMobileAsync(phoneNum, areaCode).then(data=> {
if (_.isEmpty(data)) {
return Promise.rejected('发送验证码出错');
}
if (data.code === 200) {
result.data = helpers.urlFormat('/passport/back/verifycode', {
phoneNum: phoneNum,
areaCode: areaCode
});
res.json(result);
} else {
return Promise.rejected('发送验证码出错');
}
}).catch(err => {
result.message = err;
res.json(result);
});
service.sendCodeToMobileAsync(phoneNum, areaCode)
.then(result => {
if (_.isEmpty(result) || result.code !== 200) {
ERR.message = '发送验证码出错';
res.json(ERR);
}
if (result.code === 200) {
return res.json({
code: 200,
data: helpers.urlFormat('/passport/back/mobilecode', {
phoneNum: phoneNum,
areaCode: areaCode
})
});
}
})
.catch(next);
};
/**
* 校验验证码页面
*/
module.exports.verifyCodeByMobilePage = (req, res) => {
const verifyCodeByMobilePage = (req, res) => {
let phoneNum = req.query.phoneNum || '';
let areaCode = req.query.areaCode || '86';
res.render('back/mobile-code', Object.assign({
... ... @@ -212,7 +203,7 @@ module.exports.verifyCodeByMobilePage = (req, res) => {
page: 'back-code',
title: '找回密码-通过手机号'
}, {
backUrl: helpers.urlFormat('/passport/back/mobile.html'),
backUrl: helpers.urlFormat('/passport/back/mobile'),
headerText: '找回密码',
isPassportPage: true,
backCode: true,
... ... @@ -225,40 +216,42 @@ module.exports.verifyCodeByMobilePage = (req, res) => {
/**
* 校验手机验证码
*/
module.exports.verifyCodeByMobileAPI = (req, res) => {
const verifyCodeByMobileAPI = (req, res, next) => {
let phoneNum = req.body.phoneNum || '';
let code = req.body.code || '';
let areaCode = req.body.areaCode || '86';
service.validateMobileCodeAsync(phoneNum, code, areaCode)
.then(result => {
if (result.code === 200) {
result.data = helpers.urlFormat('/passport/back/backcode.html', {
phoneNum: phoneNum,
token: result.data.token,
areaCode: areaCode
res.json({
code: 200,
data: helpers.urlFormat('/passport/back/backcode', {
phoneNum: phoneNum,
token: result.data.token,
areaCode: areaCode
})
});
} else {
res.json({
code: 400,
message: '验证码失败'
});
}
res.json(result);
}).catch(() => res.json({code: 400, message: '验证码失败'}));
})
.catch(next);
};
/**
* 找回密码页面,设置新密码页面-手机
*/
module.exports.setNewPasswordByMobilePage = (req, res) => {
const setNewPasswordByMobilePage = (req, res) => {
let phoneNum = req.query.phoneNum || '';
let token = req.query.token || '';
let areaCode = req.query.areaCode || '86';
let code = req.query.code || '';
if (!token || (!helpers.verifyMobile(phoneNum) && !code)) {
if (!(code || (token && helpers.verifyMobile(phoneNum)))) {
res.redirect(400);
return;
}
... ... @@ -268,7 +261,7 @@ module.exports.setNewPasswordByMobilePage = (req, res) => {
page: 'back-new-password',
title: '找回密码-输入新密码'
}, {
backUrl: SIGN_IN_URL,
backUrl: SIGN_IN,
headerText: '找回密码',
isPassportPage: true,
backNewPwd: true,
... ... @@ -282,21 +275,40 @@ module.exports.setNewPasswordByMobilePage = (req, res) => {
/**
* 根据手机验证码修改密码
*/
module.exports.setNewPasswordByMobileAPI = (req, res) => {
const setNewPasswordByMobileAPI = (req, res, next) => {
let phoneNum = req.body.phoneNum || '';
let token = req.body.token || '';
let areaCode = req.body.areaCode || '86';
let newPwd = req.body.password || '';
service.modifyPasswordByMobileAsync(phoneNum, token, newPwd, areaCode)
.then(result => {
console.log(result);
if (result.code === 200) {
result.data = SIGN_IN_URL;
res.json({
code: 200,
data: SIGN_IN
});
} else {
res.json({
code: 400,
message: '修改密码失败'
});
}
})
.catch(next);
};
res.json(result);
}).catch(() => res.json({code: 400, message: '修改密码失败'}));
module.exports = {
indexEmailPage,
sendCodeToEmailAPI,
resendCodeToEmailAPI,
backSuccessByEmailPage,
setNewPasswordByEmailAPI,
indexMobilePage,
sendCodeToMobileAPI,
verifyCodeByMobilePage,
verifyCodeByMobileAPI,
setNewPasswordByMobilePage,
setNewPasswordByMobileAPI
};
... ...
... ... @@ -7,7 +7,7 @@
'use strict';
const helpers = require(global.library + '/helpers');
const helpers = global.yoho.helpers;
const RegService = require('../models/reg-service');
const BindService = require('../models/bind-service');
const AuthHelper = require('../models/auth-helper');
... ...
... ... @@ -5,14 +5,13 @@
*/
'use strict';
const library = '../../../library';
const passport = require('passport');
const md5 = require('md5');
const uuid = require('uuid');
const cookie = require(`${library}/cookie`);
const helpers = require(`${library}/helpers`);
const log = require(`${library}/logger`);
const config = require('../../../config/common');
const cookie = global.yoho.cookie;
const helpers = global.yoho.helpers;
const log = global.yoho.logger;
const config = global.yoho.config;
const AuthHelper = require('../models/auth-helper');
const loginPage = `${config.siteUrl}/passport/login/index`;
... ... @@ -74,7 +73,7 @@ const local = {
res.render('login', {
loginIndex: true, // 模板中使用JS的标识
backUrl: 'javascript:history.go(-1)', // 返回的URL链接
backUrl: 'javascript:history.go(-1)', // eslint-disable-line // 返回的URL链接
showHeaderImg: true, // 控制显示头部图片
isPassportPage: true, // 模板中模块标识
registerUrl: '/reg.html', // 注册的URL链接
... ...
... ... @@ -8,9 +8,9 @@
'use strict';
const _ = require('lodash');
const helpers = require(global.library + '/helpers');
const sign = require(global.library + '/sign');
const cookie = require(global.library + '/cookie');
const helpers = global.yoho.helpers;
const sign = global.yoho.sign;
const cookie = global.yoho.cookie;
const RegService = require('../models/reg-service');
const AuthHelper = require('../models/auth-helper');
... ...
... ... @@ -26,7 +26,7 @@ app.engine('.hbs', hbs({
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: require(`${global.library}/helpers`)
helpers: global.yoho.helpers
}));
... ...
'use strict';
const library = '../../../library';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const api = new API();
const sign = global.yoho.sign;
const api = global.yoho.API;
class Auth {
... ... @@ -19,7 +17,7 @@ class Auth {
param.shopping_key = shoppingKey;
}
return api.post('', sign.apiSign(param));
return api.post('', param);
}
static signinByOpenID(nickname, openId, sourceType, shoppingKey) {
... ... @@ -35,7 +33,7 @@ class Auth {
param.shopping_key = shoppingKey;
}
return api.get('', sign.apiSign(param));
return api.get('', param);
}
static profile(uid) {
... ... @@ -44,7 +42,7 @@ class Auth {
method: 'app.passport.profile'
};
return api.get('', sign.apiSign(param));
return api.get('', param);
}
static syncUserSession(uid, req, res) {
... ...
... ... @@ -4,21 +4,18 @@
'use strict';
var API = require('../../../library/api').API;
const library = '../../../library';
const sign = require(`${library}/sign`);
var api = new API();
const api = global.yoho.API;
const YOHOBUY_URL = 'http://www.yohobuy.com/';
/**
* 获取地区数据
*/
module.exports.getAreaDataAsync = () => {
return api.get('', sign.apiSign({
const getAreaDataAsync = () => {
return api.get('', {
method: 'app.passport.getArea'
})).then(result => {
}).then(result => {
result.data = result.data.map(value => {
value.areaCode = `+${value.area}`;
... ... @@ -41,11 +38,11 @@ module.exports.getAreaDataAsync = () => {
*
* @param string mail 邮箱地址
*/
module.exports.sendCodeToEmailAsync = (email) => {
return api.get('', sign.apiSign({
const sendCodeToEmailAsync = (email) => {
return api.get('', {
method: 'app.register.backpwdByEmail',
email: email
}));
});
};
/**
... ... @@ -54,7 +51,7 @@ module.exports.sendCodeToEmailAsync = (email) => {
* @param string pwd 新密码
* @param string code 邮箱验证码
*/
module.exports.modifyPasswordByEmailAsync = (pwd, code) => {
const modifyPasswordByEmailAsync = (pwd, code) => {
const options = {
url: `${YOHOBUY_URL}passport/back/update`,
form: {
... ... @@ -74,14 +71,12 @@ module.exports.modifyPasswordByEmailAsync = (pwd, code) => {
* @param string mobile 手机号
* @param integer area 地区码ID
*/
module.exports.sendCodeToMobileAsync = (mobile, area) => {
area = area || 86;
return api.get('', sign.apiSign({
const sendCodeToMobileAsync = (mobile, area) => {
return api.get('', {
mobile: mobile,
area: area,
method: 'app.register.sendBackpwdCodeToMobile'
}));
});
};
/**
... ... @@ -91,14 +86,14 @@ module.exports.sendCodeToMobileAsync = (mobile, area) => {
* @param string code 验证码
* @param integer area 地区码ID
*/
module.exports.validateMobileCodeAsync = (mobile, code, area) => {
const validateMobileCodeAsync = (mobile, code, area) => {
area = area || 86;
return api.get('', sign.apiSign({
return api.get('', {
mobile: mobile,
code: code,
area: area,
method: 'app.register.validBackpwdCode'
}));
});
};
/**
... ... @@ -108,15 +103,22 @@ module.exports.validateMobileCodeAsync = (mobile, code, area) => {
* @param string token 验证手机验证码返回的token
* @param integer area 地区码ID
*/
module.exports.modifyPasswordByMobileAsync = (mobile, token, newpwd, area)=> {
area = area || 86;
return api.get('', sign.apiSign({
const modifyPasswordByMobileAsync = (mobile, token, newpwd, area) => {
return api.get('', {
mobile: mobile,
token: token,
newpwd: newpwd,
area: area,
method: 'app.register.changepwdByMobileCode'
}));
});
};
module.exports = {
getAreaDataAsync,
sendCodeToEmailAsync,
modifyPasswordByEmailAsync,
sendCodeToMobileAsync,
validateMobileCodeAsync,
modifyPasswordByMobileAsync
};
... ...
... ... @@ -7,8 +7,7 @@
'use strict';
const API = require(`${global.library}/api`).API;
const api = new API();
const api = global.yoho.API;
const RegService = {
bindCheck(mobile, openId, sourceType, area) {
... ...
... ... @@ -7,8 +7,7 @@
'use strict';
const API = require(`${global.library}/api`).API;
const api = new API();
const api = global.yoho.API;
const RegService = {
getAreaData() {
... ... @@ -47,7 +46,7 @@ const RegService = {
name: '英国'
}, {
areaCode: '+86',
selected: true,
selected: true, // default choose
name: '中国'
}, {
areaCode: '+853',
... ...
... ... @@ -13,6 +13,7 @@ const back = require(cRoot + '/back');
const bind = require(cRoot + '/bind');
const reg = require(cRoot + '/reg');
const router = express.Router(); // eslint-disable-line
// 登出
... ... @@ -61,44 +62,20 @@ router.get('/reg/password', reg.password);
router.post('/reg/setpassword', reg.setPassword);
/**
* 邮箱
* 密码找回
*/
// 通过邮箱找回密码
router.get('/back/email.html', back.indexByEmailPage);
// 邮箱找回密码-成功
router.get('/back/success.html', back.backSuccessByEmailPage);
// 发送邮箱验证码
router.post('/back/sendemail', back.sendCodeToEmailAPI);
// 重新发送邮箱验证码
router.get('/back/resendemail', back.resendCodeToEmailAPI);
// 据邮箱修改密码
router.post('/back/passwordbyemail', back.setNewPasswordByEmailAPI);
/**
* 手机
*/
// 通过手机找回密码
router.get('/back/mobile.html', back.indexByMobilePage);
// 发送手机验证码
router.get('/back/mobilecode.html', back.verifyCodeByMobilePage);
// 输入新密码
router.get('/back/backcode.html', back.setNewPasswordByMobilePage);
// 发送手机验证码
router.post('/back/sendcode', back.sendCodeToMobileAPI);
// 校验手机验证码
router.post('/back/verifycode', back.verifyCodeByMobileAPI);
// 根据手机验证码修改密码
router.post('/back/passwordbymobile', back.setNewPasswordByMobileAPI);
router.get('/back/email', back.indexEmailPage);// 通过邮箱找回密码页面
router.post('/back/sendemail', back.sendCodeToEmailAPI);// 发送邮箱验证码
router.get('/back/resendemail', back.resendCodeToEmailAPI);// 重新发送邮箱验证码
router.get('/back/success', back.backSuccessByEmailPage);// 邮箱找回密码-发送成功页面
router.get('/back/mobile', back.indexMobilePage);// 输入手机号找回密码页面
router.get('/back/mobilecode', back.verifyCodeByMobilePage);// 输入手机验证码页面
router.post('/back/sendcode', back.sendCodeToMobileAPI);// 发送手机验证码
router.post('/back/verifycode', back.verifyCodeByMobileAPI);// 校验手机验证码
router.get('/back/backcode', back.setNewPasswordByMobilePage);// 设置新密码页面
router.post('/back/passwordbyemail', back.setNewPasswordByEmailAPI);// 依据邮箱验证码修改密码
router.post('/back/passwordbymobile', back.setNewPasswordByMobileAPI);// 依据手机验证码修改密码
module.exports = router;
... ...
... ... @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: require(`${global.library}/helpers`)
helpers: global.yoho.helpers
}));
// router
... ...
... ... @@ -6,12 +6,9 @@
'use strict';
const library = '../../../library';
const API = require(`${library}/api`).API;
const api = global.yoho.API;
const _ = require('lodash');
const helpers = require(`${library}/helpers`);
const api = new API();
const helpers = global.yoho.helpers;
/**
* 处理品牌关联店铺信息
... ...
... ... @@ -7,13 +7,11 @@
'use strict';
const library = '../../../library';
const API = require(`${library}/api`).API;
const _ = require('lodash');
// const log = require(`${library}/logger`);
var api = new API();
var api = global.yoho.API;
/**
* 商品尺码信息处理
... ...
... ... @@ -5,22 +5,17 @@
*/
'use strict';
const library = '../../../library';
const utils = '../../../utils';
const contentCodeConfig = require('../../../config/content-code');
const _ = require('lodash');
const ServiceAPI = require(`${library}/api`).ServiceAPI;
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const camelCase = require(`${library}/camel-case`);
const resourcesProcess = require(`${utils}/resources-process`);
const log = require(`${library}/logger`);
const serviceApi = new ServiceAPI();
const api = new API();
const camelCase = global.yoho.camelCase;
const log = global.yoho.logger;
const serviceApi = global.yoho.ServiceAPI;
const api = global.yoho.API;
const resourcesProcess = require(`${utils}/resources-process`);
const dateFormate = (str) =>{
var time = new Date(str * 1000);
... ... @@ -61,7 +56,7 @@ const _getOutletResource = (channel, contentcode) => {
yh_channel: channel || ''
};
return serviceApi.get('operations/api/v5/resource/home', sign.apiSign(params)).then(result => {
return serviceApi.get('operations/api/v5/resource/home', params).then(result => {
if (result && result.code === 200) {
return resourcesProcess(result.data.list);
} else {
... ... @@ -102,7 +97,7 @@ const _getNavData = (categoryId) => {
parent_id: categoryId
};
return serviceApi.get('operations/api/v6/category/getCategory', sign.apiSign(params)).then(result => {
return serviceApi.get('operations/api/v6/category/getCategory', params).then(result => {
if (result && result.code === 200) {
let data = _convertNavData(result.data);
... ... @@ -170,7 +165,7 @@ const _getActivityDetail = (id) => {
};
return api.get('', sign.apiSign(params)).then(res => {
return api.get('', params).then(res => {
if (res.code === 200) {
return _convertActicityData(res.data);
} else {
... ... @@ -191,7 +186,7 @@ const _getHomeActivity = (data) => {
platform: 3 // h5平台代号
};
return api.get('', sign.apiSign(_.assign(params, data))).then(res => {
return api.get('', _.assign(params, data)).then(res => {
return _convertActicityData(res.data);
});
};
... ...
... ... @@ -6,13 +6,10 @@
*/
'use strict';
const library = '../../../library';
const utils = '../../../utils';
const API = require(`${library}/api`).API;
const _ = require('lodash');
const productProcess = require(`${utils}/product-process`);
const api = new API();
const productProcess = require(`${global.utils}/product-process`);
const api = global.yoho.API;
module.exports = (data) => {
let finalResult;
... ...
... ... @@ -4,21 +4,17 @@
* @date: 2016/05/17
*/
'use strict';
const library = '../../../library';
const utils = '../../../utils';
const contentCodeConfig = require('../../../config/content-code');
const API = require(`${library}/api`).API;
const ServiceAPI = require(`${library}/api`).ServiceAPI;
const sign = require(`${library}/sign`);
const logger = require(`${library}/logger`);
const camelCase = require(`${library}/camel-case`);
const logger = global.yoho.logger;
const camelCase = global.yoho.camelCase;
const resourcesProcess = require(`${utils}/resources-process`);
const productProcess = require(`${utils}/product-process`);
const processTime = require(`${utils}/time-process`);
const _ = require('lodash');
const api = new API();
const serviceAPI = new ServiceAPI();
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
... ... @@ -87,11 +83,11 @@ const _processDiscount = (list, channel) => {
const _discount = (params) => {
params = params || {};
return api.get('', sign.apiSign(Object.assign({
return api.get('', Object.assign({
method: 'app.activity.get',
sort: 2,
plateform: 3
}, params)));
}, params));
};
/**
... ... @@ -160,9 +156,9 @@ const _searchSales = (params) => {
params.order = typeCont[params.type][params.order];
}
return api.get('', sign.apiSign(Object.assign({
return api.get('', Object.assign({
method: method
}, params)), true);
}, params), true);
};
/**
... ... @@ -177,10 +173,10 @@ const _getUserProfile = (uid) => {
data: {}
});
}
return api.get('', sign.apiSign({
return api.get('', {
method: 'app.passport.profile',
uid: uid
}), true);
}, true);
};
/**
... ... @@ -189,9 +185,9 @@ const _getUserProfile = (uid) => {
* @return {[array]}
*/
const _getResources = (page, channel) => {
return serviceAPI.get('operations/api/v5/resource/get', sign.apiSign({
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: contentCode[channel][page]
})).then((result) => {
}).then((result) => {
if (result && result.code === 200) {
return resourcesProcess(result.data);
} else {
... ... @@ -207,10 +203,10 @@ const _getResources = (page, channel) => {
* @return {[object]}
*/
const _getBreakingSort = (yhChannel) => {
return api.get('', sign.apiSign({
return api.get('', {
method: 'app.sale.getBreakingSort',
yh_channel: channelType[yhChannel] || '1'
})).then((result) => {
}).then((result) => {
if (result && result.code === 200) {
return _processBreakingSort(result.data);
} else {
... ...
const _ = require('lodash');
const cookie = require('../../library/cookie');
const cookie = global.yoho.cookie;
module.exports = () => {
return (req, res, next) => {
... ...
{{#data}}
<ul class="hot-brands clearfix">
{{> common/floor-header}}
{{# list}}
{{# list}}
<li class="brand">
<a href="{{url}}">
<div class="brand-logo">
... ... @@ -11,8 +11,11 @@
</a>
</li>
{{/ list}}
<li class="more">
<a href="{{more}}"></a>
<a class="{{#unless image.src}}default{{/unless}}" href="{{image.url}}">
<img src="{{image image.src 320 172}}">
</a>
</li>
</ul>
{{/data}}
\ No newline at end of file
{{/data}}
... ...
<div class="icons-wrapper">
<ul class="icons-list clearfix">
{{#data}}
<li class="icons-item"><a href="{{url}}" class="imagebar"><img src="{{image src 98 98}}" alt=""></a><a href="{{url}}" class="linkbar">{{title}}</a></li>
<li class="icons-item item-{{../data.length}}"><a href="{{url}}" class="imagebar"><img src="{{image src 98 98}}" alt=""></a><a href="{{url}}" class="linkbar">{{title}}</a></li>
{{/data}}
</ul>
</div>
... ...
... ... @@ -55,6 +55,7 @@
"serve-favicon": "^2.3.0",
"uuid": "^2.0.2",
"winston": "^2.2.0",
"yoho-node-lib": "0.0.5",
"winston-daily-rotate-file": "^1.1.4"
},
"devDependencies": {
... ...
... ... @@ -49,7 +49,7 @@ $btnOk.on('touchstart', function() {
if (mobileBack) {
$.extend(setting, {
phoneNum: $phoneNum.val(),
areaCode: $('#areaCode').val(),
areaCode: $('#area-code').val(),
token: $('#token').val()
});
... ...
... ... @@ -20,7 +20,7 @@ var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = tip.show;
//登录按钮状态切换
// 登录按钮状态切换
function switchLoginBtnStatus() {
if (pnPass && pwdPass) {
$loginBtn.removeClass('disable');
... ... @@ -29,13 +29,13 @@ function switchLoginBtnStatus() {
}
}
//Android-UC下显示select的direction:rtl无效的临时解决办法
// Android-UC下显示select的direction:rtl无效的临时解决办法
api.selectCssHack($countrySelect);
//显示隐藏密码
// 显示隐藏密码
api.bindEyesEvt();
//清空手机号码
// 清空手机号码
api.bindClearEvt();
$phoneNum.bind('input', function() {
... ... @@ -98,14 +98,14 @@ $loginBtn.on('touchstart', function() {
success: function() {
clearTimeout(time);
//Cookie写入成功后,1s后跳转页面
// Cookie写入成功后,1s后跳转页面
setTimeout(function() {
location.href = res.href;
}, 1000);
}
});
//3秒后强制跳转
// 3秒后强制跳转
time = setTimeout(function() {
location.href = res.href;
}, 3000);
... ... @@ -128,6 +128,6 @@ $loginBtn.on('touchstart', function() {
}
});
//对初始有默认值的情况去初始化登录按钮状态
// 对初始有默认值的情况去初始化登录按钮状态
$phoneNum.trigger('input');
$pwd.trigger('input');
\ No newline at end of file
$pwd.trigger('input');
... ...
... ... @@ -21,7 +21,7 @@ var tip = require('../../plugin/tip');
var trim = $.trim;
var showErrTip = tip.show;
//登录按钮状态切换
// 登录按钮状态切换
function switchLoginBtnStatus() {
if (accPass && pwdPass) {
$loginBtn.removeClass('disable');
... ... @@ -30,22 +30,22 @@ function switchLoginBtnStatus() {
}
}
//显示找回密码面板
// 显示找回密码面板
function showRetrivePanel() {
$mask.show();
$ways.show();
}
//隐藏找回密码面板
// 隐藏找回密码面板
function hideRetrivePanel() {
$mask.hide();
$ways.hide();
}
//密码显示与隐藏
// 密码显示与隐藏
api.bindEyesEvt();
//清空账号输入框
// 清空账号输入框
api.bindClearEvt();
$account.bind('input', function() {
... ... @@ -78,7 +78,7 @@ $loginBtn.on('touchstart', function() {
$loginBtn.text('正在登录...').addClass('disable');
//验证账号(数字或者邮箱)和密码合理性
// 验证账号(数字或者邮箱)和密码合理性
if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
$.ajax({
type: 'POST',
... ... @@ -126,6 +126,6 @@ $('#cancel-retrive').on('touchstart', function(e) {
hideRetrivePanel();
});
//对初始有默认值的情况去初始化登录按钮状态
// 对初始有默认值的情况去初始化登录按钮状态
$account.trigger('input');
$pwd.trigger('input');
... ...
... ... @@ -69,13 +69,17 @@
width: 317px;
height: 174px;
border-top: 1px solid #e0e0e0;
overflow: hidden;
a {
display: block;
width: 100%;
height: 100%;
background: resolve("channel/more-brand.png") no-repeat;
background-size: 100% 100%;
&.default {
background: resolve("channel/more-brand.png") no-repeat;
background-size: 100% 100%;
}
}
}
}
... ...
... ... @@ -3,42 +3,46 @@
padding: 30px 0 16px;
background: #fff;
border-bottom: 1px solid #e0e0e0;
}
.icons-item {
float: left;
margin-bottom: 10px;
width: 25%;
height: 146px;
text-align: center;
}
.imagebar {
display: block;
margin: 0 auto;
text-align: center;
width: 98px;
height: 98px;
line-height: 98px;
box-sizing: border-box;
overflow: hidden;
.icons-item {
float: left;
margin-bottom: 10px;
width: 20%;
height: 146px;
text-align: center;
img {
width: 100%;
height: 100%;
&.item-8 {
width: 25%;
}
}
}
.linkbar {
display: block;
line-height: 44px;
font-size: 24px;
color: #444;
.imagebar {
display: block;
margin: 0 auto;
text-align: center;
width: 98px;
height: 98px;
line-height: 98px;
box-sizing: border-box;
overflow: hidden;
img {
width: 100%;
height: 100%;
}
}
&:visited,
&:link,
&:active,
&:hover {
.linkbar {
display: block;
line-height: 44px;
font-size: 24px;
color: #444;
&:visited,
&:link,
&:active,
&:hover {
color: #444;
}
}
}
... ...
'use strict';
const _ = require('lodash');
const camelCase = require('../library/camel-case');
const helpers = require('../library/helpers');
const camelCase = global.yoho.camelCase;
const helpers = global.yoho.helpers;
/**
* 根据性别来决定 默认图片获取字段 如果是 2、3
... ...
const _ = require('lodash');
const camelCase = require('../library/camel-case');
const camelCase = global.yoho.camelCase;
/**
* 处理楼层数据
... ...
... ... @@ -4,8 +4,7 @@
'use strict';
const library = '../library';
const helpers = require(`${library}/helpers`);
const helpers = global.yoho.helpers;
const timeFormat = {
d: '剩{d}天',
... ...