Authored by 王水玲

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

  1 +/**
  2 + * 支付成功页
  3 + * @author: jing.li<jing.li@yoho.cn>
  4 + * @date: 2016/10/25
  5 + */
  6 +
  7 +'use strict';
  8 +
  9 +const mRoot = '../models';
  10 +const payModel = require(`${mRoot}/pay`);
  11 +const headerModel = require('../../../doraemon/models/header'); // 头部model
  12 +
  13 +// 货到付款
  14 +const payCod = (req, res, next) => {
  15 + let headerData = headerModel.setNav({
  16 + navTitle: '支付完成'
  17 + });
  18 +
  19 + let responseData = {
  20 + pageHeader: headerData,
  21 + module: 'cart',
  22 + page: 'pay',
  23 + title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停'
  24 + };
  25 +
  26 + let param = {
  27 + uid: req.user.uid,
  28 + udid: req.sessionID || require('md5')(req.ip) || 'yoho',
  29 + orderCode: req.query.order_code,
  30 + contentCode: '05afedf76886d732573f10f7451a1703'
  31 + };
  32 +
  33 + // 如果没有uid,跳转到首页
  34 + if (!param.uid) {
  35 + res.redirect('/');
  36 + return;
  37 + }
  38 +
  39 + payModel.getPayCod(param).then(result => {
  40 + if (result.match === true) {
  41 + res.render('pay/pay-cod', Object.assign(responseData, result));
  42 + } else {
  43 + res.redirect('/');
  44 + }
  45 +
  46 + }).catch(next);
  47 +};
  48 +
  49 +// 支付宝支付
  50 +const payAli = (req, res, next) => {
  51 + let headerData = headerModel.setNav({
  52 + navTitle: '支付完成'
  53 + });
  54 +
  55 + let responseData = {
  56 + pageHeader: headerData,
  57 + module: 'cart',
  58 + page: 'pay',
  59 + title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停'
  60 + };
  61 +
  62 + let param = {
  63 + uid: req.user.uid,
  64 + udid: req.sessionID || require('md5')(req.ip) || 'yoho',
  65 + orderCode: req.query.out_trade_no,
  66 + contentCode: '05afedf76886d732573f10f7451a1703'
  67 + };
  68 +
  69 + // 如果没有uid,跳转到首页
  70 + if (!param.uid) {
  71 + res.redirect('/');
  72 + return;
  73 + }
  74 +
  75 + payModel.getPayAli(param).then(result => {
  76 + if (result.match === true) {
  77 + res.render('pay/pay-ali', Object.assign(responseData, result));
  78 + } else {
  79 + res.redirect('/');
  80 + }
  81 +
  82 + }).catch(next);
  83 +};
  84 +
  85 +module.exports = {
  86 + payCod,
  87 + payAli
  88 +};
1 /** 1 /**
  2 +<<<<<<< HEAD
2 * sub app cart 3 * sub app cart
3 * @author: xuan.chen@yoho.cn<xuan.chen@yoho.cn> 4 * @author: xuan.chen@yoho.cn<xuan.chen@yoho.cn>
4 * @date: 2016/09/26 5 * @date: 2016/09/26
  6 +=======
  7 + * sub app guang
  8 + * @author: Bi Kai<kai.bi@yoho.cn>
  9 + * @date: 2016/05/09
  10 +>>>>>>> feature/payment
5 */ 11 */
6 12
7 var express = require('express'), 13 var express = require('express'),
  1 +/**
  2 + * 支付成功页
  3 + * @author: jing.li<jing.li@yoho.cn>
  4 + * @date: 2016/10/25
  5 + */
  6 +
  7 +'use strict';
  8 +
  9 +const api = global.yoho.API;
  10 +const serviceAPI = global.yoho.ServiceAPI;
  11 +const utils = '../../../utils';
  12 +const productProcess = require(`${utils}/product-process`);
  13 +
  14 +// 资源位
  15 +const _getBanner = (param) => {
  16 + return serviceAPI.get('operations/api/v5/resource/get', {
  17 + content_code: param.contentCode
  18 + }, {
  19 + code: 200
  20 + }).then((result) => {
  21 +
  22 + result = result.data;
  23 +
  24 + return result;
  25 + });
  26 +};
  27 +
  28 +// 购买此商品的用户也购买了
  29 +const _getOthersBuy2 = (param) => {
  30 + return api.get('', {
  31 + method: 'app.recommend.purchased',
  32 + productSkn: param.skn,
  33 + udid: param.uid,
  34 + rec_pos: '100005',
  35 + limit: 2
  36 + }, {
  37 + code: 200
  38 + }).then((result) => {
  39 +
  40 + if (result && result.data && result.data.product_list) {
  41 + return productProcess.processProductList(result.data.product_list);
  42 + }
  43 +
  44 + });
  45 +};
  46 +
  47 +// 订单信息
  48 +const _getOtherDetail = (param) => {
  49 + return api.get('', {
  50 + method: 'app.SpaceOrders.detail',
  51 + uid: param.uid,
  52 + order_code: param.orderCode
  53 + }, {
  54 + code: 200
  55 + }).then((result) => {
  56 +
  57 + return result;
  58 +
  59 + });
  60 +};
  61 +
  62 +// 购买此商品的用户也购买了,要先从订单详情获取商品skn
  63 +const _getOthersBuy = (param) => {
  64 + return api.all([
  65 + _getOtherDetail(param)
  66 + ]).then((result) => {
  67 +
  68 + let goodSkn = '';
  69 +
  70 + if (result && result[0] && result[0].data && result[0].data.order_goods) {
  71 + goodSkn = result[0].data.order_goods[0].product_skn;
  72 + }
  73 +
  74 + return _getOthersBuy2(Object.assign(param, {skn: goodSkn}));
  75 +
  76 + }).then((result) => {
  77 +
  78 + return result;
  79 + });
  80 +};
  81 +
  82 +// 货到付款
  83 +const getPayCod = (param) => {
  84 + return api.all([
  85 + _getBanner(param),
  86 + _getOthersBuy(param),
  87 + _getOtherDetail(param)
  88 + ]).then((result) => {
  89 +
  90 + let resu = {
  91 + match: true,
  92 + banner: [],
  93 + othersBuy: []
  94 + };
  95 +
  96 + if (result && result[0]) {
  97 + resu.banner = result[0];
  98 + }
  99 +
  100 + if (result && result[1]) {
  101 + resu.othersBuy = result[1];
  102 + }
  103 +
  104 + if (result && result[2] && result[2].data && result[2].data.payment_amount) {
  105 + resu.payment = result[2].data.payment_amount;
  106 + } else {
  107 + resu.match = false;
  108 + }
  109 +
  110 + resu.orderCode = param.orderCode;
  111 +
  112 + resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode;
  113 +
  114 + return resu;
  115 + });
  116 +};
  117 +
  118 +// 支付宝支付
  119 +const getPayAli = (param) => {
  120 + return api.all([
  121 + _getBanner(param),
  122 + _getOthersBuy(param),
  123 + _getOtherDetail(param)
  124 + ]).then((result) => {
  125 +
  126 + let resu = {
  127 + match: true,
  128 + banner: [],
  129 + othersBuy: []
  130 + };
  131 +
  132 + if (result && result[0]) {
  133 + resu.banner = result[0];
  134 + }
  135 +
  136 + if (result && result[1]) {
  137 + resu.othersBuy = result[1];
  138 + }
  139 +
  140 + if (result && result[2] && result[2].data && result[2].data.payment_amount) {
  141 + resu.payment = result[2].data.payment_amount;
  142 + } else {
  143 + resu.match = false;
  144 + }
  145 +
  146 + resu.orderCode = param.orderCode;
  147 +
  148 + resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode;
  149 +
  150 + return resu;
  151 + });
  152 +};
  153 +
  154 +module.exports = {
  155 + getPayCod,
  156 + getPayAli
  157 +};
@@ -12,6 +12,7 @@ const authMW = require('../../doraemon/middleware/auth'); @@ -12,6 +12,7 @@ const authMW = require('../../doraemon/middleware/auth');
12 12
13 const seckill = require(cRoot + '/seckill'); 13 const seckill = require(cRoot + '/seckill');
14 const countController = require(`${cRoot}/count`); 14 const countController = require(`${cRoot}/count`);
  15 +const payController = require(`${cRoot}/pay`);
15 16
16 // Your controller here 17 // Your controller here
17 router.all('/index/seckill/', authMW); 18 router.all('/index/seckill/', authMW);
@@ -21,5 +22,7 @@ router.post('/index/seckill/compute', seckill.compute); @@ -21,5 +22,7 @@ router.post('/index/seckill/compute', seckill.compute);
21 router.post('/index/seckill/submit', seckill.submit); 22 router.post('/index/seckill/submit', seckill.submit);
22 23
23 router.get('/index/count', countController.cartCount); 24 router.get('/index/count', countController.cartCount);
  25 +router.get('/paySuccess/payCod', payController.payCod);// 支付成功,货到付款
  26 +router.get('/shopping/pay/aliwapreturn', payController.payAli);// 支付成功,支付宝付款
24 27
25 module.exports = router; 28 module.exports = router;
  1 +<div class="pay-success">
  2 + <div class="top-tip">
  3 + <div class="img-c"></div>
  4 + <p class="ok-tip">恭喜您,付款成功!</p>
  5 + </div>
  6 + <div class="info-table-c">
  7 + <table class="info-table">
  8 + <tr>
  9 + <td>订单编号</td>
  10 + <td>{{orderCode}}</td>
  11 + </tr>
  12 + <tr>
  13 + <td>付款金额</td>
  14 + <td>¥{{payment}}</td>
  15 + </tr>
  16 + <tr>
  17 + <td>付款方式</td>
  18 + <td>支付宝</td>
  19 + </tr>
  20 + </table>
  21 + </div>
  22 + <div class="btn-c">
  23 + <a href="/">随便逛逛</a>
  24 + <a href="{{orderUrl}}">查看订单</a>
  25 + </div>
  26 + {{# banner}}
  27 + {{#data}}
  28 + <a href="{{url}}" class="ad-pic" alt="{{alt}}">
  29 + <img src="{{image src 640 200}}" />
  30 + </a>
  31 + {{/data}}
  32 + {{/banner}}
  33 + <div class="others-buy clearfix">
  34 + <p>购买此商品的用户也购买了</p>
  35 + {{# othersBuy}}
  36 + {{> common/goods}}
  37 + {{/ othersBuy}}
  38 + </div>
  39 + {{> home/maybe-like}}
  40 +</div>
  41 +
  1 +<div class="pay-success">
  2 + <div class="top-tip">
  3 + <div class="img-c"></div>
  4 + <p class="ok-tip">订单提交成功</p>
  5 + <p class="left-tip">您需要在收货时向售货员支付¥{{payment}}</p>
  6 + </div>
  7 + <div class="info-table-c">
  8 + <table class="info-table">
  9 + <tr>
  10 + <td>订单编号</td>
  11 + <td>{{orderCode}}</td>
  12 + </tr>
  13 + <tr>
  14 + <td>付款金额</td>
  15 + <td>¥{{payment}}</td>
  16 + </tr>
  17 + <tr>
  18 + <td>付款方式</td>
  19 + <td>货到付款</td>
  20 + </tr>
  21 + </table>
  22 + </div>
  23 + <div class="btn-c">
  24 + <a href="/">随便逛逛</a>
  25 + <a href="{{orderUrl}}">查看订单</a>
  26 + </div>
  27 + {{# banner}}
  28 + {{#data}}
  29 + <a href="{{url}}" class="ad-pic" alt="{{alt}}">
  30 + <img src="{{image src 640 200}}" />
  31 + </a>
  32 + {{/data}}
  33 + {{/banner}}
  34 + <div class="others-buy clearfix">
  35 + <p>购买此商品的用户也购买了</p>
  36 + {{# othersBuy}}
  37 + {{> common/goods}}
  38 + {{/ othersBuy}}
  39 + </div>
  40 + {{> home/maybe-like}}
  41 +</div>
  42 +
@@ -130,6 +130,12 @@ let verifyMobile = (req, res, next) => { @@ -130,6 +130,12 @@ let verifyMobile = (req, res, next) => {
130 let token = sign.makeToken(mobile); 130 let token = sign.makeToken(mobile);
131 131
132 _.set(req.session, 'phoneReg.step', 2); // go step 2 132 _.set(req.session, 'phoneReg.step', 2); // go step 2
  133 + --req.session.phoneReg.count;
  134 +
  135 + // count is 0, will freeze;
  136 + if (!req.session.phoneReg.count) {
  137 + _.set(req.session, 'phoneReg.expire', Date.now() + 5 * 60 * 1000);
  138 + }
133 139
134 result.data = helpers.urlFormat('/passport/reg/code', { 140 result.data = helpers.urlFormat('/passport/reg/code', {
135 token: token, 141 token: token,
@@ -194,7 +200,7 @@ let sendCodeBusyBoy = (req, res, next) => { @@ -194,7 +200,7 @@ let sendCodeBusyBoy = (req, res, next) => {
194 } else { 200 } else {
195 return res.json({ 201 return res.json({
196 code: 400, 202 code: 400,
197 - message: '错误次数太多, 5分钟稍后再试' 203 + message: '发送次数太多, 5分钟稍后再试'
198 }); 204 });
199 } 205 }
200 206
@@ -242,6 +248,7 @@ let sendCode = (req, res, next) => { @@ -242,6 +248,7 @@ let sendCode = (req, res, next) => {
242 } 248 }
243 }).catch(next); 249 }).catch(next);
244 }; 250 };
  251 +
245 let verifyCode = (req, res, next) => { 252 let verifyCode = (req, res, next) => {
246 let data = { 253 let data = {
247 code: 400, 254 code: 400,
@@ -298,20 +305,19 @@ let verifyCode = (req, res, next) => { @@ -298,20 +305,19 @@ let verifyCode = (req, res, next) => {
298 /** 305 /**
299 * Step3: set Password 306 * Step3: set Password
300 */ 307 */
301 -  
302 -let passwordAction = (req, res) => { 308 +let passwordAction = (req, res, next) => {
303 let token = req.query.token; 309 let token = req.query.token;
304 let mobile = +req.query.phoneNum; 310 let mobile = +req.query.phoneNum;
305 let area = +(req.query.areaCode || 86); 311 let area = +(req.query.areaCode || 86);
306 let smsCode = +req.query.smsCode; 312 let smsCode = +req.query.smsCode;
307 313
308 // 判断是否允许访问, 不允许则跳转到错误页面 314 // 判断是否允许访问, 不允许则跳转到错误页面
309 - // if (!smsCode || !_.isString(token) || !_.isNumber(mobile) || !_.isNumber(area) || !sign.verifyToken(mobile, token)) {  
310 - // return next({  
311 - // code: 403,  
312 - // message: 'error token, mobile or verifyCode'  
313 - // });  
314 - // } 315 + if (!smsCode || !_.isString(token) || !_.isNumber(mobile) || !_.isNumber(area) || !sign.verifyToken(mobile, token)) {
  316 + return next({
  317 + code: 403,
  318 + message: 'error token, mobile or verifyCode'
  319 + });
  320 + }
315 321
316 res.render('reg/password', { 322 res.render('reg/password', {
317 page: 'password', 323 page: 'password',
1 /* eslint no-unused-vars: ["error", { "args": "none" }] */ 1 /* eslint no-unused-vars: ["error", { "args": "none" }] */
2 'use strict'; 2 'use strict';
  3 +const _ = require('lodash');
3 const helpers = global.yoho.helpers; 4 const helpers = global.yoho.helpers;
4 const cookie = global.yoho.cookie; 5 const cookie = global.yoho.cookie;
5 const RegService = require('../models/reg-service'); 6 const RegService = require('../models/reg-service');
6 const PhoneService = require('../models/phone-service'); 7 const PhoneService = require('../models/phone-service');
7 const AuthHelper = require('../models/auth-helper'); 8 const AuthHelper = require('../models/auth-helper');
  9 +const captchaService = require('../models/captcha-service');
8 10
9 // constrant 11 // constrant
10 const CODE_REQUIRED = '请输入校验码'; 12 const CODE_REQUIRED = '请输入校验码';
@@ -23,7 +25,7 @@ exports.beforeIn = (req, res, next) => { @@ -23,7 +25,7 @@ exports.beforeIn = (req, res, next) => {
23 }); 25 });
24 26
25 if (!req.xhr && req.user.uid) { 27 if (!req.xhr && req.user.uid) {
26 - return res.redirect(req.cookies.refer); 28 + return res.redirect(req.cookies.refer || '/');
27 } 29 }
28 30
29 next(); 31 next();
@@ -31,6 +33,12 @@ exports.beforeIn = (req, res, next) => { @@ -31,6 +33,12 @@ exports.beforeIn = (req, res, next) => {
31 33
32 // 短信登录 第一步: 展现页面 34 // 短信登录 第一步: 展现页面
33 const _step1 = (req, res, next) => { 35 const _step1 = (req, res, next) => {
  36 + _.set(req.session, 'smsLogin.step', 1);
  37 +
  38 + if (req.session.smsLogin.count == null) { // eslint-disable-line
  39 + req.session.smsLogin.count = 5;
  40 + }
  41 +
34 let template = 'sms/login'; 42 let template = 'sms/login';
35 let viewData = { 43 let viewData = {
36 module: 'passport', 44 module: 'passport',
@@ -38,6 +46,7 @@ const _step1 = (req, res, next) => { @@ -38,6 +46,7 @@ const _step1 = (req, res, next) => {
38 title: '手机短信登录', 46 title: '手机短信登录',
39 isPassportPage: true, 47 isPassportPage: true,
40 headerText: '手机号码快捷登录', 48 headerText: '手机号码快捷登录',
  49 + captchaUrl: helpers.urlFormat('/passport/sms_login/captcha.png', {t: Date.now()}),
41 areaCode: '+86', // 默认的区号 50 areaCode: '+86', // 默认的区号
42 countrys: RegService.getAreaData() // 地区信息列表 51 countrys: RegService.getAreaData() // 地区信息列表
43 }; 52 };
@@ -58,7 +67,7 @@ const _step2 = (req, res, next) => { @@ -58,7 +67,7 @@ const _step2 = (req, res, next) => {
58 title: '手机短信登录', 67 title: '手机短信登录',
59 isPassportPage: true, 68 isPassportPage: true,
60 headerText: '手机号码快捷登录', 69 headerText: '手机号码快捷登录',
61 - canResend: interval < Date.now(), 70 + countdown: Math.ceil((interval - Date.now()) / 1000),
62 mobile, 71 mobile,
63 area 72 area
64 }; 73 };
@@ -83,7 +92,7 @@ const _step3 = (req, res, next) => { @@ -83,7 +92,7 @@ const _step3 = (req, res, next) => {
83 // 短信 登录 92 // 短信 登录
84 exports.loginPage = (req, res, next) => { 93 exports.loginPage = (req, res, next) => {
85 let step = Number(req.query.step) || 1; 94 let step = Number(req.query.step) || 1;
86 - let smsLoginStep = req.session.smsLoginStep || 1; 95 + let smsLoginStep = _.get(req.session, 'smsLogin.step', 1);
87 96
88 if (step === 2 && smsLoginStep !== 2) { 97 if (step === 2 && smsLoginStep !== 2) {
89 return res.redirect(req.path); 98 return res.redirect(req.path);
@@ -109,23 +118,54 @@ exports.loginPage = (req, res, next) => { @@ -109,23 +118,54 @@ exports.loginPage = (req, res, next) => {
109 exports.tokenBefore = (req, res, next) => { 118 exports.tokenBefore = (req, res, next) => {
110 let area = req.query.area = (req.query.area || '').trim(); 119 let area = req.query.area = (req.query.area || '').trim();
111 let mobile = req.query.mobile = (req.query.mobile || '').trim(); 120 let mobile = req.query.mobile = (req.query.mobile || '').trim();
  121 + let step = _.get(req.session, 'smsLogin.step');
  122 + let count = _.get(req.session, 'smsLogin.count');
  123 + let interval = _.get(req.session, 'smsLogin.interval');
112 124
113 - if (!req.xhr) { 125 + if (!req.xhr && !req.session.smsLogin) {
114 return next(404); 126 return next(404);
115 } 127 }
116 128
117 - if (req.session.smsLogin && req.session.smsLogin.interval > Date.now()) { 129 + if ([area, mobile].some(val => val === '')) {
118 return res.json({ 130 return res.json({
119 - code: 429,  
120 - message: TOO_MANY 131 + code: 401,
  132 + message: '请求参数,无法处理'
121 }); 133 });
122 } 134 }
123 135
  136 + // step1 要 校验图形验证码
  137 + if (step === 1) {
  138 + let captcha1 = _.get(req.session, 'smsLogin.captcha');
  139 + let captcha2 = (req.query.captcha || '').trim();
124 140
125 - if ([area, mobile].some(val => val === '')) { 141 + if (captcha1 !== captcha2) {
  142 + return res.json({
  143 + code: 400,
  144 + message: VERIFY_ERROR
  145 + });
  146 + }
  147 + }
  148 +
  149 + let now = Date.now();
  150 +
  151 + // 重发次数用完了, 回冻结5min
  152 + // 1. 过了冻结期, count 重设为 5次
  153 + // 2. 没过冻结期, end
  154 + // 没有用完, 判断是否请求太频繁
  155 + if (!count) {
  156 + if (interval > now) {
  157 + return res.json({
  158 + code: 400,
  159 + message: TOO_MANY,
  160 + during: Math.ceil((interval - now) / 1000)
  161 + });
  162 + } else {
  163 + _.set(req.session, 'smsLogin.count', 5);
  164 + }
  165 + } else if (interval > now) {
126 return res.json({ 166 return res.json({
127 - code: 401,  
128 - message: '请求参数,无法处理' 167 + code: 429,
  168 + message: TOO_MANY
129 }); 169 });
130 } 170 }
131 171
@@ -139,12 +179,18 @@ exports.token = (req, res, next) => { @@ -139,12 +179,18 @@ exports.token = (req, res, next) => {
139 179
140 PhoneService.sendSMS(mobile, area, 1).then(result => { 180 PhoneService.sendSMS(mobile, area, 1).then(result => {
141 if (result.code === 200) { 181 if (result.code === 200) {
142 - req.session.smsLogin = {  
143 - interval: Date.now() + 60 * 1000, // 重发验证码 间隔: 60s  
144 - area,  
145 - mobile  
146 - };  
147 - req.session.smsLoginStep = 2; // 进入短信登录 step2 182 +
  183 + _.set(req.session, 'smsLogin.step', 2);
  184 + _.set(req.session, 'smsLogin.area', area);
  185 + _.set(req.session, 'smsLogin.mobile', mobile);
  186 +
  187 + --req.session.smsLogin.count;
  188 +
  189 + if (!req.session.smsLogin.count) {
  190 + _.set(req.session, 'smsLogin.interval', Date.now() + 5 * 60 * 1000);
  191 + } else {
  192 + _.set(req.session, 'smsLogin.interval', Date.now() + 60 * 1000);
  193 + }
148 194
149 result.redirect = '/passport/sms_login?step=2'; 195 result.redirect = '/passport/sms_login?step=2';
150 res.json(result); 196 res.json(result);
@@ -157,8 +203,9 @@ exports.token = (req, res, next) => { @@ -157,8 +203,9 @@ exports.token = (req, res, next) => {
157 203
158 exports.checkBefore = (req, res, next) => { 204 exports.checkBefore = (req, res, next) => {
159 let code = req.query.code = (req.query.code || '').trim(); 205 let code = req.query.code = (req.query.code || '').trim();
  206 + let step = _.get(req.session, 'smsLogin.step');
160 207
161 - if (!req.xhr && req.session.smsLoginStep !== 2) { 208 + if (!req.xhr && step !== 2) {
162 return next(404); 209 return next(404);
163 } 210 }
164 211
@@ -214,7 +261,7 @@ exports.check = (req, res, next) => { @@ -214,7 +261,7 @@ exports.check = (req, res, next) => {
214 // 手机号码 没注册 261 // 手机号码 没注册
215 if (r1.data.is_register !== 'Y') { 262 if (r1.data.is_register !== 'Y') {
216 redirect = '/passport/sms_login?step=3'; 263 redirect = '/passport/sms_login?step=3';
217 - req.session.smsLoginStep = 3; 264 + _.set(req.session, 'smsLogin.step', 3);
218 265
219 res.json({ 266 res.json({
220 code: 200, 267 code: 200,
@@ -247,7 +294,6 @@ exports.check = (req, res, next) => { @@ -247,7 +294,6 @@ exports.check = (req, res, next) => {
247 }); 294 });
248 295
249 delete req.session.smsLogin; 296 delete req.session.smsLogin;
250 - delete req.session.smsLoginStep;  
251 }) 297 })
252 .catch(error => { 298 .catch(error => {
253 res.json(error); 299 res.json(error);
@@ -259,7 +305,9 @@ exports.check = (req, res, next) => { @@ -259,7 +305,9 @@ exports.check = (req, res, next) => {
259 305
260 // AJAX 短信登录 设置密码 in step3 306 // AJAX 短信登录 设置密码 in step3
261 exports.password = (req, res, next) => { 307 exports.password = (req, res, next) => {
262 - if (req.session.smsLoginStep !== 3) { 308 + let step = _.get(req.session, 'smsLogin.step');
  309 +
  310 + if (step !== 3) {
263 return next(); 311 return next();
264 } 312 }
265 313
@@ -269,9 +317,8 @@ exports.password = (req, res, next) => { @@ -269,9 +317,8 @@ exports.password = (req, res, next) => {
269 message: BAD_PASSWORD 317 message: BAD_PASSWORD
270 }; 318 };
271 319
272 - let smsLogin = req.session.smsLogin || {};  
273 - let mobile = smsLogin.mobile;  
274 - let area = smsLogin.area; 320 + let mobile = _.get(req.session, 'smsLogin.mobile');
  321 + let area = _.get(req.session, 'smsLogin.area');
275 let password = (req.body.password || '').trim(); 322 let password = (req.body.password || '').trim();
276 let smsCode = +req.body.smsCode || 0; 323 let smsCode = +req.body.smsCode || 0;
277 324
@@ -306,11 +353,23 @@ exports.password = (req, res, next) => { @@ -306,11 +353,23 @@ exports.password = (req, res, next) => {
306 res.json({ 353 res.json({
307 code: 200, 354 code: 200,
308 message: LOGIN_SUCCSS, 355 message: LOGIN_SUCCSS,
309 - redirect: req.cookies.refer 356 + redirect: req.cookies.refer || '/'
310 }); 357 });
311 delete req.session.smsLogin; 358 delete req.session.smsLogin;
312 - delete req.session.smsLoginStep;  
313 }).catch(next); 359 }).catch(next);
  360 +};
  361 +
  362 +
  363 +/**
  364 + * 生成 校验码
  365 + */
  366 +exports.genCaptcha = (req, res) => {
  367 + let captcha = captchaService.generateCaptcha(90, 52, 4);
314 368
  369 + _.set(req.session, 'smsLogin.captcha', captcha.text);
315 370
  371 + res.type('png')
  372 + .set('Cache-Control', 'no-cache')
  373 + .status(200)
  374 + .send(captcha.image);
316 }; 375 };
@@ -13,7 +13,7 @@ const back = require(cRoot + '/back'); @@ -13,7 +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 -// const smsLogin = require(cRoot + '/sms'); 16 +const smsLogin = require(cRoot + '/sms');
17 const update = require(cRoot + '/update'); 17 const update = require(cRoot + '/update');
18 const agreement = require(cRoot + '/app-agreement'); 18 const agreement = require(cRoot + '/app-agreement');
19 19
@@ -37,15 +37,16 @@ router.get('/passport/international', login.common.beforeLogin, login.local.inte @@ -37,15 +37,16 @@ router.get('/passport/international', login.common.beforeLogin, login.local.inte
37 router.post('/passport/login/auth', login.local.login); 37 router.post('/passport/login/auth', login.local.login);
38 38
39 // SMS 短信 39 // SMS 短信
40 -// router.use('/passport/sms_login', login.common.beforeLogin, smsLogin.beforeIn);  
41 -// router.get('/passport/sms_login', smsLogin.loginPage);  
42 -// router.get('/passport/sms_login/token.json',  
43 -// smsLogin.tokenBefore,  
44 -// smsLogin.token); // only ajax;  
45 -// router.get('/passport/sms_login/check.json',  
46 -// smsLogin.checkBefore,  
47 -// smsLogin.check); // only ajax  
48 -// router.post('/passport/sms_login/password.json', smsLogin.password); 40 +router.use('/passport/sms_login', login.common.beforeLogin, smsLogin.beforeIn);
  41 +router.get('/passport/sms_login', smsLogin.loginPage);
  42 +router.get('/passport/sms_login/token.json',
  43 + smsLogin.tokenBefore,
  44 + smsLogin.token); // only ajax;
  45 +router.get('/passport/sms_login/check.json',
  46 + smsLogin.checkBefore,
  47 + smsLogin.check); // only ajax
  48 +router.post('/passport/sms_login/password.json', smsLogin.password);
  49 +router.get('/passport/sms_login/captcha.png', smsLogin.genCaptcha);
49 50
50 // 微信登录 51 // 微信登录
51 router.get('/passport/login/wechat', login.common.beforeLogin, login.wechat.login); 52 router.get('/passport/login/wechat', login.common.beforeLogin, login.wechat.login);
@@ -7,8 +7,10 @@ @@ -7,8 +7,10 @@
7 <input id="phone-num" class="input phone-num" type="text" placeholder="手机号"> 7 <input id="phone-num" class="input phone-num" type="text" placeholder="手机号">
8 </div> 8 </div>
9 <div class="passport-captcha row"> 9 <div class="passport-captcha row">
10 - <input id="verify-code" type="text" placeholder="验证码">  
11 <div class="passport-captcha-img"><img id="verify-code-img" src="{{verifySrc}}" alt="verify code"></div> 10 <div class="passport-captcha-img"><img id="verify-code-img" src="{{verifySrc}}" alt="verify code"></div>
  11 + <div class="passport-captcha-input">
  12 + <input id="verify-code" type="text" placeholder="验证码">
  13 + </div>
12 </div> 14 </div>
13 <span id="btn-next" class="btn btn-next disable row">下一步</span> 15 <span id="btn-next" class="btn btn-next disable row">下一步</span>
14 </div> 16 </div>
@@ -8,10 +8,12 @@ @@ -8,10 +8,12 @@
8 </div> 8 </div>
9 <!-- 验证码: start--> 9 <!-- 验证码: start-->
10 <div class="passport-captcha row"> 10 <div class="passport-captcha row">
11 - <input id="js-captcha" type="text" placeholder="验证码">  
12 <div class="passport-captcha-img"> 11 <div class="passport-captcha-img">
13 <img class="passport-captcha-png" src="{{captchaUrl}}"> 12 <img class="passport-captcha-png" src="{{captchaUrl}}">
14 </div> 13 </div>
  14 + <div class="passport-captcha-input">
  15 + <input id="js-captcha" type="text" placeholder="验证码">
  16 + </div>
15 </div> 17 </div>
16 <!-- 验证码: end--> 18 <!-- 验证码: end-->
17 <span id="btn-next" class="btn btn-next disable row">下一步</span> 19 <span id="btn-next" class="btn btn-next disable row">下一步</span>
@@ -15,5 +15,5 @@ @@ -15,5 +15,5 @@
15 <input type="hidden" name="area" id="area" value="{{area}}"> 15 <input type="hidden" name="area" id="area" value="{{area}}">
16 </div> 16 </div>
17 <script> 17 <script>
18 - var canResend = {{canResend}}; 18 + var countdown = {{countdown}};
19 </script> 19 </script>
@@ -7,6 +7,12 @@ @@ -7,6 +7,12 @@
7 <input id="phone-num" class="input phone-num" type="text" placeholder="手机号"> 7 <input id="phone-num" class="input phone-num" type="text" placeholder="手机号">
8 <button class="clear-input" type="button"></button> 8 <button class="clear-input" type="button"></button>
9 </div> 9 </div>
  10 + <div class="passport-captcha row">
  11 + <div class="passport-captcha-img"><img src="{{captchaUrl}}" alt=""></div>
  12 + <div class="passport-captcha-input">
  13 + <input id="js-captcha" type="text" placeholder="验证码">
  14 + </div>
  15 + </div>
10 <button id="btn-next" class="btn btn-next disable row" disabled>获取短信验证码</button> 16 <button id="btn-next" class="btn btn-next disable row" disabled>获取短信验证码</button>
11 </div> 17 </div>
12 </div> 18 </div>
@@ -16,6 +16,11 @@ module.exports = () => { @@ -16,6 +16,11 @@ module.exports = () => {
16 req.url = `/activity${req.url}`; 16 req.url = `/activity${req.url}`;
17 } 17 }
18 18
  19 + if (/^\/shopping\/pay\/aliwapreturn/.test(req.url)) {
  20 + // 兼容php的url
  21 + req.url = `/cart${req.url}`;
  22 + }
  23 +
19 if (/^\/sale/.test(req.url)) { 24 if (/^\/sale/.test(req.url)) {
20 // sale 兼容php的url 25 // sale 兼容php的url
21 res.redirect(301, helpers.urlFormat('/product/sale', req.query, 'default')); 26 res.redirect(301, helpers.urlFormat('/product/sale', req.query, 'default'));
  1 +var $ = require('yoho-jquery'),
  2 + lazyLoad = require('yoho-jquery-lazyload');
  3 +
  4 +require('../common');
  5 +
  6 +lazyLoad($('img.lazy'));
  7 +
  8 +function getGender() {
  9 + return window.cookie('_Channel') || 'boys';
  10 +}
  11 +
  12 +require('../channel/maybe-like')(getGender());
  13 +
  14 +if ($('#goods-list').length === 0) {
  15 + $('.maybe-like').hide();
  16 +}
@@ -14,20 +14,25 @@ var $footer = $('#yoho-footer'), @@ -14,20 +14,25 @@ var $footer = $('#yoho-footer'),
14 var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) + 14 var RECID = (new Date().getTime() + '_H5_YOHOBUY_' + Math.floor(Math.random() * 1000000 + 1000000) +
15 '_' + Math.floor(Math.random() * 1000000 + 1000000)); 15 '_' + Math.floor(Math.random() * 1000000 + 1000000));
16 16
17 -var _ChannelVary = {boys: 1, girls: 2, kids: 3, lifestyle: 4}; 17 +var _ChannelVary = {
  18 + boys: 1,
  19 + girls: 2,
  20 + kids: 3,
  21 + lifestyle: 4
  22 +};
18 23
19 function cookie(name) { 24 function cookie(name) {
20 var cookies = document.cookie, 25 var cookies = document.cookie,
21 - cookieVal,  
22 - offset;  
23 -  
24 - if (document.cookie && document.cookie !== '') {  
25 - offset = cookies.indexOf(name + '=');  
26 - if (offset > -1) {  
27 - offset += name.length + 1;  
28 -  
29 - cookieVal = decodeURIComponent($.trim(cookies.substring(offset, cookies.indexOf(';', offset))));  
30 - } 26 + cookieVal;
  27 +
  28 + if (cookies) {
  29 + cookies = cookies.split(';');
  30 + cookies.forEach(function(c) {
  31 + if (c.indexOf(name) > -1) {
  32 + cookieVal = decodeURIComponent($.trim(c.replace(name + '=', '')));
  33 + return;
  34 + }
  35 + });
31 } 36 }
32 37
33 return cookieVal; 38 return cookieVal;
@@ -204,7 +209,9 @@ $.extend({ @@ -204,7 +209,9 @@ $.extend({
204 209
205 // 单击下载按钮 - 接受微信商城或者第三方来源的数据埋点信息 210 // 单击下载按钮 - 接受微信商城或者第三方来源的数据埋点信息
206 if (queryString().union_type) { 211 if (queryString().union_type) {
207 - setCookie('unionTypeYas', queryString().union_type, {path: '/'}); 212 + setCookie('unionTypeYas', queryString().union_type, {
  213 + path: '/'
  214 + });
208 } 215 }
209 216
210 }()); 217 }());
@@ -229,7 +236,7 @@ $.extend({ @@ -229,7 +236,7 @@ $.extend({
229 236
230 uid = uid === 0 ? '' : uid; 237 uid = uid === 0 ? '' : uid;
231 238
232 - window._ozuid = uid;// 暴露ozuid 239 + window._ozuid = uid; // 暴露ozuid
233 240
234 if (window._yas) { 241 if (window._yas) {
235 window._yas(1 * new Date(), '1.0.18', 'yohobuy_m', uid, '', ''); 242 window._yas(1 * new Date(), '1.0.18', 'yohobuy_m', uid, '', '');
@@ -323,7 +330,10 @@ function downLoadApp() { @@ -323,7 +330,10 @@ function downLoadApp() {
323 if (window._yas && window._yas.sendCustomInfo) { 330 if (window._yas && window._yas.sendCustomInfo) {
324 window._yas.sendCustomInfo({ 331 window._yas.sendCustomInfo({
325 op: 'YB_DOWNLOAD_C', 332 op: 'YB_DOWNLOAD_C',
326 - param: JSON.stringify({C_ID: _ChannelVary[cookie('_Channel')] || 1, TO_URL: appUrl}) 333 + param: JSON.stringify({
  334 + C_ID: _ChannelVary[cookie('_Channel')] || 1,
  335 + TO_URL: appUrl
  336 + })
327 }, true); 337 }, true);
328 } 338 }
329 339
@@ -369,6 +379,7 @@ function givePoint(parameter) { @@ -369,6 +379,7 @@ function givePoint(parameter) {
369 (function() { 379 (function() {
370 var channel = cookie('_Channel'); 380 var channel = cookie('_Channel');
371 var header = $('#yoho-header, .homebuttom'); 381 var header = $('#yoho-header, .homebuttom');
  382 + var footer = $('.footer-tab .tab-item.current');
372 383
373 if (!/^\/home/.test(location.pathname)) { 384 if (!/^\/home/.test(location.pathname)) {
374 switch (channel) { 385 switch (channel) {
@@ -399,6 +410,34 @@ function givePoint(parameter) { @@ -399,6 +410,34 @@ function givePoint(parameter) {
399 break; 410 break;
400 } 411 }
401 } 412 }
  413 +
  414 + switch (channel) {
  415 + case 'boys':
  416 + if (footer) {
  417 + footer.addClass('boys');
  418 + }
  419 + break;
  420 + case 'girls':
  421 + if (footer) {
  422 + footer.addClass('girls');
  423 + }
  424 + break;
  425 + case 'lifestyle':
  426 + if (footer) {
  427 + footer.addClass('life-style');
  428 + }
  429 + break;
  430 + case 'kids':
  431 + if (footer) {
  432 + footer.addClass('kids');
  433 + }
  434 + break;
  435 + default:
  436 + if (footer) {
  437 + footer.addClass('boys');
  438 + }
  439 + break;
  440 + }
402 }()); 441 }());
403 442
404 // 暴露公共接口 443 // 暴露公共接口
@@ -23,10 +23,12 @@ window.reMarginFooter('.footer-tab'); @@ -23,10 +23,12 @@ window.reMarginFooter('.footer-tab');
23 23
24 // 部分老用户没有头像,显示默认头像 24 // 部分老用户没有头像,显示默认头像
25 avatar = $userAvatar.data('avatar'); 25 avatar = $userAvatar.data('avatar');
26 -myImage.src = avatar;  
27 -myImage.onload = function() {  
28 - $userAvatar.css('background-image', 'url(' + avatar + ')');  
29 -}; 26 +if (avatar) {
  27 + myImage.src = avatar;
  28 + myImage.onload = function() {
  29 + $userAvatar.css('background-image', 'url(' + avatar + ')');
  30 + };
  31 +}
30 32
31 noticeScroll('.notice', $('.notice').data('time') * 1000); 33 noticeScroll('.notice', $('.notice').data('time') * 1000);
32 34
@@ -36,4 +38,3 @@ $('.yoho-page').on('touchstart', '.list-item, .type-item, .order-title', functio @@ -36,4 +38,3 @@ $('.yoho-page').on('touchstart', '.list-item, .type-item, .order-title', functio
36 }).on('touchend touchcancel', '.list-item, .type-item, .order-title', function() { 38 }).on('touchend touchcancel', '.list-item, .type-item, .order-title', function() {
37 $(this).removeClass('highlight'); 39 $(this).removeClass('highlight');
38 }); 40 });
39 -  
@@ -44,7 +44,7 @@ if (qs.selected && qs.selected === 'N') { @@ -44,7 +44,7 @@ if (qs.selected && qs.selected === 'N') {
44 $('.pitch').removeClass('select').html('&#xe647;'); 44 $('.pitch').removeClass('select').html('&#xe647;');
45 } 45 }
46 46
47 -if(qs.pwd) { 47 +if (qs.pwd) {
48 $pwd.val(qs.pwd); 48 $pwd.val(qs.pwd);
49 49
50 if (trim($pwd.val()) === '') { 50 if (trim($pwd.val()) === '') {
@@ -64,6 +64,31 @@ $('.pitch').on('click', function() { @@ -64,6 +64,31 @@ $('.pitch').on('click', function() {
64 } 64 }
65 }); 65 });
66 66
  67 +function setPassword() {
  68 + return $.ajax({
  69 + type: 'POST',
  70 + url: '/passport/reg/setpassword',
  71 + data: {
  72 + password: trim($pwd.val()),
  73 + phoneNum: $('#phone-num').val(),
  74 + areaCode: $('#area-code').val(),
  75 + smsCode: $('#sms-code').val(),
  76 + token: $('#token').val()
  77 + },
  78 + success: function(data) {
  79 + var res = data.data;
  80 +
  81 + if (data.code === 200) {
  82 + showErrTip('注册成功');
  83 +
  84 + location.href = res.href;
  85 + } else {
  86 + showErrTip(data.message);
  87 + }
  88 + }
  89 + });
  90 +}
  91 +
67 $btnSure.on('touchstart', function() { 92 $btnSure.on('touchstart', function() {
68 var pwd = trim($pwd.val()); 93 var pwd = trim($pwd.val());
69 94
@@ -74,30 +99,8 @@ $btnSure.on('touchstart', function() { @@ -74,30 +99,8 @@ $btnSure.on('touchstart', function() {
74 if (!validatePWD(pwd)) { 99 if (!validatePWD(pwd)) {
75 showErrTip('密码6-20位,请重新输入'); 100 showErrTip('密码6-20位,请重新输入');
76 } else { 101 } else {
77 -  
78 if ($('.pitch').hasClass('select')) { 102 if ($('.pitch').hasClass('select')) {
79 - $.ajax({  
80 - type: 'POST',  
81 - url: '/passport/reg/setpassword',  
82 - data: {  
83 - password: pwd,  
84 - phoneNum: $('#phone-num').val(),  
85 - areaCode: $('#area-code').val(),  
86 - smsCode: $('#sms-code').val(),  
87 - token: $('#token').val()  
88 - },  
89 - success: function(data) {  
90 - var res = data.data;  
91 -  
92 - if (data.code === 200) {  
93 - showErrTip('注册成功');  
94 -  
95 - location.href = res.href;  
96 - } else {  
97 - showErrTip(data.message);  
98 - }  
99 - }  
100 - }); 103 + setPassword();
101 } else { 104 } else {
102 $('.prompt').show(); 105 $('.prompt').show();
103 106
@@ -106,27 +109,7 @@ $btnSure.on('touchstart', function() { @@ -106,27 +109,7 @@ $btnSure.on('touchstart', function() {
106 $('.pitch').addClass('select'); 109 $('.pitch').addClass('select');
107 $('.pitch').html('&#xe60a;'); 110 $('.pitch').html('&#xe60a;');
108 111
109 - $.ajax({  
110 - type: 'POST',  
111 - url: '/passport/reg/setpassword',  
112 - data: {  
113 - password: pwd,  
114 - phoneNum: $('#phone-num').val(),  
115 - areaCode: $('#area-code').val(),  
116 - token: $('#token').val()  
117 - },  
118 - success: function(data) {  
119 - var res = data.data;  
120 -  
121 - if (data.code === 200) {  
122 - showErrTip('注册成功');  
123 -  
124 - location.href = res.href;  
125 - } else {  
126 - showErrTip(data.message);  
127 - }  
128 - }  
129 - }); 112 + setPassword();
130 }); 113 });
131 114
132 $('.deny').on('click', function() { 115 $('.deny').on('click', function() {
@@ -22,8 +22,8 @@ page = { @@ -22,8 +22,8 @@ page = {
22 init: function() { 22 init: function() {
23 this.domInit(); 23 this.domInit();
24 this.bindEvents(); 24 this.bindEvents();
25 - if (!window.canResend) {  
26 - this.countDown(); 25 + if (window.countdown > 0) {
  26 + this.countDown(window.countdown);
27 } 27 }
28 }, 28 },
29 29
@@ -72,11 +72,14 @@ page = { @@ -72,11 +72,14 @@ page = {
72 }); 72 });
73 }, 73 },
74 74
75 - countDown: function() { 75 + countDown: function(during) {
76 var self = this; 76 var self = this;
77 var second = this.time; 77 var second = this.time;
78 78
79 - if (this.timerId) { 79 + if (during) {
  80 + clearInterval(this.timerId);
  81 + second = during;
  82 + } else if (this.timerId) {
80 return; 83 return;
81 } 84 }
82 85
@@ -116,6 +119,8 @@ page = { @@ -116,6 +119,8 @@ page = {
116 if (res.code === 200) { 119 if (res.code === 200) {
117 self.countDown(); 120 self.countDown();
118 return; 121 return;
  122 + } else {
  123 + res.during && (self.countDown(res.during));
119 } 124 }
120 125
121 tip.show(res.message); 126 tip.show(res.message);
@@ -6,7 +6,10 @@ var $countrySelect, @@ -6,7 +6,10 @@ var $countrySelect,
6 $areaCode, 6 $areaCode,
7 $nextBtn, 7 $nextBtn,
8 $resetBtn, 8 $resetBtn,
  9 + $captcha,
  10 + $captchaPNG,
9 $phoneNum; 11 $phoneNum;
  12 +
10 var page; 13 var page;
11 14
12 require('js/common'); 15 require('js/common');
@@ -25,6 +28,8 @@ page = { @@ -25,6 +28,8 @@ page = {
25 $nextBtn = $('#btn-next'); 28 $nextBtn = $('#btn-next');
26 $phoneNum = $('#phone-num'); 29 $phoneNum = $('#phone-num');
27 $resetBtn = $('.clear-input'); 30 $resetBtn = $('.clear-input');
  31 + $captcha = $('.passport-captcha input');
  32 + $captchaPNG = $('.passport-captcha-img img');
28 }, 33 },
29 bindEvent: function() { 34 bindEvent: function() {
30 var self = this; 35 var self = this;
@@ -36,6 +41,12 @@ page = { @@ -36,6 +41,12 @@ page = {
36 self.toggleNextBtn(); 41 self.toggleNextBtn();
37 }); 42 });
38 43
  44 + $captcha.on('input', function() {
  45 + self.toggleNextBtn();
  46 + });
  47 +
  48 + $captchaPNG.on('click', $.proxy(this.refreshCapatch, this));
  49 +
39 $nextBtn.on('click', function() { 50 $nextBtn.on('click', function() {
40 self.goNext(); 51 self.goNext();
41 }); 52 });
@@ -51,7 +62,7 @@ page = { @@ -51,7 +62,7 @@ page = {
51 62
52 // 切换$nextBtn disable状态 63 // 切换$nextBtn disable状态
53 toggleNextBtn: function() { 64 toggleNextBtn: function() {
54 - var bool = Boolean($.trim($phoneNum.val())); 65 + var bool = Boolean($.trim($phoneNum.val())) && Boolean($.trim($captcha.val()));
55 66
56 $nextBtn 67 $nextBtn
57 .toggleClass('disable', !bool) 68 .toggleClass('disable', !bool)
@@ -60,10 +71,16 @@ page = { @@ -60,10 +71,16 @@ page = {
60 $resetBtn.toggle(bool); 71 $resetBtn.toggle(bool);
61 }, 72 },
62 73
  74 + refreshCapatch: function() {
  75 + $captchaPNG.attr('src', '/passport/sms_login/captcha.png?t=' + Date.now());
  76 + },
  77 +
63 // 提交按钮 78 // 提交按钮
64 goNext: function() { 79 goNext: function() {
  80 + var self = this;
65 var areaCode = $countrySelect.val(); 81 var areaCode = $countrySelect.val();
66 var phone = $.trim($phoneNum.val()); 82 var phone = $.trim($phoneNum.val());
  83 + var captcha = $.trim($captcha.val());
67 84
68 if ($nextBtn.prop('disabled')) { 85 if ($nextBtn.prop('disabled')) {
69 return; 86 return;
@@ -77,7 +94,8 @@ page = { @@ -77,7 +94,8 @@ page = {
77 $nextBtn.prop('disabled', true); 94 $nextBtn.prop('disabled', true);
78 $.get('/passport/sms_login/token.json', { 95 $.get('/passport/sms_login/token.json', {
79 area: areaCode.replace('+', ''), 96 area: areaCode.replace('+', ''),
80 - mobile: phone 97 + mobile: phone,
  98 + captcha: captcha
81 }) 99 })
82 .done(function(data) { 100 .done(function(data) {
83 if (data.code === 200) { 101 if (data.code === 200) {
@@ -85,6 +103,7 @@ page = { @@ -85,6 +103,7 @@ page = {
85 $nextBtn.off(); 103 $nextBtn.off();
86 location.href = data.redirect; 104 location.href = data.redirect;
87 } else { 105 } else {
  106 + self.refreshCapatch();
88 tip.show(data.message); 107 tip.show(data.message);
89 } 108 }
90 }) 109 })
@@ -38,6 +38,8 @@ var $input = $('#search-input input'), @@ -38,6 +38,8 @@ var $input = $('#search-input input'),
38 38
39 var shopId, sort, brand, outlets, app_type, age_level, msort, misort, coin, app_version; 39 var shopId, sort, brand, outlets, app_type, age_level, msort, misort, coin, app_version;
40 40
  41 +var size, color, style, standard, gender, price, p_d, query, limited, specialoffer, specialsale_id, promotion;
  42 +
41 // 默认筛选条件 43 // 默认筛选条件
42 var defaultOpt = require('../../common/query-param'); 44 var defaultOpt = require('../../common/query-param');
43 45
@@ -207,12 +209,25 @@ function getQueryString(name) { @@ -207,12 +209,25 @@ function getQueryString(name) {
207 shopId = getQueryString('shop_id'); 209 shopId = getQueryString('shop_id');
208 sort = getQueryString('sort'); 210 sort = getQueryString('sort');
209 outlets = getQueryString('outlets'); 211 outlets = getQueryString('outlets');
210 -age_level = getQueryString('age_level'); 212 +age_level = getQueryString('ageLevel');
211 app_type = getQueryString('app_type'); 213 app_type = getQueryString('app_type');
212 msort = getQueryString('msort'); 214 msort = getQueryString('msort');
213 misort = getQueryString('misort'); 215 misort = getQueryString('misort');
214 coin = getQueryString('coin'); 216 coin = getQueryString('coin');
215 app_version = getQueryString('app_version') || getQueryString('appVersion'); 217 app_version = getQueryString('app_version') || getQueryString('appVersion');
  218 +size = getQueryString('size');
  219 +color = getQueryString('color');
  220 +style = getQueryString('style');
  221 +standard = getQueryString('standard');
  222 +gender = getQueryString('gender');
  223 +price = getQueryString('price');
  224 +p_d = getQueryString('p_d');
  225 +brand = getQueryString('brand');
  226 +query = getQueryString('query');
  227 +limited = getQueryString('limited');
  228 +specialoffer = getQueryString('specialoffer');
  229 +specialsale_id = getQueryString('specialsale_id');
  230 +promotion = getQueryString('promotion');
216 231
217 /** 232 /**
218 * 筛选注册的回调,筛选子项点击后逻辑 233 * 筛选注册的回调,筛选子项点击后逻辑
@@ -296,6 +311,11 @@ function search(opt) { @@ -296,6 +311,11 @@ function search(opt) {
296 outlets: opt.id 311 outlets: opt.id
297 }; 312 };
298 break; 313 break;
  314 + case 'p_d':
  315 + ext = {
  316 + p_d: opt.id
  317 + };
  318 + break;
299 default: 319 default:
300 break; 320 break;
301 } 321 }
@@ -373,6 +393,54 @@ function search(opt) { @@ -373,6 +393,54 @@ function search(opt) {
373 params.app_version = app_version; 393 params.app_version = app_version;
374 } 394 }
375 395
  396 + if (size) {
  397 + params.size = size;
  398 + }
  399 +
  400 + if (color) {
  401 + params.color = color;
  402 + }
  403 +
  404 + if (style) {
  405 + params.style = style;
  406 + }
  407 +
  408 + if (standard) {
  409 + params.standard = standard;
  410 + }
  411 +
  412 + if (gender) {
  413 + params.gender = gender;
  414 + }
  415 +
  416 + if (price) {
  417 + params.price = price;
  418 + }
  419 +
  420 + if (p_d) {
  421 + params.p_d = p_d;
  422 + }
  423 +
  424 + if (query) {
  425 + params.query = query;
  426 + }
  427 +
  428 + if (limited) {
  429 + params.limited = limited;
  430 + }
  431 +
  432 + if (specialoffer) {
  433 + params.specialoffer = specialoffer;
  434 + }
  435 +
  436 + if (specialsale_id) {
  437 + params.specialsale_id = specialsale_id;
  438 + }
  439 +
  440 + if (promotion) {
  441 + params.promotion = promotion;
  442 + }
  443 +
376 $.extend(setting, defaultOpt, params); 444 $.extend(setting, defaultOpt, params);
377 searching = true; 445 searching = true;
378 loading.showLoadingMask(); 446 loading.showLoadingMask();
@@ -479,26 +547,109 @@ if ($brandHeader.data('isbaseshop') === true) { @@ -479,26 +547,109 @@ if ($brandHeader.data('isbaseshop') === true) {
479 Object.assign(defaultOpt, {shop_id: $brandHeader.data('id')}); 547 Object.assign(defaultOpt, {shop_id: $brandHeader.data('id')});
480 } 548 }
481 549
  550 +// console.log(defaultOpt)
  551 +(function() {
  552 + var pars = {};
482 553
483 -$.ajax({  
484 - type: 'GET',  
485 - url: location.protocol + '//m.yohobuy.com/product/search/filter',  
486 - data: defaultOpt,  
487 - success: function(data) {  
488 - $goodsContainer.append(data); 554 + if (age_level) {
  555 + pars.age_level = age_level;
  556 + }
489 557
490 - // 初始化filter&注册filter回调  
491 - filter.initFilter({  
492 - fCbFn: search,  
493 - hCbFn: function() { 558 + if (size) {
  559 + pars.size = size;
  560 + }
494 561
495 - // 切换active状态到$pre上  
496 - $pre.addClass('active');  
497 - $pre.siblings('.filter').removeClass('active');  
498 - }  
499 - }); 562 + if (color) {
  563 + pars.color = color;
500 } 564 }
501 -}); 565 +
  566 + if (style) {
  567 + pars.style = style;
  568 + }
  569 +
  570 + if (standard) {
  571 + pars.standard = standard;
  572 + }
  573 +
  574 + if (gender) {
  575 + pars.gender = gender;
  576 + }
  577 +
  578 + if (price) {
  579 + pars.price = price;
  580 + }
  581 +
  582 + if (p_d) {
  583 + pars.p_d = p_d;
  584 + }
  585 +
  586 + if (brand) {
  587 + pars.brand = brand;
  588 + }
  589 +
  590 + if (sort) {
  591 + pars.sort = sort;
  592 + }
  593 +
  594 + if (msort) {
  595 + pars.msort = msort;
  596 + }
  597 +
  598 + if (misort) {
  599 + pars.misort = misort;
  600 + }
  601 +
  602 + if (outlets) {
  603 + pars.outlets = outlets;
  604 + }
  605 +
  606 + if (app_type) {
  607 + pars.app_type = app_type;
  608 + }
  609 +
  610 + if (query) {
  611 + pars.query = query;
  612 + }
  613 +
  614 + if (limited) {
  615 + pars.limited = limited;
  616 + }
  617 +
  618 + if (specialoffer) {
  619 + pars.specialoffer = specialoffer;
  620 + }
  621 +
  622 + if (specialsale_id) {
  623 + pars.specialsale_id = specialsale_id;
  624 + }
  625 +
  626 + if (promotion) {
  627 + pars.promotion = promotion;
  628 + }
  629 +
  630 + $.extend(defaultOpt, pars);
  631 +
  632 + $.ajax({
  633 + type: 'GET',
  634 + url: location.protocol + '//m.yohobuy.com/product/search/filter',
  635 + data: defaultOpt,
  636 + success: function(data) {
  637 + $goodsContainer.append(data);
  638 +
  639 + // 初始化filter&注册filter回调
  640 + filter.initFilter({
  641 + fCbFn: search,
  642 + hCbFn: function() {
  643 +
  644 + // 切换active状态到$pre上
  645 + $pre.addClass('active');
  646 + $pre.siblings('.filter').removeClass('active');
  647 + }
  648 + });
  649 + }
  650 + });
  651 +}());
  652 +
502 653
503 lazyLoad($('.lazy')); 654 lazyLoad($('.lazy'));
504 655
1 -require('./shop/shop');  
2 require('./shop/coupon'); 1 require('./shop/coupon');
  2 +require('./shop/shop');
@@ -23,16 +23,17 @@ shopCoupon = { @@ -23,16 +23,17 @@ shopCoupon = {
23 _url = location.protocol + '//m.yohobuy.com'; 23 _url = location.protocol + '//m.yohobuy.com';
24 24
25 if (that.common.shopId === '') { 25 if (that.common.shopId === '') {
26 - //品牌领券 26 + // 品牌领券
27 _url += '/product/index/getBrandCouponsList'; 27 _url += '/product/index/getBrandCouponsList';
28 } else { 28 } else {
29 - //店铺领券 29 + // 店铺领券
30 _url += '/product/index/getShopCouponsList'; 30 _url += '/product/index/getShopCouponsList';
31 } 31 }
32 32
33 $.ajax({ 33 $.ajax({
34 method: 'GET', 34 method: 'GET',
35 url: _url, 35 url: _url,
  36 + async: false,
36 data: { 37 data: {
37 shopId: that.common.shopId, 38 shopId: that.common.shopId,
38 brandId: that.common.brandId, 39 brandId: that.common.brandId,
@@ -88,7 +89,8 @@ shopCoupon = { @@ -88,7 +89,8 @@ shopCoupon = {
88 $('#shop-login').remove(); 89 $('#shop-login').remove();
89 $('body').append('<a href=\'' + data.url + '\'><span id="shop-login"><span></a>'); 90 $('body').append('<a href=\'' + data.url + '\'><span id="shop-login"><span></a>');
90 $('#shop-login').click(); 91 $('#shop-login').click();
91 - //未登录状态下 92 +
  93 + // 未登录状态下
92 window.setCookie('shopBrandCoupon', code); 94 window.setCookie('shopBrandCoupon', code);
93 } else if (data.code === 401) { 95 } else if (data.code === 401) {
94 tip.show('已领取过'); 96 tip.show('已领取过');
@@ -103,7 +105,8 @@ shopCoupon = { @@ -103,7 +105,8 @@ shopCoupon = {
103 }); 105 });
104 }); 106 });
105 }, 107 },
106 - //登录状态下,领取优惠券 108 +
  109 + // 登录状态下,领取优惠券
107 loginCoupon: function() { 110 loginCoupon: function() {
108 var $self = this, 111 var $self = this,
109 code = window.cookie('shopBrandCoupon') || false; 112 code = window.cookie('shopBrandCoupon') || false;
@@ -130,4 +133,4 @@ shopCoupon = { @@ -130,4 +133,4 @@ shopCoupon = {
130 133
131 $(function() { 134 $(function() {
132 shopCoupon.init(); 135 shopCoupon.init();
133 -});  
  136 +});
  1 +.pay-success {
  2 + width: 100%;
  3 + overflow: hidden;
  4 + position: relative;
  5 + background-color: #f0f0f0;
  6 +
  7 + .top-tip {
  8 + width: 100%;
  9 + height: 240px;
  10 + border-bottom: solid 1px #e0e0e0;
  11 + text-align: center;
  12 + background-color: #fff;
  13 +
  14 + .img-c {
  15 + margin-top: 25px;
  16 + width: 102px;
  17 + height: 102px;
  18 + background: resolve("cart/pay-ok.png") no-repeat;
  19 + background-size: 100% 100%;
  20 + display: inline-block;
  21 + }
  22 +
  23 + .ok-tip {
  24 + font-size: 24px;
  25 + color: #d0021b;
  26 + line-height: 60px;
  27 + }
  28 +
  29 + .left-tip {
  30 + font-size: 19px;
  31 + color: #b0b0b0;
  32 + }
  33 + }
  34 +
  35 + .info-table-c {
  36 + height: 160px;
  37 + border-bottom: solid 1px #e0e0e0;
  38 + padding: 20px 25px;
  39 + background-color: #fff;
  40 +
  41 + table {
  42 + width: 100%;
  43 +
  44 + tr {
  45 + height: 40px;
  46 + }
  47 +
  48 + td {
  49 + font-size: 24px;
  50 + color: #444;
  51 + }
  52 +
  53 + td:nth-child(2) {
  54 + text-align: right;
  55 + }
  56 + }
  57 + }
  58 +
  59 + .btn-c {
  60 + width: 100%;
  61 + height: 102px;
  62 + background-color: #fff;
  63 + border-bottom: solid 1px #e0e0e0;
  64 + padding: 0 25px;
  65 +
  66 + a {
  67 + width: 270px;
  68 + height: 53px;
  69 + border: solid 2px #444;
  70 + display: block;
  71 + float: left;
  72 + line-height: 53px;
  73 + text-align: center;
  74 + border-radius: 5px;
  75 + box-sizing: border-box;
  76 + -moz-box-sizing: border-box;
  77 + margin-top: 24px;
  78 + font-size: 24px;
  79 + color: #444;
  80 + }
  81 +
  82 + a:nth-child(2) {
  83 + margin-left: 50px;
  84 + }
  85 + }
  86 +
  87 + .ad-pic {
  88 + width: 100%;
  89 + height: 200px;
  90 + display: block;
  91 + background-color: #fff;
  92 + margin: 25px 0;
  93 + }
  94 +
  95 + .others-buy {
  96 + width: 100%;
  97 + margin-bottom: 25px;
  98 + background-color: #fff;
  99 + padding: 25px 0;
  100 + border-top: solid 1px #e4e4e4;
  101 + padding-left: 15px;
  102 +
  103 + p {
  104 + text-align: center;
  105 + color: #444;
  106 + font-size: 27px;
  107 + }
  108 + }
  109 +}
@@ -11,19 +11,35 @@ @@ -11,19 +11,35 @@
11 background: #fff; 11 background: #fff;
12 border-top: 1px solid #b0b0b0; 12 border-top: 1px solid #b0b0b0;
13 z-index: 3; 13 z-index: 3;
  14 +
14 .tab-item { 15 .tab-item {
15 float: left; 16 float: left;
16 width: 20%; 17 width: 20%;
17 text-align: center; 18 text-align: center;
18 color: #b0b0b0; 19 color: #b0b0b0;
19 - &.current { 20 +
  21 + &.current.boys {
20 color: #414141; 22 color: #414141;
21 } 23 }
  24 +
  25 + &.current.girls {
  26 + color: #ff88ae;
  27 + }
  28 +
  29 + &.current.kids {
  30 + color: #7ad9f9;
  31 + }
  32 +
  33 + &.current.lifestyle {
  34 + color: #4f4138;
  35 + }
22 } 36 }
  37 +
23 .tab-icon { 38 .tab-icon {
24 font-size: 40px; 39 font-size: 40px;
25 line-height: 1; 40 line-height: 1;
26 } 41 }
  42 +
27 .tab-name { 43 .tab-name {
28 margin-top: 10px; 44 margin-top: 10px;
29 font-size: 20px; 45 font-size: 20px;
@@ -27,3 +27,4 @@ @@ -27,3 +27,4 @@
27 @import "cart/index"; 27 @import "cart/index";
28 @import "home/index"; 28 @import "home/index";
29 @import "me/index"; 29 @import "me/index";
  30 +@import "cart/pay-success"
@@ -7,21 +7,27 @@ div.passport-captch @@ -7,21 +7,27 @@ div.passport-captch
7 img 7 img
8 8
9 emmet: 9 emmet:
10 -div.passport-captcha>input+div.passport-captcha-img>img 10 +div.passport-captcha>(div.passport-captcha-input>input)+div.passport-captcha-img>img
11 11
12 */ 12 */
13 13
14 .passport-captcha { 14 .passport-captcha {
15 text-align: left; 15 text-align: left;
  16 + border-radius: 5PX;
  17 + overflow: hidden;
  18 +}
  19 +
  20 +.passport-captcha-input {
  21 + overflow: hidden;
16 22
17 input { 23 input {
18 position: relative; 24 position: relative;
19 padding-left: 15px; 25 padding-left: 15px;
20 height: 52PX; 26 height: 52PX;
  27 + width: 100%;
21 font-size: 20PX; 28 font-size: 20PX;
22 background-color: #575757; 29 background-color: #575757;
23 border: 1px solid #606060; 30 border: 1px solid #606060;
24 - border-radius: 5PX;  
25 color: #fff; 31 color: #fff;
26 } 32 }
27 } 33 }