Authored by yyq

Merge branch 'feature/giftCart' of git.yoho.cn:fe/yohobuy-node into feature/giftCart

@@ -31,15 +31,19 @@ module.exports = class extends global.yoho.BaseModel { @@ -31,15 +31,19 @@ module.exports = class extends global.yoho.BaseModel {
31 * @param {[type]} limit [页大小] 31 * @param {[type]} limit [页大小]
32 * @return {[type]} [{}] 32 * @return {[type]} [{}]
33 */ 33 */
34 - consumeList(cardCode, uid, page, limit) { 34 + consumeList(params, uid) {
35 let options = { 35 let options = {
36 method: 'app.giftcard.consumelist', 36 method: 'app.giftcard.consumelist',
37 - cardCode: cardCode, 37 + cardCode: params.cardCode,
38 uid: uid, 38 uid: uid,
39 - page: page,  
40 - limit: limit || 10 39 + page: params.page,
  40 + limit: params.limit || 10
41 }; 41 };
42 42
  43 + if (params.type) {
  44 + options.type = params.type;
  45 + }
  46 +
43 return this.get({data: options}); 47 return this.get({data: options});
44 } 48 }
45 49
@@ -70,9 +70,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -70,9 +70,7 @@ module.exports = class extends global.yoho.BaseModel {
70 count: _.get(rlist[0], 'data.total', 0), 70 count: _.get(rlist[0], 'data.total', 0),
71 curPage: params.page, 71 curPage: params.page,
72 totalPages: _.get(rlist[0], 'data.pageSize', 0) 72 totalPages: _.get(rlist[0], 'data.pageSize', 0)
73 - }, setPager(_.get(rlist[0], 'data.pageSize', 0), {  
74 - page: params.page  
75 - })); 73 + }, setPager(_.get(rlist[0], 'data.pageSize', 0), params));
76 74
77 return { 75 return {
78 giftData: giftData, 76 giftData: giftData,
@@ -84,9 +82,12 @@ module.exports = class extends global.yoho.BaseModel { @@ -84,9 +82,12 @@ module.exports = class extends global.yoho.BaseModel {
84 82
85 // 获取礼品卡消费记录 83 // 获取礼品卡消费记录
86 consumeList(params, uid) { 84 consumeList(params, uid) {
  85 + let types = ['类型', '消费', '退款'];
  86 +
87 params.page = Number(params.page) || 1; 87 params.page = Number(params.page) || 1;
  88 + params.type = Number(params.type) || 0;
88 89
89 - return this.meGiftAPi.consumeList(params.cardCode, uid, params.page, params.limit).then(rlist => { 90 + return this.meGiftAPi.consumeList(params, uid).then(rlist => {
90 let giftData = {}; 91 let giftData = {};
91 92
92 giftData.data = _.get(rlist, 'data', {}); 93 giftData.data = _.get(rlist, 'data', {});
@@ -94,9 +95,8 @@ module.exports = class extends global.yoho.BaseModel { @@ -94,9 +95,8 @@ module.exports = class extends global.yoho.BaseModel {
94 count: _.get(rlist, 'data.total', 0), 95 count: _.get(rlist, 'data.total', 0),
95 curPage: params.page, 96 curPage: params.page,
96 totalPages: _.get(rlist, 'data.pageSize', 0) 97 totalPages: _.get(rlist, 'data.pageSize', 0)
97 - }, setPager(_.get(rlist, 'data.pageSize', 0), {  
98 - page: params.page  
99 - })); 98 + }, setPager(_.get(rlist, 'data.pageSize', 0), params));
  99 + _.set(giftData, 'data.types', types[params.type] || types[0]);
100 100
101 return giftData; 101 return giftData;
102 }); 102 });
@@ -136,7 +136,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -136,7 +136,7 @@ module.exports = class extends global.yoho.BaseModel {
136 return this.meGiftAPi.verifyEmail(params.code, uid); 136 return this.meGiftAPi.verifyEmail(params.code, uid);
137 } 137 }
138 138
139 - // 发验证码 139 + // 发验手机证码
140 smsBind(params) { 140 smsBind(params) {
141 return this.meGiftAPi.checkIsCanBind(params.area, params.mobile).then(res => { 141 return this.meGiftAPi.checkIsCanBind(params.area, params.mobile).then(res => {
142 if (_.get(res, 'data.isCanBind') === 'N') { 142 if (_.get(res, 'data.isCanBind') === 'N') {
1 {{# data}} 1 {{# data}}
2 - <table class="info-gift-header"> 2 + <table class="info-gift-header" data-card-code={{cardCode}}>
3 <tr> 3 <tr>
4 <td class="text-left">卡号:{{cardCode}}</td> 4 <td class="text-left">卡号:{{cardCode}}</td>
5 <td>状态:{{statusStr}}</td> 5 <td>状态:{{statusStr}}</td>
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 <div>订单编号</div> 16 <div>订单编号</div>
17 <div> 17 <div>
18 <span class="gift-filter"> 18 <span class="gift-filter">
19 - <em class="gift-type">类型</em> 19 + <em class="gift-type">{{types}}</em>
20 <ul class="ul-list"> 20 <ul class="ul-list">
21 <li data-cc="1">消费</li> 21 <li data-cc="1">消费</li>
22 <li data-cc="2">退款</li> 22 <li data-cc="2">退款</li>
@@ -28,15 +28,16 @@ @@ -28,15 +28,16 @@
28 {{#if giftCardConsumeInfoBOList}} 28 {{#if giftCardConsumeInfoBOList}}
29 {{# giftCardConsumeInfoBOList}} 29 {{# giftCardConsumeInfoBOList}}
30 <div class="me-gift-tr"> 30 <div class="me-gift-tr">
31 - <div>{{createTime}}</div> 31 + <div>{{dateFormat 'YYYY-MM-DD HH:mm' createTime}}</div>
32 <div>{{orderCode}}</div> 32 <div>{{orderCode}}</div>
33 - {{#if type}} 33 + {{#isEqual type 1}}
34 <div class="consume">消费</div> 34 <div class="consume">消费</div>
35 - <div class="consume">-{{changeAmount}}</div>  
36 - {{else if type}} 35 + <div class="consume">-{{../changeAmount}}</div>
  36 + {{/isEqual}}
  37 + {{#isEqual type 2}}
37 <div class="refund">退款</div> 38 <div class="refund">退款</div>
38 - <div class="refund">+{{changeAmount}}</div>  
39 - {{/if}} 39 + <div class="refund">+{{../changeAmount}}</div>
  40 + {{/isEqual}}
40 </div> 41 </div>
41 {{/giftCardConsumeInfoBOList}} 42 {{/giftCardConsumeInfoBOList}}
42 {{^}} 43 {{^}}
@@ -24,8 +24,8 @@ @@ -24,8 +24,8 @@
24 <div>{{cardCode}}</div> 24 <div>{{cardCode}}</div>
25 <div>{{amount}}</div> 25 <div>{{amount}}</div>
26 <div>{{remainAmount}}</div> 26 <div>{{remainAmount}}</div>
27 - <div>{{activateTime}}</div>  
28 - <div>{{endTime}}</div> 27 + <div>{{dateFormat 'YYYY-MM-DD HH:mm' activateTime}}</div>
  28 + <div>{{dateFormat 'YYYY-MM-DD HH:mm' endTime}}</div>
29 <div class="info-list">消费明细</div> 29 <div class="info-list">消费明细</div>
30 </div> 30 </div>
31 {{/giftData.data}} 31 {{/giftData.data}}
@@ -65,18 +65,18 @@ @@ -65,18 +65,18 @@
65 <em>+86</em> 65 <em>+86</em>
66 <i class="iconfont">&#xe60b;</i> 66 <i class="iconfont">&#xe60b;</i>
67 <ul class="ul-list mobile-area-list"> 67 <ul class="ul-list mobile-area-list">
  68 + <li data-cc="+86">中国 +86</li>
  69 + <li data-cc="+853">中国澳门 +853</li>
  70 + <li data-cc="+886">中国台湾 +886</li>
  71 + <li data-cc="+852">中国香港 +852</li>
  72 + <li data-cc="+1">美国 +1</li>
68 <li data-cc="+61">澳大利亚 +61</li> 73 <li data-cc="+61">澳大利亚 +61</li>
69 <li data-cc="+82">韩国 +82</li> 74 <li data-cc="+82">韩国 +82</li>
70 <li data-cc="+1">加拿大 +1</li> 75 <li data-cc="+1">加拿大 +1</li>
71 <li data-cc="+60">马来西亚 +60</li> 76 <li data-cc="+60">马来西亚 +60</li>
72 - <li data-cc="+1">美国 +1</li>  
73 <li data-cc="+81">日本 +81</li> 77 <li data-cc="+81">日本 +81</li>
74 <li data-cc="+65">新加坡 +65</li> 78 <li data-cc="+65">新加坡 +65</li>
75 <li data-cc="+44">英国 +44</li> 79 <li data-cc="+44">英国 +44</li>
76 - <li data-cc="+86" selected="">中国 +86</li>  
77 - <li data-cc="+853">中国澳门 +853</li>  
78 - <li data-cc="+886">中国台湾 +886</li>  
79 - <li data-cc="+852">中国香港 +852</li>  
80 </ul> 80 </ul>
81 </span> 81 </span>
82 <input type="text" placeholder="请输入手机号" class="right mobile" /> 82 <input type="text" placeholder="请输入手机号" class="right mobile" />
@@ -38,15 +38,10 @@ meGift = { @@ -38,15 +38,10 @@ meGift = {
38 if (that.isBinMobile) { 38 if (that.isBinMobile) {
39 that.activateGift(); 39 that.activateGift();
40 } else { 40 } else {
41 - that.getMobileCode(); 41 + that.verifyEmailCode();
42 } 42 }
43 }); 43 });
44 44
45 - // 消费明细  
46 - $('.me-gift-table').on('click', '.info-list', function() {  
47 - that.infoList($(this).closest('.me-gift-tr').data('card-code'));  
48 - });  
49 -  
50 // 显示手机区号或类型下拉列表 45 // 显示手机区号或类型下拉列表
51 $('body').on('click', '.mobile-area,.gift-filter', function() { 46 $('body').on('click', '.mobile-area,.gift-filter', function() {
52 $(this).find('.ul-list').toggle(); 47 $(this).find('.ul-list').toggle();
@@ -59,11 +54,38 @@ meGift = { @@ -59,11 +54,38 @@ meGift = {
59 $('.mobile-area').find('em').text($li.data('cc')); 54 $('.mobile-area').find('em').text($li.data('cc'));
60 }); 55 });
61 56
62 - // 选择类型筛选 57 + // 消费明细
  58 + $('.me-gift-table').on('click', '.info-list', function() {
  59 +
  60 + new dialog.Dialog({
  61 + content: that.detailGiftTpl({}),
  62 + className: 'me-page me-gift-page me-gift-confirm'
  63 + }).show();
  64 +
  65 + that.infoList('?' + $.param({
  66 + cardCode: $(this).closest('.me-gift-tr').data('card-code')
  67 + }));
  68 + });
  69 +
  70 + // 消费明细-选择类型筛选
63 $('body').on('click', '.gift-filter ul', function(event) { 71 $('body').on('click', '.gift-filter ul', function(event) {
64 var $li = $(event.target).closest('li'); 72 var $li = $(event.target).closest('li');
65 73
66 $('.gift-filter').find('em').text($li.text()); 74 $('.gift-filter').find('em').text($li.text());
  75 + that.infoList('?' + $.param({
  76 + cardCode: $('.info-gift-header').data('card-code'),
  77 + type: $li.data('cc')
  78 + }));
  79 + });
  80 +
  81 + // 消费明细翻页
  82 + $('body').on('click', '.detail-gift-content .pager a', function() {
  83 + if ($(this).hasClass('cur')) {
  84 + return false;
  85 + }
  86 +
  87 + that.infoList($(this).attr('href'));
  88 + return false;
67 }); 89 });
68 }, 90 },
69 91
@@ -72,6 +94,8 @@ meGift = { @@ -72,6 +94,8 @@ meGift = {
72 var that = this; 94 var that = this;
73 var x; 95 var x;
74 96
  97 + captcha && captcha.hideTip();
  98 +
75 if (that.isFlag) { 99 if (that.isFlag) {
76 return deferred.resolve({ 100 return deferred.resolve({
77 code: 401, 101 code: 401,
@@ -98,11 +122,9 @@ meGift = { @@ -98,11 +122,9 @@ meGift = {
98 type: 'post', 122 type: 'post',
99 data: data 123 data: data
100 }).then(function(res) { 124 }).then(function(res) {
101 - captcha && captcha.hideTip();  
102 -  
103 if (res.code === 405) { 125 if (res.code === 405) {
104 captcha && captcha.showTip(res.message); 126 captcha && captcha.showTip(res.message);
105 - } else { 127 + } else if (res.code !== 200) {
106 that.meAlert(res.message, false); 128 that.meAlert(res.message, false);
107 } 129 }
108 130
@@ -113,11 +135,6 @@ meGift = { @@ -113,11 +135,6 @@ meGift = {
113 }); 135 });
114 }, 136 },
115 137
116 - // 礼品卡详情列表  
117 - detailList: function() {  
118 -  
119 - },  
120 -  
121 intTimer: function($dom) { 138 intTimer: function($dom) {
122 var intTime = 60; 139 var intTime = 60;
123 var intval = setInterval(function() { 140 var intval = setInterval(function() {
@@ -142,7 +159,7 @@ meGift = { @@ -142,7 +159,7 @@ meGift = {
142 this.postAjax('/home/megift/sendEmailCode', { 159 this.postAjax('/home/megift/sendEmailCode', {
143 email: this.userEmail, 160 email: this.userEmail,
144 verifyCode: captcha.getResults() 161 verifyCode: captcha.getResults()
145 - }).then(function(res) { 162 + }, {}, captcha).then(function(res) {
146 if (res.code === 200) { 163 if (res.code === 200) {
147 that.intTimer($('.email-btn')); 164 that.intTimer($('.email-btn'));
148 } 165 }
@@ -167,7 +184,7 @@ meGift = { @@ -167,7 +184,7 @@ meGift = {
167 that.postAjax('/home/megift/verifyEmail', { 184 that.postAjax('/home/megift/verifyEmail', {
168 email: that.userEmail, 185 email: that.userEmail,
169 code: emailCode 186 code: emailCode
170 - }, verifyData, captcha).then(function(res) { 187 + }, verifyData).then(function(res) {
171 if (res.code === 200) { 188 if (res.code === 200) {
172 dg.close(); 189 dg.close();
173 that.getMobileCode(); 190 that.getMobileCode();
@@ -214,8 +231,8 @@ meGift = { @@ -214,8 +231,8 @@ meGift = {
214 231
215 that.postAjax('/home/megift/changeMobile', { 232 that.postAjax('/home/megift/changeMobile', {
216 area: ($('.mobile-area').find('em').text() || '').replace(/^\+/, ''), 233 area: ($('.mobile-area').find('em').text() || '').replace(/^\+/, ''),
217 - mobile: $('.mobile').val(),  
218 - code: $('.mobile-code').val() 234 + mobile: $('input.mobile').val(),
  235 + code: $('input.mobile-code').val()
219 }, verifyData, captcha).then(function(res) { 236 }, verifyData, captcha).then(function(res) {
220 if (res.code === 200) { 237 if (res.code === 200) {
221 dg.close(); 238 dg.close();
@@ -240,7 +257,7 @@ meGift = { @@ -240,7 +257,7 @@ meGift = {
240 smsBind: function(captcha) { 257 smsBind: function(captcha) {
241 var that = this; 258 var that = this;
242 var area = ($('.mobile-area').find('em').text() || '').replace(/^\+/, ''); 259 var area = ($('.mobile-area').find('em').text() || '').replace(/^\+/, '');
243 - var mobile = $('.mobile').val(); 260 + var mobile = $('input.mobile').val();
244 var verifyData = { 261 var verifyData = {
245 area: '请选择手机区号', 262 area: '请选择手机区号',
246 mobile: '手机号不能为空' 263 mobile: '手机号不能为空'
@@ -252,7 +269,7 @@ meGift = { @@ -252,7 +269,7 @@ meGift = {
252 verifyCode: captcha.getResults() 269 verifyCode: captcha.getResults()
253 }, verifyData, captcha).then(function(res) { 270 }, verifyData, captcha).then(function(res) {
254 if (res.code === 200) { 271 if (res.code === 200) {
255 - that.intTimer($('.email-btn')); 272 + that.intTimer($('.mobile-btn'));
256 } 273 }
257 }); 274 });
258 }, 275 },
@@ -300,21 +317,12 @@ meGift = { @@ -300,21 +317,12 @@ meGift = {
300 }, 317 },
301 318
302 // 消费明细 319 // 消费明细
303 - infoList: function(cardCode) {  
304 - var that = this;  
305 -  
306 - new dialog.Dialog({  
307 - content: that.detailGiftTpl({}),  
308 - className: 'me-page me-gift-page me-gift-confirm detail-gift-list'  
309 - }).show();  
310 -  
311 - $.get('/home/megift/detail', {  
312 - cardCode: cardCode  
313 - }).then(function(res) { 320 + infoList: function(url) {
  321 + url = url || '';
  322 + $.get('/home/megift/detail' + url).then(function(res) {
314 if (!res) { 323 if (!res) {
315 return false; 324 return false;
316 } 325 }
317 -  
318 $('.detail-gift-content').html(res); 326 $('.detail-gift-content').html(res);
319 }); 327 });
320 }, 328 },
@@ -187,6 +187,7 @@ @@ -187,6 +187,7 @@
187 border: 1px solid #e6e6e6; 187 border: 1px solid #e6e6e6;
188 display: none; 188 display: none;
189 cursor: pointer; 189 cursor: pointer;
  190 + z-index: 1;
190 191
191 li { 192 li {
192 border-bottom: 1px solid #e6e6e6; 193 border-bottom: 1px solid #e6e6e6;
@@ -231,7 +232,7 @@ @@ -231,7 +232,7 @@
231 } 232 }
232 233
233 .validity-time { 234 .validity-time {
234 - width: 360px; 235 + width: 330px;
235 } 236 }
236 } 237 }
237 238
@@ -260,8 +261,14 @@ @@ -260,8 +261,14 @@
260 min-height: 500px; 261 min-height: 500px;
261 262
262 .me-pager { 263 .me-pager {
263 - width: 758px; 264 + width: 755px;
264 margin: 0 10px; 265 margin: 0 10px;
  266 + border: 1px solid #e6e6e6;
  267 + border-top: none;
265 } 268 }
266 } 269 }
267 } 270 }
  271 +
  272 +.me-gift-confirm.me-page {
  273 + width: auto !important;
  274 +}