Authored by 姜枫

merge common-lib

... ... @@ -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,14 @@ 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 +46,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 +101,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
... ...
... ... @@ -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;
const 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,18 +4,15 @@
* @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 sign = require(`${library}/sign`);
const camelCase = require(`${library}/camel-case`);
const logger = require(`${library}/logger`);
const api = global.yoho.ServiceAPI;
const sign = global.yoho.sign;
const camelCase = global.yoho.camelCase;
const logger = global.yoho.logger;
const resourcesProcess = require(`${utils}/resources-process`);
const api = new ServiceAPI();
/**
* 性别数据
... ...
... ... @@ -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,16 @@
* @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 sign = global.yoho.sign;
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;
... ...
... ... @@ -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,8 +7,7 @@
const _ = require('lodash');
const library = '../../../library';
const helpers = require(`${library}/helpers`);
const helpers = global.yoho.helpers;
const service = require('../models/back-service');
... ...
... ... @@ -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`;
... ...
... ... @@ -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 {
... ...
... ... @@ -4,11 +4,8 @@
'use strict';
var API = require('../../../library/api').API;
const library = '../../../library';
const sign = require(`${library}/sign`);
var api = new API();
const sign = global.yoho.sign;
const api = global.yoho.API;
const YOHOBUY_URL = 'http://www.yohobuy.com/';
... ...
... ... @@ -7,8 +7,7 @@
'use strict';
const API = require(`${global.library}/api`).API;
const api = new API();
const api = global.yoho.API;
class RegService {
... ...
... ... @@ -7,8 +7,7 @@
'use strict';
const API = require(`${global.library}/api`).API;
const api = new API();
const api = global.yoho.API;
class RegService {
... ... @@ -48,7 +47,7 @@ class RegService {
name: '英国'
}, {
areaCode: '+86',
selected: true,
selected: true, // default choose
name: '中国'
}, {
areaCode: '+853',
... ...
... ... @@ -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,18 @@
*/
'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 sign = global.yoho.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);
... ...
... ... @@ -7,13 +7,11 @@
'use strict';
const library = '../../../library';
const utils = '../../../utils';
const API = require(`${library}/api`).API;
const sign = require(`${library}/sign`);
const api = global.yoho.API;
const sign = global.yoho.sign;
const _ = require('lodash');
const productProcess = require(`${utils}/product-process`);
var api = new API();
module.exports = (data) => {
var finalResult;
... ...
... ... @@ -4,21 +4,18 @@
* @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 sign = global.yoho.sign;
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;
... ...
const _ = require('lodash');
const cookie = require('../../library/cookie');
const cookie = global.yoho.cookie;
module.exports = () => {
return (req, res, next) => {
... ...
... ... @@ -55,6 +55,7 @@
"serve-favicon": "^2.3.0",
"uuid": "^2.0.2",
"winston": "^2.2.0",
"yoho-node-lib": "0.0.3",
"winston-daily-rotate-file": "^1.1.4"
},
"devDependencies": {
... ...
... ... @@ -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');
... ...
'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}天',
... ...