Browse Source

手机app端签章图片上传失败修复

应县
liangkun 1 year ago
parent
commit
ee6b17e944
2 changed files with 42 additions and 1 deletions
  1. +34
    -0
      Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AnnexesApiWx.cs
  2. +8
    -1
      Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/myflow/sign.vue

+ 34
- 0
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AnnexesApiWx.cs View File

@@ -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<HttpFile>)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);
}

/// <summary>
/// 上传附件图片文件
/// <summary>


+ 8
- 1
Learun.Framework.Ultimate V7/LearunApp-2.2.0/pages/nworkflow/myflow/sign.vue View File

@@ -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



Loading…
Cancel
Save