From 5df49ce2c1fb332c2ea7f0f7bdfacbf2b07b1ca9 Mon Sep 17 00:00:00 2001 From: mutoe Date: Wed, 25 Jul 2018 14:41:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(filters):=20=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=9A=84=E5=80=BC=E4=B8=BA=E7=A5=96=E9=B2=81?= =?UTF-8?q?=E6=97=B6=E9=97=B4=EF=BC=8C=E9=9C=80=E8=A6=81=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=B7=AE=E8=BD=AC=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/filters.js | 12 +++++++----- src/page/wallet/WalletDetailItem.vue | 8 +++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/filters.js b/src/filters.js index 8383f60c..bea62317 100644 --- a/src/filters.js +++ b/src/filters.js @@ -85,14 +85,16 @@ export const time2txt = str => { } }; -// 格林威治时间和本地时间之间的时差 (单位:毫秒) +/** + * 祖鲁时间和本地时间之间的时差 (单位:毫秒) + * @returns {number} timezone offset + */ export const timeOffset = new Date().getTimezoneOffset() * 60 * 1000; export const time2tips = date => { - const time = - new Date(typeof date === "string" ? date.replace(/-/g, "/") : date) - - timeOffset; - const offset = (new Date().getTime() - time) / 1000; + const time = new Date(date); + // 服务器返回的时间是祖鲁时间,需要进行本地化 + const offset = (new Date().getTime() - time + timeOffset) / 1000; if (offset < 60) return "1分钟内"; if (offset < 3600) return `${~~(offset / 60)}分钟前`; if (offset < 3600 * 24) return `${~~(offset / 3600)}小时前`; diff --git a/src/page/wallet/WalletDetailItem.vue b/src/page/wallet/WalletDetailItem.vue index 5ac14e9e..b025652b 100644 --- a/src/page/wallet/WalletDetailItem.vue +++ b/src/page/wallet/WalletDetailItem.vue @@ -13,9 +13,12 @@