Browse Source

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

新疆体育高职分支
liangkun 1 year ago
parent
commit
760745dee3
2 changed files with 67 additions and 26 deletions
  1. +59
    -25
      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

+ 59
- 25
Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/AnnexesApiWx.cs View File

@@ -7,18 +7,20 @@ using System.IO;

namespace Learun.Application.WebApi.Modules
{
public class AnnexesApiWx : BaseApi
{
public AnnexesApiWx()
: base("/learun/adms/annexes")
public class AnnexesApiWx : BaseApi
{
Get["/wxlist"] = WxGetList;
Get["/wxdown"] = WxDownload;
Get["/wxfileinfo"] = WxFileInfo;
Post["/wxupload"] = WxUpload;
Post["/wxdelete"] = WxDeleteFile;
}
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
public AnnexesApiWx()
: base("/learun/adms/annexes")
{
Get["/wxlist"] = WxGetList;
Get["/wxdown"] = WxDownload;
Get["/wxfileinfo"] = WxFileInfo;
Post["/wxupload"] = WxUpload;
Post["/wxbase64"] = WxUploadbase64;
Post["/wxdelete"] = WxDeleteFile;
Post["/wxuploadinsingle"] = WxUploadInSingle;
}
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();

/// <summary>
/// 获取附件列表
@@ -33,20 +35,52 @@ namespace Learun.Application.WebApi.Modules
return Success(list);
}

/// <summary>
/// 上传附件图片文件
/// <summary>
/// <returns></returns>
public Response WxUpload(dynamic _)
{
var files = (List<HttpFile>)this.Context.Request.Files;
var folderId = this.GetReqData();

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();
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>
/// <returns></returns>
public Response WxUpload(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();

string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, userInfo.userId, uploadDate, fileGuid, fileEextension);



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

@@ -141,6 +141,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() {
@@ -176,7 +183,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