| | |
| | | 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(); |
| | |
| | | } |
| | | typeof callback == 'function' && callback(theRequest); |
| | | }, |
| | | |
| | | |
| | | /** |
| | | * 路径转base64 |
| | | * @param {Object} string |
| | |
| | | reject(error); |
| | | }; |
| | | // #endif |
| | | |
| | | |
| | | // #ifdef MP |
| | | if (uni.canIUse('getFileSystemManager')) { |
| | | uni.getFileSystemManager().readFile({ |
| | |
| | | }) |
| | | } |
| | | // #endif |
| | | |
| | | |
| | | // #ifdef APP-PLUS |
| | | plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), (entry) => { |
| | | entry.file((file) => { |
| | |
| | | // #endif |
| | | }) |
| | | }, |
| | | roundToTwo(num){ |
| | | if(isNaN(num)){ |
| | | roundToTwo(num) { |
| | | if (isNaN(num)) { |
| | | return 0 |
| | | } |
| | | return Math.round((num + Number.EPSILON) * 100) / 100; |
| | |
| | | } |
| | | } |
| | | }, |
| | | |
| | | } |
| | | checkFileExtensions(str) { |
| | | const extensions = ['pdf', 'doc', 'docx', 'xls', 'xlsx']; |
| | | return extensions.some(extension => str.includes(extension)); |
| | | }, |
| | | previewWechat(urlPdf) { |
| | | uni.showLoading({ |
| | | title: '正在加载中..' |
| | | }) |
| | | uni.downloadFile({ |
| | | url: urlPdf, |
| | | success: function(res) { |
| | | var filePath = res.tempFilePath; |
| | | const index = urlPdf.lastIndexOf("."); |
| | | const suffix = urlPdf.substring(index + 1); |
| | | uni.openDocument({ |
| | | fileType: suffix, |
| | | filePath: filePath, |
| | | showMenu: true, |
| | | success: function(res) { |
| | | console.log('打开文档成功'); |
| | | uni.hideLoading() |
| | | }, |
| | | }); |
| | | }, |
| | | complete: function(r) { |
| | | uni.hideLoading() |
| | | } |
| | | }); |
| | | }, |
| | | } |