From 9f0f5d7767506658ab5ca47ba8ff4ede423e47e3 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期三, 22 一月 2025 10:10:45 +0800
Subject: [PATCH] -

---
 src/common/utils/util.js |   49 ++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/src/common/utils/util.js b/src/common/utils/util.js
index c728e60..2d14f09 100644
--- a/src/common/utils/util.js
+++ b/src/common/utils/util.js
@@ -133,12 +133,18 @@
 			parseInt(t[2], 10) || null
 		)).getTime() / 1000;
 	},
+	minutesBetweenDates(date1, date2) {
+		let dateOne = new Date(date1)
+		const oneMinute = 60 * 1000; // 1鍒嗛挓鐨勬绉掓暟
+		const difference = Math.abs(date2.getTime() - dateOne.getTime()); // 璁$畻涓や釜鏃ユ湡鐨勬绉掑樊
+		return Math.floor(difference / oneMinute); // 灏嗗樊寮傝浆鎹负鍒嗛挓骞跺悜涓嬪彇鏁�
+	},
 	formatDate(dat, type, addNum) {
-		if(!dat){
+		if (!dat) {
 			return '-'
 		}
 		let date = new Date(dat)
-		if(addNum){
+		if (addNum) {
 			date = new Date(date.setDate(date.getDate() + addNum));
 		}
 		const year = date.getFullYear();
@@ -714,7 +720,7 @@
 		}
 		typeof callback == 'function' && callback(theRequest);
 	},
-	
+
 	/**
 	 * 璺緞杞琤ase64
 	 * @param {Object} string
@@ -739,7 +745,7 @@
 				reject(error);
 			};
 			// #endif
-	
+
 			// #ifdef MP
 			if (uni.canIUse('getFileSystemManager')) {
 				uni.getFileSystemManager().readFile({
@@ -754,7 +760,7 @@
 				})
 			}
 			// #endif
-	
+
 			// #ifdef APP-PLUS
 			plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), (entry) => {
 				entry.file((file) => {
@@ -771,8 +777,8 @@
 			// #endif
 		})
 	},
-	roundToTwo(num){
-		if(isNaN(num)){
+	roundToTwo(num) {
+		if (isNaN(num)) {
 			return 0
 		}
 		return Math.round((num + Number.EPSILON) * 100) / 100;
@@ -832,5 +838,30 @@
 			}
 		}
 	},
-
-}
+	checkFileExtensions(str) {
+		const extensions = ['pdf', 'doc', 'docx', 'xls', 'xlsx'];
+		return extensions.some(extension => str.includes(extension));
+	},
+	previewWechat(urlPdf) {
+		uni.showLoading({
+			title: '姝e湪鍔犺浇涓�..'
+		})
+		uni.downloadFile({
+			url: urlPdf,
+			success: function(res) {
+				var filePath = res.tempFilePath;
+				uni.openDocument({
+					filePath: filePath,
+					showMenu: true,
+					success: function(res) {
+						console.log('鎵撳紑鏂囨。鎴愬姛');
+						uni.hideLoading()
+					},
+				});
+			},
+			complete: function(r) {
+				uni.hideLoading()
+			}
+		});
+	},
+}
\ No newline at end of file

--
Gitblit v1.9.1