From c9c263dc43ad90f95f24a036cee9e6b47afb596c Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期六, 21 十二月 2024 18:44:20 +0800
Subject: [PATCH] 新建盐城德森项目
---
uni_modules/uni-file-picker/components/uni-file-picker/utils.js | 218 +++++++++++++++++++++++++++---------------------------
1 files changed, 109 insertions(+), 109 deletions(-)
diff --git a/uni_modules/uni-file-picker/components/uni-file-picker/utils.js b/uni_modules/uni-file-picker/components/uni-file-picker/utils.js
index 60aaa3e..6d94b1a 100644
--- a/uni_modules/uni-file-picker/components/uni-file-picker/utils.js
+++ b/uni_modules/uni-file-picker/components/uni-file-picker/utils.js
@@ -1,109 +1,109 @@
-/**
- * 鑾峰彇鏂囦欢鍚嶅拰鍚庣紑
- * @param {String} name
- */
-export const get_file_ext = (name) => {
- const last_len = name.lastIndexOf('.')
- const len = name.length
- return {
- name: name.substring(0, last_len),
- ext: name.substring(last_len + 1, len)
- }
-}
-
-/**
- * 鑾峰彇鎵╁睍鍚�
- * @param {Array} fileExtname
- */
-export const get_extname = (fileExtname) => {
- if (!Array.isArray(fileExtname)) {
- let extname = fileExtname.replace(/(\[|\])/g, '')
- return extname.split(',')
- } else {
- return fileExtname
- }
- return []
-}
-
-/**
- * 鑾峰彇鏂囦欢鍜屾娴嬫槸鍚﹀彲閫�
- */
-export const get_files_and_is_max = (res, _extname) => {
- let filePaths = []
- let files = []
- if(!_extname || _extname.length === 0){
- return {
- filePaths,
- files
- }
- }
- res.tempFiles.forEach(v => {
- let fileFullName = get_file_ext(v.name)
- const extname = fileFullName.ext.toLowerCase()
- if (_extname.indexOf(extname) !== -1) {
- files.push(v)
- filePaths.push(v.path)
- }
- })
- if (files.length !== res.tempFiles.length) {
- uni.showToast({
- title: `褰撳墠閫夋嫨浜�${res.tempFiles.length}涓枃浠� 锛�${res.tempFiles.length - files.length} 涓枃浠舵牸寮忎笉姝g‘`,
- icon: 'none',
- duration: 5000
- })
- }
-
- return {
- filePaths,
- files
- }
-}
-
-
-/**
- * 鑾峰彇鍥剧墖淇℃伅
- * @param {Object} filepath
- */
-export const get_file_info = (filepath) => {
- return new Promise((resolve, reject) => {
- uni.getImageInfo({
- src: filepath,
- success(res) {
- resolve(res)
- },
- fail(err) {
- reject(err)
- }
- })
- })
-}
-/**
- * 鑾峰彇灏佽鏁版嵁
- */
-export const get_file_data = async (files, type = 'image') => {
- // 鏈�缁堥渶瑕佷笂浼犳暟鎹簱鐨勬暟鎹�
- let fileFullName = get_file_ext(files.name)
- const extname = fileFullName.ext.toLowerCase()
- let filedata = {
- name: files.name,
- uuid: files.uuid,
- extname: extname || '',
- cloudPath: files.cloudPath,
- fileType: files.fileType,
- url: files.path || files.path,
- size: files.size, //鍗曚綅鏄瓧鑺�
- image: {},
- path: files.path,
- video: {}
- }
- if (type === 'image') {
- const imageinfo = await get_file_info(files.path)
- delete filedata.video
- filedata.image.width = imageinfo.width
- filedata.image.height = imageinfo.height
- filedata.image.location = imageinfo.path
- } else {
- delete filedata.image
- }
- return filedata
-}
+/**
+ * 鑾峰彇鏂囦欢鍚嶅拰鍚庣紑
+ * @param {String} name
+ */
+export const get_file_ext = (name) => {
+ const last_len = name.lastIndexOf('.')
+ const len = name.length
+ return {
+ name: name.substring(0, last_len),
+ ext: name.substring(last_len + 1, len)
+ }
+}
+
+/**
+ * 鑾峰彇鎵╁睍鍚�
+ * @param {Array} fileExtname
+ */
+export const get_extname = (fileExtname) => {
+ if (!Array.isArray(fileExtname)) {
+ let extname = fileExtname.replace(/(\[|\])/g, '')
+ return extname.split(',')
+ } else {
+ return fileExtname
+ }
+ return []
+}
+
+/**
+ * 鑾峰彇鏂囦欢鍜屾娴嬫槸鍚﹀彲閫�
+ */
+export const get_files_and_is_max = (res, _extname) => {
+ let filePaths = []
+ let files = []
+ if(!_extname || _extname.length === 0){
+ return {
+ filePaths,
+ files
+ }
+ }
+ res.tempFiles.forEach(v => {
+ let fileFullName = get_file_ext(v.name)
+ const extname = fileFullName.ext.toLowerCase()
+ if (_extname.indexOf(extname) !== -1) {
+ files.push(v)
+ filePaths.push(v.path)
+ }
+ })
+ if (files.length !== res.tempFiles.length) {
+ uni.showToast({
+ title: `褰撳墠閫夋嫨浜�${res.tempFiles.length}涓枃浠� 锛�${res.tempFiles.length - files.length} 涓枃浠舵牸寮忎笉姝g‘`,
+ icon: 'none',
+ duration: 5000
+ })
+ }
+
+ return {
+ filePaths,
+ files
+ }
+}
+
+
+/**
+ * 鑾峰彇鍥剧墖淇℃伅
+ * @param {Object} filepath
+ */
+export const get_file_info = (filepath) => {
+ return new Promise((resolve, reject) => {
+ uni.getImageInfo({
+ src: filepath,
+ success(res) {
+ resolve(res)
+ },
+ fail(err) {
+ reject(err)
+ }
+ })
+ })
+}
+/**
+ * 鑾峰彇灏佽鏁版嵁
+ */
+export const get_file_data = async (files, type = 'image') => {
+ // 鏈�缁堥渶瑕佷笂浼犳暟鎹簱鐨勬暟鎹�
+ let fileFullName = get_file_ext(files.name)
+ const extname = fileFullName.ext.toLowerCase()
+ let filedata = {
+ name: files.name,
+ uuid: files.uuid,
+ extname: extname || '',
+ cloudPath: files.cloudPath,
+ fileType: files.fileType,
+ url: files.path || files.path,
+ size: files.size, //鍗曚綅鏄瓧鑺�
+ image: {},
+ path: files.path,
+ video: {}
+ }
+ if (type === 'image') {
+ const imageinfo = await get_file_info(files.path)
+ delete filedata.video
+ filedata.image.width = imageinfo.width
+ filedata.image.height = imageinfo.height
+ filedata.image.location = imageinfo.path
+ } else {
+ delete filedata.image
+ }
+ return filedata
+}
--
Gitblit v1.9.1