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'); @@ -17,6 +17,7 @@ const path = require('path');
17 const bodyParser = require('body-parser'); 17 const bodyParser = require('body-parser');
18 const cookieParser = require('cookie-parser'); 18 const cookieParser = require('cookie-parser');
19 const favicon = require('serve-favicon'); 19 const favicon = require('serve-favicon');
  20 +const yohoLib = require('yoho-node-lib');
20 const session = require('express-session'); 21 const session = require('express-session');
21 const memcached = require('connect-memcached'); 22 const memcached = require('connect-memcached');
22 const hbs = require('express-handlebars'); 23 const hbs = require('express-handlebars');
@@ -29,12 +30,13 @@ const MemcachedStore = memcached(session); @@ -29,12 +30,13 @@ const MemcachedStore = memcached(session);
29 app.locals.devEnv = app.get('env') === 'development'; 30 app.locals.devEnv = app.get('env') === 'development';
30 app.locals.version = pkg.version; 31 app.locals.version = pkg.version;
31 32
  33 +// 全局注册library
  34 +yohoLib.global(config);
  35 +
32 // 指定libray目录 36 // 指定libray目录
33 -global.library = path.resolve('./library/');  
34 -global.middleware = path.resolve('./doraemon/middleware');  
35 global.utils = path.resolve('./utils'); 37 global.utils = path.resolve('./utils');
36 38
37 -const logger = require(global.library + '/logger'); 39 +const logger = global.yoho.logger;
38 40
39 app.set('view engine', '.hbs'); 41 app.set('view engine', '.hbs');
40 app.set('views', './doraemon/views'); 42 app.set('views', './doraemon/views');
@@ -43,7 +45,7 @@ app.engine('.hbs', hbs({ @@ -43,7 +45,7 @@ app.engine('.hbs', hbs({
43 defaultLayout: 'layout', 45 defaultLayout: 'layout',
44 layoutsDir: './doraemon/views', 46 layoutsDir: './doraemon/views',
45 partialsDir: './doraemon/views/partial', 47 partialsDir: './doraemon/views/partial',
46 - helpers: require(`${global.library}/helpers`) 48 + helpers: global.yoho.helpers
47 })); 49 }));
48 50
49 app.use(favicon(path.join(__dirname, '/public/favicon.ico'))); 51 app.use(favicon(path.join(__dirname, '/public/favicon.ico')));
@@ -98,6 +100,7 @@ try { @@ -98,6 +100,7 @@ try {
98 // YOHO 后置中间件 100 // YOHO 后置中间件
99 app.use(errorHanlder.serverError()); 101 app.use(errorHanlder.serverError());
100 } catch (err) { 102 } catch (err) {
  103 + console.error(err);
101 logger.error(err); 104 logger.error(err);
102 } 105 }
103 106
@@ -23,7 +23,7 @@ app.engine('.hbs', hbs({ @@ -23,7 +23,7 @@ app.engine('.hbs', hbs({
23 defaultLayout: 'layout', 23 defaultLayout: 'layout',
24 layoutsDir: doraemon, 24 layoutsDir: doraemon,
25 partialsDir: ['./views/partial', `${doraemon}/partial`], 25 partialsDir: ['./views/partial', `${doraemon}/partial`],
26 - helpers: require(`${global.library}/helpers`) 26 + helpers: global.yoho.helpers
27 })); 27 }));
28 28
29 // router 29 // router
1 var API = require('../../../library/api').API; 1 var API = require('../../../library/api').API;
2 var api = new API(); 2 var api = new API();
3 -const library = '../../../library';  
4 -const sign = require(`${library}/sign`);  
5 3
6 /** 4 /**
7 * 分享页面基础参数 5 * 分享页面基础参数
@@ -10,6 +8,7 @@ const sign = require(`${library}/sign`); @@ -10,6 +8,7 @@ const sign = require(`${library}/sign`);
10 */ 8 */
11 const getPageInfo = (pageInfo) => { 9 const getPageInfo = (pageInfo) => {
12 var dest = {}; 10 var dest = {};
  11 +
13 dest.shareTitle = pageInfo.data.shareTitle; 12 dest.shareTitle = pageInfo.data.shareTitle;
14 dest.shareDesc = pageInfo.data.shareContent; 13 dest.shareDesc = pageInfo.data.shareContent;
15 dest.shareImg = pageInfo.data.shareImgUrl; 14 dest.shareImg = pageInfo.data.shareImgUrl;
@@ -73,13 +72,11 @@ const getUserStatus = (param) => { @@ -73,13 +72,11 @@ const getUserStatus = (param) => {
73 */ 72 */
74 exports.getPageInfo = (data) => { 73 exports.getPageInfo = (data) => {
75 var defaultParam = { 74 var defaultParam = {
76 -  
77 method: 'app.activity.getInfoOfOrderShare' 75 method: 'app.activity.getInfoOfOrderShare'
78 }, 76 },
  77 + infoData = Object.assign(defaultParam, data); // 处理完成后,发给后端
79 78
80 - // 处理完成后,发给后端  
81 - infoData = Object.assign(defaultParam, data);  
82 - return api.get('', sign.apiSign(infoData)).then(result => { 79 + return api.get('', infoData).then(result => {
83 return getPageInfo(result); 80 return getPageInfo(result);
84 }); // 所有数据返回一个 Promise,方便 Promise.all 调用 81 }); // 所有数据返回一个 Promise,方便 Promise.all 调用
85 }; 82 };
@@ -95,7 +92,7 @@ exports.getCoupon = (data) => { @@ -95,7 +92,7 @@ exports.getCoupon = (data) => {
95 // 处理完成后,发给后端 92 // 处理完成后,发给后端
96 phoneData = Object.assign(defaultParam, data); 93 phoneData = Object.assign(defaultParam, data);
97 94
98 - return api.get('', sign.apiSign(phoneData)).then(result => { 95 + return api.get('', phoneData).then(result => {
99 return getUserStatus(result); 96 return getUserStatus(result);
100 }); // 所有数据返回一个 Promise,方便 Promise.all 调用 97 }); // 所有数据返回一个 Promise,方便 Promise.all 调用
101 }; 98 };
@@ -112,7 +109,7 @@ exports.registerAndSendCoupon = (data) => { @@ -112,7 +109,7 @@ exports.registerAndSendCoupon = (data) => {
112 // 处理完成后,发给后端 109 // 处理完成后,发给后端
113 verifyData = Object.assign(defaultParam, data); 110 verifyData = Object.assign(defaultParam, data);
114 111
115 - return api.get('', sign.apiSign(verifyData)).then(result => { 112 + return api.get('', verifyData).then(result => {
116 return getUserStatus(result); 113 return getUserStatus(result);
117 }); // 所有数据返回一个 Promise,方便 Promise.all 调用 114 }); // 所有数据返回一个 Promise,方便 Promise.all 调用
118 }; 115 };
@@ -4,10 +4,10 @@ @@ -4,10 +4,10 @@
4 * @date: 2016/05/09 4 * @date: 2016/05/09
5 */ 5 */
6 'use strict'; 6 'use strict';
7 -const library = '../../../library';  
8 const _ = require('lodash'); 7 const _ = require('lodash');
9 const channelModel = require('../models/channel'); 8 const channelModel = require('../models/channel');
10 -const helpers = require(`${library}/helpers`); 9 +
  10 +const helpers = global.yoho.helpers;
11 11
12 let _renderData = { 12 let _renderData = {
13 module: 'channel', 13 module: 'channel',
@@ -24,7 +24,7 @@ app.engine('.hbs', hbs({ @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
24 defaultLayout: 'layout', 24 defaultLayout: 'layout',
25 layoutsDir: doraemon, 25 layoutsDir: doraemon,
26 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`], 26 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
27 - helpers: require(`${global.library}/helpers`) 27 + helpers: global.yoho.helpers
28 })); 28 }));
29 29
30 // router 30 // router
@@ -4,17 +4,14 @@ @@ -4,17 +4,14 @@
4 * @date: 2016/05/09 4 * @date: 2016/05/09
5 */ 5 */
6 'use strict'; 6 'use strict';
7 -const library = '../../../library';  
8 const utils = '../../../utils'; 7 const utils = '../../../utils';
9 const contentCodeConfig = require('../../../config/content-code'); 8 const contentCodeConfig = require('../../../config/content-code');
10 const _ = require('lodash'); 9 const _ = require('lodash');
11 -const ServiceAPI = require(`${library}/api`).ServiceAPI;  
12 -const camelCase = require(`${library}/camel-case`);  
13 -const logger = require(`${library}/logger`); 10 +const api = global.yoho.ServiceAPI;
  11 +const camelCase = global.yoho.camelCase;
  12 +const logger = global.yoho.logger;
14 const resourcesProcess = require(`${utils}/resources-process`); 13 const resourcesProcess = require(`${utils}/resources-process`);
15 14
16 -const api = new ServiceAPI();  
17 -  
18 15
19 /** 16 /**
20 * 性别数据 17 * 性别数据
1 -{{# content}}  
2 - {{! 头部banner}}  
3 - {{#if focus}}  
4 - {{> resources/banner-top}}  
5 - {{/if}}  
6 - {{! 图标入口}}  
7 - {{#if appIconList}}  
8 - {{> resources/icons-enter}}  
9 - {{/if}}  
10 - {{! 中间banner}}  
11 - {{#if singleImage}}  
12 - {{> resources/banner}}  
13 - {{/if}}  
14 - {{! 两个小图}}  
15 - {{#if smallPic}}  
16 - {{> resources/thumb-row}}  
17 - {{/if}}  
18 - {{! 热门品类}}  
19 - {{#if recommendContentFive}}  
20 - {{> resources/hot-category}}  
21 - {{/if}}  
22 - {{! 热门品牌}}  
23 - {{#if appHotBrands}}  
24 - {{> resources/hot-brands-list}}  
25 - {{/if}}  
26 - {{! 热门品牌可滑动}}  
27 - {{#if customBrands}}  
28 - {{> resources/hot-brands-swipe}}  
29 - {{/if}}  
30 - {{! 潮人搭配}}  
31 - {{#if trendsetterCollocation}}  
32 - {{> resources/trendsetter-collocation}}  
33 - {{/if}}  
34 - {{! 潮流话题}}  
35 - {{#if trendgoodsTopic}}  
36 - {{> resources/trend-topics}}  
37 - {{/if}}  
38 - {{! 潮流时装/经典裤裙/时尚靴履/潮人配饰/潮流上装}}  
39 - {{#if recommendContentOne}}  
40 - {{> resources/goods-category}}  
41 - {{/if}}  
42 - {{! 新入住品牌/品味生活/创意生活}}  
43 - {{#if recommendContentTwo}}  
44 - {{> resources/creative-life}}  
45 - {{/if}}  
46 - {{! PLUS}}  
47 - {{#if singleNameImage}}  
48 - {{> resources/plus-star}}  
49 - {{/if}}  
50 - {{! 新人专享}}  
51 - {{#if newUserFloor}}  
52 - {{> resources/fresh-only}}  
53 - {{/if}}  
54 -{{/ content}}  
@@ -24,7 +24,7 @@ app.engine('.hbs', hbs({ @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
24 defaultLayout: 'layout', 24 defaultLayout: 'layout',
25 layoutsDir: doraemon, 25 layoutsDir: doraemon,
26 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`], 26 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
27 - helpers: require(`${global.library}/helpers`) 27 + helpers: global.yoho.helpers
28 })); 28 }));
29 29
30 // router 30 // router
@@ -4,19 +4,15 @@ @@ -4,19 +4,15 @@
4 * @date: 2016/05/30 4 * @date: 2016/05/30
5 */ 5 */
6 'use strict'; 6 'use strict';
7 -const library = '../../../library';  
8 const utils = '../../../utils'; 7 const utils = '../../../utils';
9 const contentCodeConfig = require('../../../config/content-code'); 8 const contentCodeConfig = require('../../../config/content-code');
10 const resourcesProcess = require(`${utils}/resources-process`); 9 const resourcesProcess = require(`${utils}/resources-process`);
11 -const ServiceAPI = require(`${library}/api`).ServiceAPI;  
12 -const API = require(`${library}/api`).API;  
13 -const sign = require(`${library}/sign`);  
14 -const logger = require(`${library}/logger`);  
15 -const camelCase = require(`${library}/camel-case`);  
16 -const helpers = require(`${library}/helpers`); 10 +const logger = global.yoho.logger;
  11 +const camelCase = global.yoho.camelCase;
  12 +const helpers = global.yoho.helpers;
17 const _ = require('lodash'); 13 const _ = require('lodash');
18 -const serviceAPI = new ServiceAPI();  
19 -const api = new API(); 14 +const serviceAPI = global.yoho.ServiceAPI;
  15 +const api = global.yoho.API;
20 16
21 const contentCode = contentCodeConfig.guang; 17 const contentCode = contentCodeConfig.guang;
22 18
@@ -26,10 +22,10 @@ const contentCode = contentCodeConfig.guang; @@ -26,10 +22,10 @@ const contentCode = contentCodeConfig.guang;
26 * @return {[array]} 22 * @return {[array]}
27 */ 23 */
28 const _getResources = (page) => { 24 const _getResources = (page) => {
29 - return serviceAPI.get('operations/api/v5/resource/get', sign.apiSign({ 25 + return serviceAPI.get('operations/api/v5/resource/get', {
30 content_code: contentCode[page], 26 content_code: contentCode[page],
31 client_type: 'iphone' 27 client_type: 'iphone'
32 - })).then((result) => { 28 + }).then((result) => {
33 if (result && result.code === 200) { 29 if (result && result.code === 200) {
34 return resourcesProcess(result.data); 30 return resourcesProcess(result.data);
35 } else { 31 } else {
@@ -164,11 +160,11 @@ const _processCollocationData = (list) => { @@ -164,11 +160,11 @@ const _processCollocationData = (list) => {
164 * 星潮首页 160 * 星潮首页
165 */ 161 */
166 const getIndexData = (uid) => { 162 const getIndexData = (uid) => {
167 - return api.get('', sign.apiSign({ 163 + return api.get('', {
168 method: 'app.starClass.index', 164 method: 'app.starClass.index',
169 code: '8adc27fcf5676f356602889afcfd2a8e', 165 code: '8adc27fcf5676f356602889afcfd2a8e',
170 client_type: 'iphone' 166 client_type: 'iphone'
171 - })).then((result) => { 167 + }).then((result) => {
172 if (result && result.code === 200) { 168 if (result && result.code === 200) {
173 return _processIndexData(result.data, uid); 169 return _processIndexData(result.data, uid);
174 } else { 170 } else {
@@ -182,13 +178,13 @@ const getIndexData = (uid) => { @@ -182,13 +178,13 @@ const getIndexData = (uid) => {
182 * 明星专题 178 * 明星专题
183 */ 179 */
184 const getDetailData = (params) => { 180 const getDetailData = (params) => {
185 - return api.get('', sign.apiSign({ 181 + return api.get('', {
186 method: 'app.starClass.lastTagArticle', 182 method: 'app.starClass.lastTagArticle',
187 tag: params.tag, 183 tag: params.tag,
188 page: params.page || 1, 184 page: params.page || 1,
189 size: 10, 185 size: 10,
190 client_type: 'iphone' 186 client_type: 'iphone'
191 - })).then((result) => { 187 + }).then((result) => {
192 if (result && result.code === 200) { 188 if (result && result.code === 200) {
193 if (params.page > result.data.totalPage) { 189 if (params.page > result.data.totalPage) {
194 return ''; 190 return '';
@@ -232,10 +228,10 @@ const getSpecialData = () => { @@ -232,10 +228,10 @@ const getSpecialData = () => {
232 */ 228 */
233 const getCollocationListData = (params, uid) => { 229 const getCollocationListData = (params, uid) => {
234 230
235 - return serviceAPI.get('guang/api/v5/article/getStarClassroomArticleList', sign.apiSign(Object.assign({ 231 + return serviceAPI.get('guang/api/v5/article/getStarClassroomArticleList', Object.assign({
236 limit: '20', 232 limit: '20',
237 uid: uid 233 uid: uid
238 - }, params))).then((result) => { 234 + }, params)).then((result) => {
239 if (result && result.code === 200) { 235 if (result && result.code === 200) {
240 return _processCollocationData(result.data.list.artList); 236 return _processCollocationData(result.data.list.artList);
241 } else { 237 } else {
@@ -253,12 +249,12 @@ const setFavorite = (params, uid) => { @@ -253,12 +249,12 @@ const setFavorite = (params, uid) => {
253 }); 249 });
254 } 250 }
255 251
256 - return api.get('', sign.apiSign({ 252 + return api.get('', {
257 method: params.type === 'del' ? 'app.sns.cancelFavorBackCount' : 'app.sns.setFavorBackCount', 253 method: params.type === 'del' ? 'app.sns.cancelFavorBackCount' : 'app.sns.setFavorBackCount',
258 client_type: 'h5', 254 client_type: 'h5',
259 article_id: params.articleId, 255 article_id: params.articleId,
260 uid: uid 256 uid: uid
261 - })); 257 + });
262 }; 258 };
263 259
264 module.exports = { 260 module.exports = {
@@ -16,10 +16,10 @@ const AlipayStrategy = require('./models/passport-alipay').Strategy; @@ -16,10 +16,10 @@ const AlipayStrategy = require('./models/passport-alipay').Strategy;
16 const _ = require('lodash'); 16 const _ = require('lodash');
17 const md5 = require('md5'); 17 const md5 = require('md5');
18 18
19 -const config = require('../../config/common');  
20 -const logger = require(global.library + '/logger');  
21 -const helpers = require(global.library + '/helpers');  
22 -const cookie = require(global.library + '/cookie'); 19 +const config = global.yoho.config;
  20 +const logger = global.yoho.logger;
  21 +const helpers = global.yoho.helpers;
  22 +const cookie = global.yoho.cookie;
23 23
24 const AuthHelper = require('./models/auth-helper'); 24 const AuthHelper = require('./models/auth-helper');
25 25
@@ -7,73 +7,74 @@ @@ -7,73 +7,74 @@
7 7
8 const _ = require('lodash'); 8 const _ = require('lodash');
9 9
10 -const library = '../../../library';  
11 -const helpers = require(`${library}/helpers`); 10 +const helpers = global.yoho.helpers;
12 11
13 const service = require('../models/back-service'); 12 const service = require('../models/back-service');
14 13
15 -const SIGN_IN_URL = helpers.urlFormat('/signin.html'); 14 +const SIGN_IN = helpers.urlFormat('/passport/login');
16 15
17 /** 16 /**
18 * 通过邮箱找回密码页面 17 * 通过邮箱找回密码页面
19 */ 18 */
20 -module.exports.indexByEmailPage = (req, res) => {  
21 -  
22 - let data = {  
23 - backUrl: SIGN_IN_URL,  
24 - headerText: '找回密码',  
25 - isPassportPage: true,  
26 - backEmail: true  
27 - };  
28 -  
29 - res.render('back/email', Object.assign({ 19 +const indexEmailPage = (req, res) => {
  20 + res.render('back/email', Object.assign(
  21 + {
30 module: 'passport', 22 module: 'passport',
31 page: 'back-email', 23 page: 'back-email',
32 title: '找回密码-通过邮箱' 24 title: '找回密码-通过邮箱'
33 - }, data)); 25 + }, {
  26 + backUrl: SIGN_IN,
  27 + headerText: '找回密码',
  28 + isPassportPage: true,
  29 + backEmail: true
  30 + }
  31 + ));
34 }; 32 };
35 33
36 /** 34 /**
37 * 发送验证码到邮箱 35 * 发送验证码到邮箱
38 */ 36 */
39 -module.exports.sendCodeToEmailAPI = (req, res) => { 37 +const sendCodeToEmailAPI = (req, res) => {
40 let email = req.body.email || ''; 38 let email = req.body.email || '';
41 -  
42 - let error = { 39 + const ERR = {
43 code: 400, 40 code: 400,
44 message: '邮箱格式不正确,请重新输入', 41 message: '邮箱格式不正确,请重新输入',
45 data: '' 42 data: ''
46 }; 43 };
47 44
48 if (!helpers.verifyEmail(email)) { 45 if (!helpers.verifyEmail(email)) {
49 - res.json(error); 46 + res.json(ERR);
50 return; 47 return;
51 } 48 }
52 49
53 - service.sendCodeToEmailAsync(email).then(result => { 50 + service.sendCodeToEmailAsync(email)
  51 + .then(result => {
54 if (result.code === 200) { 52 if (result.code === 200) {
55 - result.data = helpers.urlFormat('/passport/back/success.html', {email: email}); 53 + result.data = helpers.urlFormat('/passport/back/success', { email: email });
56 } 54 }
57 55
58 res.json(result); 56 res.json(result);
59 - }).catch(() => {  
60 - res.json(error); 57 + })
  58 + .catch(() => {
  59 + res.json(ERR);
61 }); 60 });
62 }; 61 };
63 62
64 /** 63 /**
65 * 重新发送验证码到邮箱 64 * 重新发送验证码到邮箱
66 */ 65 */
67 -module.exports.resendCodeToEmailAPI = (req, res) => { 66 +const resendCodeToEmailAPI = (req, res) => {
68 let email = req.query.email || ''; 67 let email = req.query.email || '';
69 68
70 - service.sendCodeToEmailAsync(email).then(result => { 69 + service.sendCodeToEmailAsync(email)
  70 + .then(result => {
71 if (_.isEmpty(result)) { 71 if (_.isEmpty(result)) {
72 return Promise.rejected('重新发邮件失败'); 72 return Promise.rejected('重新发邮件失败');
73 } 73 }
74 74
75 res.json(result); 75 res.json(result);
76 - }).catch(err => { 76 + })
  77 + .catch(err => {
77 res.json({ 78 res.json({
78 code: 400, 79 code: 400,
79 message: err 80 message: err
@@ -84,7 +85,7 @@ module.exports.resendCodeToEmailAPI = (req, res) => { @@ -84,7 +85,7 @@ module.exports.resendCodeToEmailAPI = (req, res) => {
84 /** 85 /**
85 * 邮箱找回密码-返回成功页面 86 * 邮箱找回密码-返回成功页面
86 */ 87 */
87 -module.exports.backSuccessByEmailPage = (req, res) => { 88 +const backSuccessByEmailPage = (req, res) => {
88 let email = req.query.email || ''; 89 let email = req.query.email || '';
89 90
90 if (!helpers.verifyEmail(email)) { 91 if (!helpers.verifyEmail(email)) {
@@ -92,46 +93,43 @@ module.exports.backSuccessByEmailPage = (req, res) => { @@ -92,46 +93,43 @@ module.exports.backSuccessByEmailPage = (req, res) => {
92 } 93 }
93 94
94 let domain = email.split('@')[1]; 95 let domain = email.split('@')[1];
95 -  
96 let emailUrl = `http://${domain === 'gmail.com' ? 'mail.google.com' : 'mail.'}${domain}`; 96 let emailUrl = `http://${domain === 'gmail.com' ? 'mail.google.com' : 'mail.'}${domain}`;
97 97
98 -  
99 res.render('back/email-success', Object.assign({ 98 res.render('back/email-success', Object.assign({
100 module: 'passport', 99 module: 'passport',
101 page: 'back-email-success', 100 page: 'back-email-success',
102 title: '找回密码-通过邮箱' 101 title: '找回密码-通过邮箱'
103 }, { 102 }, {
104 - backUrl: helpers.urlFormat('/passport/back/email.html'), 103 + backUrl: helpers.urlFormat('/passport/back/email'),
105 headerText: '找回密码', 104 headerText: '找回密码',
106 isPassportPage: true, 105 isPassportPage: true,
107 backEmailSuccess: true, 106 backEmailSuccess: true,
108 goEmail: emailUrl, 107 goEmail: emailUrl,
109 - resendUrl: helpers.urlFormat('/passport/back/resendemail', {email: email}) 108 + resendUrl: helpers.urlFormat('/passport/back/resendemail', { email: email })
110 })); 109 }));
111 }; 110 };
112 111
113 -  
114 /** 112 /**
115 * 根据邮箱修改密码 113 * 根据邮箱修改密码
116 */ 114 */
117 -module.exports.setNewPasswordByEmailAPI = (req, res) => { 115 +const setNewPasswordByEmailAPI = (req, res) => {
118 let pwd = req.body.password || ''; 116 let pwd = req.body.password || '';
119 -  
120 let code = req.body.code || ''; 117 let code = req.body.code || '';
121 -  
122 let data = { 118 let data = {
123 code: 200, 119 code: 200,
124 - data: SIGN_IN_URL 120 + data: SIGN_IN
125 }; 121 };
126 122
127 - service.modifyPasswordByEmailAsync(pwd, code).then(result => { 123 + service.modifyPasswordByEmailAsync(pwd, code)
  124 + .then(result => {
128 if (result.includes('history.back')) { 125 if (result.includes('history.back')) {
129 data.code = 400; 126 data.code = 400;
130 data.message = '修改失败'; 127 data.message = '修改失败';
131 } 128 }
132 129
133 res.json(data); 130 res.json(data);
134 - }).catch(() => { 131 + })
  132 + .catch(() => {
135 res.json(data); 133 res.json(data);
136 }); 134 });
137 }; 135 };
@@ -139,8 +137,7 @@ module.exports.setNewPasswordByEmailAPI = (req, res) => { @@ -139,8 +137,7 @@ module.exports.setNewPasswordByEmailAPI = (req, res) => {
139 /** 137 /**
140 * 找回密码页面-通过手机号 138 * 找回密码页面-通过手机号
141 */ 139 */
142 -module.exports.indexByMobilePage = (req, res, next) => {  
143 - 140 +const indexMobilePage = (req, res, next) => {
144 service.getAreaDataAsync() 141 service.getAreaDataAsync()
145 .then(result => { 142 .then(result => {
146 res.render('back/mobile', Object.assign({ 143 res.render('back/mobile', Object.assign({
@@ -148,63 +145,57 @@ module.exports.indexByMobilePage = (req, res, next) => { @@ -148,63 +145,57 @@ module.exports.indexByMobilePage = (req, res, next) => {
148 page: 'back-mobile', 145 page: 'back-mobile',
149 title: '找回密码-通过手机号' 146 title: '找回密码-通过手机号'
150 }, { 147 }, {
151 - backUrl: SIGN_IN_URL, 148 + backUrl: SIGN_IN,
152 headerText: '找回密码', 149 headerText: '找回密码',
153 isPassportPage: true, 150 isPassportPage: true,
154 backMobile: true, 151 backMobile: true,
155 countrys: result.data, 152 countrys: result.data,
156 areaCode: '+86' 153 areaCode: '+86'
157 })); 154 }));
158 - }).catch(next); 155 + })
  156 + .catch(next);
159 }; 157 };
160 158
161 /** 159 /**
162 * 发送手机验证码 160 * 发送手机验证码
163 */ 161 */
164 -module.exports.sendCodeToMobileAPI = (req, res) => {  
165 - let result = {  
166 - code: 400,  
167 - message: '密码只能使用数字、字母和半角标点符号,请重新输入',  
168 - data: ''  
169 - };  
170 - 162 +const sendCodeToMobileAPI = (req, res, next) => {
171 let phoneNum = req.body.phoneNum || ''; 163 let phoneNum = req.body.phoneNum || '';
172 -  
173 let areaCode = req.body.areaCode || '86'; 164 let areaCode = req.body.areaCode || '86';
  165 + let ERR = {
  166 + code: 400,
  167 + message: '输入手机号码出错'
  168 + };
174 169
175 if (!helpers.verifyMobile(phoneNum)) { 170 if (!helpers.verifyMobile(phoneNum)) {
176 - res.json(result);  
177 - return; 171 + return res.json(ERR);
178 } 172 }
179 173
180 - service.sendCodeToMobileAsync(phoneNum, areaCode).then(data=> {  
181 - if (_.isEmpty(data)) {  
182 - return Promise.rejected('发送验证码出错'); 174 + service.sendCodeToMobileAsync(phoneNum, areaCode)
  175 + .then(result => {
  176 + if (_.isEmpty(result) || result.code !== 200) {
  177 + ERR.message = '发送验证码出错';
  178 + res.json(ERR);
183 } 179 }
184 180
185 - if (data.code === 200) {  
186 - result.data = helpers.urlFormat('/passport/back/verifycode', { 181 + if (result.code === 200) {
  182 + return res.json({
  183 + code: 200,
  184 + data: helpers.urlFormat('/passport/back/mobilecode', {
187 phoneNum: phoneNum, 185 phoneNum: phoneNum,
188 areaCode: areaCode 186 areaCode: areaCode
  187 + })
189 }); 188 });
190 -  
191 - res.json(result);  
192 - } else {  
193 - return Promise.rejected('发送验证码出错');  
194 } 189 }
195 - }).catch(err => {  
196 - result.message = err;  
197 - res.json(result);  
198 - });  
199 - 190 + })
  191 + .catch(next);
200 }; 192 };
201 193
202 /** 194 /**
203 * 校验验证码页面 195 * 校验验证码页面
204 */ 196 */
205 -module.exports.verifyCodeByMobilePage = (req, res) => { 197 +const verifyCodeByMobilePage = (req, res) => {
206 let phoneNum = req.query.phoneNum || ''; 198 let phoneNum = req.query.phoneNum || '';
207 -  
208 let areaCode = req.query.areaCode || '86'; 199 let areaCode = req.query.areaCode || '86';
209 200
210 res.render('back/mobile-code', Object.assign({ 201 res.render('back/mobile-code', Object.assign({
@@ -212,7 +203,7 @@ module.exports.verifyCodeByMobilePage = (req, res) => { @@ -212,7 +203,7 @@ module.exports.verifyCodeByMobilePage = (req, res) => {
212 page: 'back-code', 203 page: 'back-code',
213 title: '找回密码-通过手机号' 204 title: '找回密码-通过手机号'
214 }, { 205 }, {
215 - backUrl: helpers.urlFormat('/passport/back/mobile.html'), 206 + backUrl: helpers.urlFormat('/passport/back/mobile'),
216 headerText: '找回密码', 207 headerText: '找回密码',
217 isPassportPage: true, 208 isPassportPage: true,
218 backCode: true, 209 backCode: true,
@@ -225,40 +216,42 @@ module.exports.verifyCodeByMobilePage = (req, res) => { @@ -225,40 +216,42 @@ module.exports.verifyCodeByMobilePage = (req, res) => {
225 /** 216 /**
226 * 校验手机验证码 217 * 校验手机验证码
227 */ 218 */
228 -module.exports.verifyCodeByMobileAPI = (req, res) => { 219 +const verifyCodeByMobileAPI = (req, res, next) => {
229 let phoneNum = req.body.phoneNum || ''; 220 let phoneNum = req.body.phoneNum || '';
230 -  
231 let code = req.body.code || ''; 221 let code = req.body.code || '';
232 -  
233 let areaCode = req.body.areaCode || '86'; 222 let areaCode = req.body.areaCode || '86';
234 223
235 service.validateMobileCodeAsync(phoneNum, code, areaCode) 224 service.validateMobileCodeAsync(phoneNum, code, areaCode)
236 .then(result => { 225 .then(result => {
237 if (result.code === 200) { 226 if (result.code === 200) {
238 - result.data = helpers.urlFormat('/passport/back/backcode.html', { 227 + res.json({
  228 + code: 200,
  229 + data: helpers.urlFormat('/passport/back/backcode', {
239 phoneNum: phoneNum, 230 phoneNum: phoneNum,
240 token: result.data.token, 231 token: result.data.token,
241 areaCode: areaCode 232 areaCode: areaCode
  233 + })
  234 + });
  235 + } else {
  236 + res.json({
  237 + code: 400,
  238 + message: '验证码失败'
242 }); 239 });
243 } 240 }
244 -  
245 - res.json(result);  
246 - }).catch(() => res.json({code: 400, message: '验证码失败'})); 241 + })
  242 + .catch(next);
247 }; 243 };
248 244
249 /** 245 /**
250 * 找回密码页面,设置新密码页面-手机 246 * 找回密码页面,设置新密码页面-手机
251 */ 247 */
252 -module.exports.setNewPasswordByMobilePage = (req, res) => { 248 +const setNewPasswordByMobilePage = (req, res) => {
253 let phoneNum = req.query.phoneNum || ''; 249 let phoneNum = req.query.phoneNum || '';
254 -  
255 let token = req.query.token || ''; 250 let token = req.query.token || '';
256 -  
257 let areaCode = req.query.areaCode || '86'; 251 let areaCode = req.query.areaCode || '86';
258 -  
259 let code = req.query.code || ''; 252 let code = req.query.code || '';
260 253
261 - if (!token || (!helpers.verifyMobile(phoneNum) && !code)) { 254 + if (!(code || (token && helpers.verifyMobile(phoneNum)))) {
262 res.redirect(400); 255 res.redirect(400);
263 return; 256 return;
264 } 257 }
@@ -268,7 +261,7 @@ module.exports.setNewPasswordByMobilePage = (req, res) => { @@ -268,7 +261,7 @@ module.exports.setNewPasswordByMobilePage = (req, res) => {
268 page: 'back-new-password', 261 page: 'back-new-password',
269 title: '找回密码-输入新密码' 262 title: '找回密码-输入新密码'
270 }, { 263 }, {
271 - backUrl: SIGN_IN_URL, 264 + backUrl: SIGN_IN,
272 headerText: '找回密码', 265 headerText: '找回密码',
273 isPassportPage: true, 266 isPassportPage: true,
274 backNewPwd: true, 267 backNewPwd: true,
@@ -282,21 +275,40 @@ module.exports.setNewPasswordByMobilePage = (req, res) => { @@ -282,21 +275,40 @@ module.exports.setNewPasswordByMobilePage = (req, res) => {
282 /** 275 /**
283 * 根据手机验证码修改密码 276 * 根据手机验证码修改密码
284 */ 277 */
285 -module.exports.setNewPasswordByMobileAPI = (req, res) => { 278 +const setNewPasswordByMobileAPI = (req, res, next) => {
286 let phoneNum = req.body.phoneNum || ''; 279 let phoneNum = req.body.phoneNum || '';
287 -  
288 let token = req.body.token || ''; 280 let token = req.body.token || '';
289 -  
290 let areaCode = req.body.areaCode || '86'; 281 let areaCode = req.body.areaCode || '86';
291 -  
292 let newPwd = req.body.password || ''; 282 let newPwd = req.body.password || '';
293 283
294 service.modifyPasswordByMobileAsync(phoneNum, token, newPwd, areaCode) 284 service.modifyPasswordByMobileAsync(phoneNum, token, newPwd, areaCode)
295 .then(result => { 285 .then(result => {
  286 + console.log(result);
296 if (result.code === 200) { 287 if (result.code === 200) {
297 - result.data = SIGN_IN_URL; 288 + res.json({
  289 + code: 200,
  290 + data: SIGN_IN
  291 + });
  292 + } else {
  293 + res.json({
  294 + code: 400,
  295 + message: '修改密码失败'
  296 + });
298 } 297 }
  298 + })
  299 + .catch(next);
  300 +};
299 301
300 - res.json(result);  
301 - }).catch(() => res.json({code: 400, message: '修改密码失败'})); 302 +module.exports = {
  303 + indexEmailPage,
  304 + sendCodeToEmailAPI,
  305 + resendCodeToEmailAPI,
  306 + backSuccessByEmailPage,
  307 + setNewPasswordByEmailAPI,
  308 + indexMobilePage,
  309 + sendCodeToMobileAPI,
  310 + verifyCodeByMobilePage,
  311 + verifyCodeByMobileAPI,
  312 + setNewPasswordByMobilePage,
  313 + setNewPasswordByMobileAPI
302 }; 314 };
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 7
8 'use strict'; 8 'use strict';
9 9
10 -const helpers = require(global.library + '/helpers'); 10 +const helpers = global.yoho.helpers;
11 const RegService = require('../models/reg-service'); 11 const RegService = require('../models/reg-service');
12 const BindService = require('../models/bind-service'); 12 const BindService = require('../models/bind-service');
13 const AuthHelper = require('../models/auth-helper'); 13 const AuthHelper = require('../models/auth-helper');
@@ -5,14 +5,13 @@ @@ -5,14 +5,13 @@
5 */ 5 */
6 'use strict'; 6 'use strict';
7 7
8 -const library = '../../../library';  
9 const passport = require('passport'); 8 const passport = require('passport');
10 const md5 = require('md5'); 9 const md5 = require('md5');
11 const uuid = require('uuid'); 10 const uuid = require('uuid');
12 -const cookie = require(`${library}/cookie`);  
13 -const helpers = require(`${library}/helpers`);  
14 -const log = require(`${library}/logger`);  
15 -const config = require('../../../config/common'); 11 +const cookie = global.yoho.cookie;
  12 +const helpers = global.yoho.helpers;
  13 +const log = global.yoho.logger;
  14 +const config = global.yoho.config;
16 const AuthHelper = require('../models/auth-helper'); 15 const AuthHelper = require('../models/auth-helper');
17 16
18 const loginPage = `${config.siteUrl}/passport/login/index`; 17 const loginPage = `${config.siteUrl}/passport/login/index`;
@@ -74,7 +73,7 @@ const local = { @@ -74,7 +73,7 @@ const local = {
74 73
75 res.render('login', { 74 res.render('login', {
76 loginIndex: true, // 模板中使用JS的标识 75 loginIndex: true, // 模板中使用JS的标识
77 - backUrl: 'javascript:history.go(-1)', // 返回的URL链接 76 + backUrl: 'javascript:history.go(-1)', // eslint-disable-line // 返回的URL链接
78 showHeaderImg: true, // 控制显示头部图片 77 showHeaderImg: true, // 控制显示头部图片
79 isPassportPage: true, // 模板中模块标识 78 isPassportPage: true, // 模板中模块标识
80 registerUrl: '/reg.html', // 注册的URL链接 79 registerUrl: '/reg.html', // 注册的URL链接
@@ -8,9 +8,9 @@ @@ -8,9 +8,9 @@
8 'use strict'; 8 'use strict';
9 9
10 const _ = require('lodash'); 10 const _ = require('lodash');
11 -const helpers = require(global.library + '/helpers');  
12 -const sign = require(global.library + '/sign');  
13 -const cookie = require(global.library + '/cookie'); 11 +const helpers = global.yoho.helpers;
  12 +const sign = global.yoho.sign;
  13 +const cookie = global.yoho.cookie;
14 const RegService = require('../models/reg-service'); 14 const RegService = require('../models/reg-service');
15 const AuthHelper = require('../models/auth-helper'); 15 const AuthHelper = require('../models/auth-helper');
16 16
@@ -26,7 +26,7 @@ app.engine('.hbs', hbs({ @@ -26,7 +26,7 @@ app.engine('.hbs', hbs({
26 defaultLayout: 'layout', 26 defaultLayout: 'layout',
27 layoutsDir: doraemon, 27 layoutsDir: doraemon,
28 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`], 28 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
29 - helpers: require(`${global.library}/helpers`) 29 + helpers: global.yoho.helpers
30 })); 30 }));
31 31
32 32
1 'use strict'; 1 'use strict';
2 2
3 -const library = '../../../library';  
4 -const API = require(`${library}/api`).API;  
5 -const sign = require(`${library}/sign`);  
6 -const api = new API(); 3 +const sign = global.yoho.sign;
  4 +const api = global.yoho.API;
7 5
8 class Auth { 6 class Auth {
9 7
@@ -19,7 +17,7 @@ class Auth { @@ -19,7 +17,7 @@ class Auth {
19 param.shopping_key = shoppingKey; 17 param.shopping_key = shoppingKey;
20 } 18 }
21 19
22 - return api.post('', sign.apiSign(param)); 20 + return api.post('', param);
23 } 21 }
24 22
25 static signinByOpenID(nickname, openId, sourceType, shoppingKey) { 23 static signinByOpenID(nickname, openId, sourceType, shoppingKey) {
@@ -35,7 +33,7 @@ class Auth { @@ -35,7 +33,7 @@ class Auth {
35 param.shopping_key = shoppingKey; 33 param.shopping_key = shoppingKey;
36 } 34 }
37 35
38 - return api.get('', sign.apiSign(param)); 36 + return api.get('', param);
39 } 37 }
40 38
41 static profile(uid) { 39 static profile(uid) {
@@ -44,7 +42,7 @@ class Auth { @@ -44,7 +42,7 @@ class Auth {
44 method: 'app.passport.profile' 42 method: 'app.passport.profile'
45 }; 43 };
46 44
47 - return api.get('', sign.apiSign(param)); 45 + return api.get('', param);
48 } 46 }
49 47
50 static syncUserSession(uid, req, res) { 48 static syncUserSession(uid, req, res) {
@@ -4,21 +4,18 @@ @@ -4,21 +4,18 @@
4 4
5 'use strict'; 5 'use strict';
6 6
7 -var API = require('../../../library/api').API;  
8 -const library = '../../../library';  
9 -const sign = require(`${library}/sign`);  
10 7
11 -var api = new API(); 8 +const api = global.yoho.API;
12 9
13 const YOHOBUY_URL = 'http://www.yohobuy.com/'; 10 const YOHOBUY_URL = 'http://www.yohobuy.com/';
14 11
15 /** 12 /**
16 * 获取地区数据 13 * 获取地区数据
17 */ 14 */
18 -module.exports.getAreaDataAsync = () => {  
19 - return api.get('', sign.apiSign({ 15 +const getAreaDataAsync = () => {
  16 + return api.get('', {
20 method: 'app.passport.getArea' 17 method: 'app.passport.getArea'
21 - })).then(result => { 18 + }).then(result => {
22 result.data = result.data.map(value => { 19 result.data = result.data.map(value => {
23 value.areaCode = `+${value.area}`; 20 value.areaCode = `+${value.area}`;
24 21
@@ -41,11 +38,11 @@ module.exports.getAreaDataAsync = () => { @@ -41,11 +38,11 @@ module.exports.getAreaDataAsync = () => {
41 * 38 *
42 * @param string mail 邮箱地址 39 * @param string mail 邮箱地址
43 */ 40 */
44 -module.exports.sendCodeToEmailAsync = (email) => {  
45 - return api.get('', sign.apiSign({ 41 +const sendCodeToEmailAsync = (email) => {
  42 + return api.get('', {
46 method: 'app.register.backpwdByEmail', 43 method: 'app.register.backpwdByEmail',
47 email: email 44 email: email
48 - })); 45 + });
49 }; 46 };
50 47
51 /** 48 /**
@@ -54,7 +51,7 @@ module.exports.sendCodeToEmailAsync = (email) => { @@ -54,7 +51,7 @@ module.exports.sendCodeToEmailAsync = (email) => {
54 * @param string pwd 新密码 51 * @param string pwd 新密码
55 * @param string code 邮箱验证码 52 * @param string code 邮箱验证码
56 */ 53 */
57 -module.exports.modifyPasswordByEmailAsync = (pwd, code) => { 54 +const modifyPasswordByEmailAsync = (pwd, code) => {
58 const options = { 55 const options = {
59 url: `${YOHOBUY_URL}passport/back/update`, 56 url: `${YOHOBUY_URL}passport/back/update`,
60 form: { 57 form: {
@@ -74,14 +71,12 @@ module.exports.modifyPasswordByEmailAsync = (pwd, code) => { @@ -74,14 +71,12 @@ module.exports.modifyPasswordByEmailAsync = (pwd, code) => {
74 * @param string mobile 手机号 71 * @param string mobile 手机号
75 * @param integer area 地区码ID 72 * @param integer area 地区码ID
76 */ 73 */
77 -module.exports.sendCodeToMobileAsync = (mobile, area) => {  
78 - area = area || 86;  
79 -  
80 - return api.get('', sign.apiSign({ 74 +const sendCodeToMobileAsync = (mobile, area) => {
  75 + return api.get('', {
81 mobile: mobile, 76 mobile: mobile,
82 area: area, 77 area: area,
83 method: 'app.register.sendBackpwdCodeToMobile' 78 method: 'app.register.sendBackpwdCodeToMobile'
84 - })); 79 + });
85 }; 80 };
86 81
87 /** 82 /**
@@ -91,14 +86,14 @@ module.exports.sendCodeToMobileAsync = (mobile, area) => { @@ -91,14 +86,14 @@ module.exports.sendCodeToMobileAsync = (mobile, area) => {
91 * @param string code 验证码 86 * @param string code 验证码
92 * @param integer area 地区码ID 87 * @param integer area 地区码ID
93 */ 88 */
94 -module.exports.validateMobileCodeAsync = (mobile, code, area) => { 89 +const validateMobileCodeAsync = (mobile, code, area) => {
95 area = area || 86; 90 area = area || 86;
96 - return api.get('', sign.apiSign({ 91 + return api.get('', {
97 mobile: mobile, 92 mobile: mobile,
98 code: code, 93 code: code,
99 area: area, 94 area: area,
100 method: 'app.register.validBackpwdCode' 95 method: 'app.register.validBackpwdCode'
101 - })); 96 + });
102 }; 97 };
103 98
104 /** 99 /**
@@ -108,15 +103,22 @@ module.exports.validateMobileCodeAsync = (mobile, code, area) => { @@ -108,15 +103,22 @@ module.exports.validateMobileCodeAsync = (mobile, code, area) => {
108 * @param string token 验证手机验证码返回的token 103 * @param string token 验证手机验证码返回的token
109 * @param integer area 地区码ID 104 * @param integer area 地区码ID
110 */ 105 */
111 -module.exports.modifyPasswordByMobileAsync = (mobile, token, newpwd, area)=> {  
112 - area = area || 86;  
113 - return api.get('', sign.apiSign({ 106 +const modifyPasswordByMobileAsync = (mobile, token, newpwd, area) => {
  107 + return api.get('', {
114 mobile: mobile, 108 mobile: mobile,
115 token: token, 109 token: token,
116 newpwd: newpwd, 110 newpwd: newpwd,
117 area: area, 111 area: area,
118 method: 'app.register.changepwdByMobileCode' 112 method: 'app.register.changepwdByMobileCode'
119 - })); 113 + });
120 }; 114 };
121 115
  116 +module.exports = {
  117 + getAreaDataAsync,
  118 + sendCodeToEmailAsync,
  119 + modifyPasswordByEmailAsync,
  120 + sendCodeToMobileAsync,
  121 + validateMobileCodeAsync,
  122 + modifyPasswordByMobileAsync
  123 +};
122 124
@@ -7,8 +7,7 @@ @@ -7,8 +7,7 @@
7 7
8 'use strict'; 8 'use strict';
9 9
10 -const API = require(`${global.library}/api`).API;  
11 -const api = new API(); 10 +const api = global.yoho.API;
12 11
13 const RegService = { 12 const RegService = {
14 bindCheck(mobile, openId, sourceType, area) { 13 bindCheck(mobile, openId, sourceType, area) {
@@ -7,8 +7,7 @@ @@ -7,8 +7,7 @@
7 7
8 'use strict'; 8 'use strict';
9 9
10 -const API = require(`${global.library}/api`).API;  
11 -const api = new API(); 10 +const api = global.yoho.API;
12 11
13 const RegService = { 12 const RegService = {
14 getAreaData() { 13 getAreaData() {
@@ -47,7 +46,7 @@ const RegService = { @@ -47,7 +46,7 @@ const RegService = {
47 name: '英国' 46 name: '英国'
48 }, { 47 }, {
49 areaCode: '+86', 48 areaCode: '+86',
50 - selected: true, 49 + selected: true, // default choose
51 name: '中国' 50 name: '中国'
52 }, { 51 }, {
53 areaCode: '+853', 52 areaCode: '+853',
@@ -13,6 +13,7 @@ const back = require(cRoot + '/back'); @@ -13,6 +13,7 @@ const back = require(cRoot + '/back');
13 const bind = require(cRoot + '/bind'); 13 const bind = require(cRoot + '/bind');
14 const reg = require(cRoot + '/reg'); 14 const reg = require(cRoot + '/reg');
15 15
  16 +
16 const router = express.Router(); // eslint-disable-line 17 const router = express.Router(); // eslint-disable-line
17 18
18 // 登出 19 // 登出
@@ -61,44 +62,20 @@ router.get('/reg/password', reg.password); @@ -61,44 +62,20 @@ router.get('/reg/password', reg.password);
61 router.post('/reg/setpassword', reg.setPassword); 62 router.post('/reg/setpassword', reg.setPassword);
62 63
63 /** 64 /**
64 - * 邮箱 65 + * 密码找回
65 */ 66 */
66 -  
67 -// 通过邮箱找回密码  
68 -router.get('/back/email.html', back.indexByEmailPage);  
69 -  
70 -// 邮箱找回密码-成功  
71 -router.get('/back/success.html', back.backSuccessByEmailPage);  
72 -  
73 -// 发送邮箱验证码  
74 -router.post('/back/sendemail', back.sendCodeToEmailAPI);  
75 -  
76 -// 重新发送邮箱验证码  
77 -router.get('/back/resendemail', back.resendCodeToEmailAPI);  
78 -  
79 -// 据邮箱修改密码  
80 -router.post('/back/passwordbyemail', back.setNewPasswordByEmailAPI);  
81 -  
82 -/**  
83 - * 手机  
84 - */  
85 -  
86 -// 通过手机找回密码  
87 -router.get('/back/mobile.html', back.indexByMobilePage);  
88 -  
89 -// 发送手机验证码  
90 -router.get('/back/mobilecode.html', back.verifyCodeByMobilePage);  
91 -  
92 -// 输入新密码  
93 -router.get('/back/backcode.html', back.setNewPasswordByMobilePage);  
94 -  
95 -// 发送手机验证码  
96 -router.post('/back/sendcode', back.sendCodeToMobileAPI);  
97 -  
98 -// 校验手机验证码  
99 -router.post('/back/verifycode', back.verifyCodeByMobileAPI);  
100 -  
101 -// 根据手机验证码修改密码  
102 -router.post('/back/passwordbymobile', back.setNewPasswordByMobileAPI); 67 +router.get('/back/email', back.indexEmailPage);// 通过邮箱找回密码页面
  68 +router.post('/back/sendemail', back.sendCodeToEmailAPI);// 发送邮箱验证码
  69 +router.get('/back/resendemail', back.resendCodeToEmailAPI);// 重新发送邮箱验证码
  70 +router.get('/back/success', back.backSuccessByEmailPage);// 邮箱找回密码-发送成功页面
  71 +
  72 +router.get('/back/mobile', back.indexMobilePage);// 输入手机号找回密码页面
  73 +router.get('/back/mobilecode', back.verifyCodeByMobilePage);// 输入手机验证码页面
  74 +router.post('/back/sendcode', back.sendCodeToMobileAPI);// 发送手机验证码
  75 +router.post('/back/verifycode', back.verifyCodeByMobileAPI);// 校验手机验证码
  76 +
  77 +router.get('/back/backcode', back.setNewPasswordByMobilePage);// 设置新密码页面
  78 +router.post('/back/passwordbyemail', back.setNewPasswordByEmailAPI);// 依据邮箱验证码修改密码
  79 +router.post('/back/passwordbymobile', back.setNewPasswordByMobileAPI);// 依据手机验证码修改密码
103 80
104 module.exports = router; 81 module.exports = router;
@@ -24,7 +24,7 @@ app.engine('.hbs', hbs({ @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
24 defaultLayout: 'layout', 24 defaultLayout: 'layout',
25 layoutsDir: doraemon, 25 layoutsDir: doraemon,
26 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`], 26 partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
27 - helpers: require(`${global.library}/helpers`) 27 + helpers: global.yoho.helpers
28 })); 28 }));
29 29
30 // router 30 // router
@@ -6,12 +6,9 @@ @@ -6,12 +6,9 @@
6 6
7 'use strict'; 7 'use strict';
8 8
9 -const library = '../../../library';  
10 -const API = require(`${library}/api`).API; 9 +const api = global.yoho.API;
11 const _ = require('lodash'); 10 const _ = require('lodash');
12 -const helpers = require(`${library}/helpers`);  
13 -  
14 -const api = new API(); 11 +const helpers = global.yoho.helpers;
15 12
16 /** 13 /**
17 * 处理品牌关联店铺信息 14 * 处理品牌关联店铺信息
@@ -7,13 +7,11 @@ @@ -7,13 +7,11 @@
7 7
8 'use strict'; 8 'use strict';
9 9
10 -const library = '../../../library';  
11 -const API = require(`${library}/api`).API;  
12 const _ = require('lodash'); 10 const _ = require('lodash');
13 11
14 // const log = require(`${library}/logger`); 12 // const log = require(`${library}/logger`);
15 13
16 -var api = new API(); 14 +var api = global.yoho.API;
17 15
18 /** 16 /**
19 * 商品尺码信息处理 17 * 商品尺码信息处理
@@ -5,22 +5,17 @@ @@ -5,22 +5,17 @@
5 */ 5 */
6 'use strict'; 6 'use strict';
7 7
8 -const library = '../../../library';  
9 const utils = '../../../utils'; 8 const utils = '../../../utils';
10 const contentCodeConfig = require('../../../config/content-code'); 9 const contentCodeConfig = require('../../../config/content-code');
11 10
12 const _ = require('lodash'); 11 const _ = require('lodash');
13 -const ServiceAPI = require(`${library}/api`).ServiceAPI;  
14 -const API = require(`${library}/api`).API;  
15 -const sign = require(`${library}/sign`);  
16 12
17 -const camelCase = require(`${library}/camel-case`);  
18 -const resourcesProcess = require(`${utils}/resources-process`);  
19 -const log = require(`${library}/logger`);  
20 -  
21 -const serviceApi = new ServiceAPI();  
22 -const api = new API(); 13 +const camelCase = global.yoho.camelCase;
  14 +const log = global.yoho.logger;
  15 +const serviceApi = global.yoho.ServiceAPI;
  16 +const api = global.yoho.API;
23 17
  18 +const resourcesProcess = require(`${utils}/resources-process`);
24 19
25 const dateFormate = (str) =>{ 20 const dateFormate = (str) =>{
26 var time = new Date(str * 1000); 21 var time = new Date(str * 1000);
@@ -61,7 +56,7 @@ const _getOutletResource = (channel, contentcode) => { @@ -61,7 +56,7 @@ const _getOutletResource = (channel, contentcode) => {
61 yh_channel: channel || '' 56 yh_channel: channel || ''
62 }; 57 };
63 58
64 - return serviceApi.get('operations/api/v5/resource/home', sign.apiSign(params)).then(result => { 59 + return serviceApi.get('operations/api/v5/resource/home', params).then(result => {
65 if (result && result.code === 200) { 60 if (result && result.code === 200) {
66 return resourcesProcess(result.data.list); 61 return resourcesProcess(result.data.list);
67 } else { 62 } else {
@@ -102,7 +97,7 @@ const _getNavData = (categoryId) => { @@ -102,7 +97,7 @@ const _getNavData = (categoryId) => {
102 parent_id: categoryId 97 parent_id: categoryId
103 }; 98 };
104 99
105 - return serviceApi.get('operations/api/v6/category/getCategory', sign.apiSign(params)).then(result => { 100 + return serviceApi.get('operations/api/v6/category/getCategory', params).then(result => {
106 if (result && result.code === 200) { 101 if (result && result.code === 200) {
107 let data = _convertNavData(result.data); 102 let data = _convertNavData(result.data);
108 103
@@ -170,7 +165,7 @@ const _getActivityDetail = (id) => { @@ -170,7 +165,7 @@ const _getActivityDetail = (id) => {
170 }; 165 };
171 166
172 167
173 - return api.get('', sign.apiSign(params)).then(res => { 168 + return api.get('', params).then(res => {
174 if (res.code === 200) { 169 if (res.code === 200) {
175 return _convertActicityData(res.data); 170 return _convertActicityData(res.data);
176 } else { 171 } else {
@@ -191,7 +186,7 @@ const _getHomeActivity = (data) => { @@ -191,7 +186,7 @@ const _getHomeActivity = (data) => {
191 platform: 3 // h5平台代号 186 platform: 3 // h5平台代号
192 }; 187 };
193 188
194 - return api.get('', sign.apiSign(_.assign(params, data))).then(res => { 189 + return api.get('', _.assign(params, data)).then(res => {
195 return _convertActicityData(res.data); 190 return _convertActicityData(res.data);
196 }); 191 });
197 }; 192 };
@@ -6,13 +6,10 @@ @@ -6,13 +6,10 @@
6 */ 6 */
7 7
8 'use strict'; 8 'use strict';
9 -  
10 -const library = '../../../library';  
11 -const utils = '../../../utils';  
12 -const API = require(`${library}/api`).API;  
13 const _ = require('lodash'); 9 const _ = require('lodash');
14 -const productProcess = require(`${utils}/product-process`);  
15 -const api = new API(); 10 +const productProcess = require(`${global.utils}/product-process`);
  11 +
  12 +const api = global.yoho.API;
16 13
17 module.exports = (data) => { 14 module.exports = (data) => {
18 let finalResult; 15 let finalResult;
@@ -4,21 +4,17 @@ @@ -4,21 +4,17 @@
4 * @date: 2016/05/17 4 * @date: 2016/05/17
5 */ 5 */
6 'use strict'; 6 'use strict';
7 -const library = '../../../library';  
8 const utils = '../../../utils'; 7 const utils = '../../../utils';
9 const contentCodeConfig = require('../../../config/content-code'); 8 const contentCodeConfig = require('../../../config/content-code');
10 9
11 -const API = require(`${library}/api`).API;  
12 -const ServiceAPI = require(`${library}/api`).ServiceAPI;  
13 -const sign = require(`${library}/sign`);  
14 -const logger = require(`${library}/logger`);  
15 -const camelCase = require(`${library}/camel-case`); 10 +const logger = global.yoho.logger;
  11 +const camelCase = global.yoho.camelCase;
16 const resourcesProcess = require(`${utils}/resources-process`); 12 const resourcesProcess = require(`${utils}/resources-process`);
17 const productProcess = require(`${utils}/product-process`); 13 const productProcess = require(`${utils}/product-process`);
18 const processTime = require(`${utils}/time-process`); 14 const processTime = require(`${utils}/time-process`);
19 const _ = require('lodash'); 15 const _ = require('lodash');
20 -const api = new API();  
21 -const serviceAPI = new ServiceAPI(); 16 +const api = global.yoho.API;
  17 +const serviceAPI = global.yoho.ServiceAPI;
22 18
23 19
24 20
@@ -87,11 +83,11 @@ const _processDiscount = (list, channel) => { @@ -87,11 +83,11 @@ const _processDiscount = (list, channel) => {
87 const _discount = (params) => { 83 const _discount = (params) => {
88 params = params || {}; 84 params = params || {};
89 85
90 - return api.get('', sign.apiSign(Object.assign({ 86 + return api.get('', Object.assign({
91 method: 'app.activity.get', 87 method: 'app.activity.get',
92 sort: 2, 88 sort: 2,
93 plateform: 3 89 plateform: 3
94 - }, params))); 90 + }, params));
95 }; 91 };
96 92
97 /** 93 /**
@@ -160,9 +156,9 @@ const _searchSales = (params) => { @@ -160,9 +156,9 @@ const _searchSales = (params) => {
160 params.order = typeCont[params.type][params.order]; 156 params.order = typeCont[params.type][params.order];
161 } 157 }
162 158
163 - return api.get('', sign.apiSign(Object.assign({ 159 + return api.get('', Object.assign({
164 method: method 160 method: method
165 - }, params)), true); 161 + }, params), true);
166 }; 162 };
167 163
168 /** 164 /**
@@ -177,10 +173,10 @@ const _getUserProfile = (uid) => { @@ -177,10 +173,10 @@ const _getUserProfile = (uid) => {
177 data: {} 173 data: {}
178 }); 174 });
179 } 175 }
180 - return api.get('', sign.apiSign({ 176 + return api.get('', {
181 method: 'app.passport.profile', 177 method: 'app.passport.profile',
182 uid: uid 178 uid: uid
183 - }), true); 179 + }, true);
184 }; 180 };
185 181
186 /** 182 /**
@@ -189,9 +185,9 @@ const _getUserProfile = (uid) => { @@ -189,9 +185,9 @@ const _getUserProfile = (uid) => {
189 * @return {[array]} 185 * @return {[array]}
190 */ 186 */
191 const _getResources = (page, channel) => { 187 const _getResources = (page, channel) => {
192 - return serviceAPI.get('operations/api/v5/resource/get', sign.apiSign({ 188 + return serviceAPI.get('operations/api/v5/resource/get', {
193 content_code: contentCode[channel][page] 189 content_code: contentCode[channel][page]
194 - })).then((result) => { 190 + }).then((result) => {
195 if (result && result.code === 200) { 191 if (result && result.code === 200) {
196 return resourcesProcess(result.data); 192 return resourcesProcess(result.data);
197 } else { 193 } else {
@@ -207,10 +203,10 @@ const _getResources = (page, channel) => { @@ -207,10 +203,10 @@ const _getResources = (page, channel) => {
207 * @return {[object]} 203 * @return {[object]}
208 */ 204 */
209 const _getBreakingSort = (yhChannel) => { 205 const _getBreakingSort = (yhChannel) => {
210 - return api.get('', sign.apiSign({ 206 + return api.get('', {
211 method: 'app.sale.getBreakingSort', 207 method: 'app.sale.getBreakingSort',
212 yh_channel: channelType[yhChannel] || '1' 208 yh_channel: channelType[yhChannel] || '1'
213 - })).then((result) => { 209 + }).then((result) => {
214 if (result && result.code === 200) { 210 if (result && result.code === 200) {
215 return _processBreakingSort(result.data); 211 return _processBreakingSort(result.data);
216 } else { 212 } else {
1 const _ = require('lodash'); 1 const _ = require('lodash');
2 -const cookie = require('../../library/cookie'); 2 +const cookie = global.yoho.cookie;
3 3
4 module.exports = () => { 4 module.exports = () => {
5 return (req, res, next) => { 5 return (req, res, next) => {
@@ -11,8 +11,11 @@ @@ -11,8 +11,11 @@
11 </a> 11 </a>
12 </li> 12 </li>
13 {{/ list}} 13 {{/ list}}
  14 +
14 <li class="more"> 15 <li class="more">
15 - <a href="{{more}}"></a> 16 + <a class="{{#unless image.src}}default{{/unless}}" href="{{image.url}}">
  17 + <img src="{{image image.src 320 172}}">
  18 + </a>
16 </li> 19 </li>
17 </ul> 20 </ul>
18 {{/data}} 21 {{/data}}
1 <div class="icons-wrapper"> 1 <div class="icons-wrapper">
2 <ul class="icons-list clearfix"> 2 <ul class="icons-list clearfix">
3 {{#data}} 3 {{#data}}
4 - <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> 4 + <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>
5 {{/data}} 5 {{/data}}
6 </ul> 6 </ul>
7 </div> 7 </div>
@@ -55,6 +55,7 @@ @@ -55,6 +55,7 @@
55 "serve-favicon": "^2.3.0", 55 "serve-favicon": "^2.3.0",
56 "uuid": "^2.0.2", 56 "uuid": "^2.0.2",
57 "winston": "^2.2.0", 57 "winston": "^2.2.0",
  58 + "yoho-node-lib": "0.0.5",
58 "winston-daily-rotate-file": "^1.1.4" 59 "winston-daily-rotate-file": "^1.1.4"
59 }, 60 },
60 "devDependencies": { 61 "devDependencies": {
@@ -49,7 +49,7 @@ $btnOk.on('touchstart', function() { @@ -49,7 +49,7 @@ $btnOk.on('touchstart', function() {
49 if (mobileBack) { 49 if (mobileBack) {
50 $.extend(setting, { 50 $.extend(setting, {
51 phoneNum: $phoneNum.val(), 51 phoneNum: $phoneNum.val(),
52 - areaCode: $('#areaCode').val(), 52 + areaCode: $('#area-code').val(),
53 token: $('#token').val() 53 token: $('#token').val()
54 }); 54 });
55 55
@@ -20,7 +20,7 @@ var tip = require('../../plugin/tip'); @@ -20,7 +20,7 @@ var tip = require('../../plugin/tip');
20 var trim = $.trim; 20 var trim = $.trim;
21 var showErrTip = tip.show; 21 var showErrTip = tip.show;
22 22
23 -//登录按钮状态切换 23 +// 登录按钮状态切换
24 function switchLoginBtnStatus() { 24 function switchLoginBtnStatus() {
25 if (pnPass && pwdPass) { 25 if (pnPass && pwdPass) {
26 $loginBtn.removeClass('disable'); 26 $loginBtn.removeClass('disable');
@@ -29,13 +29,13 @@ function switchLoginBtnStatus() { @@ -29,13 +29,13 @@ function switchLoginBtnStatus() {
29 } 29 }
30 } 30 }
31 31
32 -//Android-UC下显示select的direction:rtl无效的临时解决办法 32 +// Android-UC下显示select的direction:rtl无效的临时解决办法
33 api.selectCssHack($countrySelect); 33 api.selectCssHack($countrySelect);
34 34
35 -//显示隐藏密码 35 +// 显示隐藏密码
36 api.bindEyesEvt(); 36 api.bindEyesEvt();
37 37
38 -//清空手机号码 38 +// 清空手机号码
39 api.bindClearEvt(); 39 api.bindClearEvt();
40 40
41 $phoneNum.bind('input', function() { 41 $phoneNum.bind('input', function() {
@@ -98,14 +98,14 @@ $loginBtn.on('touchstart', function() { @@ -98,14 +98,14 @@ $loginBtn.on('touchstart', function() {
98 success: function() { 98 success: function() {
99 clearTimeout(time); 99 clearTimeout(time);
100 100
101 - //Cookie写入成功后,1s后跳转页面 101 + // Cookie写入成功后,1s后跳转页面
102 setTimeout(function() { 102 setTimeout(function() {
103 location.href = res.href; 103 location.href = res.href;
104 }, 1000); 104 }, 1000);
105 } 105 }
106 }); 106 });
107 107
108 - //3秒后强制跳转 108 + // 3秒后强制跳转
109 time = setTimeout(function() { 109 time = setTimeout(function() {
110 location.href = res.href; 110 location.href = res.href;
111 }, 3000); 111 }, 3000);
@@ -128,6 +128,6 @@ $loginBtn.on('touchstart', function() { @@ -128,6 +128,6 @@ $loginBtn.on('touchstart', function() {
128 } 128 }
129 }); 129 });
130 130
131 -//对初始有默认值的情况去初始化登录按钮状态 131 +// 对初始有默认值的情况去初始化登录按钮状态
132 $phoneNum.trigger('input'); 132 $phoneNum.trigger('input');
133 $pwd.trigger('input'); 133 $pwd.trigger('input');
@@ -21,7 +21,7 @@ var tip = require('../../plugin/tip'); @@ -21,7 +21,7 @@ var tip = require('../../plugin/tip');
21 var trim = $.trim; 21 var trim = $.trim;
22 var showErrTip = tip.show; 22 var showErrTip = tip.show;
23 23
24 -//登录按钮状态切换 24 +// 登录按钮状态切换
25 function switchLoginBtnStatus() { 25 function switchLoginBtnStatus() {
26 if (accPass && pwdPass) { 26 if (accPass && pwdPass) {
27 $loginBtn.removeClass('disable'); 27 $loginBtn.removeClass('disable');
@@ -30,22 +30,22 @@ function switchLoginBtnStatus() { @@ -30,22 +30,22 @@ function switchLoginBtnStatus() {
30 } 30 }
31 } 31 }
32 32
33 -//显示找回密码面板 33 +// 显示找回密码面板
34 function showRetrivePanel() { 34 function showRetrivePanel() {
35 $mask.show(); 35 $mask.show();
36 $ways.show(); 36 $ways.show();
37 } 37 }
38 38
39 -//隐藏找回密码面板 39 +// 隐藏找回密码面板
40 function hideRetrivePanel() { 40 function hideRetrivePanel() {
41 $mask.hide(); 41 $mask.hide();
42 $ways.hide(); 42 $ways.hide();
43 } 43 }
44 44
45 -//密码显示与隐藏 45 +// 密码显示与隐藏
46 api.bindEyesEvt(); 46 api.bindEyesEvt();
47 47
48 -//清空账号输入框 48 +// 清空账号输入框
49 api.bindClearEvt(); 49 api.bindClearEvt();
50 50
51 $account.bind('input', function() { 51 $account.bind('input', function() {
@@ -78,7 +78,7 @@ $loginBtn.on('touchstart', function() { @@ -78,7 +78,7 @@ $loginBtn.on('touchstart', function() {
78 78
79 $loginBtn.text('正在登录...').addClass('disable'); 79 $loginBtn.text('正在登录...').addClass('disable');
80 80
81 - //验证账号(数字或者邮箱)和密码合理性 81 + // 验证账号(数字或者邮箱)和密码合理性
82 if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) { 82 if ((/^[0-9]+$/.test(acc) || api.emailRegx.test(acc)) && api.pwdValidate(pwd)) {
83 $.ajax({ 83 $.ajax({
84 type: 'POST', 84 type: 'POST',
@@ -126,6 +126,6 @@ $('#cancel-retrive').on('touchstart', function(e) { @@ -126,6 +126,6 @@ $('#cancel-retrive').on('touchstart', function(e) {
126 hideRetrivePanel(); 126 hideRetrivePanel();
127 }); 127 });
128 128
129 -//对初始有默认值的情况去初始化登录按钮状态 129 +// 对初始有默认值的情况去初始化登录按钮状态
130 $account.trigger('input'); 130 $account.trigger('input');
131 $pwd.trigger('input'); 131 $pwd.trigger('input');
@@ -69,15 +69,19 @@ @@ -69,15 +69,19 @@
69 width: 317px; 69 width: 317px;
70 height: 174px; 70 height: 174px;
71 border-top: 1px solid #e0e0e0; 71 border-top: 1px solid #e0e0e0;
  72 + overflow: hidden;
72 73
73 a { 74 a {
74 display: block; 75 display: block;
75 width: 100%; 76 width: 100%;
76 height: 100%; 77 height: 100%;
  78 +
  79 + &.default {
77 background: resolve("channel/more-brand.png") no-repeat; 80 background: resolve("channel/more-brand.png") no-repeat;
78 background-size: 100% 100%; 81 background-size: 100% 100%;
79 } 82 }
80 } 83 }
  84 + }
81 } 85 }
82 86
83 .brands-swiper { 87 .brands-swiper {
@@ -3,17 +3,20 @@ @@ -3,17 +3,20 @@
3 padding: 30px 0 16px; 3 padding: 30px 0 16px;
4 background: #fff; 4 background: #fff;
5 border-bottom: 1px solid #e0e0e0; 5 border-bottom: 1px solid #e0e0e0;
6 -}  
7 6
8 -.icons-item { 7 + .icons-item {
9 float: left; 8 float: left;
10 margin-bottom: 10px; 9 margin-bottom: 10px;
11 - width: 25%; 10 + width: 20%;
12 height: 146px; 11 height: 146px;
13 text-align: center; 12 text-align: center;
14 -}  
15 13
16 -.imagebar { 14 + &.item-8 {
  15 + width: 25%;
  16 + }
  17 + }
  18 +
  19 + .imagebar {
17 display: block; 20 display: block;
18 margin: 0 auto; 21 margin: 0 auto;
19 text-align: center; 22 text-align: center;
@@ -27,9 +30,9 @@ @@ -27,9 +30,9 @@
27 width: 100%; 30 width: 100%;
28 height: 100%; 31 height: 100%;
29 } 32 }
30 -} 33 + }
31 34
32 -.linkbar { 35 + .linkbar {
33 display: block; 36 display: block;
34 line-height: 44px; 37 line-height: 44px;
35 font-size: 24px; 38 font-size: 24px;
@@ -41,4 +44,5 @@ @@ -41,4 +44,5 @@
41 &:hover { 44 &:hover {
42 color: #444; 45 color: #444;
43 } 46 }
  47 + }
44 } 48 }
1 'use strict'; 1 'use strict';
2 const _ = require('lodash'); 2 const _ = require('lodash');
3 -const camelCase = require('../library/camel-case');  
4 -const helpers = require('../library/helpers'); 3 +const camelCase = global.yoho.camelCase;
  4 +const helpers = global.yoho.helpers;
5 5
6 /** 6 /**
7 * 根据性别来决定 默认图片获取字段 如果是 2、3 7 * 根据性别来决定 默认图片获取字段 如果是 2、3
1 const _ = require('lodash'); 1 const _ = require('lodash');
2 -const camelCase = require('../library/camel-case'); 2 +const camelCase = global.yoho.camelCase;
3 3
4 /** 4 /**
5 * 处理楼层数据 5 * 处理楼层数据
@@ -4,8 +4,7 @@ @@ -4,8 +4,7 @@
4 4
5 'use strict'; 5 'use strict';
6 6
7 -const library = '../library';  
8 -const helpers = require(`${library}/helpers`); 7 +const helpers = global.yoho.helpers;
9 8
10 const timeFormat = { 9 const timeFormat = {
11 d: '剩{d}天', 10 d: '剩{d}天',