Authored by 郭成尧

折扣专场倒计时

@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2016-05-25 18:16:59 3 * @Date: 2016-05-25 18:16:59
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2016-06-08 16:17:06 5 + * @Last Modified time: 2016-06-08 16:32:07
6 */ 6 */
7 7
8 'use strict'; 8 'use strict';
@@ -10,7 +10,7 @@ const library = '../../../library'; @@ -10,7 +10,7 @@ const library = '../../../library';
10 const helpers = require(`${library}/helpers`); 10 const helpers = require(`${library}/helpers`);
11 const _ = require('lodash'); 11 const _ = require('lodash');
12 12
13 -// const aMinute = 60000; 13 +const aMinute = 60000;
14 const anHour = 3600000; 14 const anHour = 3600000;
15 const aDay = anHour * 24; 15 const aDay = anHour * 24;
16 const timeFormat = { 16 const timeFormat = {
@@ -52,28 +52,28 @@ const processTime = (time) => { @@ -52,28 +52,28 @@ const processTime = (time) => {
52 * @param {[string]} time 52 * @param {[string]} time
53 * @return {[boject]} 53 * @return {[boject]}
54 */ 54 */
55 -// const processTimes = (time) => {  
56 -// let data = {};  
57 -// let type = '';  
58 -  
59 -// if (time > aDay) {  
60 -// type = 'dhms';  
61 -// } else {  
62 -// if (time > anHour) {  
63 -// type = 'hms';  
64 -// } else {  
65 -// if (time > aMinute) {  
66 -// type = 'ms';  
67 -// } else {  
68 -// type = 's';  
69 -// }  
70 -// }  
71 -// }  
72 -  
73 -// data.time = helpers.dateDiffFormat(timeFormat[type], time, 'ms');  
74 -  
75 -// return data;  
76 -// }; 55 +const processTimes = (time) => {
  56 + let data = {};
  57 + let type = '';
  58 +
  59 + if (time > aDay) {
  60 + type = 'dhms';
  61 + } else {
  62 + if (time > anHour) {
  63 + type = 'hms';
  64 + } else {
  65 + if (time > aMinute) {
  66 + type = 'ms';
  67 + } else {
  68 + type = 's';
  69 + }
  70 + }
  71 + }
  72 +
  73 + data.time = helpers.dateDiffFormat(timeFormat[type], time, 'ms');
  74 +
  75 + return data.time;
  76 +};
77 77
78 /** 78 /**
79 * 折扣文本切割 79 * 折扣文本切割
@@ -556,7 +556,7 @@ exports.handleDiscountTitleData = (origin) => { @@ -556,7 +556,7 @@ exports.handleDiscountTitleData = (origin) => {
556 dest.title = origin.title; 556 dest.title = origin.title;
557 dest.up = true; 557 dest.up = true;
558 dest.discount = origin.promotion_name; 558 dest.discount = origin.promotion_name;
559 - dest.time = processTime(origin.left_time); 559 + dest.time = processTimes(origin.left_time);
560 560
561 return dest; 561 return dest;
562 }; 562 };