Showing
11 changed files
with
240 additions
and
0 deletions
apps/coupon/controllers/coupon.js
0 → 100644
apps/coupon/index.js
0 → 100644
1 | +/** | ||
2 | + * sub app coupon | ||
3 | + * @author: lixia.zhang<lixia.zhang@yoho.cn> | ||
4 | + * @date: 2016/05/31 | ||
5 | + */ | ||
6 | + | ||
7 | +var express = require('express'), | ||
8 | + path = require('path'), | ||
9 | + hbs = require('express-handlebars'); | ||
10 | + | ||
11 | +var app = express(); | ||
12 | + | ||
13 | +// set view engin | ||
14 | +var doraemon = path.join(__dirname, '../../doraemon/views'); // parent view root | ||
15 | + | ||
16 | +app.set('views', path.join(__dirname, 'views/action')); | ||
17 | +app.engine('.hbs', hbs({ | ||
18 | + extname: '.hbs', | ||
19 | + defaultLayout: 'layout', | ||
20 | + layoutsDir: doraemon, | ||
21 | + partialsDir: ['./views/partial', `${doraemon}/partial`], | ||
22 | + helpers: 'helpers' | ||
23 | +})); | ||
24 | + | ||
25 | +// router | ||
26 | +app.use(require('./router')); | ||
27 | + | ||
28 | +module.exports = app; |
apps/coupon/router.js
0 → 100644
1 | +/** | ||
2 | + * router of sub app coupon | ||
3 | + * @author: lixia.zhang<lixia.zhang@yoho.cn> | ||
4 | + * @date: 2016/05/31 | ||
5 | + */ | ||
6 | + | ||
7 | +'use strict'; | ||
8 | + | ||
9 | +const router = require('express').Router(); | ||
10 | +const cRoot = './controllers'; | ||
11 | + | ||
12 | +const coupon = require(`${cRoot}/coupon`); | ||
13 | + | ||
14 | +// routers | ||
15 | + | ||
16 | +router.get('/index', coupon.index); | ||
17 | + | ||
18 | +module.exports = router; |
apps/coupon/views/action/coupon.hbs
0 → 100644
1 | +<div class="receive-coupon-page"> | ||
2 | + <div class="page"> | ||
3 | + <div class="coupon-header"> | ||
4 | + </div> | ||
5 | + <div class="coupon-centent"> | ||
6 | + <div class="title"> | ||
7 | + </div> | ||
8 | + | ||
9 | + <div class="input-content"> | ||
10 | + <input id="phone" type="text" placeholder="请输入手机号" maxlength="11"/> | ||
11 | + <div>获取红包</div> | ||
12 | + </div> | ||
13 | + | ||
14 | + <div class="input-content hidden"> | ||
15 | + <input id="verification hidden" type="text" placeholder="请输入验证码" maxlength="4"/> | ||
16 | + <div>验证领红包</div> | ||
17 | + </div> | ||
18 | + | ||
19 | + <div class="coupon-description"> | ||
20 | + <span></span> | ||
21 | + </div> | ||
22 | + </div> | ||
23 | + | ||
24 | + <div class="gain-coupon-centent hidden"> | ||
25 | + <div class="gain-coupon-centent"> | ||
26 | + <div class="coupon"> | ||
27 | + <!-- <img src="/activity/cocacola/images/cokeCoupon.png"> --> | ||
28 | + </div> | ||
29 | + <p class="phone" id="mobile"></p> | ||
30 | + <p>登录Yoho!Buy有货客户端即可使用</p> | ||
31 | + | ||
32 | + <div class="use-coupon-btn"> | ||
33 | + <!-- <img src="/activity/cocacola/images/cokeBtn.png"> --> | ||
34 | + </div> | ||
35 | + <span>活动说明</span> | ||
36 | + </div> | ||
37 | + </div> | ||
38 | + | ||
39 | + </div> | ||
40 | + | ||
41 | + <div class="messages hidden" id="dialog"> | ||
42 | + <div class="content"></div> | ||
43 | + </div> | ||
44 | + | ||
45 | + <div class="keep-out hidden"></div> | ||
46 | + <div class="dialog hidden" id="message"> | ||
47 | + <span class="close"></span> | ||
48 | + <div class="activity-message"> | ||
49 | + <h3>活动说明</h3> | ||
50 | + <div class="message"> | ||
51 | + <P>1、活动时间:2016年4月7日到2016年7月7日</P> | ||
52 | + <P>2、仅限新注册用户以及首次购买用户使用</P> | ||
53 | + <P>3、同一手机号限领一次优惠券</P> | ||
54 | + </div> | ||
55 | + </div> | ||
56 | + </div> | ||
57 | + | ||
58 | + | ||
59 | +</div> |
public/img/coupon/close.png
0 → 100644

2.15 KB
public/img/coupon/coupon-footer.png
0 → 100644

16.5 KB
public/img/coupon/coupon-title.png
0 → 100644

11.4 KB
public/img/coupon/header.png
0 → 100644

33.4 KB
public/img/coupon/use-coupon-btn.png
0 → 100644

9.11 KB
public/img/sprite.img.png
0 → 100644

84.5 KB
public/js/coupon/index.page.js
0 → 100644
1 | + | ||
2 | +var $ = require('yoho-jquery'), | ||
3 | + num = 0, | ||
4 | + phone, | ||
5 | + reg, | ||
6 | + time; | ||
7 | + | ||
8 | +$('#phone').bind('input propertychange', function() { | ||
9 | + if ($(this).val().length === 11) { | ||
10 | + $('.centent span').eq('0').addClass('verification-code'); | ||
11 | + } else { | ||
12 | + $('.centent span').eq('0').removeClass(); | ||
13 | + } | ||
14 | +}); | ||
15 | +$('#verification').bind('input propertychange', function() { | ||
16 | + if ($(this).val().length === 4) { | ||
17 | + $('.centent span').eq('1').addClass('get'); | ||
18 | + } else { | ||
19 | + $('.centent span').eq('1').removeClass(); | ||
20 | + } | ||
21 | +}); | ||
22 | + | ||
23 | +$('.centent').on('click', '.verification-code', function() { | ||
24 | + $('.centent span').eq('0').removeClass('verification-code'); | ||
25 | + phone = $(this).siblings('input').val(); | ||
26 | + reg = /[0-9]{11}/; | ||
27 | + if (!reg.test(phone)) { | ||
28 | + $('#dialog').removeClass('hidden'); | ||
29 | + $('.keep-out').removeClass('hidden'); | ||
30 | + $('#dialog .content').html('<p class="phone-error">手机号错误,请重新输入。<p>'); | ||
31 | + setTimeout(function() { | ||
32 | + $('.messages').addClass('hidden'); | ||
33 | + $('.keep-out').addClass('hidden'); | ||
34 | + $('#dialog .content').html(' '); | ||
35 | + }, 1400); | ||
36 | + return; | ||
37 | + } | ||
38 | + $.ajax({ | ||
39 | + url: '/activity/cocacola/CocacolaController/sendSms', | ||
40 | + data: { | ||
41 | + mobile: $('#phone').val() | ||
42 | + }, | ||
43 | + dataType: 'json', | ||
44 | + success: function(data) { | ||
45 | + if (data.code === 200) { | ||
46 | + time = setInterval(function() { | ||
47 | + num++; | ||
48 | + if (num > 60) { | ||
49 | + num = 0; | ||
50 | + $('.centent span').eq('0').addClass('verification-code').html('获取验证码'); | ||
51 | + clearInterval(time); | ||
52 | + | ||
53 | + } else { | ||
54 | + $('.centent span').eq('0').removeClass('verification-code').html('重新发送' + (60 - num)); | ||
55 | + } | ||
56 | + }, 1000); | ||
57 | + } else { | ||
58 | + $('#dialog').removeClass('hidden'); | ||
59 | + $('.keep-out').removeClass('hidden'); | ||
60 | + $('#dialog .content').html('<p class="phone-error">' + data.message + '<p>'); | ||
61 | + setTimeout(function() { | ||
62 | + $('.messages').addClass('hidden'); | ||
63 | + $('.keep-out').addClass('hidden'); | ||
64 | + $('#dialog .content').html(' '); | ||
65 | + }, 1400); | ||
66 | + } | ||
67 | + } | ||
68 | + }); | ||
69 | +}); | ||
70 | +$('.centent').on('click', '.get', function() { | ||
71 | + $('.centent span').eq('1').removeClass('get'); | ||
72 | + if ($(this).siblings('input').val().length === 4) { | ||
73 | + $.ajax({ | ||
74 | + url: '/activity/cocacola/CocacolaController/validRegCodeAndSendCode', | ||
75 | + data: { | ||
76 | + code: $('#verification').val(), | ||
77 | + mobile: $('#phone').val(), | ||
78 | + client_id: $.cookie('_yasvd') | ||
79 | + }, | ||
80 | + dataType: 'json', | ||
81 | + success: function(data) { | ||
82 | + if (data.code === 200) { | ||
83 | + location.href = 'gain.html?mobile=' + $('#phone').val(); | ||
84 | + } else { | ||
85 | + $('#dialog').removeClass('hidden'); | ||
86 | + $('.keep-out').removeClass('hidden'); | ||
87 | + $('#dialog .content').html('<p class="phone-error">' + data.message + '<p>'); | ||
88 | + setTimeout(function() { | ||
89 | + $('.messages').addClass('hidden'); | ||
90 | + $('.keep-out').addClass('hidden'); | ||
91 | + $('#dialog .content').html(' '); | ||
92 | + }, 1400); | ||
93 | + } | ||
94 | + } | ||
95 | + }); | ||
96 | + } else { | ||
97 | + $('#dialog').removeClass('hidden'); | ||
98 | + $('.keep-out').removeClass('hidden'); | ||
99 | + $('#dialog .content').html('<p class="phone-error">验证码错误,请重新输入。<p>'); | ||
100 | + setTimeout(function() { | ||
101 | + $('.messages').addClass('hidden'); | ||
102 | + $('.keep-out').addClass('hidden'); | ||
103 | + $('#dialog .content').html(' '); | ||
104 | + }, 1400); | ||
105 | + } | ||
106 | +}); | ||
107 | +$('.close').on('click', function() { | ||
108 | + $('.dialog').addClass('hidden'); | ||
109 | + $('.keep-out').addClass('hidden'); | ||
110 | + $('#dialog .content').html(' '); | ||
111 | +}); | ||
112 | +$('.footer span').on('click', function() { | ||
113 | + $('#message').removeClass('hidden'); | ||
114 | + $('.keep-out').removeClass('hidden'); | ||
115 | +}); | ||
116 | + | ||
117 | + | ||
118 | +$('.centent').on('click', '.get', function() { | ||
119 | + if (window._yas) { | ||
120 | + window._yas.sendCustomInfo({ | ||
121 | + receiveCoupon: 'Y' | ||
122 | + }, true); | ||
123 | + } | ||
124 | +}); |
-
Please register or login to post a comment