Showing
1 changed file
with
10 additions
and
8 deletions
@@ -8,6 +8,8 @@ const UserData = require('./user-data'); | @@ -8,6 +8,8 @@ const UserData = require('./user-data'); | ||
8 | const helpers = global.yoho.helpers; | 8 | const helpers = global.yoho.helpers; |
9 | const path = require('path'); | 9 | const path = require('path'); |
10 | const _ = require('lodash'); | 10 | const _ = require('lodash'); |
11 | +const moment = require('moment'); | ||
12 | + | ||
11 | // 使用 product中的分页逻辑 | 13 | // 使用 product中的分页逻辑 |
12 | const pagerPath = path.join(global.appRoot, '/apps/product/models/public-handler.js'); | 14 | const pagerPath = path.join(global.appRoot, '/apps/product/models/public-handler.js'); |
13 | const pager = require(pagerPath).handlePagerData; | 15 | const pager = require(pagerPath).handlePagerData; |
@@ -27,6 +29,7 @@ const getCouponsList = (uid, type, page, limit)=>{ | @@ -27,6 +29,7 @@ const getCouponsList = (uid, type, page, limit)=>{ | ||
27 | }; | 29 | }; |
28 | } | 30 | } |
29 | let coupons = _.get(couponsInfo, 'data.couponList'); | 31 | let coupons = _.get(couponsInfo, 'data.couponList'); |
32 | + | ||
30 | if (coupons) { | 33 | if (coupons) { |
31 | coupons.forEach(function(item, i) { | 34 | coupons.forEach(function(item, i) { |
32 | result[i] = {}; | 35 | result[i] = {}; |
@@ -36,8 +39,8 @@ const getCouponsList = (uid, type, page, limit)=>{ | @@ -36,8 +39,8 @@ const getCouponsList = (uid, type, page, limit)=>{ | ||
36 | // 格式化有效日期 "couponValidity": "2016.03.15-2016.03.31" | 39 | // 格式化有效日期 "couponValidity": "2016.03.15-2016.03.31" |
37 | let dates = item.couponValidity.split('-'); | 40 | let dates = item.couponValidity.split('-'); |
38 | 41 | ||
39 | - result[i].beginTime = dates[0].replace('.', '-'); | ||
40 | - result[i].endTime = dates[1].replace('.', '-'); | 42 | + result[i].beginTime = _.replace(dates[0], /\./g, '-'); |
43 | + result[i].endTime = _.replace(dates[1], /\./g, '-'); | ||
41 | 44 | ||
42 | if (!item.couponImageUrl) { | 45 | if (!item.couponImageUrl) { |
43 | result[i].img = '//static.yohobuy.com/images/v2/activity/default_coupon.jpg'; | 46 | result[i].img = '//static.yohobuy.com/images/v2/activity/default_coupon.jpg'; |
@@ -53,11 +56,10 @@ const getCouponsList = (uid, type, page, limit)=>{ | @@ -53,11 +56,10 @@ const getCouponsList = (uid, type, page, limit)=>{ | ||
53 | result[i].validity = item.couponValidity; | 56 | result[i].validity = item.couponValidity; |
54 | result[i].useRemark = item.couponDetailInfomation; | 57 | result[i].useRemark = item.couponDetailInfomation; |
55 | 58 | ||
56 | - | ||
57 | - | ||
58 | if (type === USED) { | 59 | if (type === USED) { |
59 | result[i].orderNum = _.get(item, 'orderCode', ''); | 60 | result[i].orderNum = _.get(item, 'orderCode', ''); |
60 | - result[i].orderDetailUrl = helpers.urlFormat('/home/orders/detail', {orderCode: item.orderCode || ''}); | 61 | + result[i].orderDetailUrl = helpers.urlFormat('/home/orders/detail', |
62 | + {orderCode: item.orderCode || ''}); | ||
61 | result[i].orderSum = _.get(item, 'orderPrice', 0).toFixed(2); | 63 | result[i].orderSum = _.get(item, 'orderPrice', 0).toFixed(2); |
62 | result[i].payment = _.get(item, 'actuallyPaid', 0).toFixed(2); | 64 | result[i].payment = _.get(item, 'actuallyPaid', 0).toFixed(2); |
63 | let data = result[i].usedTime ? moment(result[i].usedTime).format('YYYY-MM-DD') : 0; | 65 | let data = result[i].usedTime ? moment(result[i].usedTime).format('YYYY-MM-DD') : 0; |
@@ -72,7 +74,7 @@ const getCouponsList = (uid, type, page, limit)=>{ | @@ -72,7 +74,7 @@ const getCouponsList = (uid, type, page, limit)=>{ | ||
72 | } | 74 | } |
73 | if (item.couponType) { | 75 | if (item.couponType) { |
74 | result[i].type = item.couponType; | 76 | result[i].type = item.couponType; |
75 | - if (item.couponType == 5) { | 77 | + if (Number(item.couponType) === 5) { |
76 | result[i].value = '免邮'; | 78 | result[i].value = '免邮'; |
77 | } | 79 | } |
78 | } | 80 | } |
@@ -83,7 +85,7 @@ const getCouponsList = (uid, type, page, limit)=>{ | @@ -83,7 +85,7 @@ const getCouponsList = (uid, type, page, limit)=>{ | ||
83 | page: page, | 85 | page: page, |
84 | limit: limit, | 86 | limit: limit, |
85 | type: type | 87 | type: type |
86 | - }) | 88 | + }); |
87 | 89 | ||
88 | return { | 90 | return { |
89 | list: result, | 91 | list: result, |
@@ -104,7 +106,7 @@ const couponsData = (uid, params)=>{ | @@ -104,7 +106,7 @@ const couponsData = (uid, params)=>{ | ||
104 | return co(function*() { | 106 | return co(function*() { |
105 | let coupons = yield getCouponsList(uid, type, page, limit); | 107 | let coupons = yield getCouponsList(uid, type, page, limit); |
106 | let data = {}; | 108 | let data = {}; |
107 | -console.log(coupons); | 109 | + |
108 | if (type === UNUSED) { | 110 | if (type === UNUSED) { |
109 | data.unUseCoupons = !coupons.list.length ? {empty: '您没有优惠券'} : coupons.list; | 111 | data.unUseCoupons = !coupons.list.length ? {empty: '您没有优惠券'} : coupons.list; |
110 | data.unUse = true; | 112 | data.unUse = true; |
-
Please register or login to post a comment