From 9465dc404f7e7cd56100e4859ee0946a3fef7b09 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 05 三月 2026 11:14:40 +0800
Subject: [PATCH] 去除视频界面,以通过审核
---
utils/util.js | 95 +++++++++++++++++++++++++++++++----------------
1 files changed, 62 insertions(+), 33 deletions(-)
diff --git a/utils/util.js b/utils/util.js
index cc27905..7b753dd 100644
--- a/utils/util.js
+++ b/utils/util.js
@@ -1,59 +1,88 @@
-const formatTime = date => {
- const year = date.getFullYear()
- const month = date.getMonth() + 1
- const day = date.getDate()
- const hour = date.getHours()
- const minute = date.getMinutes()
- const second = date.getSeconds()
+const moment = require('./moment.min');
- return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
-}
+const formatTime = date => {
+ const time = moment(date);
+ const now = moment();
+
+ const timeYear = time.year();
+ const timeMonth = time.month() + 1;
+ const timeDay = time.date();
+
+ const thisYear = now.year();
+ const thisMonth = now.month() + 1;
+ const thisDay = now.date();
+
+ if (timeYear < thisYear) {
+ return time.format('YYYY-MM-DD');
+ } else if (timeMonth < thisMonth) {
+ return time.format('MM-DD');
+ } else if (timeDay < thisDay) {
+ if (timeDay + 1 == thisDay) {
+ return '鏄ㄥぉ';
+ } else {
+ return time.format('MM-DD');
+ }
+ } else {
+ return time.fromNow();
+ }
+};
const formatNumber = n => {
- n = n.toString()
- return n[1] ? n : '0' + n
-}
+ n = n.toString();
+ return n[1] ? n : '0' + n;
+};
const navContentHeight = function () {
//鑳跺泭楂樺害
- const capsuleHeight = wx.getMenuButtonBoundingClientRect().bottom - wx.getMenuButtonBoundingClientRect().top
+ const capsuleHeight =
+ wx.getMenuButtonBoundingClientRect().bottom -
+ wx.getMenuButtonBoundingClientRect().top;
//鑳跺泭涓婅竟妗嗚窛椤堕儴璺濈
- const capsuleTop = wx.getMenuButtonBoundingClientRect().top
+ const capsuleTop = wx.getMenuButtonBoundingClientRect().top;
//鐘舵�佹爮楂樺害
- const statusBarHeight = wx.getSystemInfoSync().statusBarHeight
+ const statusBarHeight = wx.getSystemInfoSync().statusBarHeight;
//鑽泭涓婅竟璺濈姸鎬佹爮涓嬭竟鐨勮窛绂伙紝鍗宠嵂鍥婂湪瀵艰埅鍐呭鏍忎腑鐨勪笂涓嬭竟璺�
- const capsuleGap = capsuleTop - statusBarHeight
+ const capsuleGap = capsuleTop - statusBarHeight;
//瀵艰埅鍐呭鏍忕殑楂樺害鍔ㄦ�佽绠�
- const navContentHeight = capsuleGap * 2 + capsuleHeight
+ const navContentHeight = capsuleGap * 2 + capsuleHeight;
- return navContentHeight + statusBarHeight
-}
+ return navContentHeight + statusBarHeight;
+};
const deepCopy = function (obj) {
- let b1 = typeof obj
- if (b1 != 'object' || (obj instanceof Array) || obj == null) {
+ let b1 = typeof obj;
+ if (b1 != 'object' || obj == null) {
return obj;
}
- var newobj = {};
- for (var attr in obj) {
- newobj[attr] = this.deepCopy(obj[attr]);
+ let newobj;
+ if (obj instanceof Array) {
+ newobj = [];
+ obj.forEach(e => {
+ newobj.push(this.deepCopy(e));
+ });
+ } else {
+ newobj = {};
+ for (var attr in obj) {
+ newobj[attr] = this.deepCopy(obj[attr]);
+ }
}
return newobj;
-}
+};
const lastMonth = function (year, month) {
- var lM = month - 1
- var lY = year
+ var lM = month - 1;
+ var lY = year;
if (lM <= 0) {
- lM += 12
- lY -= 1
+ lM += 12;
+ lY -= 1;
}
- return [lY, lM]
-}
+ return [lY, lM];
+};
module.exports = {
formatTime: formatTime,
navContentHeight: navContentHeight,
deepCopy: deepCopy,
- lastMonth: lastMonth
-}
\ No newline at end of file
+ lastMonth: lastMonth,
+ formatNumber: formatNumber,
+};
--
Gitblit v1.9.3