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 | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/common/utils/util.js b/src/common/utils/util.js index 3594f55..2d14f09 100644 --- a/src/common/utils/util.js +++ b/src/common/utils/util.js @@ -133,11 +133,20 @@ parseInt(t[2], 10) || null )).getTime() / 1000; }, - formatDate(dat, type) { - if(!dat){ + 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) { return '-' } let date = new Date(dat) + if (addNum) { + date = new Date(date.setDate(date.getDate() + addNum)); + } const year = date.getFullYear(); const month = (date.getMonth() + 1).toString().padStart(2, '0'); const day = date.getDate().toString().padStart(2, '0'); @@ -711,7 +720,7 @@ } typeof callback == 'function' && callback(theRequest); }, - + /** * 璺緞杞琤ase64 * @param {Object} string @@ -736,7 +745,7 @@ reject(error); }; // #endif - + // #ifdef MP if (uni.canIUse('getFileSystemManager')) { uni.getFileSystemManager().readFile({ @@ -751,7 +760,7 @@ }) } // #endif - + // #ifdef APP-PLUS plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), (entry) => { entry.file((file) => { @@ -768,8 +777,8 @@ // #endif }) }, - roundToTwo(num){ - if(isNaN(num)){ + roundToTwo(num) { + if (isNaN(num)) { return 0 } return Math.round((num + Number.EPSILON) * 100) / 100; @@ -829,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