jinbi-utils 1.0.0-beta.4 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.versionrc.json +9 -0
- package/CHANGELOG.md +18 -0
- package/README.md +30 -0
- package/dist/index.esm.js +66 -2
- package/dist/index.esm.min.js +2 -2
- package/dist/index.umd.js +74 -6
- package/dist/index.umd.min.js +2 -2
- package/docs/assets/js/search.json +1 -1
- package/docs/globals.html +8 -0
- package/docs/index.html +8 -2
- package/docs/interfaces/constant.ifromtype.html +6 -0
- package/docs/interfaces/file.compressimgqualitycallback.html +6 -0
- package/docs/interfaces/file.compressimgscalecallback.html +6 -0
- package/docs/interfaces/file.exportbyblobparams.html +6 -0
- package/docs/interfaces/file.filesizeobject.html +6 -0
- package/docs/interfaces/file.genexportbyblobparams.html +6 -0
- package/docs/modules/common.html +6 -0
- package/docs/modules/constant.html +6 -0
- package/docs/modules/date.html +8 -2
- package/docs/modules/file.html +11 -5
- package/docs/modules/http.html +6 -0
- package/docs/modules/iam.html +185 -0
- package/docs/modules/middleware.html +182 -0
- package/docs/modules/number.html +6 -0
- package/docs/modules/object.html +8 -2
- package/docs/modules/print.html +6 -0
- package/docs/modules/string.html +6 -0
- package/docs/modules/validate.html +6 -0
- package/package.json +7 -2
- package/src/iam/index.ts +46 -0
- package/src/index.ts +2 -0
- package/src/middleware/requestLogger.middware.ts +61 -0
- package/types/iam/index.d.ts +1 -0
- package/types/index.d.ts +2 -0
- package/types/middleware/requestLogger.middware.d.ts +1 -0
package/.versionrc.json
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"types": [
|
|
3
|
+
{ "type": "feat", "section": "✨ Features" },
|
|
4
|
+
{ "type": "fix", "section": "🐞 Bug Fixes" },
|
|
5
|
+
{ "type": "docs", "section": "📖 Documentation" },
|
|
6
|
+
{ "type": "style", "section": "🎨 Style" }
|
|
7
|
+
],
|
|
8
|
+
"releaseCommitMessageFormat": "chore(release): 发布版本 v{{currentTag}}"
|
|
9
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
+
|
|
5
|
+
### [1.0.1](https://e.coding.net/jinbicloud/P8/jbwy-utils/compare/v1.0.0...v1.0.1) (2025-07-25)
|
|
6
|
+
|
|
7
|
+
## 1.0.0 (2025-07-25)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### ✨ Features
|
|
11
|
+
|
|
12
|
+
* 1.调整日志中间件 接入的服务地址 ([5bf17c3](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/5bf17c3ada3ec825c7dc8ac1f1cae74e1ea54e76))
|
|
13
|
+
* 1.新增 nodejs 日志中间件工具库 2. 新增iam工具库 ([07a48c8](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/07a48c87cb061401aadca3026a7821ee6f0b8069))
|
|
14
|
+
* 更新版本和依赖项 ([1bcc026](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/1bcc026a8d2c8019180e0418bde7bef485ade566))
|
|
15
|
+
* 删除 wecom 模块及相关文档 ([6ef1215](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/6ef12157d1b7ff4b4bd1217a34fcca5af49bc3e2))
|
|
16
|
+
* 添加版本控制配置和更新依赖项 ([cfecef1](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/cfecef19fff25fb167ae251246ee268d9caaaa22))
|
|
17
|
+
* 添加新模块和配置更新 ([bba4a67](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/bba4a67f1f5094dd89f6e51708aa50f8e1b00b65))
|
|
18
|
+
* 新增分转元方法 ([cc9d640](https://e.coding.net/jinbicloud/P8/jbwy-utils/commit/cc9d640d53497c4c7784606538d9a0bf49bd15cb))
|
package/README.md
CHANGED
|
@@ -140,6 +140,36 @@ import { initWWConfig } from 'jbwy-utils/wecom'
|
|
|
140
140
|
// 初始化企业微信配置
|
|
141
141
|
initWWConfig()
|
|
142
142
|
```
|
|
143
|
+
## 8. middleware 模块 (middleware)
|
|
144
|
+
中间件相关功能:
|
|
145
|
+
### 8.1 requestLogger.middware.ts
|
|
146
|
+
|
|
147
|
+
日志服务 此插件支持使用了koa的nodejs项目
|
|
148
|
+
注意:(recordLogMiddleWare('project-plan-service'))需要传入项目名,日志文件会根据传入的项目名来 命名前缀
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
// midway 项目接入方案 configuration.ts
|
|
152
|
+
import { recordLogMiddleWare } from 'jinbi-utils'
|
|
153
|
+
|
|
154
|
+
export class MainConfiguration {
|
|
155
|
+
@App('koa')
|
|
156
|
+
app: koa.Application;
|
|
157
|
+
|
|
158
|
+
async onReady() {
|
|
159
|
+
//
|
|
160
|
+
this.app.useMiddleware([recordLogMiddleWare('project-plan-service')]);
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
```typescript
|
|
166
|
+
// 只用了koa的nodejs项目接入方案 app.js
|
|
167
|
+
import { recordLogMiddleWare } from 'jinbi-utils'
|
|
168
|
+
|
|
169
|
+
const app = new Koa();
|
|
170
|
+
app.use(bodyParser());
|
|
171
|
+
app.use(router.routes()).use(router.allowedMethods()).use(recordLogMiddleWare('project-plan-service'));
|
|
172
|
+
```
|
|
143
173
|
|
|
144
174
|
## 安装和使用
|
|
145
175
|
|
package/dist/index.esm.js
CHANGED
|
@@ -1347,7 +1347,7 @@ var request = axios.create({
|
|
|
1347
1347
|
* @param tokenKey
|
|
1348
1348
|
* */
|
|
1349
1349
|
var http = function (_a) {
|
|
1350
|
-
var cacheType = _a.cacheType, currentMode = _a.currentMode, errorCb = _a.errorCb, getTokenCb = _a.getTokenCb
|
|
1350
|
+
var cacheType = _a.cacheType, currentMode = _a.currentMode, errorCb = _a.errorCb, getTokenCb = _a.getTokenCb; _a.tokenKey;
|
|
1351
1351
|
request.interceptors.request.use(function (config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1352
1352
|
var token, deviceType;
|
|
1353
1353
|
return __generator(this, function (_a) {
|
|
@@ -1400,4 +1400,68 @@ var http = function (_a) {
|
|
|
1400
1400
|
return request;
|
|
1401
1401
|
};
|
|
1402
1402
|
|
|
1403
|
-
|
|
1403
|
+
var recordLogMiddleWare = function (systemName) {
|
|
1404
|
+
return function (ctx, next) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1405
|
+
var ip, path, method, timeToString, requestParams, headers, result, logData;
|
|
1406
|
+
return __generator(this, function (_a) {
|
|
1407
|
+
switch (_a.label) {
|
|
1408
|
+
case 0:
|
|
1409
|
+
ip = ctx.ip || ctx.request.ip;
|
|
1410
|
+
path = ctx.path;
|
|
1411
|
+
method = ctx.method;
|
|
1412
|
+
timeToString = new Date().toISOString();
|
|
1413
|
+
requestParams = {
|
|
1414
|
+
method: ctx.method,
|
|
1415
|
+
url: ctx.url,
|
|
1416
|
+
query: ctx.query,
|
|
1417
|
+
body: ctx.request.body,
|
|
1418
|
+
};
|
|
1419
|
+
headers = ctx.headers;
|
|
1420
|
+
// 继续处理后续中间件
|
|
1421
|
+
return [4 /*yield*/, next()];
|
|
1422
|
+
case 1:
|
|
1423
|
+
// 继续处理后续中间件
|
|
1424
|
+
_a.sent();
|
|
1425
|
+
result = {
|
|
1426
|
+
status: ctx.status,
|
|
1427
|
+
body: ctx.body,
|
|
1428
|
+
headers: ctx.response.headers,
|
|
1429
|
+
};
|
|
1430
|
+
logData = {
|
|
1431
|
+
system: systemName,
|
|
1432
|
+
ip: ip,
|
|
1433
|
+
path: path,
|
|
1434
|
+
method: method,
|
|
1435
|
+
time: timeToString,
|
|
1436
|
+
params: requestParams,
|
|
1437
|
+
headers: headers,
|
|
1438
|
+
result: result,
|
|
1439
|
+
};
|
|
1440
|
+
sendLog(logData);
|
|
1441
|
+
return [2 /*return*/];
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
}); };
|
|
1445
|
+
};
|
|
1446
|
+
var sendLog = function (logData) {
|
|
1447
|
+
console.log('logData---------', logData);
|
|
1448
|
+
var LOG_HOST = 'http://localhost:7003';
|
|
1449
|
+
axios.post(LOG_HOST + "/log/save", logData);
|
|
1450
|
+
};
|
|
1451
|
+
|
|
1452
|
+
// 获取state,(针对iam跳转)
|
|
1453
|
+
var getUrlState = function (route) {
|
|
1454
|
+
var state = route.query.state;
|
|
1455
|
+
var stateObj = {};
|
|
1456
|
+
if (state && typeof state === 'string' && state.indexOf('?') > -1) {
|
|
1457
|
+
var jsonPart = state.slice(0, state.indexOf('?'));
|
|
1458
|
+
// const queryPart = state.slice(state.indexOf('?') + 1);
|
|
1459
|
+
stateObj = JSON.parse(decodeURIComponent(jsonPart));
|
|
1460
|
+
}
|
|
1461
|
+
else if (state && typeof state === 'string') {
|
|
1462
|
+
stateObj = JSON.parse(decodeURIComponent(state));
|
|
1463
|
+
}
|
|
1464
|
+
return stateObj;
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1467
|
+
export { addDays, base64ToBlob, base64ToFile, blobToDataURL, buildUUID, calcFileSize, ceil, clearLoginData, compatibleDate, compressImg, computeMoney, convertBase64UrlToBlob, convertCurrency, dataURLtoBlob, deepEqual, fileSizeFormat, filterRepeat, findNodePath, floor, formatBank, formatCentsToYuan, formatEmptyValue, formatFloat, formatMoney, formatPhone, formatPhoneHide, formatTime, formateTimestamp, fromNow, genExportByBlob, generateEnglishLetters, getCookie, getDeviceType, getEnvironment, getFileData, getFromType, getIsComWx, getIsDevelopment, getQueryString, getQueryVariable, getTicket, getToken, getUrlState, getWecomToken, http, httpEnum, humpTurnDashed, isEmail, isEmpty, isExternal, isImage, isMobile, isMobileSimple, isQQ, isTelephone, newDate, randomString, recordLogMiddleWare, removeTicket, removeToken, setTicket, toThousands, trimVal, uuid, validateTwoDecimal };
|
package/dist/index.esm.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"axios";var t={isWxWork:"wecom",isWeixin:"wechat",isMobile:"mobile",isMobileAny:"mobile"};function r(e){return null===e||""===e||void 0===e}var n=function(){localStorage.removeItem("wecom_userinfo"),localStorage.removeItem("wecom_token"),localStorage.removeItem("projectActive"),localStorage.removeItem("loginTime"),localStorage.removeItem("projectInfo")},o=function(e,t){var r=new RegExp("&{1}"+t+"\\=[a-zA-Z0-9_-]+","g"),n=e.replace(/\?/g,"&").match(r)[0];return n.substr(n.indexOf("=")+1)},i=function(e){for(var t=window.location.search.substring(1).split("&"),r=0;r<t.length;r++){var n=t[r].split("=");if(n[0]===e)return n[1]}return!1},a=function(){return localStorage.getItem("wecom_token")},u=function(){var e=navigator.userAgent.toLowerCase(),t=/wxwork/.test(e),r=/micromessenger/.test(e)&&!t,n=window.innerWidth<=768;return{isWxWork:t,isWeixin:r,isMobileScreen:n,isMobileAny:t||r||n}},c=function(e){var r="wecom";for(var n in e){if(e[n]){r=t[n];break}}return r};function s(e){e=e||32;for(var t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",r=t.length,n="",o=0;o<e;o++)n+=t.charAt(Math.floor(Math.random()*r));return n}var l=function(e){for(var t="",r=document.cookie.split("; "),n=0;n<r.length;n++){var o=r[n].split("=");if(o[0]===e){t=o[1];break}}return t},f=function(){for(var e=[],t=0;t<=15;t++)e[t]=t.toString(16);var r="";for(t=1;t<=36;t++)r+=9===t||14===t||19===t||24===t?"-":15===t?4:20===t?e[4*Math.random()|8]:e[16*Math.random()|0];return r.replace(/-/g,"")},d=function(){return localStorage.getItem("jsapiTicket")},g=function(e){return localStorage.setItem("jsapiTicket",e)},
|
|
1
|
+
import e from"axios";var t={isWxWork:"wecom",isWeixin:"wechat",isMobile:"mobile",isMobileAny:"mobile"};function r(e){return null===e||""===e||void 0===e}var n=function(){localStorage.removeItem("wecom_userinfo"),localStorage.removeItem("wecom_token"),localStorage.removeItem("projectActive"),localStorage.removeItem("loginTime"),localStorage.removeItem("projectInfo")},o=function(e,t){var r=new RegExp("&{1}"+t+"\\=[a-zA-Z0-9_-]+","g"),n=e.replace(/\?/g,"&").match(r)[0];return n.substr(n.indexOf("=")+1)},i=function(e){for(var t=window.location.search.substring(1).split("&"),r=0;r<t.length;r++){var n=t[r].split("=");if(n[0]===e)return n[1]}return!1},a=function(){return localStorage.getItem("wecom_token")},u=function(){var e=navigator.userAgent.toLowerCase(),t=/wxwork/.test(e),r=/micromessenger/.test(e)&&!t,n=window.innerWidth<=768;return{isWxWork:t,isWeixin:r,isMobileScreen:n,isMobileAny:t||r||n}},c=function(e){var r="wecom";for(var n in e){if(e[n]){r=t[n];break}}return r};function s(e){e=e||32;for(var t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",r=t.length,n="",o=0;o<e;o++)n+=t.charAt(Math.floor(Math.random()*r));return n}var l=function(e){for(var t="",r=document.cookie.split("; "),n=0;n<r.length;n++){var o=r[n].split("=");if(o[0]===e){t=o[1];break}}return t},f=function(){for(var e=[],t=0;t<=15;t++)e[t]=t.toString(16);var r="";for(t=1;t<=36;t++)r+=9===t||14===t||19===t||24===t?"-":15===t?4:20===t?e[4*Math.random()|8]:e[16*Math.random()|0];return r.replace(/-/g,"")},d=function(){return localStorage.getItem("jsapiTicket")},g=function(e){return localStorage.setItem("jsapiTicket",e)},p=function(){return localStorage.removeItem("jsapiTicket")},h=function(e,t){if(void 0===t&&(t="YYYY年MM月DD日 hh:mm:ss"),!e)return"-";var r=new Date(e),n=r.getFullYear()+"",o=r.getMonth()+1,i=r.getDate(),a=r.getHours()>9?r.getHours():"0"+r.getHours(),u=r.getMinutes()>9?r.getMinutes():"0"+r.getMinutes(),c=r.getSeconds()>9?r.getSeconds():"0"+r.getSeconds();return t.replace("YYYY",n+"").replace("MM",o+"").replace("DD",i+"").replace("hh",a+"").replace("mm",u+"").replace("ss",c+"")},v=function(e){for(var t=window.atob(e.split(",")[1]),r=new ArrayBuffer(t.length),n=new Uint8Array(r),o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return new Blob([r],{type:"image/png"})},m=function(){var e=window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i),t=/micromessenger/i.test(navigator.userAgent),r=/wxwork/i.test(navigator.userAgent);return r&&e?"com-wx-mobile":r&&!e?"com-wx-pc":t&&e?"wx-mobile":t&&!e?"wx-pc":"other"},w=function(){return/wxwork/i.test(navigator.userAgent)},y=function(){var e=!1;return"uat2-h5-wecom.hengdayun.com"!==location.origin&&"127.0.0.1:8081"!==location.origin&&"localhost:8081"!==location.origin||(e=!0),e},b=function(e,t){var r=new Set;return e.filter((function(e){var n=e[t];return!r.has(n)&&(r.add(n),!0)}))},S=function(e){for(var t=e.split(","),r=t[0].match(/:(.\*?);/)[1],n=atob(t[1]),o=n.length,i=new Uint8Array(o);o--;)i[o]=n.charCodeAt(o);return new Blob([i],{type:r})},M=function(e,t){for(var r=e.split(","),n=r[0].match(/:(.*);/)[1],o=atob(r[1]),i=o.length,a=new Uint8Array(i);i--;)a[i]=o.charCodeAt(i);return new File([a],t,{type:n})},A=function(e){return/^image\//i.test(e)},C=function(e){var t=e.split(","),r=t[0],n=void 0===r?"":r,o=t[1],i=void 0===o?"":o;return{name:decodeURIComponent(n),url:decodeURIComponent(i)}},R=function(e){return!e||""===e||/^(\d+)(\.\d{1,2})?$/.test(e.toString())},x=function(e,t){var r,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];if(t=t||n.length,e)for(r=0;r<e;r++)o[r]=n[0|Math.random()*t];else{var i=void 0;for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",r=0;r<36;r++)o[r]||(i=0|16*Math.random(),o[r]=n[19==r?3&i|8:i])}return o.join("")},I=function(e,t){var r=e.toLowerCase();return"localstorage"===r?localStorage.getItem("token")||"":"sessionstorage"===r?sessionStorage.getItem("token")||"":localStorage.getItem("token")||sessionStorage.getItem("token")||""},k=function(e,t){var r=e.toLowerCase();"localstorage"===r?localStorage.removeItem("token"):"sessionstorage"===r?sessionStorage.removeItem("token"):(localStorage.removeItem("token"),sessionStorage.getItem("token"))};function E(e){return"string"==typeof e?e.replace(/-/g,"/"):e}function N(e){return e?new Date(E(e)):new Date}function T(e,t){void 0===e&&(e=Date.now()),void 0===t&&(t="yyyy-MM-dd HH:mm:ss"),e=E(e);var r={"M+":(e=new Date(e)).getMonth()+1,"d+":e.getDate(),"h+":e.getHours()%12==0?12:e.getHours()%12,"H+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};return/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(""+e.getFullYear()).substr(4-RegExp.$1.length))),Object.keys(r).forEach((function(e){new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?r[e]:("00"+r[e]).substr((""+r[e]).length)))})),t}function D(e,t,n){if(void 0===t&&(t="yyyy年MM月dd日 HH时mm分ss秒"),void 0===n&&(n="-"),r(e))return n;e=E(e);var o=new Date(e),i=(Date.now()-o.getTime())/1e3;return i<0?e:i<30?"刚刚":i<3600?Math.ceil(i/60)+"分钟前":i<86400?Math.floor(i/3600)+"小时前":i<172800?"1天前":T(e,t)}function O(e,t,n){if(void 0===t&&(t=0),void 0===n&&(n="yyyy-MM-dd"),r(e))return"-";e=E(e);var o=new Date(e);return o.setDate(o.getDate()+Number(t)),T(o,n)}
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -12,4 +12,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
12
12
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */var U=function(){return(U=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function B(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}c((n=n.apply(e,t||[])).next())}))}function O(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var F={operation:"divide",factor:100,precision:2,formatAsCurrency:!1,currencySymbol:"¥"};function j(e,t){if(void 0===t&&(t="-"),r(e))return t;var n=e.toString();return n.includes(".")||(n+="."),n.replace(/\d(?=(\d{3})+\.)/g,(function(e){return e+","})).replace(/\.$/,"")}function z(e){void 0===e&&(e="");if(r(e))return"";if(Number(e)>=1e15)return e;var t,n,o,i=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],a=["","拾","佰","仟"],u=["","万","亿","兆"],c=["角","分","毫","厘"],s="";if("0"===(e=parseFloat(e).toString()))return s=i[0]+"元整";if(-1===(e=e.toString()).indexOf(".")?(t=e,n=""):(t=(o=e.split("."))[0],n=o[1].substr(0,4)),parseInt(t,10)>0){for(var l=0,f=t.length,d=0;d<f;d+=1){var g=t.substr(d,1),v=f-d-1,p=v/4,h=v%4;"0"===g?l+=1:(l>0&&(s+=i[0]),l=0,s+=i[parseInt(g,10)]+a[h]),0===h&&l<4&&(s+=u[p])}s+="元"}if(""!==n){var m=n.length;for(d=0;d<m;d+=1){var w=n.substr(d,1);"0"!==w&&(s+=i[Number(w)]+c[d])}}return""===s?s+=i[0]+"元整":""===n&&(s+="整"),s}function H(e,t){void 0===t&&(t=2);var r=parseFloat(String(e));if(Number.isNaN(r))return"";var n=(r=Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)).toString(),o=n.indexOf(".");for(o<0&&(o=n.length,n+=".");n.length<=o+t;)n+="0";return n}function W(e,t){if(void 0===t&&(t=0),r(e))return e;var n=Math.pow(10,t),o=Number(e)*n;return Math.ceil(o)/n}function $(e,t){if(void 0===t&&(t=0),r(e))return e;var n=Math.pow(10,t),o=Number(e)*n;return Math.floor(o)/n}function Y(e,t){var r=_(e,t),n=U(U({},F),t);if(n.formatter)return n.formatter(r);if(n.formatAsCurrency){var o=r.toFixed(n.precision),i=r>=1e3?j(o):o;return""+n.currencySymbol+i}return r.toFixed(n.precision)}function _(e,t){var r,n,o=U(U({},F),t);if(null==e||""===e)return 0;if("string"==typeof e){var i=e.replace(/[^\d.-]/g,"");r=i?parseFloat(i):0}else r=e;if(isNaN(r))return 0;if(n="multiply"===o.operation?r*o.factor:0!==o.factor?r/o.factor:0,void 0!==o.precision){var a=Math.pow(10,o.precision);n=Math.round(n*a)/a}return n}function L(e,t){return Y(e,U({operation:"divide",factor:100,formatAsCurrency:!0},t))}function q(e,t){void 0===t&&(t="B");var r=["B","KB","MB","GB","TB"],n=r.indexOf(t.toUpperCase());for(n=-1===n?0:n;e>=1024&&n<r.length;)e/=1024,n+=1;return{size:e,unit:r[n]}}function G(e,t,n){if(void 0===t&&(t="B"),void 0===n&&(n="-"),r(e))return n;var o=q(parseFloat(e.toString()),t);return""+W(o.size,2)+o.unit}function Z(e){for(var t=e.match(/:(.*?);/)[1],r=window.atob(e.split(",")[1]),n=new ArrayBuffer(r.length),o=new Uint8Array(n),i=0;i<r.length;i+=1)o[i]=r.charCodeAt(i);return new Blob([n],{type:t})}function Q(e){return new Promise((function(t,r){var n=new FileReader;n.onload=function(e){e&&e.target?t(e.target.result):r(e)},n.onerror=function(e){r(e)},n.readAsDataURL(e)}))}function J(e,t,r){return new Promise((function(n,o){var i=parseFloat((e.size/1024/1024).toString()),a=new FileReader;a.onload=function(a){var u=new Image;u.onload=function(){var o=u.width,a=u.height,c=document.createElement("canvas"),s=c.getContext("2d"),l=t?t(o,a):1;(Number.isNaN(l)||"number"!=typeof l)&&(l=1);var f=r?r(i,l,o,a):1;if((Number.isNaN(f)||"number"!=typeof f)&&(f=1),s){var d=parseInt((o*l).toString(),10),g=parseInt((a*l).toString(),10);c.setAttribute("width",d.toString()),c.setAttribute("height",g.toString()),s.drawImage(u,0,0,d,g)}var v=c.toDataURL(e.type,f);n(Z(v))},u.onerror=function(e){o(e)},a.target&&(u.src=a.target.result)},a.onerror=function(e){o(e)},a.readAsDataURL(e)}))}function K(e){var t=e.axiosRequest,r=e.notWithCredentials,n=void 0===r?[]:r;return function(e){var r=this,o=e.filename,i=e.url,a=e.data,u=void 0===a?{}:a,c=e.params,s=void 0===c?{}:c,l=e.method,f=void 0===l?"post":l;return new Promise((function(e,a){t({method:f,url:i,data:u,params:s,responseType:"blob",config:{withCredentials:n.some((function(e){return!i.includes(e)}))}}).then((function(t){return B(r,void 0,void 0,(function(){var r,n,i,u,c,s,l,f,d,g;return O(this,(function(v){switch(v.label){case 0:return"application/json"!==(r=null==t?void 0:t.data).type?[3,1]:((n=new FileReader).readAsText(r,"utf-8"),n.onload=function(){var e={};try{e=JSON.parse(n.result)}catch(t){e=r}a(e)},[3,3]);case 1:try{i=t.headers,u=i["content-disposition"],c=decodeURIComponent(u.split(";")[1].split("filename=")[1]),o&&!o.includes(".")?(s=c.split("."),l=s[s.length-1],o+="."+l):o||(o=c)}catch(e){o||(o="download.xlsx")}return f=new Blob([t.data]),d=document.createElement("a"),[4,Q(f)];case 2:g=v.sent(),d.href=g,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),e(t),v.label=3;case 3:return[2]}}))}))})).catch((function(e){a(e)}))}))}}function V(e,t){var r=Object.keys,n=typeof e;return e&&t&&"object"===n&&n===typeof t?r(e).length===r(t).length&&r(e).every((function(r){return V(e[r],t[r])})):e===t}function X(e,t,r,n,o){if(void 0===o&&(o=[]),o.push(e),e[r]===t)throw"GOT IT!";if(e[n]&&e[n].length>0)for(var i=0;i<e[n].length;i++)X(e[n][i],t,r,n,o);o.pop()}function ee(e,t,r,n){var o=[];try{for(var i=0;i<r.length;i++)X(r[i],e,t,n,o)}catch(e){return o}}function te(e){return/^(https?:|mailto:|tel:)/.test(e)}function re(e){if(!e)return e;return e.replace(/^\s+|\s+$/g,"")}function ne(e){return/^0?(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/.test(e.toString())}function oe(e){return e=e.toString(),/^1/.test(e)&&11===e.length}function ie(e){return/^0[1-9][0-9]{1,2}-[2-8][0-9]{6,7}$/.test(String(e))}function ae(e){return/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(e)}function ue(e){return/^[1-9][0-9]{4,9}$/gim.test(String(e))}function ce(e,t){return void 0===t&&(t="-"),r(e)?t:e}function se(e,t,n){if(void 0===t&&(t=" "),void 0===n&&(n="-"),r(e))return n;if(11!==e.toString().length)return e;var o=e.toString().replace(/[^\d]/g,"").split(""),i="";return o.forEach((function(e,r){3!==r&&7!==r||(i+=t),i+=e})),i}function le(e,t){if(void 0===t&&(t=""),r(e))return t;if(11!==e.toString().length)return e;var n=e.toString();return n.substr(0,3)+"****"+n.substr(7,11)}function fe(e,t){return void 0===t&&(t=""),r(e)?t:e.toString().replace(/\s/g,"").replace(/(.{4})/g,"$1 ")}function de(){for(var e=[],t=65;t<91;t+=1)e.push(String.fromCharCode(t));return e}function ge(e){void 0===e&&(e="");return e.replace(/\B([A-Z])/g,"-$1").toLowerCase()}var ve={HTTP_STATUS:{TEMP_RESPOND:{Continue:100,SwitchingProtocal:101},SUCCESS:{Ok:200,Created:201,Accepted:202,NoAuthoritativeInformation:203,NoContent:204,ResetContent:205,ParticalContent:206},REDIRECT:{MultipleChoice:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308},REQUEST_ERROR:{BadRequest:400,UnAuthorized:401,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAccepted:406,ProxyAuthorizationRequired:407,RequestTimeout:408,UpgradeRequired:426,TokenUnAuthorized:499},SERVER_ERROR:{InternalServerError:500,BadGateway:502,ServiceUnavailable:503,GateTimeout:504,HttpVersionNotSupported:505}},CODES:{Success:"00000",UnAuthorized:"00099",UnAuthorizedPhone:"11001",UnAuthorizedWecom:"11000",UnAuthorizedHavePhone:"11002"},ERR_CODE_WHITE_LIST:[]},pe=e.create({timeout:15e3,headers:{"Content-Type":"application/json"}}),he=function(e){var t=e.cacheType,r=e.currentMode,n=e.errorCb,o=e.getTokenCb;e.tokenKey;return pe.interceptors.request.use((function(e){return B(void 0,void 0,void 0,(function(){var r,n;return O(this,(function(o){return r=k(t),n=u(),e.headers.Authorization=r,e.headers.token=r,e.headers.FrontType=c(n),[2,e]}))}))}),(function(e){return Promise.reject(e)})),pe.interceptors.response.use((function(e){return B(void 0,void 0,void 0,(function(){var n,i,a;return O(this,(function(u){return n=e.data,i=n.code||e.status,n instanceof Blob||i===ve.CODES.Success?[2,n]:i===ve.CODES.UnAuthorized?("local"!==r&&"dev"!==r&&"development"!==r&&(E(t),o&&"function"==typeof o&&o()),[2,Promise.reject(new Error("token过期!"))]):(a=n.message||n.msg,[2,Promise.reject(new Error(a||"Error"))])}))}))}),(function(e){return B(void 0,void 0,void 0,(function(){return O(this,(function(t){return n&&"function"==typeof n&&n(e),[2,Promise.reject(e)]}))}))})),pe};export{P as addDays,S as base64ToBlob,M as base64ToFile,Q as blobToDataURL,f as buildUUID,q as calcFileSize,W as ceil,n as clearLoginData,I as compatibleDate,J as compressImg,_ as computeMoney,h as convertBase64UrlToBlob,z as convertCurrency,Z as dataURLtoBlob,V as deepEqual,G as fileSizeFormat,b as filterRepeat,ee as findNodePath,$ as floor,fe as formatBank,L as formatCentsToYuan,ce as formatEmptyValue,H as formatFloat,Y as formatMoney,se as formatPhone,le as formatPhoneHide,N as formatTime,p as formateTimestamp,D as fromNow,K as genExportByBlob,de as generateEnglishLetters,l as getCookie,u as getDeviceType,m as getEnvironment,C as getFileData,c as getFromType,w as getIsComWx,y as getIsDevelopment,o as getQueryString,i as getQueryVariable,d as getTicket,k as getToken,a as getWecomToken,he as http,ve as httpEnum,ge as humpTurnDashed,ae as isEmail,r as isEmpty,te as isExternal,A as isImage,ne as isMobile,oe as isMobileSimple,ue as isQQ,ie as isTelephone,T as newDate,s as randomString,v as removeTicket,E as removeToken,g as setTicket,j as toThousands,re as trimVal,x as uuid,R as validateTwoDecimal};
|
|
15
|
+
***************************************************************************** */var U=function(){return(U=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function P(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}c((n=n.apply(e,t||[])).next())}))}function B(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var F={operation:"divide",factor:100,precision:2,formatAsCurrency:!1,currencySymbol:"¥"};function j(e,t){if(void 0===t&&(t="-"),r(e))return t;var n=e.toString();return n.includes(".")||(n+="."),n.replace(/\d(?=(\d{3})+\.)/g,(function(e){return e+","})).replace(/\.$/,"")}function z(e){void 0===e&&(e="");if(r(e))return"";if(Number(e)>=1e15)return e;var t,n,o,i=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],a=["","拾","佰","仟"],u=["","万","亿","兆"],c=["角","分","毫","厘"],s="";if("0"===(e=parseFloat(e).toString()))return s=i[0]+"元整";if(-1===(e=e.toString()).indexOf(".")?(t=e,n=""):(t=(o=e.split("."))[0],n=o[1].substr(0,4)),parseInt(t,10)>0){for(var l=0,f=t.length,d=0;d<f;d+=1){var g=t.substr(d,1),p=f-d-1,h=p/4,v=p%4;"0"===g?l+=1:(l>0&&(s+=i[0]),l=0,s+=i[parseInt(g,10)]+a[v]),0===v&&l<4&&(s+=u[h])}s+="元"}if(""!==n){var m=n.length;for(d=0;d<m;d+=1){var w=n.substr(d,1);"0"!==w&&(s+=i[Number(w)]+c[d])}}return""===s?s+=i[0]+"元整":""===n&&(s+="整"),s}function H(e,t){void 0===t&&(t=2);var r=parseFloat(String(e));if(Number.isNaN(r))return"";var n=(r=Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)).toString(),o=n.indexOf(".");for(o<0&&(o=n.length,n+=".");n.length<=o+t;)n+="0";return n}function W(e,t){if(void 0===t&&(t=0),r(e))return e;var n=Math.pow(10,t),o=Number(e)*n;return Math.ceil(o)/n}function q(e,t){if(void 0===t&&(t=0),r(e))return e;var n=Math.pow(10,t),o=Number(e)*n;return Math.floor(o)/n}function $(e,t){var r=Y(e,t),n=U(U({},F),t);if(n.formatter)return n.formatter(r);if(n.formatAsCurrency){var o=r.toFixed(n.precision),i=r>=1e3?j(o):o;return""+n.currencySymbol+i}return r.toFixed(n.precision)}function Y(e,t){var r,n,o=U(U({},F),t);if(null==e||""===e)return 0;if("string"==typeof e){var i=e.replace(/[^\d.-]/g,"");r=i?parseFloat(i):0}else r=e;if(isNaN(r))return 0;if(n="multiply"===o.operation?r*o.factor:0!==o.factor?r/o.factor:0,void 0!==o.precision){var a=Math.pow(10,o.precision);n=Math.round(n*a)/a}return n}function _(e,t){return $(e,U({operation:"divide",factor:100,formatAsCurrency:!0},t))}function L(e,t){void 0===t&&(t="B");var r=["B","KB","MB","GB","TB"],n=r.indexOf(t.toUpperCase());for(n=-1===n?0:n;e>=1024&&n<r.length;)e/=1024,n+=1;return{size:e,unit:r[n]}}function G(e,t,n){if(void 0===t&&(t="B"),void 0===n&&(n="-"),r(e))return n;var o=L(parseFloat(e.toString()),t);return""+W(o.size,2)+o.unit}function Z(e){for(var t=e.match(/:(.*?);/)[1],r=window.atob(e.split(",")[1]),n=new ArrayBuffer(r.length),o=new Uint8Array(n),i=0;i<r.length;i+=1)o[i]=r.charCodeAt(i);return new Blob([n],{type:t})}function J(e){return new Promise((function(t,r){var n=new FileReader;n.onload=function(e){e&&e.target?t(e.target.result):r(e)},n.onerror=function(e){r(e)},n.readAsDataURL(e)}))}function Q(e,t,r){return new Promise((function(n,o){var i=parseFloat((e.size/1024/1024).toString()),a=new FileReader;a.onload=function(a){var u=new Image;u.onload=function(){var o=u.width,a=u.height,c=document.createElement("canvas"),s=c.getContext("2d"),l=t?t(o,a):1;(Number.isNaN(l)||"number"!=typeof l)&&(l=1);var f=r?r(i,l,o,a):1;if((Number.isNaN(f)||"number"!=typeof f)&&(f=1),s){var d=parseInt((o*l).toString(),10),g=parseInt((a*l).toString(),10);c.setAttribute("width",d.toString()),c.setAttribute("height",g.toString()),s.drawImage(u,0,0,d,g)}var p=c.toDataURL(e.type,f);n(Z(p))},u.onerror=function(e){o(e)},a.target&&(u.src=a.target.result)},a.onerror=function(e){o(e)},a.readAsDataURL(e)}))}function K(e){var t=e.axiosRequest,r=e.notWithCredentials,n=void 0===r?[]:r;return function(e){var r=this,o=e.filename,i=e.url,a=e.data,u=void 0===a?{}:a,c=e.params,s=void 0===c?{}:c,l=e.method,f=void 0===l?"post":l;return new Promise((function(e,a){t({method:f,url:i,data:u,params:s,responseType:"blob",config:{withCredentials:n.some((function(e){return!i.includes(e)}))}}).then((function(t){return P(r,void 0,void 0,(function(){var r,n,i,u,c,s,l,f,d,g;return B(this,(function(p){switch(p.label){case 0:return"application/json"!==(r=null==t?void 0:t.data).type?[3,1]:((n=new FileReader).readAsText(r,"utf-8"),n.onload=function(){var e={};try{e=JSON.parse(n.result)}catch(t){e=r}a(e)},[3,3]);case 1:try{i=t.headers,u=i["content-disposition"],c=decodeURIComponent(u.split(";")[1].split("filename=")[1]),o&&!o.includes(".")?(s=c.split("."),l=s[s.length-1],o+="."+l):o||(o=c)}catch(e){o||(o="download.xlsx")}return f=new Blob([t.data]),d=document.createElement("a"),[4,J(f)];case 2:g=p.sent(),d.href=g,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),e(t),p.label=3;case 3:return[2]}}))}))})).catch((function(e){a(e)}))}))}}function V(e,t){var r=Object.keys,n=typeof e;return e&&t&&"object"===n&&n===typeof t?r(e).length===r(t).length&&r(e).every((function(r){return V(e[r],t[r])})):e===t}function X(e,t,r,n,o){if(void 0===o&&(o=[]),o.push(e),e[r]===t)throw"GOT IT!";if(e[n]&&e[n].length>0)for(var i=0;i<e[n].length;i++)X(e[n][i],t,r,n,o);o.pop()}function ee(e,t,r,n){var o=[];try{for(var i=0;i<r.length;i++)X(r[i],e,t,n,o)}catch(e){return o}}function te(e){return/^(https?:|mailto:|tel:)/.test(e)}function re(e){if(!e)return e;return e.replace(/^\s+|\s+$/g,"")}function ne(e){return/^0?(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/.test(e.toString())}function oe(e){return e=e.toString(),/^1/.test(e)&&11===e.length}function ie(e){return/^0[1-9][0-9]{1,2}-[2-8][0-9]{6,7}$/.test(String(e))}function ae(e){return/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(e)}function ue(e){return/^[1-9][0-9]{4,9}$/gim.test(String(e))}function ce(e,t){return void 0===t&&(t="-"),r(e)?t:e}function se(e,t,n){if(void 0===t&&(t=" "),void 0===n&&(n="-"),r(e))return n;if(11!==e.toString().length)return e;var o=e.toString().replace(/[^\d]/g,"").split(""),i="";return o.forEach((function(e,r){3!==r&&7!==r||(i+=t),i+=e})),i}function le(e,t){if(void 0===t&&(t=""),r(e))return t;if(11!==e.toString().length)return e;var n=e.toString();return n.substr(0,3)+"****"+n.substr(7,11)}function fe(e,t){return void 0===t&&(t=""),r(e)?t:e.toString().replace(/\s/g,"").replace(/(.{4})/g,"$1 ")}function de(){for(var e=[],t=65;t<91;t+=1)e.push(String.fromCharCode(t));return e}function ge(e){void 0===e&&(e="");return e.replace(/\B([A-Z])/g,"-$1").toLowerCase()}var pe={HTTP_STATUS:{TEMP_RESPOND:{Continue:100,SwitchingProtocal:101},SUCCESS:{Ok:200,Created:201,Accepted:202,NoAuthoritativeInformation:203,NoContent:204,ResetContent:205,ParticalContent:206},REDIRECT:{MultipleChoice:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308},REQUEST_ERROR:{BadRequest:400,UnAuthorized:401,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAccepted:406,ProxyAuthorizationRequired:407,RequestTimeout:408,UpgradeRequired:426,TokenUnAuthorized:499},SERVER_ERROR:{InternalServerError:500,BadGateway:502,ServiceUnavailable:503,GateTimeout:504,HttpVersionNotSupported:505}},CODES:{Success:"00000",UnAuthorized:"00099",UnAuthorizedPhone:"11001",UnAuthorizedWecom:"11000",UnAuthorizedHavePhone:"11002"},ERR_CODE_WHITE_LIST:[]},he=e.create({timeout:15e3,headers:{"Content-Type":"application/json"}}),ve=function(e){var t=e.cacheType,r=e.currentMode,n=e.errorCb,o=e.getTokenCb;return e.tokenKey,he.interceptors.request.use((function(e){return P(void 0,void 0,void 0,(function(){var r,n;return B(this,(function(o){return r=I(t),n=u(),e.headers.Authorization=r,e.headers.token=r,e.headers.FrontType=c(n),[2,e]}))}))}),(function(e){return Promise.reject(e)})),he.interceptors.response.use((function(e){return P(void 0,void 0,void 0,(function(){var n,i,a;return B(this,(function(u){return n=e.data,i=n.code||e.status,n instanceof Blob||i===pe.CODES.Success?[2,n]:i===pe.CODES.UnAuthorized?("local"!==r&&"dev"!==r&&"development"!==r&&(k(t),o&&"function"==typeof o&&o()),[2,Promise.reject(new Error("token过期!"))]):(a=n.message||n.msg,[2,Promise.reject(new Error(a||"Error"))])}))}))}),(function(e){return P(void 0,void 0,void 0,(function(){return B(this,(function(t){return n&&"function"==typeof n&&n(e),[2,Promise.reject(e)]}))}))})),he},me=function(e){return function(t,r){return P(void 0,void 0,void 0,(function(){var n,o,i,a,u,c,s;return B(this,(function(l){switch(l.label){case 0:return n=t.ip||t.request.ip,o=t.path,i=t.method,a=(new Date).toISOString(),u={method:t.method,url:t.url,query:t.query,body:t.request.body},c=t.headers,[4,r()];case 1:return l.sent(),s={status:t.status,body:t.body,headers:t.response.headers},we({system:e,ip:n,path:o,method:i,time:a,params:u,headers:c,result:s}),[2]}}))}))}},we=function(t){console.log("logData---------",t);e.post("http://localhost:7003/log/save",t)},ye=function(e){var t=e.query.state,r={};if(t&&"string"==typeof t&&t.indexOf("?")>-1){var n=t.slice(0,t.indexOf("?"));r=JSON.parse(decodeURIComponent(n))}else t&&"string"==typeof t&&(r=JSON.parse(decodeURIComponent(t)));return r};export{O as addDays,S as base64ToBlob,M as base64ToFile,J as blobToDataURL,f as buildUUID,L as calcFileSize,W as ceil,n as clearLoginData,E as compatibleDate,Q as compressImg,Y as computeMoney,v as convertBase64UrlToBlob,z as convertCurrency,Z as dataURLtoBlob,V as deepEqual,G as fileSizeFormat,b as filterRepeat,ee as findNodePath,q as floor,fe as formatBank,_ as formatCentsToYuan,ce as formatEmptyValue,H as formatFloat,$ as formatMoney,se as formatPhone,le as formatPhoneHide,T as formatTime,h as formateTimestamp,D as fromNow,K as genExportByBlob,de as generateEnglishLetters,l as getCookie,u as getDeviceType,m as getEnvironment,C as getFileData,c as getFromType,w as getIsComWx,y as getIsDevelopment,o as getQueryString,i as getQueryVariable,d as getTicket,I as getToken,ye as getUrlState,a as getWecomToken,ve as http,pe as httpEnum,ge as humpTurnDashed,ae as isEmail,r as isEmpty,te as isExternal,A as isImage,ne as isMobile,oe as isMobileSimple,ue as isQQ,ie as isTelephone,N as newDate,s as randomString,me as recordLogMiddleWare,p as removeTicket,k as removeToken,g as setTicket,j as toThousands,re as trimVal,x as uuid,R as validateTwoDecimal};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('axios')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'axios'], factory) :
|
|
4
|
-
(global = global || self, factory(global[
|
|
5
|
-
}(this, (function (exports, axios) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["jinbi-utils"] = {}, global.axios));
|
|
5
|
+
})(this, (function (exports, axios) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
8
10
|
|
|
9
11
|
var fromTypeMap = {
|
|
10
12
|
isWxWork: 'wecom',
|
|
@@ -1337,7 +1339,7 @@
|
|
|
1337
1339
|
ERR_CODE_WHITE_LIST: []
|
|
1338
1340
|
};
|
|
1339
1341
|
|
|
1340
|
-
var request =
|
|
1342
|
+
var request = axios__default["default"].create({
|
|
1341
1343
|
timeout: 15000,
|
|
1342
1344
|
headers: {
|
|
1343
1345
|
// 'Authorization': getToken(),
|
|
@@ -1353,7 +1355,7 @@
|
|
|
1353
1355
|
* @param tokenKey
|
|
1354
1356
|
* */
|
|
1355
1357
|
var http = function (_a) {
|
|
1356
|
-
var cacheType = _a.cacheType, currentMode = _a.currentMode, errorCb = _a.errorCb, getTokenCb = _a.getTokenCb
|
|
1358
|
+
var cacheType = _a.cacheType, currentMode = _a.currentMode, errorCb = _a.errorCb, getTokenCb = _a.getTokenCb; _a.tokenKey;
|
|
1357
1359
|
request.interceptors.request.use(function (config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1358
1360
|
var token, deviceType;
|
|
1359
1361
|
return __generator(this, function (_a) {
|
|
@@ -1406,6 +1408,70 @@
|
|
|
1406
1408
|
return request;
|
|
1407
1409
|
};
|
|
1408
1410
|
|
|
1411
|
+
var recordLogMiddleWare = function (systemName) {
|
|
1412
|
+
return function (ctx, next) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1413
|
+
var ip, path, method, timeToString, requestParams, headers, result, logData;
|
|
1414
|
+
return __generator(this, function (_a) {
|
|
1415
|
+
switch (_a.label) {
|
|
1416
|
+
case 0:
|
|
1417
|
+
ip = ctx.ip || ctx.request.ip;
|
|
1418
|
+
path = ctx.path;
|
|
1419
|
+
method = ctx.method;
|
|
1420
|
+
timeToString = new Date().toISOString();
|
|
1421
|
+
requestParams = {
|
|
1422
|
+
method: ctx.method,
|
|
1423
|
+
url: ctx.url,
|
|
1424
|
+
query: ctx.query,
|
|
1425
|
+
body: ctx.request.body,
|
|
1426
|
+
};
|
|
1427
|
+
headers = ctx.headers;
|
|
1428
|
+
// 继续处理后续中间件
|
|
1429
|
+
return [4 /*yield*/, next()];
|
|
1430
|
+
case 1:
|
|
1431
|
+
// 继续处理后续中间件
|
|
1432
|
+
_a.sent();
|
|
1433
|
+
result = {
|
|
1434
|
+
status: ctx.status,
|
|
1435
|
+
body: ctx.body,
|
|
1436
|
+
headers: ctx.response.headers,
|
|
1437
|
+
};
|
|
1438
|
+
logData = {
|
|
1439
|
+
system: systemName,
|
|
1440
|
+
ip: ip,
|
|
1441
|
+
path: path,
|
|
1442
|
+
method: method,
|
|
1443
|
+
time: timeToString,
|
|
1444
|
+
params: requestParams,
|
|
1445
|
+
headers: headers,
|
|
1446
|
+
result: result,
|
|
1447
|
+
};
|
|
1448
|
+
sendLog(logData);
|
|
1449
|
+
return [2 /*return*/];
|
|
1450
|
+
}
|
|
1451
|
+
});
|
|
1452
|
+
}); };
|
|
1453
|
+
};
|
|
1454
|
+
var sendLog = function (logData) {
|
|
1455
|
+
console.log('logData---------', logData);
|
|
1456
|
+
var LOG_HOST = 'http://localhost:7003';
|
|
1457
|
+
axios__default["default"].post(LOG_HOST + "/log/save", logData);
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
// 获取state,(针对iam跳转)
|
|
1461
|
+
var getUrlState = function (route) {
|
|
1462
|
+
var state = route.query.state;
|
|
1463
|
+
var stateObj = {};
|
|
1464
|
+
if (state && typeof state === 'string' && state.indexOf('?') > -1) {
|
|
1465
|
+
var jsonPart = state.slice(0, state.indexOf('?'));
|
|
1466
|
+
// const queryPart = state.slice(state.indexOf('?') + 1);
|
|
1467
|
+
stateObj = JSON.parse(decodeURIComponent(jsonPart));
|
|
1468
|
+
}
|
|
1469
|
+
else if (state && typeof state === 'string') {
|
|
1470
|
+
stateObj = JSON.parse(decodeURIComponent(state));
|
|
1471
|
+
}
|
|
1472
|
+
return stateObj;
|
|
1473
|
+
};
|
|
1474
|
+
|
|
1409
1475
|
exports.addDays = addDays;
|
|
1410
1476
|
exports.base64ToBlob = base64ToBlob;
|
|
1411
1477
|
exports.base64ToFile = base64ToFile;
|
|
@@ -1448,6 +1514,7 @@
|
|
|
1448
1514
|
exports.getQueryVariable = getQueryVariable;
|
|
1449
1515
|
exports.getTicket = getTicket;
|
|
1450
1516
|
exports.getToken = getToken;
|
|
1517
|
+
exports.getUrlState = getUrlState;
|
|
1451
1518
|
exports.getWecomToken = getWecomToken;
|
|
1452
1519
|
exports.http = http;
|
|
1453
1520
|
exports.httpEnum = httpEnum;
|
|
@@ -1462,6 +1529,7 @@
|
|
|
1462
1529
|
exports.isTelephone = isTelephone;
|
|
1463
1530
|
exports.newDate = newDate;
|
|
1464
1531
|
exports.randomString = randomString;
|
|
1532
|
+
exports.recordLogMiddleWare = recordLogMiddleWare;
|
|
1465
1533
|
exports.removeTicket = removeTicket;
|
|
1466
1534
|
exports.removeToken = removeToken;
|
|
1467
1535
|
exports.setTicket = setTicket;
|
|
@@ -1472,4 +1540,4 @@
|
|
|
1472
1540
|
|
|
1473
1541
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1474
1542
|
|
|
1475
|
-
}))
|
|
1543
|
+
}));
|
package/dist/index.umd.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],t):t((e=e||self)["jinbi-utils"]={},e.axios)}(this,(function(e,t){"use strict";
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("axios")):"function"==typeof define&&define.amd?define(["exports","axios"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["jinbi-utils"]={},e.axios)}(this,(function(e,t){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(t),o={isWxWork:"wecom",isWeixin:"wechat",isMobile:"mobile",isMobileAny:"mobile"};function i(e){return null===e||""===e||void 0===e}var a=function(){var e=navigator.userAgent.toLowerCase(),t=/wxwork/.test(e),r=/micromessenger/.test(e)&&!t,n=window.innerWidth<=768;return{isWxWork:t,isWeixin:r,isMobileScreen:n,isMobileAny:t||r||n}},u=function(e){var t="wecom";for(var r in e){if(e[r]){t=o[r];break}}return t};var c=function(e,t){var r=e.toLowerCase();return"localstorage"===r?localStorage.getItem("token")||"":"sessionstorage"===r?sessionStorage.getItem("token")||"":localStorage.getItem("token")||sessionStorage.getItem("token")||""},s=function(e,t){var r=e.toLowerCase();"localstorage"===r?localStorage.removeItem("token"):"sessionstorage"===r?sessionStorage.removeItem("token"):(localStorage.removeItem("token"),sessionStorage.getItem("token"))};function l(e){return"string"==typeof e?e.replace(/-/g,"/"):e}function f(e,t){void 0===e&&(e=Date.now()),void 0===t&&(t="yyyy-MM-dd HH:mm:ss"),e=l(e);var r={"M+":(e=new Date(e)).getMonth()+1,"d+":e.getDate(),"h+":e.getHours()%12==0?12:e.getHours()%12,"H+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};return/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(""+e.getFullYear()).substr(4-RegExp.$1.length))),Object.keys(r).forEach((function(e){new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1===RegExp.$1.length?r[e]:("00"+r[e]).substr((""+r[e]).length)))})),t}
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
var l=function(){return(l=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function f(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}c((n=n.apply(e,t||[])).next())}))}function d(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var g={operation:"divide",factor:100,precision:2,formatAsCurrency:!1,currencySymbol:"¥"};function p(e,t){if(void 0===t&&(t="-"),n(e))return t;var r=e.toString();return r.includes(".")||(r+="."),r.replace(/\d(?=(\d{3})+\.)/g,(function(e){return e+","})).replace(/\.$/,"")}function m(e,t){if(void 0===t&&(t=0),n(e))return e;var r=Math.pow(10,t),o=Number(e)*r;return Math.ceil(o)/r}function v(e,t){var r=h(e,t),n=l(l({},g),t);if(n.formatter)return n.formatter(r);if(n.formatAsCurrency){var o=r.toFixed(n.precision),i=r>=1e3?p(o):o;return""+n.currencySymbol+i}return r.toFixed(n.precision)}function h(e,t){var r,n,o=l(l({},g),t);if(null==e||""===e)return 0;if("string"==typeof e){var i=e.replace(/[^\d.-]/g,"");r=i?parseFloat(i):0}else r=e;if(isNaN(r))return 0;if(n="multiply"===o.operation?r*o.factor:0!==o.factor?r/o.factor:0,void 0!==o.precision){var a=Math.pow(10,o.precision);n=Math.round(n*a)/a}return n}function w(e,t){void 0===t&&(t="B");var r=["B","KB","MB","GB","TB"],n=r.indexOf(t.toUpperCase());for(n=-1===n?0:n;e>=1024&&n<r.length;)e/=1024,n+=1;return{size:e,unit:r[n]}}function y(e){for(var t=e.match(/:(.*?);/)[1],r=window.atob(e.split(",")[1]),n=new ArrayBuffer(r.length),o=new Uint8Array(n),i=0;i<r.length;i+=1)o[i]=r.charCodeAt(i);return new Blob([n],{type:t})}function b(e){return new Promise((function(t,r){var n=new FileReader;n.onload=function(e){e&&e.target?t(e.target.result):r(e)},n.onerror=function(e){r(e)},n.readAsDataURL(e)}))}function S(e,t,r,n,o){if(void 0===o&&(o=[]),o.push(e),e[r]===t)throw"GOT IT!";if(e[n]&&e[n].length>0)for(var i=0;i<e[n].length;i++)S(e[n][i],t,r,n,o);o.pop()}var M={HTTP_STATUS:{TEMP_RESPOND:{Continue:100,SwitchingProtocal:101},SUCCESS:{Ok:200,Created:201,Accepted:202,NoAuthoritativeInformation:203,NoContent:204,ResetContent:205,ParticalContent:206},REDIRECT:{MultipleChoice:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308},REQUEST_ERROR:{BadRequest:400,UnAuthorized:401,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAccepted:406,ProxyAuthorizationRequired:407,RequestTimeout:408,UpgradeRequired:426,TokenUnAuthorized:499},SERVER_ERROR:{InternalServerError:500,BadGateway:502,ServiceUnavailable:503,GateTimeout:504,HttpVersionNotSupported:505}},CODES:{Success:"00000",UnAuthorized:"00099",UnAuthorizedPhone:"11001",UnAuthorizedWecom:"11000",UnAuthorizedHavePhone:"11002"},ERR_CODE_WHITE_LIST:[]},A=t.create({timeout:15e3,headers:{"Content-Type":"application/json"}});e.addDays=function(e,t,r){if(void 0===t&&(t=0),void 0===r&&(r="yyyy-MM-dd"),n(e))return"-";e=c(e);var o=new Date(e);return o.setDate(o.getDate()+Number(t)),s(o,r)},e.base64ToBlob=function(e){for(var t=e.split(","),r=t[0].match(/:(.\*?);/)[1],n=atob(t[1]),o=n.length,i=new Uint8Array(o);o--;)i[o]=n.charCodeAt(o);return new Blob([i],{type:r})},e.base64ToFile=function(e,t){for(var r=e.split(","),n=r[0].match(/:(.*);/)[1],o=atob(r[1]),i=o.length,a=new Uint8Array(i);i--;)a[i]=o.charCodeAt(i);return new File([a],t,{type:n})},e.blobToDataURL=b,e.buildUUID=function(){for(var e=[],t=0;t<=15;t++)e[t]=t.toString(16);var r="";for(t=1;t<=36;t++)r+=9===t||14===t||19===t||24===t?"-":15===t?4:20===t?e[4*Math.random()|8]:e[16*Math.random()|0];return r.replace(/-/g,"")},e.calcFileSize=w,e.ceil=m,e.clearLoginData=function(){localStorage.removeItem("wecom_userinfo"),localStorage.removeItem("wecom_token"),localStorage.removeItem("projectActive"),localStorage.removeItem("loginTime"),localStorage.removeItem("projectInfo")},e.compatibleDate=c,e.compressImg=function(e,t,r){return new Promise((function(n,o){var i=parseFloat((e.size/1024/1024).toString()),a=new FileReader;a.onload=function(a){var u=new Image;u.onload=function(){var o=u.width,a=u.height,c=document.createElement("canvas"),s=c.getContext("2d"),l=t?t(o,a):1;(Number.isNaN(l)||"number"!=typeof l)&&(l=1);var f=r?r(i,l,o,a):1;if((Number.isNaN(f)||"number"!=typeof f)&&(f=1),s){var d=parseInt((o*l).toString(),10),g=parseInt((a*l).toString(),10);c.setAttribute("width",d.toString()),c.setAttribute("height",g.toString()),s.drawImage(u,0,0,d,g)}var p=c.toDataURL(e.type,f);n(y(p))},u.onerror=function(e){o(e)},a.target&&(u.src=a.target.result)},a.onerror=function(e){o(e)},a.readAsDataURL(e)}))},e.computeMoney=h,e.convertBase64UrlToBlob=function(e){for(var t=window.atob(e.split(",")[1]),r=new ArrayBuffer(t.length),n=new Uint8Array(r),o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return new Blob([r],{type:"image/png"})},e.convertCurrency=function(e){if(void 0===e&&(e=""),n(e))return"";if(Number(e)>=1e15)return e;var t,r,o,i=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],a=["","拾","佰","仟"],u=["","万","亿","兆"],c=["角","分","毫","厘"],s="";if("0"===(e=parseFloat(e).toString()))return s=i[0]+"元整";if(-1===(e=e.toString()).indexOf(".")?(t=e,r=""):(t=(o=e.split("."))[0],r=o[1].substr(0,4)),parseInt(t,10)>0){for(var l=0,f=t.length,d=0;d<f;d+=1){var g=t.substr(d,1),p=f-d-1,m=p/4,v=p%4;"0"===g?l+=1:(l>0&&(s+=i[0]),l=0,s+=i[parseInt(g,10)]+a[v]),0===v&&l<4&&(s+=u[m])}s+="元"}if(""!==r){var h=r.length;for(d=0;d<h;d+=1){var w=r.substr(d,1);"0"!==w&&(s+=i[Number(w)]+c[d])}}return""===s?s+=i[0]+"元整":""===r&&(s+="整"),s},e.dataURLtoBlob=y,e.deepEqual=function e(t,r){var n=Object.keys,o=typeof t;return t&&r&&"object"===o&&o===typeof r?n(t).length===n(r).length&&n(t).every((function(n){return e(t[n],r[n])})):t===r},e.fileSizeFormat=function(e,t,r){if(void 0===t&&(t="B"),void 0===r&&(r="-"),n(e))return r;var o=w(parseFloat(e.toString()),t);return""+m(o.size,2)+o.unit},e.filterRepeat=function(e,t){var r=new Set;return e.filter((function(e){var n=e[t];return!r.has(n)&&(r.add(n),!0)}))},e.findNodePath=function(e,t,r,n){var o=[];try{for(var i=0;i<r.length;i++)S(r[i],e,t,n,o)}catch(e){return o}},e.floor=function(e,t){if(void 0===t&&(t=0),n(e))return e;var r=Math.pow(10,t),o=Number(e)*r;return Math.floor(o)/r},e.formatBank=function(e,t){return void 0===t&&(t=""),n(e)?t:e.toString().replace(/\s/g,"").replace(/(.{4})/g,"$1 ")},e.formatCentsToYuan=function(e,t){return v(e,l({operation:"divide",factor:100,formatAsCurrency:!0},t))},e.formatEmptyValue=function(e,t){return void 0===t&&(t="-"),n(e)?t:e},e.formatFloat=function(e,t){void 0===t&&(t=2);var r=parseFloat(String(e));if(Number.isNaN(r))return"";var n=(r=Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)).toString(),o=n.indexOf(".");for(o<0&&(o=n.length,n+=".");n.length<=o+t;)n+="0";return n},e.formatMoney=v,e.formatPhone=function(e,t,r){if(void 0===t&&(t=" "),void 0===r&&(r="-"),n(e))return r;if(11!==e.toString().length)return e;var o=e.toString().replace(/[^\d]/g,"").split(""),i="";return o.forEach((function(e,r){3!==r&&7!==r||(i+=t),i+=e})),i},e.formatPhoneHide=function(e,t){if(void 0===t&&(t=""),n(e))return t;if(11!==e.toString().length)return e;var r=e.toString();return r.substr(0,3)+"****"+r.substr(7,11)},e.formatTime=s,e.formateTimestamp=function(e,t){if(void 0===t&&(t="YYYY年MM月DD日 hh:mm:ss"),!e)return"-";var r=new Date(e),n=r.getFullYear()+"",o=r.getMonth()+1,i=r.getDate(),a=r.getHours()>9?r.getHours():"0"+r.getHours(),u=r.getMinutes()>9?r.getMinutes():"0"+r.getMinutes(),c=r.getSeconds()>9?r.getSeconds():"0"+r.getSeconds();return t.replace("YYYY",n+"").replace("MM",o+"").replace("DD",i+"").replace("hh",a+"").replace("mm",u+"").replace("ss",c+"")},e.fromNow=function(e,t,r){if(void 0===t&&(t="yyyy年MM月dd日 HH时mm分ss秒"),void 0===r&&(r="-"),n(e))return r;e=c(e);var o=new Date(e),i=(Date.now()-o.getTime())/1e3;return i<0?e:i<30?"刚刚":i<3600?Math.ceil(i/60)+"分钟前":i<86400?Math.floor(i/3600)+"小时前":i<172800?"1天前":s(e,t)},e.genExportByBlob=function(e){var t=e.axiosRequest,r=e.notWithCredentials,n=void 0===r?[]:r;return function(e){var r=this,o=e.filename,i=e.url,a=e.data,u=void 0===a?{}:a,c=e.params,s=void 0===c?{}:c,l=e.method,g=void 0===l?"post":l;return new Promise((function(e,a){t({method:g,url:i,data:u,params:s,responseType:"blob",config:{withCredentials:n.some((function(e){return!i.includes(e)}))}}).then((function(t){return f(r,void 0,void 0,(function(){var r,n,i,u,c,s,l,f,g,p;return d(this,(function(d){switch(d.label){case 0:return"application/json"!==(r=null==t?void 0:t.data).type?[3,1]:((n=new FileReader).readAsText(r,"utf-8"),n.onload=function(){var e={};try{e=JSON.parse(n.result)}catch(t){e=r}a(e)},[3,3]);case 1:try{i=t.headers,u=i["content-disposition"],c=decodeURIComponent(u.split(";")[1].split("filename=")[1]),o&&!o.includes(".")?(s=c.split("."),l=s[s.length-1],o+="."+l):o||(o=c)}catch(e){o||(o="download.xlsx")}return f=new Blob([t.data]),g=document.createElement("a"),[4,b(f)];case 2:p=d.sent(),g.href=p,g.download=o,document.body.appendChild(g),g.click(),document.body.removeChild(g),e(t),d.label=3;case 3:return[2]}}))}))})).catch((function(e){a(e)}))}))}},e.generateEnglishLetters=function(){for(var e=[],t=65;t<91;t+=1)e.push(String.fromCharCode(t));return e},e.getCookie=function(e){for(var t="",r=document.cookie.split("; "),n=0;n<r.length;n++){var o=r[n].split("=");if(o[0]===e){t=o[1];break}}return t},e.getDeviceType=o,e.getEnvironment=function(){var e=window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i),t=/micromessenger/i.test(navigator.userAgent),r=/wxwork/i.test(navigator.userAgent);return r&&e?"com-wx-mobile":r&&!e?"com-wx-pc":t&&e?"wx-mobile":t&&!e?"wx-pc":"other"},e.getFileData=function(e){var t=e.split(","),r=t[0],n=void 0===r?"":r,o=t[1],i=void 0===o?"":o;return{name:decodeURIComponent(n),url:decodeURIComponent(i)}},e.getFromType=i,e.getIsComWx=function(){return/wxwork/i.test(navigator.userAgent)},e.getIsDevelopment=function(){var e=!1;return"uat2-h5-wecom.hengdayun.com"!==location.origin&&"127.0.0.1:8081"!==location.origin&&"localhost:8081"!==location.origin||(e=!0),e},e.getQueryString=function(e,t){var r=new RegExp("&{1}"+t+"\\=[a-zA-Z0-9_-]+","g"),n=e.replace(/\?/g,"&").match(r)[0];return n.substr(n.indexOf("=")+1)},e.getQueryVariable=function(e){for(var t=window.location.search.substring(1).split("&"),r=0;r<t.length;r++){var n=t[r].split("=");if(n[0]===e)return n[1]}return!1},e.getTicket=function(){return localStorage.getItem("jsapiTicket")},e.getToken=a,e.getWecomToken=function(){return localStorage.getItem("wecom_token")},e.http=function(e){var t=e.cacheType,r=e.currentMode,n=e.errorCb,c=e.getTokenCb;e.tokenKey;return A.interceptors.request.use((function(e){return f(void 0,void 0,void 0,(function(){var r,n;return d(this,(function(u){return r=a(t),n=o(),e.headers.Authorization=r,e.headers.token=r,e.headers.FrontType=i(n),[2,e]}))}))}),(function(e){return Promise.reject(e)})),A.interceptors.response.use((function(e){return f(void 0,void 0,void 0,(function(){var n,o,i;return d(this,(function(a){return n=e.data,o=n.code||e.status,n instanceof Blob||o===M.CODES.Success?[2,n]:o===M.CODES.UnAuthorized?("local"!==r&&"dev"!==r&&"development"!==r&&(u(t),c&&"function"==typeof c&&c()),[2,Promise.reject(new Error("token过期!"))]):(i=n.message||n.msg,[2,Promise.reject(new Error(i||"Error"))])}))}))}),(function(e){return f(void 0,void 0,void 0,(function(){return d(this,(function(t){return n&&"function"==typeof n&&n(e),[2,Promise.reject(e)]}))}))})),A},e.httpEnum=M,e.humpTurnDashed=function(e){return void 0===e&&(e=""),e.replace(/\B([A-Z])/g,"-$1").toLowerCase()},e.isEmail=function(e){return/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(e)},e.isEmpty=n,e.isExternal=function(e){return/^(https?:|mailto:|tel:)/.test(e)},e.isImage=function(e){return/^image\//i.test(e)},e.isMobile=function(e){return/^0?(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/.test(e.toString())},e.isMobileSimple=function(e){return e=e.toString(),/^1/.test(e)&&11===e.length},e.isQQ=function(e){return/^[1-9][0-9]{4,9}$/gim.test(String(e))},e.isTelephone=function(e){return/^0[1-9][0-9]{1,2}-[2-8][0-9]{6,7}$/.test(String(e))},e.newDate=function(e){return e?new Date(c(e)):new Date},e.randomString=function(e){e=e||32;for(var t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",r=t.length,n="",o=0;o<e;o++)n+=t.charAt(Math.floor(Math.random()*r));return n},e.removeTicket=function(){return localStorage.removeItem("jsapiTicket")},e.removeToken=u,e.setTicket=function(e){return localStorage.setItem("jsapiTicket",e)},e.toThousands=p,e.trimVal=function(e){return e?e.replace(/^\s+|\s+$/g,""):e},e.uuid=function(e,t){var r,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];if(t=t||n.length,e)for(r=0;r<e;r++)o[r]=n[0|Math.random()*t];else{var i=void 0;for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",r=0;r<36;r++)o[r]||(i=0|16*Math.random(),o[r]=n[19==r?3&i|8:i])}return o.join("")},e.validateTwoDecimal=function(e){return!e||""===e||/^(\d+)(\.\d{1,2})?$/.test(e.toString())},Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
16
|
+
var d=function(){return(d=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function g(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function u(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,u)}c((n=n.apply(e,t||[])).next())}))}function p(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var m={operation:"divide",factor:100,precision:2,formatAsCurrency:!1,currencySymbol:"¥"};function h(e,t){if(void 0===t&&(t="-"),i(e))return t;var r=e.toString();return r.includes(".")||(r+="."),r.replace(/\d(?=(\d{3})+\.)/g,(function(e){return e+","})).replace(/\.$/,"")}function v(e,t){if(void 0===t&&(t=0),i(e))return e;var r=Math.pow(10,t),n=Number(e)*r;return Math.ceil(n)/r}function y(e,t){var r=w(e,t),n=d(d({},m),t);if(n.formatter)return n.formatter(r);if(n.formatAsCurrency){var o=r.toFixed(n.precision),i=r>=1e3?h(o):o;return""+n.currencySymbol+i}return r.toFixed(n.precision)}function w(e,t){var r,n,o=d(d({},m),t);if(null==e||""===e)return 0;if("string"==typeof e){var i=e.replace(/[^\d.-]/g,"");r=i?parseFloat(i):0}else r=e;if(isNaN(r))return 0;if(n="multiply"===o.operation?r*o.factor:0!==o.factor?r/o.factor:0,void 0!==o.precision){var a=Math.pow(10,o.precision);n=Math.round(n*a)/a}return n}function b(e,t){void 0===t&&(t="B");var r=["B","KB","MB","GB","TB"],n=r.indexOf(t.toUpperCase());for(n=-1===n?0:n;e>=1024&&n<r.length;)e/=1024,n+=1;return{size:e,unit:r[n]}}function S(e){for(var t=e.match(/:(.*?);/)[1],r=window.atob(e.split(",")[1]),n=new ArrayBuffer(r.length),o=new Uint8Array(n),i=0;i<r.length;i+=1)o[i]=r.charCodeAt(i);return new Blob([n],{type:t})}function M(e){return new Promise((function(t,r){var n=new FileReader;n.onload=function(e){e&&e.target?t(e.target.result):r(e)},n.onerror=function(e){r(e)},n.readAsDataURL(e)}))}function T(e,t,r,n,o){if(void 0===o&&(o=[]),o.push(e),e[r]===t)throw"GOT IT!";if(e[n]&&e[n].length>0)for(var i=0;i<e[n].length;i++)T(e[n][i],t,r,n,o);o.pop()}var A={HTTP_STATUS:{TEMP_RESPOND:{Continue:100,SwitchingProtocal:101},SUCCESS:{Ok:200,Created:201,Accepted:202,NoAuthoritativeInformation:203,NoContent:204,ResetContent:205,ParticalContent:206},REDIRECT:{MultipleChoice:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308},REQUEST_ERROR:{BadRequest:400,UnAuthorized:401,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAccepted:406,ProxyAuthorizationRequired:407,RequestTimeout:408,UpgradeRequired:426,TokenUnAuthorized:499},SERVER_ERROR:{InternalServerError:500,BadGateway:502,ServiceUnavailable:503,GateTimeout:504,HttpVersionNotSupported:505}},CODES:{Success:"00000",UnAuthorized:"00099",UnAuthorizedPhone:"11001",UnAuthorizedWecom:"11000",UnAuthorizedHavePhone:"11002"},ERR_CODE_WHITE_LIST:[]},x=n.default.create({timeout:15e3,headers:{"Content-Type":"application/json"}}),C=function(e){console.log("logData---------",e);n.default.post("http://localhost:7003/log/save",e)};e.addDays=function(e,t,r){if(void 0===t&&(t=0),void 0===r&&(r="yyyy-MM-dd"),i(e))return"-";e=l(e);var n=new Date(e);return n.setDate(n.getDate()+Number(t)),f(n,r)},e.base64ToBlob=function(e){for(var t=e.split(","),r=t[0].match(/:(.\*?);/)[1],n=atob(t[1]),o=n.length,i=new Uint8Array(o);o--;)i[o]=n.charCodeAt(o);return new Blob([i],{type:r})},e.base64ToFile=function(e,t){for(var r=e.split(","),n=r[0].match(/:(.*);/)[1],o=atob(r[1]),i=o.length,a=new Uint8Array(i);i--;)a[i]=o.charCodeAt(i);return new File([a],t,{type:n})},e.blobToDataURL=M,e.buildUUID=function(){for(var e=[],t=0;t<=15;t++)e[t]=t.toString(16);var r="";for(t=1;t<=36;t++)r+=9===t||14===t||19===t||24===t?"-":15===t?4:20===t?e[4*Math.random()|8]:e[16*Math.random()|0];return r.replace(/-/g,"")},e.calcFileSize=b,e.ceil=v,e.clearLoginData=function(){localStorage.removeItem("wecom_userinfo"),localStorage.removeItem("wecom_token"),localStorage.removeItem("projectActive"),localStorage.removeItem("loginTime"),localStorage.removeItem("projectInfo")},e.compatibleDate=l,e.compressImg=function(e,t,r){return new Promise((function(n,o){var i=parseFloat((e.size/1024/1024).toString()),a=new FileReader;a.onload=function(a){var u=new Image;u.onload=function(){var o=u.width,a=u.height,c=document.createElement("canvas"),s=c.getContext("2d"),l=t?t(o,a):1;(Number.isNaN(l)||"number"!=typeof l)&&(l=1);var f=r?r(i,l,o,a):1;if((Number.isNaN(f)||"number"!=typeof f)&&(f=1),s){var d=parseInt((o*l).toString(),10),g=parseInt((a*l).toString(),10);c.setAttribute("width",d.toString()),c.setAttribute("height",g.toString()),s.drawImage(u,0,0,d,g)}var p=c.toDataURL(e.type,f);n(S(p))},u.onerror=function(e){o(e)},a.target&&(u.src=a.target.result)},a.onerror=function(e){o(e)},a.readAsDataURL(e)}))},e.computeMoney=w,e.convertBase64UrlToBlob=function(e){for(var t=window.atob(e.split(",")[1]),r=new ArrayBuffer(t.length),n=new Uint8Array(r),o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return new Blob([r],{type:"image/png"})},e.convertCurrency=function(e){if(void 0===e&&(e=""),i(e))return"";if(Number(e)>=1e15)return e;var t,r,n,o=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],a=["","拾","佰","仟"],u=["","万","亿","兆"],c=["角","分","毫","厘"],s="";if("0"===(e=parseFloat(e).toString()))return s=o[0]+"元整";if(-1===(e=e.toString()).indexOf(".")?(t=e,r=""):(t=(n=e.split("."))[0],r=n[1].substr(0,4)),parseInt(t,10)>0){for(var l=0,f=t.length,d=0;d<f;d+=1){var g=t.substr(d,1),p=f-d-1,m=p/4,h=p%4;"0"===g?l+=1:(l>0&&(s+=o[0]),l=0,s+=o[parseInt(g,10)]+a[h]),0===h&&l<4&&(s+=u[m])}s+="元"}if(""!==r){var v=r.length;for(d=0;d<v;d+=1){var y=r.substr(d,1);"0"!==y&&(s+=o[Number(y)]+c[d])}}return""===s?s+=o[0]+"元整":""===r&&(s+="整"),s},e.dataURLtoBlob=S,e.deepEqual=function e(t,r){var n=Object.keys,o=typeof t;return t&&r&&"object"===o&&o===typeof r?n(t).length===n(r).length&&n(t).every((function(n){return e(t[n],r[n])})):t===r},e.fileSizeFormat=function(e,t,r){if(void 0===t&&(t="B"),void 0===r&&(r="-"),i(e))return r;var n=b(parseFloat(e.toString()),t);return""+v(n.size,2)+n.unit},e.filterRepeat=function(e,t){var r=new Set;return e.filter((function(e){var n=e[t];return!r.has(n)&&(r.add(n),!0)}))},e.findNodePath=function(e,t,r,n){var o=[];try{for(var i=0;i<r.length;i++)T(r[i],e,t,n,o)}catch(e){return o}},e.floor=function(e,t){if(void 0===t&&(t=0),i(e))return e;var r=Math.pow(10,t),n=Number(e)*r;return Math.floor(n)/r},e.formatBank=function(e,t){return void 0===t&&(t=""),i(e)?t:e.toString().replace(/\s/g,"").replace(/(.{4})/g,"$1 ")},e.formatCentsToYuan=function(e,t){return y(e,d({operation:"divide",factor:100,formatAsCurrency:!0},t))},e.formatEmptyValue=function(e,t){return void 0===t&&(t="-"),i(e)?t:e},e.formatFloat=function(e,t){void 0===t&&(t=2);var r=parseFloat(String(e));if(Number.isNaN(r))return"";var n=(r=Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)).toString(),o=n.indexOf(".");for(o<0&&(o=n.length,n+=".");n.length<=o+t;)n+="0";return n},e.formatMoney=y,e.formatPhone=function(e,t,r){if(void 0===t&&(t=" "),void 0===r&&(r="-"),i(e))return r;if(11!==e.toString().length)return e;var n=e.toString().replace(/[^\d]/g,"").split(""),o="";return n.forEach((function(e,r){3!==r&&7!==r||(o+=t),o+=e})),o},e.formatPhoneHide=function(e,t){if(void 0===t&&(t=""),i(e))return t;if(11!==e.toString().length)return e;var r=e.toString();return r.substr(0,3)+"****"+r.substr(7,11)},e.formatTime=f,e.formateTimestamp=function(e,t){if(void 0===t&&(t="YYYY年MM月DD日 hh:mm:ss"),!e)return"-";var r=new Date(e),n=r.getFullYear()+"",o=r.getMonth()+1,i=r.getDate(),a=r.getHours()>9?r.getHours():"0"+r.getHours(),u=r.getMinutes()>9?r.getMinutes():"0"+r.getMinutes(),c=r.getSeconds()>9?r.getSeconds():"0"+r.getSeconds();return t.replace("YYYY",n+"").replace("MM",o+"").replace("DD",i+"").replace("hh",a+"").replace("mm",u+"").replace("ss",c+"")},e.fromNow=function(e,t,r){if(void 0===t&&(t="yyyy年MM月dd日 HH时mm分ss秒"),void 0===r&&(r="-"),i(e))return r;e=l(e);var n=new Date(e),o=(Date.now()-n.getTime())/1e3;return o<0?e:o<30?"刚刚":o<3600?Math.ceil(o/60)+"分钟前":o<86400?Math.floor(o/3600)+"小时前":o<172800?"1天前":f(e,t)},e.genExportByBlob=function(e){var t=e.axiosRequest,r=e.notWithCredentials,n=void 0===r?[]:r;return function(e){var r=this,o=e.filename,i=e.url,a=e.data,u=void 0===a?{}:a,c=e.params,s=void 0===c?{}:c,l=e.method,f=void 0===l?"post":l;return new Promise((function(e,a){t({method:f,url:i,data:u,params:s,responseType:"blob",config:{withCredentials:n.some((function(e){return!i.includes(e)}))}}).then((function(t){return g(r,void 0,void 0,(function(){var r,n,i,u,c,s,l,f,d,g;return p(this,(function(p){switch(p.label){case 0:return"application/json"!==(r=null==t?void 0:t.data).type?[3,1]:((n=new FileReader).readAsText(r,"utf-8"),n.onload=function(){var e={};try{e=JSON.parse(n.result)}catch(t){e=r}a(e)},[3,3]);case 1:try{i=t.headers,u=i["content-disposition"],c=decodeURIComponent(u.split(";")[1].split("filename=")[1]),o&&!o.includes(".")?(s=c.split("."),l=s[s.length-1],o+="."+l):o||(o=c)}catch(e){o||(o="download.xlsx")}return f=new Blob([t.data]),d=document.createElement("a"),[4,M(f)];case 2:g=p.sent(),d.href=g,d.download=o,document.body.appendChild(d),d.click(),document.body.removeChild(d),e(t),p.label=3;case 3:return[2]}}))}))})).catch((function(e){a(e)}))}))}},e.generateEnglishLetters=function(){for(var e=[],t=65;t<91;t+=1)e.push(String.fromCharCode(t));return e},e.getCookie=function(e){for(var t="",r=document.cookie.split("; "),n=0;n<r.length;n++){var o=r[n].split("=");if(o[0]===e){t=o[1];break}}return t},e.getDeviceType=a,e.getEnvironment=function(){var e=window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i),t=/micromessenger/i.test(navigator.userAgent),r=/wxwork/i.test(navigator.userAgent);return r&&e?"com-wx-mobile":r&&!e?"com-wx-pc":t&&e?"wx-mobile":t&&!e?"wx-pc":"other"},e.getFileData=function(e){var t=e.split(","),r=t[0],n=void 0===r?"":r,o=t[1],i=void 0===o?"":o;return{name:decodeURIComponent(n),url:decodeURIComponent(i)}},e.getFromType=u,e.getIsComWx=function(){return/wxwork/i.test(navigator.userAgent)},e.getIsDevelopment=function(){var e=!1;return"uat2-h5-wecom.hengdayun.com"!==location.origin&&"127.0.0.1:8081"!==location.origin&&"localhost:8081"!==location.origin||(e=!0),e},e.getQueryString=function(e,t){var r=new RegExp("&{1}"+t+"\\=[a-zA-Z0-9_-]+","g"),n=e.replace(/\?/g,"&").match(r)[0];return n.substr(n.indexOf("=")+1)},e.getQueryVariable=function(e){for(var t=window.location.search.substring(1).split("&"),r=0;r<t.length;r++){var n=t[r].split("=");if(n[0]===e)return n[1]}return!1},e.getTicket=function(){return localStorage.getItem("jsapiTicket")},e.getToken=c,e.getUrlState=function(e){var t=e.query.state,r={};if(t&&"string"==typeof t&&t.indexOf("?")>-1){var n=t.slice(0,t.indexOf("?"));r=JSON.parse(decodeURIComponent(n))}else t&&"string"==typeof t&&(r=JSON.parse(decodeURIComponent(t)));return r},e.getWecomToken=function(){return localStorage.getItem("wecom_token")},e.http=function(e){var t=e.cacheType,r=e.currentMode,n=e.errorCb,o=e.getTokenCb;return e.tokenKey,x.interceptors.request.use((function(e){return g(void 0,void 0,void 0,(function(){var r,n;return p(this,(function(o){return r=c(t),n=a(),e.headers.Authorization=r,e.headers.token=r,e.headers.FrontType=u(n),[2,e]}))}))}),(function(e){return Promise.reject(e)})),x.interceptors.response.use((function(e){return g(void 0,void 0,void 0,(function(){var n,i,a;return p(this,(function(u){return n=e.data,i=n.code||e.status,n instanceof Blob||i===A.CODES.Success?[2,n]:i===A.CODES.UnAuthorized?("local"!==r&&"dev"!==r&&"development"!==r&&(s(t),o&&"function"==typeof o&&o()),[2,Promise.reject(new Error("token过期!"))]):(a=n.message||n.msg,[2,Promise.reject(new Error(a||"Error"))])}))}))}),(function(e){return g(void 0,void 0,void 0,(function(){return p(this,(function(t){return n&&"function"==typeof n&&n(e),[2,Promise.reject(e)]}))}))})),x},e.httpEnum=A,e.humpTurnDashed=function(e){return void 0===e&&(e=""),e.replace(/\B([A-Z])/g,"-$1").toLowerCase()},e.isEmail=function(e){return/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(e)},e.isEmpty=i,e.isExternal=function(e){return/^(https?:|mailto:|tel:)/.test(e)},e.isImage=function(e){return/^image\//i.test(e)},e.isMobile=function(e){return/^0?(13[0-9]|14[5-9]|15[012356789]|166|17[0-8]|18[0-9]|19[8-9])[0-9]{8}$/.test(e.toString())},e.isMobileSimple=function(e){return e=e.toString(),/^1/.test(e)&&11===e.length},e.isQQ=function(e){return/^[1-9][0-9]{4,9}$/gim.test(String(e))},e.isTelephone=function(e){return/^0[1-9][0-9]{1,2}-[2-8][0-9]{6,7}$/.test(String(e))},e.newDate=function(e){return e?new Date(l(e)):new Date},e.randomString=function(e){e=e||32;for(var t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678",r=t.length,n="",o=0;o<e;o++)n+=t.charAt(Math.floor(Math.random()*r));return n},e.recordLogMiddleWare=function(e){return function(t,r){return g(void 0,void 0,void 0,(function(){var n,o,i,a,u,c,s;return p(this,(function(l){switch(l.label){case 0:return n=t.ip||t.request.ip,o=t.path,i=t.method,a=(new Date).toISOString(),u={method:t.method,url:t.url,query:t.query,body:t.request.body},c=t.headers,[4,r()];case 1:return l.sent(),s={status:t.status,body:t.body,headers:t.response.headers},C({system:e,ip:n,path:o,method:i,time:a,params:u,headers:c,result:s}),[2]}}))}))}},e.removeTicket=function(){return localStorage.removeItem("jsapiTicket")},e.removeToken=s,e.setTicket=function(e){return localStorage.setItem("jsapiTicket",e)},e.toThousands=h,e.trimVal=function(e){return e?e.replace(/^\s+|\s+$/g,""):e},e.uuid=function(e,t){var r,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];if(t=t||n.length,e)for(r=0;r<e;r++)o[r]=n[0|Math.random()*t];else{var i=void 0;for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",r=0;r<36;r++)o[r]||(i=0|16*Math.random(),o[r]=n[19==r?3&i|8:i])}return o.join("")},e.validateTwoDecimal=function(e){return!e||""===e||/^(\d+)(\.\d{1,2})?$/.test(e.toString())},Object.defineProperty(e,"__esModule",{value:!0})}));
|