|
|
@@ -5,7 +5,7 @@ import { agentId } from "@/utils/network/difference"; |
|
|
|
import { |
|
|
|
requestNew |
|
|
|
} from "@/utils/network/request.js"; |
|
|
|
import {ocrDo} from "@/utils/network/api.js"; |
|
|
|
import { ocrDo } from "@/utils/network/api.js"; |
|
|
|
export const msg = (title : string = "", param : any = {}) => { |
|
|
|
if (!title) return; |
|
|
|
uni.showToast({ |
|
|
@@ -61,19 +61,19 @@ export const navTo = (url : string = "", login : boolean = false) => { |
|
|
|
let pages = getCurrentPages(); |
|
|
|
// 获取页面栈总页数 |
|
|
|
// this.pagesCount = pages.length; |
|
|
|
// 如果页面栈总数大于10 |
|
|
|
console.log("pages.length",pages.length) |
|
|
|
if(pages.length >= 10){ |
|
|
|
// 使用重定向跳转页面 |
|
|
|
uni.redirectTo({ |
|
|
|
url |
|
|
|
}) |
|
|
|
}else{ |
|
|
|
// 如果页面栈总数小于10,则打开新页面 |
|
|
|
uni.navigateTo({ |
|
|
|
url, |
|
|
|
}); |
|
|
|
} |
|
|
|
// 如果页面栈总数大于10 |
|
|
|
console.log("pages.length", pages.length) |
|
|
|
if (pages.length >= 10) { |
|
|
|
// 使用重定向跳转页面 |
|
|
|
uni.redirectTo({ |
|
|
|
url |
|
|
|
}) |
|
|
|
} else { |
|
|
|
// 如果页面栈总数小于10,则打开新页面 |
|
|
|
uni.navigateTo({ |
|
|
|
url, |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
@@ -424,8 +424,8 @@ export const imgPathMontage = (str : string) => { |
|
|
|
} |
|
|
|
// 身份证号脱敏 |
|
|
|
export const desensitization = (val) => { |
|
|
|
if(val){ |
|
|
|
return val.replace(/^\d{14}/,'**************'); |
|
|
|
if (val) { |
|
|
|
return val.replace(/^\d{14}/, '**************'); |
|
|
|
} |
|
|
|
} |
|
|
|
//查看大图 |
|
|
@@ -518,17 +518,17 @@ function formatNumber(n : any) { |
|
|
|
return n[1] ? n : `0${n}` |
|
|
|
} |
|
|
|
export const uploadFile = (tempImagePath, imageType) => { |
|
|
|
console.log("tempImagePath",tempImagePath,tempImagePath.size) |
|
|
|
console.log("tempImagePath", tempImagePath, tempImagePath.size) |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
uni.uploadFile({ |
|
|
|
url: 'https://qtzl.etcjz.cn/newDev/minIo/upload', //仅为示例,非真实的接口地址 |
|
|
|
filePath: tempImagePath, |
|
|
|
name: 'file', |
|
|
|
formData: { |
|
|
|
'busCode':'iaw', |
|
|
|
'busCode': 'iaw', |
|
|
|
}, |
|
|
|
success: (uploadFileRes) => { |
|
|
|
console.log("uploadFileRes",uploadFileRes,JSON.parse(uploadFileRes.data).data.ossFilePath) |
|
|
|
console.log("uploadFileRes", uploadFileRes, JSON.parse(uploadFileRes.data).data.ossFilePath) |
|
|
|
// let uploadFileImage = 'http://100.64.2.113:9000' + '/default-bucket/' + JSON.parse(uploadFileRes.data).data.ossFilePath |
|
|
|
// console.log("111", JSON.parse(uploadFileRes.data).data.ossFilePath,JSON.parse(uploadFileRes.data)); |
|
|
|
// var data={} |
|
|
@@ -563,7 +563,10 @@ export const uploadFile = (tempImagePath, imageType) => { |
|
|
|
// }; |
|
|
|
// console.log("91", uploadFileImage) |
|
|
|
// } |
|
|
|
|
|
|
|
if (imageType == 99) { |
|
|
|
resolve({ imageUrl: JSON.parse(uploadFileRes.data).data.ossFilePath }) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
const options = { |
|
|
|
type: 2, |
|
|
@@ -575,14 +578,14 @@ export const uploadFile = (tempImagePath, imageType) => { |
|
|
|
showLoading: true, |
|
|
|
}; |
|
|
|
requestNew(ocrDo, options).then((res) => { |
|
|
|
console.log("res===",res) |
|
|
|
const data = {...res, imageUrl: JSON.parse(uploadFileRes.data).data.ossFilePath}; |
|
|
|
console.log("res===", res) |
|
|
|
const data = { ...res, imageUrl: JSON.parse(uploadFileRes.data).data.ossFilePath }; |
|
|
|
console.log('输出内容=====123', data) |
|
|
|
resolve(data) |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
fail:()=>{ |
|
|
|
fail: () => { |
|
|
|
uni.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: '图片上传失败,请联系管理人员', |
|
|
@@ -663,12 +666,12 @@ export const noticeUser = (callback : Function) => { |
|
|
|
// #endif |
|
|
|
} |
|
|
|
// 压缩图片 |
|
|
|
export const compressImage = (tempFilePaths : any,scall, callback : Function) => { |
|
|
|
export const compressImage = (tempFilePaths : any, scall, callback : Function) => { |
|
|
|
uni.compressImage({ |
|
|
|
src: tempFilePaths, // 图片路径 |
|
|
|
quality: 80, // 压缩质量,范围为0 - 100,100为不压缩 |
|
|
|
success: function (res) { |
|
|
|
console.log('压缩后的图片路径:' + res.tempFilePath,res) |
|
|
|
console.log('压缩后的图片路径:' + res.tempFilePath, res) |
|
|
|
callback(res) |
|
|
|
}, |
|
|
|
fail: function (err) { |
|
|
@@ -676,15 +679,15 @@ export const compressImage = (tempFilePaths : any,scall, callback : Function) => |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
export const chooseImageCompress = ( callback : Function) => { |
|
|
|
export const chooseImageCompress = (callback : Function) => { |
|
|
|
uni.chooseImage({ |
|
|
|
count: 1, //只能选取一张照片 |
|
|
|
sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有 |
|
|
|
sourceType: ["album"], //从相册选择 |
|
|
|
success: function (res) { |
|
|
|
let scall=res.tempFiles[0].size/1024/1024/2 |
|
|
|
console.log("scall",scall) |
|
|
|
console.log("res.tempFiles[0].size", res.tempFilePaths[0], res.tempFiles[0].size/1024/1024) |
|
|
|
let scall = res.tempFiles[0].size / 1024 / 1024 / 2 |
|
|
|
console.log("scall", scall) |
|
|
|
console.log("res.tempFiles[0].size", res.tempFilePaths[0], res.tempFiles[0].size / 1024 / 1024) |
|
|
|
// if(scall>1){ |
|
|
|
// console.log("压缩") |
|
|
|
// let quality=100 |
|
|
@@ -711,33 +714,33 @@ export const chooseImageCompress = ( callback : Function) => { |
|
|
|
// } |
|
|
|
// }) |
|
|
|
// }else{ |
|
|
|
callback(res) |
|
|
|
callback(res) |
|
|
|
// } |
|
|
|
}, |
|
|
|
}) |
|
|
|
} |
|
|
|
// 身份证有效期是否过期 |
|
|
|
export function compareDates(specifiedDateString) { |
|
|
|
const newTime=specifiedDateString.substring(0,4)+"-"+specifiedDateString.substring(4,6)+"-"+specifiedDateString.substring(6,8) |
|
|
|
console.log("newTime",newTime) |
|
|
|
const currentDate = new Date(); |
|
|
|
const specifiedDate = new Date(newTime); |
|
|
|
|
|
|
|
if (currentDate > specifiedDate) { |
|
|
|
console.log("当前日期晚于指定日期") |
|
|
|
msg("身份证过期请重新上传", { |
|
|
|
'duration': 2000 |
|
|
|
}) |
|
|
|
return "当前日期晚于指定日期"; |
|
|
|
} else if (currentDate < specifiedDate) { |
|
|
|
console.log("当前日期早于指定日期") |
|
|
|
return "当前日期早于指定日期"; |
|
|
|
} else { |
|
|
|
console.log("当前日期等于指定日期") |
|
|
|
return "当前日期等于指定日期"; |
|
|
|
} |
|
|
|
const newTime = specifiedDateString.substring(0, 4) + "-" + specifiedDateString.substring(4, 6) + "-" + specifiedDateString.substring(6, 8) |
|
|
|
console.log("newTime", newTime) |
|
|
|
const currentDate = new Date(); |
|
|
|
const specifiedDate = new Date(newTime); |
|
|
|
|
|
|
|
if (currentDate > specifiedDate) { |
|
|
|
console.log("当前日期晚于指定日期") |
|
|
|
msg("身份证过期请重新上传", { |
|
|
|
'duration': 2000 |
|
|
|
}) |
|
|
|
return "当前日期晚于指定日期"; |
|
|
|
} else if (currentDate < specifiedDate) { |
|
|
|
console.log("当前日期早于指定日期") |
|
|
|
return "当前日期早于指定日期"; |
|
|
|
} else { |
|
|
|
console.log("当前日期等于指定日期") |
|
|
|
return "当前日期等于指定日期"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 示例使用 |
|
|
|
// const dateComparison = compareDates('2023-12-31'); |
|
|
|
// console.log(dateComparison); |
|
|
@@ -745,26 +748,26 @@ export function compareDates(specifiedDateString) { |
|
|
|
// 跳转运维小程序 |
|
|
|
export function jumpOldMini() { |
|
|
|
uni.navigateToMiniProgram({ |
|
|
|
appId: "wx008c60533388527a", |
|
|
|
path: `pages/main/serve/serve`, |
|
|
|
envVersion: "release", |
|
|
|
success(res) { |
|
|
|
console.log('成功', res); |
|
|
|
}, |
|
|
|
fail(res) { |
|
|
|
console.log('失败' + res); |
|
|
|
}, |
|
|
|
appId: "wx008c60533388527a", |
|
|
|
path: `pages/main/serve/serve`, |
|
|
|
envVersion: "release", |
|
|
|
success(res) { |
|
|
|
console.log('成功', res); |
|
|
|
}, |
|
|
|
fail(res) { |
|
|
|
console.log('失败' + res); |
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
// 图片转base64 |
|
|
|
export const getFileBase64 = (path) => { |
|
|
|
console.log("进来",path) |
|
|
|
console.log("进来", path) |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
uni.getFileSystemManager().readFile({ |
|
|
|
filePath: path, //参数path:图片相对路径 |
|
|
|
encoding: 'base64', |
|
|
|
success: (res) => { |
|
|
|
console.log("进来1",res) |
|
|
|
console.log("进来1", res) |
|
|
|
resolve(res.data); |
|
|
|
}, |
|
|
|
fail: (err) => { |