From ee6b17e9441a8ba99191c1887f510c0efe38f718 Mon Sep 17 00:00:00 2001 From: liangkun Date: Tue, 25 Apr 2023 11:38:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E6=9C=BAapp=E7=AB=AF=E7=AD=BE?= =?UTF-8?q?=E7=AB=A0=E5=9B=BE=E7=89=87=E4=B8=8A=E4=BC=A0=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/AnnexesApiWx.cs | 34 +++++++++++++++++++ .../pages/nworkflow/myflow/sign.vue | 9 ++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AnnexesApiWx.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AnnexesApiWx.cs index 3f345891b..44cccb91e 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AnnexesApiWx.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AnnexesApiWx.cs @@ -16,6 +16,7 @@ namespace Learun.Application.WebApi.Modules Get["/wxdown"] = WxDownload; Get["/wxfileinfo"] = WxFileInfo; Post["/wxupload"] = WxUpload; + Post["/wxbase64"] = WxUploadbase64; Post["/wxdelete"] = WxDeleteFile; Post["/wxuploadinsingle"] = WxUploadInSingle; } @@ -34,6 +35,39 @@ namespace Learun.Application.WebApi.Modules return Success(list); } + public Response WxUploadbase64(dynamic _) + { + var files = (List)this.Context.Request.Files; + //string folderId = Request.Form["folderId"]; + //string filePath = Config.GetValue("AnnexesFile"); + //string uploadDate = DateTime.Now.ToString("yyyyMMdd"); + //string fileEextension = Path.GetExtension(files[0].Name); + //string fileType = fileEextension.Replace(".", ""); + //string fileGuid = Guid.NewGuid().ToString(); + byte[] bytes = new byte[files[0].Value.Length]; + files[0].Value.Read(bytes, 0, bytes.Length); + string src = Convert.ToBase64String(bytes); + //string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, userInfo.userId, uploadDate, fileGuid, fileEextension); + + ////创建文件夹 + //string path = Path.GetDirectoryName(virtualPath); + //Directory.CreateDirectory(path); + //AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity(); + //if (!System.IO.File.Exists(virtualPath)) + //{ + // byte[] bytes = new byte[files[0].Value.Length]; + // files[0].Value.Read(bytes, 0, bytes.Length); + // //FileInfo file = new FileInfo(virtualPath); + // //FileStream fs = file.Create(); + // //fs.Write(bytes, 0, bytes.Length); + // //fs.Close(); + // string src = "data:image/png;base64," + Convert.ToBase64String(bytes); + // //virtualPath + //} + + return SuccessString(src); + } + /// /// 上传附件图片文件 /// diff --git a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/myflow/sign.vue b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/myflow/sign.vue index 82caf3356..195ac899b 100644 --- a/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/myflow/sign.vue +++ b/Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/myflow/sign.vue @@ -300,6 +300,13 @@ export default { this.TOAST(`已成功提交${this.typeText}`, 'success') }, + newguid() { + return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = Math.random() * 16 | 0, + v = c == 'x' ? r : (r & 0x3 | 0x8); + return v.toString(16); + }); + }, // 点击「提交」按钮 async submit() { @@ -347,7 +354,7 @@ export default { // App 平台,canvasToTempFilePath 输出文件,上传后台转为 base64 格式 // #ifdef APP-VUE const [err, { tempFilePath }] = await uni.canvasToTempFilePath({ canvasId: 'sign-canvas' }) - const signBase64 = await this.HTTP_UPLOAD('/annexes/wxtobase64', tempFilePath) + const signBase64 = await this.HTTP_UPLOAD2('/learun/adms/annexes/wxbase64',tempFilePath,{folderId:this.newguid()}) postData.signUrl = 'data:image/png;base64,' + signBase64 // #endif