Showing
6 changed files
with
0 additions
and
320 deletions
apps/home/controllers/coupons.js
deleted
100644 → 0
1 | -// 优惠券 by acgpiano | ||
2 | -'use strict'; | ||
3 | -const headerModel = require('../../../doraemon/models/header'), // 头部model | ||
4 | - model = require('../models/coupons'); | ||
5 | - | ||
6 | -// status为使用状态 | ||
7 | -const index = (req, res, next) => { | ||
8 | - req.ctx(model).couponData({ | ||
9 | - method: 'app.coupons.li', | ||
10 | - uid: req.user.uid, | ||
11 | - status: req.body.status || 0, | ||
12 | - page: req.body.page || 1, | ||
13 | - limit: 10, | ||
14 | - }).then(result => { | ||
15 | - let options = { | ||
16 | - module: 'home', | ||
17 | - page: 'coupons', | ||
18 | - pageHeader: headerModel.setNav({ | ||
19 | - navTitle: '优惠券' | ||
20 | - }), | ||
21 | - title: '优惠券', | ||
22 | - pageFooter: true, | ||
23 | - list: result, | ||
24 | - localCss: true | ||
25 | - }; | ||
26 | - | ||
27 | - res.render('coupons', options); | ||
28 | - }).catch(next); | ||
29 | -}; | ||
30 | - | ||
31 | -const couponsAjax = (req, res, next) => { | ||
32 | - req.ctx(model).couponData({ | ||
33 | - method: 'app.coupons.li', | ||
34 | - uid: req.user.uid, | ||
35 | - status: parseInt(req.body.status || 0, 10), | ||
36 | - page: parseInt(req.body.page || 1, 10), | ||
37 | - limit: 10, | ||
38 | - }).then(result => { | ||
39 | - res.json(result); | ||
40 | - }).catch(next); | ||
41 | -}; | ||
42 | - | ||
43 | -module.exports = { | ||
44 | - index, | ||
45 | - couponsAjax | ||
46 | -}; |
apps/home/models/coupons.js
deleted
100644 → 0
1 | -// 优惠券 by acgpiano | ||
2 | -'use strict'; | ||
3 | - | ||
4 | -const helpers = global.yoho.helpers; | ||
5 | - | ||
6 | -class couponsModel extends global.yoho.BaseModel { | ||
7 | - constructor(ctx) { | ||
8 | - super(ctx); | ||
9 | - } | ||
10 | - | ||
11 | - couponData(params) { | ||
12 | - return this.get({data: params}).then(result => { | ||
13 | - | ||
14 | - if (result && result.data && result.data.couponList) { | ||
15 | - let status0 = params.status === 0; | ||
16 | - let status1 = params.status === 1; | ||
17 | - | ||
18 | - return result.data.couponList.map(function(elem) { | ||
19 | - delete elem.id; | ||
20 | - | ||
21 | - if (status0) { | ||
22 | - elem.bestowLink = helpers.urlFormat('/product/index/index', | ||
23 | - { | ||
24 | - coupon_id: elem.couponId, | ||
25 | - coupon_code: elem.couponCode, | ||
26 | - title: '优惠活动商品', | ||
27 | - intro_text: `以下商品可使用【${elem.couponDetailInfomation}】优惠券` | ||
28 | - } | ||
29 | - ); | ||
30 | - } else if (status1) { | ||
31 | - delete elem.overState; | ||
32 | - elem.employbg = true; | ||
33 | - } | ||
34 | - return elem; | ||
35 | - }); | ||
36 | - } | ||
37 | - | ||
38 | - return []; | ||
39 | - }); | ||
40 | - } | ||
41 | -} | ||
42 | - | ||
43 | -module.exports = couponsModel; |
apps/home/views/action/coupons.hbs
deleted
100644 → 0
1 | -<div class="yoho-page my-coupon-page"> | ||
2 | - <div class="coupon-tab"> | ||
3 | - <ul> | ||
4 | - <li class="activate">未使用</li> | ||
5 | - <li>已使用</li> | ||
6 | - </ul> | ||
7 | - </div> | ||
8 | - | ||
9 | - {{!--coupon-list start--}} | ||
10 | - <div class="coupon-list coupon-tab1"> | ||
11 | - {{#each list}} | ||
12 | - <div class="coupon-group{{#isEqualOr couponType '5'}} usable-frees{{/isEqualOr}}" data-coupon-id={{couponId}}> | ||
13 | - <div class="coupon-header">{{couponDetailInfomation}}</div> | ||
14 | - <div class="coupon-content"> | ||
15 | - <div class="coupon-content-group1"> | ||
16 | - <p class="coupon-money">{{couponValue}}</p> | ||
17 | - <p>{{rule4ShortName}}</p> | ||
18 | - </div> | ||
19 | - <div class="coupon-content-group2"> | ||
20 | - <div class="coupon-content-group2-table"> | ||
21 | - <div> | ||
22 | - {{couponValidity}} | ||
23 | - {{#if overState}}<span class="coupon-soon-expire">({{overState}})</span>{{/if}} | ||
24 | - </div> | ||
25 | - <div> | ||
26 | - <div class="left down info-btn">详细信息<i class="iconfont"></i></div> | ||
27 | - <div class="right"> | ||
28 | - {{#if employbg}} | ||
29 | - <span class="employ"></span> | ||
30 | - {{else if bestowLink}} | ||
31 | - <a href="javascript:void(0);" data-link="{{bestowLink}}" class="btn">立即使用</a> | ||
32 | - {{/if}} | ||
33 | - </div> | ||
34 | - </div> | ||
35 | - </div> | ||
36 | - </div> | ||
37 | - </div> | ||
38 | - <div class="coupon-footer hide"> | ||
39 | - {{#notes}} | ||
40 | - <p>{{.}}</p> | ||
41 | - {{/notes}} | ||
42 | - </div> | ||
43 | - </div> | ||
44 | - {{/each}} | ||
45 | - </div> | ||
46 | - {{!--coupon-list end--}} | ||
47 | - <div class="coupon-list coupon-tab2"></div> | ||
48 | - <div class="coupon-list coupon-tab3"></div> | ||
49 | -</div> | ||
50 | -<input type="hidden" id="no-download"> |
public/hbs/home/coupons-list.hbs
deleted
100644 → 0
1 | -{{#each list}} | ||
2 | - <div class="coupon-group{{#is-equal-or couponType '5'}} usable-frees{{/is-equal-or}}" data-coupon-id={{couponId}}> | ||
3 | - <div class="coupon-header">{{couponDetailInfomation}}</div> | ||
4 | - <div class="coupon-content"> | ||
5 | - <div class="coupon-content-group1"> | ||
6 | - <p class="coupon-money">{{couponValue}}</p> | ||
7 | - <p>{{rule4ShortName}}</p> | ||
8 | - </div> | ||
9 | - <div class="coupon-content-group2"> | ||
10 | - <div class="coupon-content-group2-table"> | ||
11 | - <div> | ||
12 | - {{couponValidity}} | ||
13 | - {{#if overState}}<span class="coupon-soon-expire">({{overState}})</span>{{/if}} | ||
14 | - </div> | ||
15 | - <div> | ||
16 | - <div class="left down info-btn">详细信息<i class="iconfont"></i></div> | ||
17 | - <div class="right"> | ||
18 | - {{#if employbg}} | ||
19 | - <span class="employ"></span> | ||
20 | - {{else if bestowLink}} | ||
21 | - <a href="javascript:void(0);" data-link="{{bestowLink}}" class="btn">立即使用</a> | ||
22 | - {{/if}} | ||
23 | - </div> | ||
24 | - </div> | ||
25 | - </div> | ||
26 | - </div> | ||
27 | - </div> | ||
28 | - <div class="coupon-footer hide"> | ||
29 | - {{#notes}} | ||
30 | - <p>{{.}}</p> | ||
31 | - {{/notes}} | ||
32 | - </div> | ||
33 | - </div> | ||
34 | -{{/each}} |
public/js/home/coupons.page.js
deleted
100644 → 0
1 | -// 不要使用es6 | ||
2 | -'use strict'; | ||
3 | - | ||
4 | -require('home/coupons.page.css'); | ||
5 | -require('common'); | ||
6 | - | ||
7 | -let $ = require('yoho-jquery'), | ||
8 | - couponsListHbs = require('home/coupons-list.hbs'), | ||
9 | - notResultHbs = require('home/coupon-not-result.hbs'); | ||
10 | - | ||
11 | -let $couponTab1 = $('.coupon-tab1'), | ||
12 | - $couponTab2 = $('.coupon-tab2'), | ||
13 | - $couponTab3 = $('.coupon-tab3'), | ||
14 | - $couponUl = $('.coupon-tab'), | ||
15 | - page = 1, | ||
16 | - indexNum, | ||
17 | - couponFun, | ||
18 | - scrollHandler, | ||
19 | - $tabDom; | ||
20 | - | ||
21 | -$('body').css({'background-color': '#f2f2f2'}); | ||
22 | - | ||
23 | -couponFun = function() { | ||
24 | - $tabDom = $couponUl.find('li.activate'); | ||
25 | - | ||
26 | - if (!$tabDom) { | ||
27 | - return false; | ||
28 | - } | ||
29 | - | ||
30 | - if ($tabDom.data('AjaxFlag')) { | ||
31 | - return false; | ||
32 | - } | ||
33 | - | ||
34 | - $tabDom.data('AjaxFlag', true); | ||
35 | - page = $tabDom.data('page') || 1; | ||
36 | - indexNum = $tabDom.index() * 1; | ||
37 | - | ||
38 | - // 首屏渲染page = 2 | ||
39 | - if (indexNum === 0 && !$tabDom.data('page')) { | ||
40 | - page = 2; | ||
41 | - } | ||
42 | - | ||
43 | - $.ajax({ | ||
44 | - type: 'POST', | ||
45 | - url: '/home/couponsAjax', | ||
46 | - dataType: 'json', | ||
47 | - data: { | ||
48 | - status: indexNum, | ||
49 | - page: page | ||
50 | - }, | ||
51 | - success: function(data) { | ||
52 | - let $activeDom; | ||
53 | - | ||
54 | - if (indexNum === 1) { | ||
55 | - $activeDom = $couponTab2; | ||
56 | - } else if (indexNum === 2) { | ||
57 | - $activeDom = $couponTab3; | ||
58 | - } else { | ||
59 | - $activeDom = $couponTab1; | ||
60 | - } | ||
61 | - | ||
62 | - if (page <= 1 && data.length <= 0) { | ||
63 | - $activeDom.html(notResultHbs()); | ||
64 | - return false; | ||
65 | - } | ||
66 | - | ||
67 | - if (data.length <= 0) { | ||
68 | - return false; | ||
69 | - } | ||
70 | - | ||
71 | - $tabDom.data('page', ++page); | ||
72 | - $tabDom.data('AjaxFlag', false); | ||
73 | - $activeDom.append(couponsListHbs({list: data})); | ||
74 | - window.rePosFooter(); // 重新计算底部位置 | ||
75 | - } | ||
76 | - }); | ||
77 | -}; | ||
78 | - | ||
79 | -scrollHandler = function() { | ||
80 | - if ($(window).scrollTop() + $(window).height() > $('body').height() - 100) { | ||
81 | - couponFun(); | ||
82 | - return; | ||
83 | - } | ||
84 | -}; | ||
85 | - | ||
86 | -$(window).scroll(function() { | ||
87 | - window.requestAnimationFrame(scrollHandler); | ||
88 | -}); | ||
89 | - | ||
90 | -// tab 事件 | ||
91 | -$couponUl.on('click', 'li', function() { | ||
92 | - $(this).addClass('activate').siblings().removeClass('activate'); | ||
93 | - $('.coupon-list').addClass('hide').eq($(this).index()).removeClass('hide'); | ||
94 | - couponFun(); | ||
95 | - window.rePosFooter(); // 重新计算底部位置 | ||
96 | -}); | ||
97 | - | ||
98 | -// 详细信息事件 | ||
99 | -$('.coupon-list').on('click', '.info-btn', function() { | ||
100 | - let $this = $(this); | ||
101 | - | ||
102 | - if ($this.hasClass('down')) { | ||
103 | - $this.removeClass('down').addClass('up'); | ||
104 | - $this.closest('.coupon-group').find('.coupon-footer').removeClass('hide'); | ||
105 | - } else { | ||
106 | - $this.removeClass('up').addClass('down'); | ||
107 | - $this.closest('.coupon-group').find('.coupon-footer').addClass('hide'); | ||
108 | - } | ||
109 | - | ||
110 | - // 优惠券埋点 | ||
111 | - window._yas && window._yas.sendCustomInfo && window._yas.sendCustomInfo({ | ||
112 | - op: 'YB_COUPON_DETAIL_C', | ||
113 | - param: JSON.stringify({ | ||
114 | - C_ID: window._ChannelVary[window.cookie('_Channel')] || 1, | ||
115 | - COUPON_ID: $this.closest('.coupon-group').data('coupon-id') | ||
116 | - }) | ||
117 | - }, true); | ||
118 | - | ||
119 | - window.rePosFooter(); // 重新计算底部位置 | ||
120 | -}); | ||
121 | - | ||
122 | -// 立即使用 | ||
123 | -$('.coupon-list').on('click', 'a.btn', function() { | ||
124 | - let $this = $(this); | ||
125 | - | ||
126 | - // 优惠券埋点 | ||
127 | - window._yas && window._yas.sendCustomInfo && window._yas.sendCustomInfo({ | ||
128 | - op: 'YB_COUPON_IMMEDIATE_USE_C', | ||
129 | - param: JSON.stringify({ | ||
130 | - C_ID: window._ChannelVary[window.cookie('_Channel')] || 1, | ||
131 | - COUPON_ID: $this.closest('.coupon-group').data('coupon-id') | ||
132 | - }) | ||
133 | - }, true); | ||
134 | - | ||
135 | - document.location.href = $this.data('link'); | ||
136 | -}); | ||
137 | - | ||
138 | -// 首屏渲染无结果判断 | ||
139 | -if ($('.coupon-tab1').find('.coupon-group').length <= 0) { | ||
140 | - $('.coupon-tab1').html(notResultHbs()); | ||
141 | - window.rePosFooter(); // 重新计算底部位置 | ||
142 | -} |
-
Please register or login to post a comment