baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)
This commit is contained in:
commit
c2b0e7be0d
6522 files changed
+3530643
No files matched your search
+54
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title class="title">[文件管理器]</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
|
||||
<style type="text/css">
|
||||
.content {background: transparent;}
|
||||
.fixed {position: fixed;bottom: 0;left: 0;right: 0;width: 100%;}
|
||||
.content .mask {top: 0;background: rgba(0,0,0,.4);z-index: 90;}
|
||||
.content .file-content {z-index: 91;height: 60px;background: #fff;text-align: center;}
|
||||
.btn {position: relative;}
|
||||
.btn .file {position: absolute;z-index: 93;left: 0;right: 0;top: 0;bottom: 0;height: 60px;width: 100%;opacity: 0;}
|
||||
.btn-bg {margin-top: 10px;background: #0066CC;color: #fff;width: 80%;height: 40px;border: 0;border-radius: 5px;}
|
||||
.tis {top: 0;z-index: 95;display: none;justify-content: center;align-items: center;}
|
||||
.tis .tis-content {background: #fff;width: 60%;border-radius: 10px;padding: 20px 0;}
|
||||
.tis .tis-content img {width: 50px;height: 50px;}
|
||||
.tis-progress {margin: 10px 0;color: #999;}
|
||||
.cancel-btn {margin-top: 30px;height: 30px;line-height: 1;padding: 0 2em;background: #e3e3e3;color: #898989;border: 0;border-radius: 5px;}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="content">
|
||||
|
||||
<div class="fixed mask"></div>
|
||||
|
||||
<div align="center" class="fixed tis">
|
||||
<div class="tis-content">
|
||||
<div class="logo"></div>
|
||||
<div class="tis-progress">
|
||||
努力上传中..
|
||||
</div>
|
||||
<div class="cancel">
|
||||
<button type="button" class="cancel-btn">取消上传</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="fixed file-content">
|
||||
<div class="btn">
|
||||
<button type="button" class="btn-bg">打开文件管理器</button>
|
||||
<input class="file" type="file" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
|
||||
<script src="js/h5-uploader.js" type="text/javascript" charset="utf-8"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
let mask = document.querySelector(".mask");
|
||||
let fileDom = document.querySelector(".file");
|
||||
let tis = document.querySelector(".tis");
|
||||
let logoDom = document.querySelector(".logo");
|
||||
let progress = document.querySelector(".tis-progress");
|
||||
let cancel = document.querySelector(".cancel-btn");
|
||||
|
||||
|
||||
let createUpload = (file,{ url, key='file', header = {},data = {},addName,addSize}) => {
|
||||
console.log(`
|
||||
上传地址:${url}\n
|
||||
上传附件:${file.name} 附件大小:${file.size}\n
|
||||
请求头:${JSON.stringify(header)}\n
|
||||
业务参数:${JSON.stringify(data)}
|
||||
`);
|
||||
if (!url) {return;}
|
||||
tis.style.display = 'flex';
|
||||
|
||||
let formData = new FormData();
|
||||
for (let keys in data) {formData.append(keys, data[keys]);}
|
||||
if (addName) {formData.append(addName, file.name);console.log('补充参数:',JSON.stringify({addName:file.name}));}
|
||||
if (addSize) {formData.append(addSize, file.size);console.log('补充参数:',JSON.stringify({addSize:file.size}));}
|
||||
formData.append(key, file);
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", url, true);
|
||||
|
||||
for (let keys in header) {
|
||||
xhr.setRequestHeader(keys, header[keys]);
|
||||
}
|
||||
xhr.upload.addEventListener("progress", function(event) {
|
||||
if(event.lengthComputable){
|
||||
let percent = Math.ceil(event.loaded * 100 / event.total) + "%";
|
||||
progress.innerText = `努力上传中..${percent}`;
|
||||
}
|
||||
}, false);
|
||||
|
||||
xhr.ontimeout = function(){
|
||||
// xhr请求超时事件处理
|
||||
progress.innerText = '请求超时';
|
||||
setTimeout(()=>{
|
||||
tis.style.display = 'none';
|
||||
plus.webview.currentWebview().close();
|
||||
},1000);
|
||||
};
|
||||
|
||||
xhr.onreadystatechange = (ev) => {
|
||||
|
||||
if(xhr.readyState == 4) {
|
||||
console.log('status:'+xhr.status);
|
||||
|
||||
if (xhr.status == 200) {
|
||||
progress.innerText = '上传成功';
|
||||
console.log('服务端返回数据:'+xhr.responseText);
|
||||
location.href = `callback?fileName=${escape(file.name)}&size=${file.size}&str=${escape(xhr.responseText)}`;
|
||||
}
|
||||
else {
|
||||
progress.innerText = '上传失败了';
|
||||
if (xhr.status == 0) {
|
||||
console.log('请检查请求头Content-Type与服务端是否匹配,并确认服务端已正确开启跨域');
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(()=>{
|
||||
tis.style.display = 'none';
|
||||
plus.webview.currentWebview().close();
|
||||
},1000);
|
||||
|
||||
}
|
||||
};
|
||||
xhr.send(formData);
|
||||
|
||||
cancel.addEventListener("click", ()=>{
|
||||
xhr.abort();
|
||||
plus.webview.currentWebview().close();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
mask.addEventListener("click", () => {
|
||||
plus.webview.currentWebview().close();
|
||||
});
|
||||
|
||||
document.addEventListener('UniAppJSBridgeReady', () => {
|
||||
let {url,key,header,formData,logo,maxSize,addName,addSize} = plus.webview.currentWebview();
|
||||
if (logo) {
|
||||
let img = document.createElement('img');
|
||||
img.src = logo;
|
||||
logoDom.appendChild(img);
|
||||
}
|
||||
|
||||
fileDom.value = '';
|
||||
fileDom.addEventListener('change', (event) => {
|
||||
let file = fileDom.files[0];
|
||||
// 默认限制文件小于10M,可自行修改
|
||||
if(file.size > (1024*1024 * Math.abs(maxSize))) {
|
||||
plus.nativeUI.toast(`单个文件请勿超过${maxSize}M,请重新上传`);
|
||||
return;
|
||||
}
|
||||
console.log('flie------');
|
||||
uni.setStorageSync("flie--------", file);
|
||||
createUpload(file,{ url, key,header,addName,addSize,data:formData});
|
||||
}, false);
|
||||
});
|
||||
Reference in new issue
Block a user