Authored by zhangxiaoru

yohocoin

  1 +'use strict';
  2 +const headerModel = require('../../../doraemon/models/header'); // 头部model
  3 +
  4 +const index = (req, res) => {
  5 + res.render('coupons', {
  6 + module: 'home',
  7 + page: 'coupons',
  8 + pageHeader: headerModel.setNav({
  9 + navTitle: '优惠券'
  10 + }),
  11 + title: '优惠券',
  12 + pageFooter: true,
  13 + });
  14 +};
  15 +
  16 +const couponData = (req, res) => {
  17 +};
  18 +
  19 +module.exports = {
  20 + index,
  21 + couponData
  22 +};
@@ -92,21 +92,28 @@ exports.record = (req, res) => { @@ -92,21 +92,28 @@ exports.record = (req, res) => {
92 }; 92 };
93 93
94 exports.recordContent = (req, res, next) => { 94 exports.recordContent = (req, res, next) => {
95 - let uid = req.user.uid || 6228593; // TODO 95 + let uid = req.user.uid;
96 96
97 let udid = req.user.udid; 97 let udid = req.user.udid;
98 98
99 let page = req.query.page || 1; 99 let page = req.query.page || 1;
100 100
101 - let limit = 10; 101 + let limit = 30;
102 102
103 indexModel.recordContent(uid, udid, page, limit).then((result) => { 103 indexModel.recordContent(uid, udid, page, limit).then((result) => {
104 - res.render('browse-record-content', result); 104 +
  105 + if (result.browseRecord && result.browseRecord.length === 0) {
  106 + res.json(false);
  107 + } else {
  108 + res.render('browse-record-content', Object.assign({
  109 + layout: false
  110 + }, result));
  111 + }
105 }).catch(next); 112 }).catch(next);
106 }; 113 };
107 114
108 exports.delRecord = (req, res, next) => { 115 exports.delRecord = (req, res, next) => {
109 - let uid = req.user.uid || 6228593; // TODO 116 + let uid = req.user.uid;
110 117
111 let skn = req.user.skn || 0; 118 let skn = req.user.skn || 0;
112 119
@@ -154,47 +154,49 @@ const recordContent = (uid, udid, page, limit) => { @@ -154,47 +154,49 @@ const recordContent = (uid, udid, page, limit) => {
154 154
155 return api.get('', { 155 return api.get('', {
156 method: 'app.browse.product', 156 method: 'app.browse.product',
157 - uid: uid || 6228593, // TODO 157 + uid: uid,
158 limit: limit, 158 limit: limit,
159 page: page 159 page: page
160 }, {code: 200}).then((result) => { 160 }, {code: 200}).then((result) => {
161 161
162 - let resu = {  
163 - browseRecord: []  
164 - }; 162 + let resu = {};
165 163
166 if (result && result.code === 200) { 164 if (result && result.code === 200) {
  165 +
167 let list = result; 166 let list = result;
168 167
169 - // 不能再查到结果了  
170 - if (page > 1 && list === []) { 168 + if (!result || page === '1' && result.data.total === 0) {
  169 + resu.walkwayUrl = helpers.urlFormat('/product/new');
171 resu.noRecord = true; 170 resu.noRecord = true;
172 - }  
173 171
174 - if (result.data.total === 0) {  
175 - resu.total = 0; 172 + return resu;
176 } 173 }
177 174
178 -  
179 - _.forEach(list.data.product_list, function(val) {  
180 - let obj = {  
181 - productList: [] 175 + if (list.data && list.data.product_list) {
  176 + resu = {
  177 + browseRecord: []
182 }; 178 };
183 179
184 -  
185 - obj = _.assign(obj, {  
186 - product_name: val.product_name,  
187 - product_skn: val.product_skn,  
188 - storage: val.storage,  
189 - image: val.image,  
190 - link: '/product/show_' + val.product_skn + '.html',  
191 - sales_price: val.sales_price,  
192 - market_price: (val.market_price - val.sales_price) > 0 ? val.market_price : false,  
193 - invalidGoods: val.status === 0 180 + _.forEach(list.data.product_list, function(val) {
  181 + let obj = {
  182 + productList: []
  183 + };
  184 +
  185 + obj = _.assign(obj, {
  186 + product_name: val.product_name,
  187 + product_skn: val.product_skn,
  188 + storage: val.storage,
  189 + image: val.image,
  190 + link: '/product/show_' + val.product_skn + '.html',
  191 + sales_price: val.sales_price,
  192 + market_price: (val.market_price - val.sales_price) > 0 ? val.market_price : false,
  193 + invalidGoods: val.status === 0
  194 + });
  195 +
  196 + resu.browseRecord.push(obj);
194 }); 197 });
  198 + }
195 199
196 - resu.browseRecord.push(obj);  
197 - });  
198 return resu; 200 return resu;
199 } 201 }
200 }); 202 });
@@ -17,6 +17,7 @@ const favorite = require(`${cRoot}/favorite`); @@ -17,6 +17,7 @@ const favorite = require(`${cRoot}/favorite`);
17 const orderController = require(`${cRoot}/order`); 17 const orderController = require(`${cRoot}/order`);
18 const orderDetailController = require(`${cRoot}/orderDetail`); 18 const orderDetailController = require(`${cRoot}/orderDetail`);
19 const currencyController = require(`${cRoot}/myCurrency`); 19 const currencyController = require(`${cRoot}/myCurrency`);
  20 +const coupons = require(`${cRoot}/coupons`);
20 21
21 // const myDetail = require(`${cRoot}/myDetail); 22 // const myDetail = require(`${cRoot}/myDetail);
22 23
@@ -63,4 +64,8 @@ router.get('/favBrand', favorite.favfavBrand); @@ -63,4 +64,8 @@ router.get('/favBrand', favorite.favfavBrand);
63 // 取消收藏 64 // 取消收藏
64 router.post('/favoriteDel', favorite.favoriteDelete); 65 router.post('/favoriteDel', favorite.favoriteDelete);
65 66
  67 +// 优惠券
  68 +router.get('/coupons', coupons.index);
  69 +router.post('/couponData', coupons.couponData);
  70 +
66 module.exports = router; 71 module.exports = router;
  1 +<div class="yoho-page my-coupon-page">
  2 + <div class="employ">
  3 + <span class="active">未使用</span>
  4 + <span>已使用</span>
  5 + </div>
  6 + <div id="employ" class="coupon-list"></div>
  7 +</div>
@@ -45,9 +45,8 @@ function moreRecord(cb) { @@ -45,9 +45,8 @@ function moreRecord(cb) {
45 page: page + 1 45 page: page + 1
46 }, 46 },
47 success: function(data) { 47 success: function(data) {
48 - if (data === ' ') { 48 + if (!data) {
49 end = true; 49 end = true;
50 -  
51 $more.addClass('hide'); 50 $more.addClass('hide');
52 $noMore.removeClass('hide'); 51 $noMore.removeClass('hide');
53 } else { 52 } else {
  1 +var $ = require('yoho-jquery'),
  2 + Hammer = require('yoho-hammer'),
  3 + ellipsis = require('yoho-mlellipsis'),
  4 + loading = require('../plugin/loading');
  5 +
  6 +var employ,
  7 + statu = 0,
  8 + page = 1;
  9 +
  10 +ellipsis.init();
  11 +
  12 +function couponAJAX(statu, page) {
  13 + return;
  14 + loading.showLoadingMask();
  15 + $.ajax({
  16 + type: 'POST',
  17 + url: '/home/couponData',
  18 + dataType: 'html',
  19 + data: {
  20 + status: statu,
  21 + page: page
  22 + },
  23 + success: function(data) {
  24 + $('#employ').append(data);
  25 + window.rePosFooter();
  26 + loading.hideLoadingMask();
  27 + }
  28 + });
  29 +}
  30 +
  31 +$('.yoho-footer').css('border-top', '1px solid #e0e0e0');
  32 +$('.employ span').each(function(index) {
  33 + employ = new Hammer($('.employ span')[index]);
  34 + employ.on('tap', function(e) {
  35 + $('.employ span').removeClass('active').eq(index).addClass('active');
  36 + $('#employ').html(' ');
  37 + statu = index;
  38 + page = 1;
  39 + couponAJAX(statu, page);
  40 + window.rePosFooter();
  41 + });
  42 +});
  43 +
  44 +
  45 +function scrollHandler() {
  46 + if ($(window).scrollTop() + $(window).height() > $('body').height() - 100) {
  47 + page++;
  48 + couponAJAX(statu, page);
  49 + return;
  50 + }
  51 +}
  52 +
  53 +$(window).scroll(function() {
  54 + window.requestAnimationFrame(scrollHandler);
  55 +});
  56 +
  57 +couponAJAX(statu, page);
@@ -2,3 +2,4 @@ @@ -2,3 +2,4 @@
2 @import "favorite"; 2 @import "favorite";
3 @import "address/index"; 3 @import "address/index";
4 @import "favorite"; 4 @import "favorite";
  5 +@import "coupons";
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 35
36 .sale-price { 36 .sale-price {
37 color: #f00; 37 color: #f00;
38 - 38 +
39 &.original-price { 39 &.original-price {
40 color: #000; 40 color: #000;
41 } 41 }
@@ -80,13 +80,13 @@ @@ -80,13 +80,13 @@
80 background: #fff; 80 background: #fff;
81 text-align: center; 81 text-align: center;
82 top: 50%; 82 top: 50%;
83 - margin-top: -220px; 83 + margin-top: 200px;
84 width: 100%; 84 width: 100%;
85 85
86 .icon { 86 .icon {
87 width: 196px; 87 width: 196px;
88 height: 207px; 88 height: 207px;
89 - background: resolve('me/no-record.png') no-repeat; 89 + background: resolve("me/no-record.png") no-repeat;
90 background-size: 100%; 90 background-size: 100%;
91 margin: 0 auto; 91 margin: 0 auto;
92 } 92 }
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 @import "vip-grade"; 2 @import "vip-grade";
3 @import "order"; 3 @import "order";
4 @import "order-detail"; 4 @import "order-detail";
5 -@import "coupons";  
6 @import "personal-details"; 5 @import "personal-details";
7 @import "yoho-coin"; 6 @import "yoho-coin";
8 @import "fav"; 7 @import "fav";