merge couponcneter
Showing
23 changed files
with
652 additions
and
28 deletions
@@ -13,7 +13,7 @@ const bodyParser = require('body-parser'); | @@ -13,7 +13,7 @@ const bodyParser = require('body-parser'); | ||
13 | const cookieParser = require('cookie-parser'); | 13 | const cookieParser = require('cookie-parser'); |
14 | const favicon = require('serve-favicon'); | 14 | const favicon = require('serve-favicon'); |
15 | const yohoLib = require('yoho-node-lib'); | 15 | const yohoLib = require('yoho-node-lib'); |
16 | -const session = require('express-session'); | 16 | +const session = require('yoho-express-session'); |
17 | const memcached = require('connect-memcached'); | 17 | const memcached = require('connect-memcached'); |
18 | const hbs = require('express-handlebars'); | 18 | const hbs = require('express-handlebars'); |
19 | const pkg = require('./package.json'); | 19 | const pkg = require('./package.json'); |
@@ -68,7 +68,9 @@ app.use(session({ | @@ -68,7 +68,9 @@ app.use(session({ | ||
68 | }, | 68 | }, |
69 | store: new MemcachedStore({ | 69 | store: new MemcachedStore({ |
70 | hosts: config.memcache.session, | 70 | hosts: config.memcache.session, |
71 | - prefix: 'yohobuy_session:' | 71 | + prefix: 'yohobuy_session:', |
72 | + timeout: 1000, | ||
73 | + retries: 0 | ||
72 | }) | 74 | }) |
73 | })); | 75 | })); |
74 | 76 |
apps/activity/controllers/coupon-floor.js
0 → 100644
1 | +// 领券中心 by acgpiano 16-9-19 | ||
2 | +'use strict'; | ||
3 | + | ||
4 | +const model = require('../models/coupon-floor'), | ||
5 | + headerModel = require('../../../doraemon/models/header'); | ||
6 | + | ||
7 | +exports.index = (req, res, next) => { | ||
8 | + let uid = ''; | ||
9 | + | ||
10 | + if (req.yoho.isApp) { | ||
11 | + uid = req.query.uid; | ||
12 | + } else { | ||
13 | + uid = req.user.uid; | ||
14 | + } | ||
15 | + model.floor({ | ||
16 | + uid: uid, | ||
17 | + contentCode: req.query.code | ||
18 | + }, req.yoho.isApp).then(result => { | ||
19 | + res.render('coupon-floor', { | ||
20 | + module: 'activity', | ||
21 | + page: 'coupon-floor', | ||
22 | + wechatShare: true, | ||
23 | + title: '领券中心', | ||
24 | + pageHeader: headerModel.setNav({ | ||
25 | + navTitle: '领券中心' | ||
26 | + }), | ||
27 | + content: result, | ||
28 | + }); | ||
29 | + }).catch(next); | ||
30 | +}; | ||
31 | + | ||
32 | +exports.receive = (req, res, next) => { | ||
33 | + let receiveData = { | ||
34 | + couponID: req.query.couponID, | ||
35 | + code: req.query.code, | ||
36 | + app_version: req.query.app_version, | ||
37 | + }; | ||
38 | + | ||
39 | + let uid = ''; | ||
40 | + | ||
41 | + if (req.yoho.isApp) { | ||
42 | + uid = req.query.uid; | ||
43 | + } else { | ||
44 | + uid = req.user.uid; | ||
45 | + } | ||
46 | + | ||
47 | + model.receiveCoupon(receiveData, req.yoho.isApp, uid).then(result => { | ||
48 | + res.json(result); | ||
49 | + }).catch(next); | ||
50 | +}; |
apps/activity/models/coupon-floor.js
0 → 100644
1 | +// 领券中心 by acgpiano 16-9-19 | ||
2 | +'use strict'; | ||
3 | + | ||
4 | +const Promise = require('bluebird'); | ||
5 | +const api = global.yoho.API; | ||
6 | +const _ = require('lodash'); | ||
7 | +const helpers = global.yoho.helpers; | ||
8 | +const crypto = global.yoho.crypto; | ||
9 | + | ||
10 | +const SUB_DOMAIN = '.dev.yohobuy.com', | ||
11 | + OLD_MAIN = '//m.yohobuy.com', | ||
12 | + SITE_MAIN = '//m.dev.yohobuy.com'; | ||
13 | + | ||
14 | +/** | ||
15 | + * 仿php的strrpos | ||
16 | + */ | ||
17 | +const strrpos = (str1, str2) => { | ||
18 | + return str1.indexOf(str2) > -1 ? str1.indexOf(str2) : false; | ||
19 | +}; | ||
20 | + | ||
21 | +/** | ||
22 | + * 仿php的strstr | ||
23 | + */ | ||
24 | +const strstr = (str1, str2, bfsearch) => { | ||
25 | + if (str1.indexOf(str2) > -1) { | ||
26 | + if (bfsearch) { | ||
27 | + return str1.substring(0, str1.indexOf(str2)); | ||
28 | + } else { | ||
29 | + return str1.substr(str1.indexOf(str2)); | ||
30 | + } | ||
31 | + } else { | ||
32 | + return false; | ||
33 | + } | ||
34 | +}; | ||
35 | + | ||
36 | +const rtrim = (str1, str2) => { | ||
37 | + return str1[str1.length - 1] === str2 ? str1.substr(0, str1.length - 1) : str1; | ||
38 | +}; | ||
39 | + | ||
40 | +const transHttpsUrl = url => { | ||
41 | + return url.replace(/^\/\//, 'http://'); | ||
42 | +}; | ||
43 | + | ||
44 | +/** | ||
45 | + * app内的分享按钮 | ||
46 | + */ | ||
47 | +const getShare = (code, shareTitle, shareDesc, shareImg) => { | ||
48 | + return { | ||
49 | + shareLink: helpers.urlFormat('/coupon/floor', { code: code }, ''), | ||
50 | + shareTitle: shareTitle || '', | ||
51 | + shareDesc: shareDesc || '', | ||
52 | + shareImg: shareImg || '', | ||
53 | + hasWxShare: true, | ||
54 | + }; | ||
55 | +}; | ||
56 | + | ||
57 | +/** | ||
58 | + * 过滤app的url | ||
59 | + */ | ||
60 | +const _getFilterUrl = url => { | ||
61 | + url = url.replace('.m.yohobuy.com', SUB_DOMAIN).replace(OLD_MAIN, SITE_MAIN).replace('www.yohobuy.com', SITE_MAIN); | ||
62 | + if (strrpos(url, 'm.yohobuy.com') && !strrpos(url, 'sale.m.yohobuy.com') && !strrpos(url, 'cuxiao.m.yohobuy.com') && | ||
63 | + !strrpos(url, 'activity.m.yohobuy.com') && !strrpos(url, 'huodong.m.yohobuy.com') && | ||
64 | + strrpos(url, 'cdn.yoho.cn/myohobuy') && !strrpos(url, '/home/orders/pay')) { | ||
65 | + url = url.replace('http://', '//'); | ||
66 | + } | ||
67 | + | ||
68 | + if (strrpos(url, 'feature.yoho.cn')) { | ||
69 | + url = transHttpsUrl(url); | ||
70 | + } | ||
71 | + | ||
72 | + let filter = strstr(url, 'openby:yohobuy=', true); | ||
73 | + | ||
74 | + if (filter) { | ||
75 | + return rtrim(rtrim(filter, '?'), '&'); | ||
76 | + } else { | ||
77 | + return url; | ||
78 | + } | ||
79 | +}; | ||
80 | + | ||
81 | +/** | ||
82 | + * 获得的数据处理 | ||
83 | + */ | ||
84 | +const processFun = { | ||
85 | + carousel_banner(data) { | ||
86 | + if (!data.list || !data.list.length) { | ||
87 | + return []; | ||
88 | + } | ||
89 | + for (let item of data.list) { | ||
90 | + item.img = helpers.image(item.src, 0, 0); | ||
91 | + if (typeof item.url !== 'string') { | ||
92 | + item.url = ''; | ||
93 | + } | ||
94 | + } | ||
95 | + data.isCarouselBanner = true; | ||
96 | + return data; | ||
97 | + }, | ||
98 | + | ||
99 | + getCoupon(data, isApp) { | ||
100 | + let result = []; | ||
101 | + | ||
102 | + if (!data.length) { | ||
103 | + return []; | ||
104 | + } | ||
105 | + let floorTitle = '', | ||
106 | + item = data[0], | ||
107 | + imageSrc = ''; | ||
108 | + | ||
109 | + for (let key in item) { | ||
110 | + if (key === 'floorTitle') { | ||
111 | + floorTitle = (_.has(item[key], 'text') && (item[key].text !== '')) ? item[key].text : ''; | ||
112 | + continue; | ||
113 | + } | ||
114 | + if (!item.encrypt) { | ||
115 | + item.couponID = crypto.encryption('yoho9646abcdefgh', item.couponID); | ||
116 | + item.encrypt = true; | ||
117 | + } | ||
118 | + imageSrc = helpers.image(item.image.src, 0, 0); | ||
119 | + item.image.src = imageSrc; | ||
120 | + | ||
121 | + item.image.url = isApp ? item.image.url : _getFilterUrl(item.image.url); | ||
122 | + switch (item.status) { | ||
123 | + case '1': | ||
124 | + item.isGet = true; | ||
125 | + break; | ||
126 | + case '2': | ||
127 | + item.isZero = true; | ||
128 | + break; | ||
129 | + case '3': | ||
130 | + item.isGeted = true; | ||
131 | + break; | ||
132 | + default: | ||
133 | + break; | ||
134 | + } | ||
135 | + } | ||
136 | + if (floorTitle !== '') { | ||
137 | + data[0].floorTitle = floorTitle; | ||
138 | + data[0].showFloorTitle = true; | ||
139 | + } | ||
140 | + result = data[0]; | ||
141 | + result.isCoupon = true; | ||
142 | + return result; | ||
143 | + }, | ||
144 | + | ||
145 | + text(data) { | ||
146 | + data.isTitle = true; | ||
147 | + if (data.text) { | ||
148 | + data.isShow = true; | ||
149 | + } | ||
150 | + return data; | ||
151 | + }, | ||
152 | + | ||
153 | + single_image(data, isApp) { | ||
154 | + data[0].isSingleImage = true; | ||
155 | + data[0].url = isApp ? data[0].url : _getFilterUrl(data[0].url); | ||
156 | + return data[0]; | ||
157 | + }, | ||
158 | + | ||
159 | + focus(data, isApp) { | ||
160 | + let result = {}; | ||
161 | + | ||
162 | + for (let item of data) { | ||
163 | + item.url = isApp ? item.url : _getFilterUrl(item.url); | ||
164 | + } | ||
165 | + result.isFocus = true; | ||
166 | + result.data = data; | ||
167 | + return result; | ||
168 | + }, | ||
169 | + | ||
170 | + image_list(data, isApp) { | ||
171 | + let result = {}, | ||
172 | + num, | ||
173 | + width; | ||
174 | + | ||
175 | + for (let image of data.list) { | ||
176 | + num = data.title.column_num; | ||
177 | + if (num === 0) { | ||
178 | + image.src = image.src.replace('?imageView/{mode}/w/{width}/h/{height}', ''); | ||
179 | + } else { | ||
180 | + if (640 % num === 0) { | ||
181 | + width = parseInt(640 / num, 10); | ||
182 | + width = !width ? 640 : width; | ||
183 | + image.src = image.src.replace('?imageView/{mode}/w/{width}/h/{height}', '?imageView2/2/w/' + width); | ||
184 | + image.src = helpers.image(image.src, width, 0); | ||
185 | + } else { | ||
186 | + image.src = image.src.replace('?imageView/{mode}/w/{width}/h/{height}', ''); | ||
187 | + } | ||
188 | + } | ||
189 | + | ||
190 | + if (isApp) { | ||
191 | + image.url = !image.url ? 'javascript:void(0);' : image.url; | ||
192 | + } else { | ||
193 | + image.url = !image.url ? 'javascript:void(0);' : _getFilterUrl(image.url); | ||
194 | + } | ||
195 | + } | ||
196 | + result.isImageList = true; | ||
197 | + result.imageList = { | ||
198 | + col: data.title.column_num, | ||
199 | + title: data.title.title, | ||
200 | + list: data.list, | ||
201 | + }; | ||
202 | + return result; | ||
203 | + }, | ||
204 | +}; | ||
205 | + | ||
206 | +const _getContent = (data, isApp) => { | ||
207 | + let result = [], | ||
208 | + build = []; | ||
209 | + | ||
210 | + const TEMPLATE_LIST = ['single_image', 'focus']; | ||
211 | + | ||
212 | + if (!data) { | ||
213 | + return []; | ||
214 | + } | ||
215 | + | ||
216 | + for (let i = 0, n = data.length; i < n; i++) { | ||
217 | + | ||
218 | + let fun = ''; | ||
219 | + | ||
220 | + if (!data[i] || typeof data[i] !== 'object' || !_.has(data[i], 'template_name')) { | ||
221 | + if (data[i].templateName) { | ||
222 | + fun = data[i].templateName; | ||
223 | + } else { | ||
224 | + continue; | ||
225 | + } | ||
226 | + } | ||
227 | + if (TEMPLATE_LIST.indexOf(fun) === -1) { | ||
228 | + fun = data[i].template_name; | ||
229 | + } | ||
230 | + if (!data[i].data || !_.has(processFun, fun)) { | ||
231 | + continue; | ||
232 | + } | ||
233 | + | ||
234 | + // tar note 处理楼层标题 | ||
235 | + if (fun === 'getCoupon' && _.has(data[i - 1], 'template_name') && data[i - 1].template_name === 'text') { | ||
236 | + data[i].data[0].floorTitle = data[i - 1].data; | ||
237 | + } | ||
238 | + build = processFun[fun](data[i].data, isApp); | ||
239 | + if (!build) { | ||
240 | + continue; | ||
241 | + } | ||
242 | + result.push(build); | ||
243 | + } | ||
244 | + build = []; | ||
245 | + return result; | ||
246 | +}; | ||
247 | + | ||
248 | +exports.floor = (params, isApp) => { | ||
249 | + return Promise.coroutine(function*() { | ||
250 | + let result = {}, | ||
251 | + resource = yield api.get('', Object.assign(params, { | ||
252 | + method: 'app.promotion.queryCouponCenter', | ||
253 | + })); | ||
254 | + | ||
255 | + if (resource && resource.code === 200) { | ||
256 | + result = _getContent(resource.data, isApp); | ||
257 | + } else { | ||
258 | + result.noData = true; | ||
259 | + } | ||
260 | + | ||
261 | + result.share = getShare(params.contentCode, '领券中心'); | ||
262 | + return result; | ||
263 | + })(); | ||
264 | +}; | ||
265 | + | ||
266 | +/** | ||
267 | + * 前端ajax领券 | ||
268 | + */ | ||
269 | +exports.receiveCoupon = (receiveData, isApp, uid) => { | ||
270 | + let returnData = {}; | ||
271 | + | ||
272 | + // 获取优惠券 ID | ||
273 | + if (receiveData.couponID) { | ||
274 | + receiveData.couponID = crypto.decrypt('yoho9646abcdefgh', receiveData.couponID); | ||
275 | + } | ||
276 | + | ||
277 | + // 登录后调用领券接口 | ||
278 | + return api.get('', { | ||
279 | + method: 'app.promotion.getCoupon', | ||
280 | + couponId: receiveData.couponID, | ||
281 | + uid: uid, | ||
282 | + }).then(result => { | ||
283 | + switch (result.code) { | ||
284 | + case 200: | ||
285 | + returnData = { | ||
286 | + msg: '领券成功!', | ||
287 | + status: true, | ||
288 | + }; | ||
289 | + break; | ||
290 | + case 401: | ||
291 | + returnData = { | ||
292 | + code: 401, | ||
293 | + message: '您已领取过优惠券' | ||
294 | + }; | ||
295 | + break; | ||
296 | + case 315: | ||
297 | + returnData = { | ||
298 | + code: 315, | ||
299 | + message: '优惠券已过期' | ||
300 | + }; | ||
301 | + break; | ||
302 | + default: | ||
303 | + returnData = { | ||
304 | + msg: '领券失败!', | ||
305 | + status: false, | ||
306 | + }; | ||
307 | + break; | ||
308 | + } | ||
309 | + return returnData; | ||
310 | + }); | ||
311 | +}; |
@@ -16,6 +16,8 @@ const live = require(`${cRoot}/live`); | @@ -16,6 +16,8 @@ const live = require(`${cRoot}/live`); | ||
16 | const invite = require(`${cRoot}/invite`); | 16 | const invite = require(`${cRoot}/invite`); |
17 | const vipDay = require(`${cRoot}/vipDay`); | 17 | const vipDay = require(`${cRoot}/vipDay`); |
18 | 18 | ||
19 | +const couponFloor = require(`${cRoot}/coupon-floor`); | ||
20 | +const auth = require('../../doraemon/middleware/auth'); | ||
19 | const market = require(`${cRoot}/market`); | 21 | const market = require(`${cRoot}/market`); |
20 | 22 | ||
21 | // routers | 23 | // routers |
@@ -28,6 +30,10 @@ router.get('/coupon/verify', coupon.verify); | @@ -28,6 +30,10 @@ router.get('/coupon/verify', coupon.verify); | ||
28 | 30 | ||
29 | router.get('/wechat/share', wechat.wechatShare); | 31 | router.get('/wechat/share', wechat.wechatShare); |
30 | 32 | ||
33 | +router.get('/coupon/floor', auth, couponFloor.index); | ||
34 | + | ||
35 | +router.get('/coupon/receiveCoupon', auth, couponFloor.receive); | ||
36 | + | ||
31 | router.get('/student', student.getUser, student.index); | 37 | router.get('/student', student.getUser, student.index); |
32 | 38 | ||
33 | router.get('/student/register', student.isLogin, student.register); | 39 | router.get('/student/register', student.isLogin, student.register); |
apps/activity/views/action/coupon-floor.hbs
0 → 100644
1 | +<div class="coupon-area-page yoho-page"> | ||
2 | + {{# content}} | ||
3 | + {{#if isSingleImage}} | ||
4 | + <a href="{{url}}"><img src="{{image src 0 0}}" class="just-img"/></a> | ||
5 | + {{/if}} | ||
6 | + {{#if isCarouselBanner}} | ||
7 | + {{> resources/banner-top}} | ||
8 | + {{/if}} | ||
9 | + {{#if isFocus}} | ||
10 | + {{> resources/banner-top}} | ||
11 | + {{/if}} | ||
12 | + {{#if isCoupon}} | ||
13 | + <div class="coupon-floor" coupon-id="{{couponID}}"> | ||
14 | + {{#if showFloorTitle}} | ||
15 | + <div class="floor-title"> | ||
16 | + {{floorTitle}} | ||
17 | + </div> | ||
18 | + {{/if}} | ||
19 | + <div class="floor-main" style="background-image: url({{image.src}});"> | ||
20 | + <a href="{{image.url}}" class="main-left"></a> | ||
21 | + {{#if isGet}} | ||
22 | + <div class="main-right-receive"> | ||
23 | + <span class="on-receive"></span> | ||
24 | + </div> | ||
25 | + <a href="{{image.url}}" class="main-right-use" style="display: none"> | ||
26 | + <span class="received"></span> | ||
27 | + </a> | ||
28 | + {{/if}} | ||
29 | + {{#if isGeted}} | ||
30 | + <a href="{{image.url}}" class="main-right-use"> | ||
31 | + <span class="received"></span> | ||
32 | + </a> | ||
33 | + {{/if}} | ||
34 | + {{#if isZero}} | ||
35 | + <a href="{{image.url}}" class="main-right-go"> | ||
36 | + <span class="zero"></span> | ||
37 | + </a> | ||
38 | + {{/if}} | ||
39 | + </div> | ||
40 | + </div> | ||
41 | + {{/if}} | ||
42 | + {{#if isImageList}} | ||
43 | + {{> coupon/imagelist}} | ||
44 | + {{/if}} | ||
45 | + {{#if isNewArrival}} | ||
46 | + {{> coupon/newarrival}} | ||
47 | + {{/if}} | ||
48 | + {{# share}} | ||
49 | + <input id="shareLink" type="hidden" value="{{shareLink}}"> | ||
50 | + <input id="shareDesc" type="hidden" value="{{shareDesc}}"> | ||
51 | + <input id="shareImg" type="hidden" value="{{shareImg}}"> | ||
52 | + <input id="shareTitle" type="hidden" value="{{shareTitle}}"> | ||
53 | + {{/ share}} | ||
54 | + {{#if noData}} | ||
55 | + <input id="noData" type="hidden"> | ||
56 | + {{/if}} | ||
57 | + {{/ content}} | ||
58 | +</div> | ||
59 | +<div class="floor-mask"></div> | ||
60 | +<div class="floor-message"> | ||
61 | + <div class="coupon-message-content"></div> | ||
62 | + <div class="coupon-message-op"> | ||
63 | + <span class="coupon-message-op-rel">刷新</span> | ||
64 | + </div> | ||
65 | +</div> | ||
66 | +<div class="floor-tooltip"> | ||
67 | + <div class="iconfont icon-box"></div> | ||
68 | + <div class="icon-msg">领取成功</div> | ||
69 | +</div> |
1 | +<div class="coupon-floor" coupon-id="{{couponID}}"> | ||
2 | + {{#if showFloorTitle}} | ||
3 | + <div class="floor-title"> | ||
4 | + {{floorTitle}} | ||
5 | + </div> | ||
6 | + {{/if}} | ||
7 | + <div class="floor-main" style="background-image: url({{image.src}});"> | ||
8 | + <a href="{{image.url}}" class="main-left"></a> | ||
9 | + {{#if isGet}} | ||
10 | + <div class="main-right-receive"> | ||
11 | + <span class="on-receive"></span> | ||
12 | + </div> | ||
13 | + <a href="{{image.url}}" class="main-right-use" style="display: none"> | ||
14 | + <span class="received"></span> | ||
15 | + </a> | ||
16 | + {{/if}} | ||
17 | + {{#if isGeted}} | ||
18 | + <a href="{{image.url}}" class="main-right-use"> | ||
19 | + <span class="received"></span> | ||
20 | + </a> | ||
21 | + {{/if}} | ||
22 | + {{#if isZero}} | ||
23 | + <a href="{{image.url}}" class="main-right-go"> | ||
24 | + <span class="zero"></span> | ||
25 | + </a> | ||
26 | + {{/if}} | ||
27 | + </div> | ||
28 | +</div> |
1 | +<div class="newfestival-container"> | ||
2 | + {{# slider}} | ||
3 | + <div class="swiper-container newfestival-block"> | ||
4 | + <div class="swiper-wrapper"> | ||
5 | + {{# imgs}} | ||
6 | + <div class="swiper-slide"> | ||
7 | + <a href="{{url}}"> | ||
8 | + <img src="{{src}}" alt=""> | ||
9 | + </a> | ||
10 | + </div> | ||
11 | + {{/ imgs}} | ||
12 | + </div> | ||
13 | + <div class="swiper-pagination"></div> | ||
14 | + </div> | ||
15 | + {{/ slider}} | ||
16 | +</div> |
1 | +<div class="newfestival-container"> | ||
2 | + {{# imageList}} | ||
3 | + <div class="img-list newfestival-block newfestival-recom-{{col}} clearfix"> | ||
4 | + {{# title}} | ||
5 | + <div class="new-arrival-header"> | ||
6 | + <span class="header-text"> {{.}}</span> | ||
7 | + </div> | ||
8 | + {{/ title}} | ||
9 | + | ||
10 | + {{# list}} | ||
11 | + <div class="newfestival-recom-item"> | ||
12 | + <a href="{{url}}" class="img-wrapper"> | ||
13 | + <img class="img" src="{{src}}" alt="" style="display:block"> | ||
14 | + </a> | ||
15 | + </div> | ||
16 | + {{/ list}} | ||
17 | + | ||
18 | + </div> | ||
19 | + {{/ imageList}} | ||
20 | +</div> |
@@ -144,7 +144,7 @@ const _article = (param) => { | @@ -144,7 +144,7 @@ const _article = (param) => { | ||
144 | sort_id: param.type === '0' ? param.type : '1', | 144 | sort_id: param.type === '0' ? param.type : '1', |
145 | tag: param.tag ? param.tag : null, | 145 | tag: param.tag ? param.tag : null, |
146 | author_id: param.authorId ? param.authorId : null, | 146 | author_id: param.authorId ? param.authorId : null, |
147 | - limit: param.limit ? param.limit : null, | 147 | + limit: param.limit ? param.limit : null |
148 | }, { | 148 | }, { |
149 | cache: true, | 149 | cache: true, |
150 | code: 200 | 150 | code: 200 |
@@ -89,7 +89,8 @@ if (isProduction) { | @@ -89,7 +89,8 @@ if (isProduction) { | ||
89 | master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], | 89 | master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], |
90 | slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'], | 90 | slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'], |
91 | session: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], | 91 | session: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'], |
92 | - timeout: 100, | 92 | + reconnect: 5000, |
93 | + timeout: 1000, | ||
93 | retries: 0 | 94 | retries: 0 |
94 | }, | 95 | }, |
95 | useCache: true, | 96 | useCache: true, |
@@ -113,6 +114,7 @@ if (isProduction) { | @@ -113,6 +114,7 @@ if (isProduction) { | ||
113 | slave: ['127.0.0.1:12112'], | 114 | slave: ['127.0.0.1:12112'], |
114 | session: ['127.0.0.1:12111'], | 115 | session: ['127.0.0.1:12111'], |
115 | timeout: 100, | 116 | timeout: 100, |
117 | + reconnect: 5000, | ||
116 | retries: 0 | 118 | retries: 0 |
117 | }, | 119 | }, |
118 | useCache: true | 120 | useCache: true |
@@ -26,7 +26,6 @@ | @@ -26,7 +26,6 @@ | ||
26 | "cookie-parser": "^1.4.3", | 26 | "cookie-parser": "^1.4.3", |
27 | "express": "^4.14.0", | 27 | "express": "^4.14.0", |
28 | "express-handlebars": "^3.0.0", | 28 | "express-handlebars": "^3.0.0", |
29 | - "express-session": "^1.14.1", | ||
30 | "influxdb-winston": "^1.0.1", | 29 | "influxdb-winston": "^1.0.1", |
31 | "lodash": "^4.16.1", | 30 | "lodash": "^4.16.1", |
32 | "md5": "^2.1.0", | 31 | "md5": "^2.1.0", |
@@ -43,6 +42,7 @@ | @@ -43,6 +42,7 @@ | ||
43 | "serve-favicon": "^2.3.0", | 42 | "serve-favicon": "^2.3.0", |
44 | "uuid": "^2.0.3", | 43 | "uuid": "^2.0.3", |
45 | "winston": "^2.2.0", | 44 | "winston": "^2.2.0", |
45 | + "yoho-express-session": "^1.14.1", | ||
46 | "winston-daily-rotate-file": "^1.3.0", | 46 | "winston-daily-rotate-file": "^1.3.0", |
47 | "yoho-node-lib": "0.0.49" | 47 | "yoho-node-lib": "0.0.49" |
48 | }, | 48 | }, |
public/js/activity/coupon-floor.page.js
0 → 100644
1 | +/** | ||
2 | + * Created by Acgpiano on 2016/9/19. | ||
3 | + */ | ||
4 | +var $ = require('yoho-jquery'), | ||
5 | + Swiper = require('yoho-swiper'), | ||
6 | + $receive = $('.main-right-receive'), | ||
7 | + $mask = $('.floor-mask'), | ||
8 | + $message = $('.floor-message'), | ||
9 | + $tooltip = $('.floor-tooltip'), | ||
10 | + tip = require('../plugin/tip'); | ||
11 | + | ||
12 | +var bannerSwiper; | ||
13 | + | ||
14 | +// 获取url中的参数 | ||
15 | +function getUrlParam(name) { | ||
16 | + | ||
17 | + // 构造一个含有目标参数的正则表达式对象 | ||
18 | + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); | ||
19 | + | ||
20 | + // 匹配目标参数 | ||
21 | + var r = window.location.search.substr(1).match(reg); | ||
22 | + | ||
23 | + // 返回参数值 | ||
24 | + if (r !== null) { | ||
25 | + return r[2]; | ||
26 | + } | ||
27 | + | ||
28 | + return null; | ||
29 | +} | ||
30 | + | ||
31 | +$receive.on('click', function() { | ||
32 | + var $curDom = $(this), | ||
33 | + req = ''; | ||
34 | + | ||
35 | + if (getUrlParam('app_version')) { | ||
36 | + req += '&app_version=' + getUrlParam('app_version'); | ||
37 | + } | ||
38 | + | ||
39 | + if (getUrlParam('uid')) { | ||
40 | + req += '&uid=' + getUrlParam('uid'); | ||
41 | + } | ||
42 | + | ||
43 | + $.ajax({ | ||
44 | + url: '//m.yohobuy.com/coupon/receiveCoupon?code=' + getUrlParam('code') + req, | ||
45 | + data: { | ||
46 | + couponID: $curDom.parents('.coupon-floor').attr('coupon-id') | ||
47 | + }, | ||
48 | + dataType: 'json', | ||
49 | + success: function(data) { | ||
50 | + var msg = data.msg, | ||
51 | + status = data.status, | ||
52 | + newUrl = data.url + '?code=' + getUrlParam('code'); | ||
53 | + | ||
54 | + | ||
55 | + if (data.isApp === true) { | ||
56 | + newUrl = data.url; | ||
57 | + } | ||
58 | + if (data.noLogin === true) { | ||
59 | + if ($('#intimacy-link').length <= 0) { | ||
60 | + $('body').append('<a href=\'' + newUrl + '\' style="display:none;" id="intimacy-link">' + | ||
61 | + '<span class="intimacy-link"></span></a>'); | ||
62 | + } | ||
63 | + | ||
64 | + $('.intimacy-link').click(); | ||
65 | + } else { | ||
66 | + if (status) { | ||
67 | + $curDom.hide(); | ||
68 | + $curDom.next().show(); | ||
69 | + $tooltip.show(); | ||
70 | + | ||
71 | + setTimeout(function() { | ||
72 | + $tooltip.hide(); | ||
73 | + }, 3000); | ||
74 | + } else { | ||
75 | + $message.find('.coupon-message-content').text(msg); | ||
76 | + $mask.show(); | ||
77 | + $message.show(); | ||
78 | + } | ||
79 | + } | ||
80 | + }, | ||
81 | + error: function() { | ||
82 | + tip.show('网络异常!'); | ||
83 | + } | ||
84 | + }); | ||
85 | +}); | ||
86 | + | ||
87 | +$('.coupon-floor a, .banner-top a').on('click', function() { | ||
88 | + if ($(this).attr('href').length <= 0 || $(this).attr('href') === '#') { | ||
89 | + return false; | ||
90 | + } | ||
91 | +}); | ||
92 | + | ||
93 | +if ($('.banner-swiper').find('li').length > 1) { | ||
94 | + bannerSwiper = new Swiper('.banner-swiper', { | ||
95 | + lazyLoading: true, | ||
96 | + lazyLoadingInPrevNext: true, | ||
97 | + loop: true, | ||
98 | + autoplay: 3000, | ||
99 | + autoplayDisableOnInteraction: false, | ||
100 | + paginationClickable: true, | ||
101 | + slideElement: 'li', | ||
102 | + pagination: '.banner-top .pagination-inner' | ||
103 | + }); | ||
104 | +} | ||
105 | + | ||
106 | +$('.coupon-message-op-rel').on('click', function() { | ||
107 | + location.reload(); | ||
108 | +}); | ||
109 | + | ||
110 | +if ($('#noData').length > 0) { | ||
111 | + if (location.href.indexOf('?openby:yohobuy=') <= 0) { | ||
112 | + tip.show('网络异常!'); | ||
113 | + } | ||
114 | +} | ||
115 | + | ||
116 | +$mask.on('click', function() { | ||
117 | + $mask.hide(); | ||
118 | + $message.hide(); | ||
119 | +}); | ||
120 | + |
@@ -8,7 +8,7 @@ var swiper = new Swiper('.tab .swiper-container', { | @@ -8,7 +8,7 @@ var swiper = new Swiper('.tab .swiper-container', { | ||
8 | lazyLoadingInPrevNext: true, | 8 | lazyLoadingInPrevNext: true, |
9 | paginationClickable: true, | 9 | paginationClickable: true, |
10 | loop: true, | 10 | loop: true, |
11 | - autoplay: 3000, | 11 | + autoplay: 3000 |
12 | }); | 12 | }); |
13 | 13 | ||
14 | require('lodash/commit'); | 14 | require('lodash/commit'); |
@@ -301,7 +301,7 @@ starIScroll.iScroll.on('scroll', function() { | @@ -301,7 +301,7 @@ starIScroll.iScroll.on('scroll', function() { | ||
301 | // } else { | 301 | // } else { |
302 | // $avatarClone.hide(); | 302 | // $avatarClone.hide(); |
303 | // } | 303 | // } |
304 | - }); | 304 | +}); |
305 | 305 | ||
306 | starIScroll.iScroll.on('scrollEnd', function() { | 306 | starIScroll.iScroll.on('scrollEnd', function() { |
307 | // $loadingTip.slideUp(); | 307 | // $loadingTip.slideUp(); |
@@ -110,7 +110,7 @@ page = { | @@ -110,7 +110,7 @@ page = { | ||
110 | 110 | ||
111 | $.get('/passport/sms_login/token.json', { | 111 | $.get('/passport/sms_login/token.json', { |
112 | area: area, | 112 | area: area, |
113 | - mobile: mobile, | 113 | + mobile: mobile |
114 | }) | 114 | }) |
115 | .done(function(res) { | 115 | .done(function(res) { |
116 | if (res.code === 200) { | 116 | if (res.code === 200) { |
@@ -3,12 +3,11 @@ | @@ -3,12 +3,11 @@ | ||
3 | overflow: hidden; | 3 | overflow: hidden; |
4 | } | 4 | } |
5 | 5 | ||
6 | -.just-img { | 6 | +.just-img{ |
7 | width: 100%; | 7 | width: 100%; |
8 | float: left; | 8 | float: left; |
9 | - margin: 0; | 9 | + margin:0; |
10 | } | 10 | } |
11 | - | ||
12 | .coupon-floor { | 11 | .coupon-floor { |
13 | float: left; | 12 | float: left; |
14 | width: 100%; | 13 | width: 100%; |
@@ -32,13 +31,11 @@ | @@ -32,13 +31,11 @@ | ||
32 | 31 | ||
33 | .main-left { | 32 | .main-left { |
34 | float: left; | 33 | float: left; |
35 | - width: 467px; | 34 | + width: 450px; |
36 | height: 160px; | 35 | height: 160px; |
37 | } | 36 | } |
38 | 37 | ||
39 | - .main-right-receive, | ||
40 | - .main-right-use, | ||
41 | - .main-right-go { | 38 | + .main-right-receive, .main-right-use, .main-right-go { |
42 | float: right; | 39 | float: right; |
43 | width: 113px; | 40 | width: 113px; |
44 | height: 160px; | 41 | height: 160px; |
@@ -56,13 +53,13 @@ | @@ -56,13 +53,13 @@ | ||
56 | display: inline-block; | 53 | display: inline-block; |
57 | width: 52px; | 54 | width: 52px; |
58 | height: 54px; | 55 | height: 54px; |
59 | - background-image: url("/channel/click-txt.png"); | 56 | + background-image: resolve('activity/click-txt.png'); |
60 | } | 57 | } |
61 | 58 | ||
62 | &.received { | 59 | &.received { |
63 | width: 113px; | 60 | width: 113px; |
64 | - height: 140px; | ||
65 | - background-image: url("/channel/received.png"); | 61 | + height: 132px; |
62 | + background-image: resolve('activity/received.png'); | ||
66 | position: absolute; | 63 | position: absolute; |
67 | top: 0; | 64 | top: 0; |
68 | right: 0; | 65 | right: 0; |
@@ -70,8 +67,8 @@ | @@ -70,8 +67,8 @@ | ||
70 | 67 | ||
71 | &.zero { | 68 | &.zero { |
72 | width: 111px; | 69 | width: 111px; |
73 | - height: 140px; | ||
74 | - background-image: url("/channel/zero.png"); | 70 | + height: 132px; |
71 | + background-image: resolve('activity/zero.png'); | ||
75 | position: absolute; | 72 | position: absolute; |
76 | top: 0; | 73 | top: 0; |
77 | right: 0; | 74 | right: 0; |
@@ -87,7 +84,7 @@ | @@ -87,7 +84,7 @@ | ||
87 | left: 0; | 84 | left: 0; |
88 | right: 0; | 85 | right: 0; |
89 | bottom: 0; | 86 | bottom: 0; |
90 | - background-color: rgba(0, 0, 0, 0.5); | 87 | + background-color: rgba(0, 0, 0, .5); |
91 | display: none; | 88 | display: none; |
92 | z-index: 9; | 89 | z-index: 9; |
93 | } | 90 | } |
@@ -101,7 +98,7 @@ | @@ -101,7 +98,7 @@ | ||
101 | margin-left: -275px; | 98 | margin-left: -275px; |
102 | margin-top: -125px; | 99 | margin-top: -125px; |
103 | z-index: 10; | 100 | z-index: 10; |
104 | - background-color: rgba(250, 250, 250, 0.92); | 101 | + background-color: rgba(250, 250, 250, .92); |
105 | display: none; | 102 | display: none; |
106 | border-radius: 10px; | 103 | border-radius: 10px; |
107 | 104 | ||
@@ -122,7 +119,7 @@ | @@ -122,7 +119,7 @@ | ||
122 | } | 119 | } |
123 | } | 120 | } |
124 | 121 | ||
125 | -.floor-tooltip { | 122 | +.floor-tooltip{ |
126 | position: fixed; | 123 | position: fixed; |
127 | top: 50%; | 124 | top: 50%; |
128 | left: 50%; | 125 | left: 50%; |
@@ -131,18 +128,18 @@ | @@ -131,18 +128,18 @@ | ||
131 | margin-left: -110px; | 128 | margin-left: -110px; |
132 | margin-top: -70px; | 129 | margin-top: -70px; |
133 | z-index: 11; | 130 | z-index: 11; |
134 | - background-color: rgba(60, 60, 60, 0.7); | 131 | + background-color: rgba(60, 60, 60, .7); |
135 | display: none; | 132 | display: none; |
136 | border-radius: 8px; | 133 | border-radius: 8px; |
137 | color: #fff; | 134 | color: #fff; |
138 | 135 | ||
139 | - .icon-box { | 136 | + .icon-box{ |
140 | height: 84px; | 137 | height: 84px; |
141 | line-height: 84px; | 138 | line-height: 84px; |
142 | text-align: center; | 139 | text-align: center; |
143 | } | 140 | } |
144 | 141 | ||
145 | - .icon-msg { | 142 | + .icon-msg{ |
146 | height: 56px; | 143 | height: 56px; |
147 | text-align: center; | 144 | text-align: center; |
148 | } | 145 | } |
@@ -20,7 +20,6 @@ | @@ -20,7 +20,6 @@ | ||
20 | @import "thumb-row"; | 20 | @import "thumb-row"; |
21 | @import "notice"; | 21 | @import "notice"; |
22 | @import "fresh-only"; | 22 | @import "fresh-only"; |
23 | -@import "coupon"; | ||
24 | @import "discount-list"; | 23 | @import "discount-list"; |
25 | @import "left-right"; | 24 | @import "left-right"; |
26 | @import "cate"; | 25 | @import "cate"; |
-
Please register or login to post a comment