handle merge
Showing
11 changed files
with
191 additions
and
54 deletions
@@ -35,7 +35,7 @@ passport.use(new LocalStrategy({ | @@ -35,7 +35,7 @@ passport.use(new LocalStrategy({ | ||
35 | passReqToCallback: true | 35 | passReqToCallback: true |
36 | }, (req, username, password, done) => { | 36 | }, (req, username, password, done) => { |
37 | 37 | ||
38 | - let area = req.body.area || '86'; | 38 | + let area = req.body.areaCode || '86'; |
39 | 39 | ||
40 | if (isNaN(_.parseInt(area)) || _.isEmpty(username) || _.isEmpty(password)) { | 40 | if (isNaN(_.parseInt(area)) || _.isEmpty(username) || _.isEmpty(password)) { |
41 | logger.info(`【Passport Login】bad params, area:${area} account:${username} password:${password}`); | 41 | logger.info(`【Passport Login】bad params, area:${area} account:${username} password:${password}`); |
@@ -43,7 +43,7 @@ passport.use(new LocalStrategy({ | @@ -43,7 +43,7 @@ passport.use(new LocalStrategy({ | ||
43 | } | 43 | } |
44 | 44 | ||
45 | let verifyEmail = helpers.verifyEmail(username); | 45 | let verifyEmail = helpers.verifyEmail(username); |
46 | - let verifyMobile = helpers.verifyAreaMobile(area + '-' + username, area); | 46 | + let verifyMobile = area === '86' ? helpers.verifyAreaMobile(area + '-' + username) : true; |
47 | 47 | ||
48 | if (!verifyEmail && !verifyMobile) { | 48 | if (!verifyEmail && !verifyMobile) { |
49 | logger.info(`【Passport Login】bad account, email:${verifyEmail} mobile:${verifyMobile}`); | 49 | logger.info(`【Passport Login】bad account, email:${verifyEmail} mobile:${verifyMobile}`); |
@@ -90,23 +90,23 @@ const sendCodePage = (req, res, next) => { | @@ -90,23 +90,23 @@ const sendCodePage = (req, res, next) => { | ||
90 | const saveInSession = (req, res) => { | 90 | const saveInSession = (req, res) => { |
91 | switch (req.inputInfo.type) { | 91 | switch (req.inputInfo.type) { |
92 | case 'email': | 92 | case 'email': |
93 | - { | ||
94 | - req.session.email = req.inputInfo.phone; | ||
95 | - res.redirect(helpers.urlFormat('/passport/back/sendEmail')); | ||
96 | - break; | ||
97 | - } | 93 | + { |
94 | + req.session.email = req.inputInfo.phone; | ||
95 | + res.redirect(helpers.urlFormat('/passport/back/sendEmail')); | ||
96 | + break; | ||
97 | + } | ||
98 | case 'mobile': | 98 | case 'mobile': |
99 | - { | ||
100 | - req.session.mobile = req.inputInfo.phone; | ||
101 | - req.session.area = req.inputInfo.area; | ||
102 | - req.session.verifyCode = req.session.captcha; | ||
103 | - res.redirect(helpers.urlFormat('/passport/back/verification')); | ||
104 | - break; | ||
105 | - } | 99 | + { |
100 | + req.session.mobile = req.inputInfo.phone; | ||
101 | + req.session.area = req.inputInfo.area; | ||
102 | + req.session.verifyCode = req.session.captcha; | ||
103 | + res.redirect(helpers.urlFormat('/passport/back/verification')); | ||
104 | + break; | ||
105 | + } | ||
106 | default: | 106 | default: |
107 | - { | ||
108 | - res.redirect(helpers.urlFormat('/passport/back/index')); | ||
109 | - } | 107 | + { |
108 | + res.redirect(helpers.urlFormat('/passport/back/index')); | ||
109 | + } | ||
110 | } | 110 | } |
111 | }; | 111 | }; |
112 | 112 |
@@ -30,22 +30,6 @@ let checkCode = (req, res, next) => { | @@ -30,22 +30,6 @@ let checkCode = (req, res, next) => { | ||
30 | }; | 30 | }; |
31 | 31 | ||
32 | /** | 32 | /** |
33 | - * 检查手机格式 | ||
34 | - */ | ||
35 | -let checkMobileMiddleware = (req, res, next) => { | ||
36 | - let mobile = +req.body.mobile; | ||
37 | - let area = +req.body.area; | ||
38 | - | ||
39 | - if (!_.isNumber(mobile) || !_.isNumber(area)) { | ||
40 | - return res.json({ | ||
41 | - code: 400, | ||
42 | - message: '手机号码格式不正确' | ||
43 | - }); | ||
44 | - } | ||
45 | - next(); | ||
46 | -}; | ||
47 | - | ||
48 | -/** | ||
49 | * 检查密码格式 | 33 | * 检查密码格式 |
50 | */ | 34 | */ |
51 | let checkPassword = (req, res, next) => { | 35 | let checkPassword = (req, res, next) => { |
@@ -96,8 +80,8 @@ let checkMobile = (req, res, next) => { | @@ -96,8 +80,8 @@ let checkMobile = (req, res, next) => { | ||
96 | let data = { | 80 | let data = { |
97 | code: 400 | 81 | code: 400 |
98 | }; | 82 | }; |
99 | - let mobile = +req.body.mobile; | ||
100 | - let area = +req.body.area; | 83 | + let mobile = req.body.mobile; |
84 | + let area = req.body.area; | ||
101 | 85 | ||
102 | // 判断手机号是否检查超过指定次数 | 86 | // 判断手机号是否检查超过指定次数 |
103 | let regCheckKey = 'regCheckMobileNum_' + passportHelper.makeAreaMobile(area, mobile); | 87 | let regCheckKey = 'regCheckMobileNum_' + passportHelper.makeAreaMobile(area, mobile); |
@@ -149,8 +133,8 @@ let sendBindMsg = (req, res, next) => { | @@ -149,8 +133,8 @@ let sendBindMsg = (req, res, next) => { | ||
149 | data: '' | 133 | data: '' |
150 | }; | 134 | }; |
151 | 135 | ||
152 | - let mobile = +req.body.mobile; | ||
153 | - let area = +req.body.area; | 136 | + let mobile = req.body.mobile; |
137 | + let area = req.body.area; | ||
154 | 138 | ||
155 | // 检查是否检查过 | 139 | // 检查是否检查过 |
156 | let checkNum = yield cache.get(`regCheckMobileNum_${passportHelper.makeAreaMobile(area, mobile)}`); | 140 | let checkNum = yield cache.get(`regCheckMobileNum_${passportHelper.makeAreaMobile(area, mobile)}`); |
@@ -193,9 +177,9 @@ let msgCaptcha = (req, res, next) => { | @@ -193,9 +177,9 @@ let msgCaptcha = (req, res, next) => { | ||
193 | message: '', | 177 | message: '', |
194 | data: '' | 178 | data: '' |
195 | }; | 179 | }; |
196 | - let area = +req.body.area; | ||
197 | - let mobile = +req.body.mobile; | ||
198 | - let code = +req.body.code; // 短信验证码 | 180 | + let area = req.body.area; |
181 | + let mobile = req.body.mobile; | ||
182 | + let code = req.body.code; // 短信验证码 | ||
199 | 183 | ||
200 | regService.validMobileCode(area, mobile, code).then((result) => { | 184 | regService.validMobileCode(area, mobile, code).then((result) => { |
201 | if (result.code) { | 185 | if (result.code) { |
@@ -243,9 +227,9 @@ let mobileRegister = (req, res, next) => { | @@ -243,9 +227,9 @@ let mobileRegister = (req, res, next) => { | ||
243 | 227 | ||
244 | yield cache.set(ipKey, ipTimes + 1, 3600); | 228 | yield cache.set(ipKey, ipTimes + 1, 3600); |
245 | 229 | ||
246 | - let area = +req.body.area; | ||
247 | - let mobile = +req.body.mobile; | ||
248 | - let code = +req.body.code; // 短信验证码 | 230 | + let area = req.body.area; |
231 | + let mobile = req.body.mobile; | ||
232 | + let code = req.body.code; // 短信验证码 | ||
249 | let password = req.body.password; | 233 | let password = req.body.password; |
250 | let result = yield regService.validMobileCode(area, mobile, code); // 验证注册的标识码是否有效 | 234 | let result = yield regService.validMobileCode(area, mobile, code); // 验证注册的标识码是否有效 |
251 | 235 | ||
@@ -295,7 +279,6 @@ let success = (req, res) => { | @@ -295,7 +279,6 @@ let success = (req, res) => { | ||
295 | 279 | ||
296 | module.exports = { | 280 | module.exports = { |
297 | checkCode, | 281 | checkCode, |
298 | - checkMobileMiddleware, | ||
299 | checkPassword, | 282 | checkPassword, |
300 | index, | 283 | index, |
301 | success, | 284 | success, |
@@ -64,11 +64,11 @@ router.post('/autouserinfo/relateMobile', bind.relateMobile); | @@ -64,11 +64,11 @@ router.post('/autouserinfo/relateMobile', bind.relateMobile); | ||
64 | * 注册页面路由 | 64 | * 注册页面路由 |
65 | */ | 65 | */ |
66 | router.get('/reg', reg.index); | 66 | router.get('/reg', reg.index); |
67 | -router.post('/reg/checkmobile', reg.checkMobileMiddleware, reg.checkMobile); | 67 | +router.post('/reg/checkmobile', reg.checkMobile); |
68 | router.post('/reg/piccaptcha', reg.checkCode, reg.picCaptcha); | 68 | router.post('/reg/piccaptcha', reg.checkCode, reg.picCaptcha); |
69 | -router.post('/reg/msgcaptcha', reg.checkMobileMiddleware, reg.msgCaptcha); | ||
70 | -router.post('/reg/sendBindMsg', reg.checkMobileMiddleware, reg.checkCode, reg.sendBindMsg); | ||
71 | -router.post('/reg/mobileregister', reg.checkMobileMiddleware, reg.checkPassword, reg.checkCode, reg.mobileRegister); | 69 | +router.post('/reg/msgcaptcha', reg.msgCaptcha); |
70 | +router.post('/reg/sendBindMsg', reg.checkCode, reg.sendBindMsg); | ||
71 | +router.post('/reg/mobileregister', reg.checkPassword, reg.checkCode, reg.mobileRegister); | ||
72 | router.get('/reg/success', reg.success); | 72 | router.get('/reg/success', reg.success); |
73 | 73 | ||
74 | /** | 74 | /** |
@@ -10,7 +10,11 @@ | @@ -10,7 +10,11 @@ | ||
10 | </li> | 10 | </li> |
11 | <li> | 11 | <li> |
12 | <div id="name" class="title center"> | 12 | <div id="name" class="title center"> |
13 | - <span>咸鸭蛋</span> | 13 | + {{#if name}} |
14 | + <span>{{name}}</span> | ||
15 | + {{^}} | ||
16 | + <span>咸鸭蛋</span> | ||
17 | + {{/if}} | ||
14 | </div> | 18 | </div> |
15 | </li> | 19 | </li> |
16 | 20 |
@@ -93,6 +93,28 @@ | @@ -93,6 +93,28 @@ | ||
93 | <span>限购码已抢光</span> | 93 | <span>限购码已抢光</span> |
94 | {{/if}} | 94 | {{/if}} |
95 | {{/ fashionTopGoods}} | 95 | {{/ fashionTopGoods}} |
96 | + | ||
97 | + {{#if soldOut}} | ||
98 | + <span> | ||
99 | + 点击 | ||
100 | + <i class="arr-notice blue">到货通知</i> | ||
101 | + ,到货第一时间通知您 | ||
102 | + </span> | ||
103 | + | ||
104 | + <script type="text/html" id="arrival-notice-tpl"> | ||
105 | + <h1>到货通知</h1> | ||
106 | + <p>商品一旦在30日内到货,我们将会第一时间通知您,请及时关注哦!</p> | ||
107 | + <div class="phone-num">手机号<input type="text" class="notice-phone"></div> | ||
108 | + <p> | ||
109 | + <span class="iconfont add-fav checked"></span> | ||
110 | + 添加到收藏夹 | ||
111 | + </p> | ||
112 | + </script> | ||
113 | + <script type="text/html" id="arrival-notice-success-tpl"> | ||
114 | + <h1>到货通知</h1> | ||
115 | + <p>商品订阅到货通知成功!</p> | ||
116 | + </script> | ||
117 | + {{/if}} | ||
96 | </div> | 118 | </div> |
97 | <p class="btns"> | 119 | <p class="btns"> |
98 | {{#unless soldOut}} | 120 | {{#unless soldOut}} |
@@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
20 | </div> | 20 | </div> |
21 | <div class="goods-list hide"> | 21 | <div class="goods-list hide"> |
22 | {{#each goodsList}} | 22 | {{#each goodsList}} |
23 | - <i data-url="{{url}}">{{image imagesUrl 265 344}}</i> | 23 | + <i data-url="{{url}}">{{image imagesUrl 256 343}}</i> |
24 | {{/each}} | 24 | {{/each}} |
25 | </div> | 25 | </div> |
26 | </div> | 26 | </div> |
@@ -39,6 +39,7 @@ var $errTip = $('.tips'), | @@ -39,6 +39,7 @@ var $errTip = $('.tips'), | ||
39 | $errMsg = $errTip.find('.rectangle'); | 39 | $errMsg = $errTip.find('.rectangle'); |
40 | 40 | ||
41 | require('yoho-jquery-placeholder'); | 41 | require('yoho-jquery-placeholder'); |
42 | +require('../../plugins/tips'); | ||
42 | 43 | ||
43 | function errTip(ele, msg) { | 44 | function errTip(ele, msg) { |
44 | var topLeft = ele.offset(); | 45 | var topLeft = ele.offset(); |
@@ -7,7 +7,7 @@ var jQuery = require('yoho-jquery'), | @@ -7,7 +7,7 @@ var jQuery = require('yoho-jquery'), | ||
7 | 7 | ||
8 | ((function($) { | 8 | ((function($) { |
9 | 9 | ||
10 | - var tpl = '<div class="tips">' + | 10 | + var tpl = '<div class="tips hide">' + |
11 | '<div class="triangle"></div>' + | 11 | '<div class="triangle"></div>' + |
12 | '<div class="rectangle"> {{content}}</div>' + | 12 | '<div class="rectangle"> {{content}}</div>' + |
13 | '</div>'; | 13 | '</div>'; |
@@ -19,6 +19,8 @@ var jQuery = require('yoho-jquery'), | @@ -19,6 +19,8 @@ var jQuery = require('yoho-jquery'), | ||
19 | 19 | ||
20 | var methods = { | 20 | var methods = { |
21 | show: function() { | 21 | show: function() { |
22 | + var topLeft = this.offset(); | ||
23 | + | ||
22 | if (_that.isInit) { | 24 | if (_that.isInit) { |
23 | $tips = this.find('.tips'); | 25 | $tips = this.find('.tips'); |
24 | this.find('.rectangle').text(arguments[0]); | 26 | this.find('.rectangle').text(arguments[0]); |
@@ -26,14 +28,23 @@ var jQuery = require('yoho-jquery'), | @@ -26,14 +28,23 @@ var jQuery = require('yoho-jquery'), | ||
26 | _that.isInit = true; | 28 | _that.isInit = true; |
27 | this.append(tplFn({content: arguments[0]})); | 29 | this.append(tplFn({content: arguments[0]})); |
28 | $tips = this.find('.tips'); | 30 | $tips = this.find('.tips'); |
29 | - $tips.css('top', this.height() - 2); | 31 | + $tips.css({ |
32 | + top: topLeft.top + this.height() - 2, | ||
33 | + left: topLeft.left, | ||
34 | + width: this.width() + 2, | ||
35 | + height: this.height | ||
36 | + }); | ||
30 | } | 37 | } |
38 | + | ||
39 | + return this.removeClass('hide'); | ||
31 | }, | 40 | }, |
32 | hide: function() { | 41 | hide: function() { |
33 | if (_that.isInit) { | 42 | if (_that.isInit) { |
34 | - this.find('.tips').remove(); | 43 | + this.find('.tips').addClass('hide'); |
35 | _that.isInit = false; | 44 | _that.isInit = false; |
36 | } | 45 | } |
46 | + | ||
47 | + return this; | ||
37 | }, | 48 | }, |
38 | status: function() { | 49 | status: function() { |
39 | return _that.isInit; | 50 | return _that.isInit; |
@@ -4,7 +4,10 @@ | @@ -4,7 +4,10 @@ | ||
4 | * @date: 2016/7/15 | 4 | * @date: 2016/7/15 |
5 | */ | 5 | */ |
6 | var $ = require('yoho-jquery'), | 6 | var $ = require('yoho-jquery'), |
7 | - lazyload = require('yoho-jquery-lazyload'); | 7 | + handlebars = require('yoho-handlebars'), |
8 | + lazyload = require('yoho-jquery-lazyload'), | ||
9 | + Dialog = require('../plugins/dialog').Dialog, | ||
10 | + regx = require('../passport/common/mail-phone-regx').phoneRegx; | ||
8 | 11 | ||
9 | var $main = $('.product-main'), | 12 | var $main = $('.product-main'), |
10 | $mainThumb = $('#main-thumb'), | 13 | $mainThumb = $('#main-thumb'), |
@@ -26,6 +29,9 @@ var $thumbCur = $('.thumb-wrap .cur'); // 当前选中展示图片 | @@ -26,6 +29,9 @@ var $thumbCur = $('.thumb-wrap .cur'); // 当前选中展示图片 | ||
26 | 29 | ||
27 | var SLIDETIME = 200; | 30 | var SLIDETIME = 200; |
28 | 31 | ||
32 | +var noticeFn = handlebars.compile($('#arrival-notice-tpl').html() || ''), | ||
33 | + noticeSuccFn = handlebars.compile($('#arrival-notice-success-tpl').html() || ''); | ||
34 | + | ||
29 | var thumbsLoaded = [], | 35 | var thumbsLoaded = [], |
30 | id = $main.data('id'); | 36 | id = $main.data('id'); |
31 | 37 | ||
@@ -94,6 +100,34 @@ function chooseColor(index) { | @@ -94,6 +100,34 @@ function chooseColor(index) { | ||
94 | $sizeText.text(''); | 100 | $sizeText.text(''); |
95 | } | 101 | } |
96 | 102 | ||
103 | +function arrivalNotice() { | ||
104 | + // $.ajax({ | ||
105 | + // type: 'POST', | ||
106 | + // url: '/shopping/cart/add', | ||
107 | + // data: { | ||
108 | + // productSku: sku, | ||
109 | + // buyNumber: 1 | ||
110 | + // } | ||
111 | + // }).then(function(data) { | ||
112 | + // if (data.code === 200) { | ||
113 | + // } | ||
114 | + // }); | ||
115 | + var tip = new Dialog({ | ||
116 | + className: 'arr-notice-dialog', | ||
117 | + content: noticeSuccFn(), | ||
118 | + btns: [ | ||
119 | + { | ||
120 | + id: 'sure', | ||
121 | + btnClass: ['sure'], | ||
122 | + name: '确定', | ||
123 | + cb: function() { | ||
124 | + tip.close(); | ||
125 | + } | ||
126 | + } | ||
127 | + ] | ||
128 | + }).show(); | ||
129 | +} | ||
130 | + | ||
97 | // 缩略图垂直居中 | 131 | // 缩略图垂直居中 |
98 | $thumbWrap.each(function() { | 132 | $thumbWrap.each(function() { |
99 | var $this = $(this), | 133 | var $this = $(this), |
@@ -161,6 +195,40 @@ $('.size-list').on('click', 'li', function() { | @@ -161,6 +195,40 @@ $('.size-list').on('click', 'li', function() { | ||
161 | } | 195 | } |
162 | }); | 196 | }); |
163 | 197 | ||
198 | +// 到货通知 | ||
199 | +$('.arr-notice').click(function() { | ||
200 | + var tip = new Dialog({ | ||
201 | + className: 'arr-notice-dialog', | ||
202 | + content: noticeFn({}), | ||
203 | + btns: [ | ||
204 | + { | ||
205 | + id: 'apply', | ||
206 | + btnClass: ['apply'], | ||
207 | + name: '订阅', | ||
208 | + cb: function() { | ||
209 | + var dom = tip.$el.find('.notice-phone'), | ||
210 | + num = dom.val ? dom.val() : ''; | ||
211 | + | ||
212 | + if (regx['+86'].test(num)) { | ||
213 | + arrivalNotice(num); | ||
214 | + tip.close(); | ||
215 | + } else { | ||
216 | + dom.addClass('err'); | ||
217 | + } | ||
218 | + } | ||
219 | + }, | ||
220 | + { | ||
221 | + id: 'cancel', | ||
222 | + btnClass: ['cancel'], | ||
223 | + name: '取消', | ||
224 | + cb: function() { | ||
225 | + tip.close(); | ||
226 | + } | ||
227 | + } | ||
228 | + ] | ||
229 | + }).show(); | ||
230 | +}); | ||
231 | + | ||
164 | // 加入购物袋 | 232 | // 加入购物袋 |
165 | $addToBag.click(function() { | 233 | $addToBag.click(function() { |
166 | var sku = getBuyProduct(); | 234 | var sku = getBuyProduct(); |
@@ -443,4 +443,52 @@ | @@ -443,4 +443,52 @@ | ||
443 | } | 443 | } |
444 | } | 444 | } |
445 | } | 445 | } |
446 | + | ||
447 | + + .arr-notice-dialog { | ||
448 | + .content { | ||
449 | + width: 260px; | ||
450 | + text-align: center; | ||
451 | + margin: 0 auto; | ||
452 | + } | ||
453 | + | ||
454 | + } | ||
455 | +} | ||
456 | + | ||
457 | +.arr-notice-dialog { | ||
458 | + .content { | ||
459 | + width: 280px; | ||
460 | + text-align: center; | ||
461 | + margin: 0 auto; | ||
462 | + line-height: 1.5; | ||
463 | + font-size: 14px; | ||
464 | + | ||
465 | + h1 { | ||
466 | + font-size: 20px; | ||
467 | + font-weight: bold; | ||
468 | + padding-bottom: 30px; | ||
469 | + } | ||
470 | + } | ||
471 | + | ||
472 | + .phone-num { | ||
473 | + text-align: left; | ||
474 | + padding: 12px 0; | ||
475 | + | ||
476 | + input { | ||
477 | + width: 210px; | ||
478 | + height: 30px; | ||
479 | + border: 1px solid #eee; | ||
480 | + margin-left: 20px; | ||
481 | + padding: 0 20px; | ||
482 | + } | ||
483 | + | ||
484 | + .err { | ||
485 | + border-color: #f00; | ||
486 | + } | ||
487 | + } | ||
488 | + | ||
489 | + .add-fav { | ||
490 | + font-size: 14px; | ||
491 | + cursor: pointer; | ||
492 | + margin-right: 4px; | ||
493 | + } | ||
446 | } | 494 | } |
-
Please register or login to post a comment