增加接口联调
This commit is contained in:
@@ -139,7 +139,6 @@ const jumpAuthPermission=()=>{
|
||||
|
||||
// 跳转授权
|
||||
const jumpAuthPermission2 = () => {
|
||||
|
||||
let main = plus.android.runtimeMainActivity();
|
||||
let Intent = plus.android.importClass('android.content.Intent');
|
||||
let Uri = plus.android.importClass('android.net.Uri');
|
||||
@@ -227,4 +226,69 @@ export const getFileType = (filePathOrName) => {
|
||||
} else {
|
||||
return 'other';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 计算图片的新尺寸
|
||||
const calculateNewSize = (originalWidth, originalHeight)=>{
|
||||
const MAX_SIZE = 1920;
|
||||
let newWidth = originalWidth;
|
||||
let newHeight = originalHeight;
|
||||
// 如果宽或高超过最大尺寸,进行等比缩放
|
||||
if (originalWidth > MAX_SIZE || originalHeight > MAX_SIZE) {
|
||||
if (originalWidth > originalHeight) {
|
||||
// 宽图
|
||||
newWidth = MAX_SIZE;
|
||||
newHeight = Math.round((originalHeight * MAX_SIZE) / originalWidth);
|
||||
} else {
|
||||
// 高图或方图
|
||||
newHeight = MAX_SIZE;
|
||||
newWidth = Math.round((originalWidth * MAX_SIZE) / originalHeight);
|
||||
}
|
||||
}
|
||||
// console.log('调整后尺寸:', newWidth, 'x', newHeight);
|
||||
return {
|
||||
width: newWidth,
|
||||
height: newHeight
|
||||
};
|
||||
}
|
||||
|
||||
// 图片压缩处理tempFilePaths
|
||||
export const compressImageUni = (file) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
console.log("compressImageUni=>file=>",file)
|
||||
uni.getImageInfo({
|
||||
src: file,
|
||||
success: function (image) {
|
||||
const newSize = calculateNewSize(image.width, image.height);
|
||||
console.log("调整后的尺寸=>",newSize)
|
||||
|
||||
uni.compressImage({
|
||||
src: file,
|
||||
compressedWidth:newSize.width,
|
||||
compressedHeight:newSize.height,
|
||||
quality: 100, // 压缩质量 (0-100)
|
||||
success: (res) => {
|
||||
// console.log('压缩成功,临时路径:', res.tempFilePath);
|
||||
resolve(res.tempFilePath)
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('压缩失败:', err);
|
||||
reject(err)
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.log('压缩失败:', error);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 获取minio缩略图地址
|
||||
export function getMinioThumbUrl(ossObj,path){
|
||||
let baseUrl = process.env.VUE_APP_MINIO?process.env.VUE_APP_MINIO:'';
|
||||
// let replaceStr="http://"+ossObj.clientObj.url+":"+ossObj.clientObj.port+"/new-gd-manager"
|
||||
// let thumbUrl = path.replace(replaceStr,baseUrl+'/thumb/new-gd-manager');
|
||||
return {baseUrl}
|
||||
}
|
||||
Reference in New Issue
Block a user