UNPKG

imba-uni-request

Version:

uniapp框架封装的请求包 imba-uni-request

1 lines 24.6 kB
var t={758:t=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}var r=Object.prototype.hasOwnProperty;t.exports=function t(n,o){var i=[];for(var a in n)if(r.call(n,a)){var c,u=n[a],s=encodeURIComponent(a);c="object"===e(u)?t(u,o?o+"["+s+"]":s):(o?o+"["+s+"]":s)+"="+encodeURIComponent(u),i.push(c)}return i.join("&")}},778:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,u(n.key),n)}}function a(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function c(t,e,r){return(e=u(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t){var e=function(t,e){if("object"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==n(e)?e:e+""}r.d(e,{l:()=>l});var s=function(){return a((function t(e){o(this,t),c(this,"taskProList",[]),this.taskType=e}),[{key:"use",value:function(t,e){var r=Math.random().toString(36).slice(2),n=this.taskType;return e||(e=function(t){return Promise.reject(t)}),this.taskProList.push({id:r,type:n,resolved:t,rejected:e}),r}},{key:"call",value:function(t){this.taskProList.forEach((function(e){return e&&t(e)}))}},{key:"abort",value:function(t){return this.eject(t)}},{key:"eject",value:function(t){var e=this.taskProList.findIndex((function(e){return e.id===t})),r=-1!==e;return r&&this.taskProList.splice(1,e),r}}])}(),l=a((function t(){o(this,t),c(this,"request",new s("request")),c(this,"response",new s("response"))}))},882:(t,e,r)=>{r.d(e,{A:()=>n});const n=function(t){return function(t,e){function r(t,e){return t<<e|t>>>32-e}function n(t,e){var r=2147483648&t,n=2147483648&e,o=1073741824&t,i=1073741824&e,a=(1073741823&t)+(1073741823&e);return o&i?2147483648^a^r^n:o|i?1073741824&a?3221225472^a^r^n:1073741824^a^r^n:a^r^n}function o(t,e,o,i,a,c,u){return t=n(t,n(n(function(t,e,r){return t&e|~t&r}(e,o,i),a),u)),n(r(t,c),e)}function i(t,e,o,i,a,c,u){return t=n(t,n(n(function(t,e,r){return t&r|e&~r}(e,o,i),a),u)),n(r(t,c),e)}function a(t,e,o,i,a,c,u){return t=n(t,n(n(function(t,e,r){return t^e^r}(e,o,i),a),u)),n(r(t,c),e)}function c(t,e,o,i,a,c,u){return t=n(t,n(n(function(t,e,r){return e^(t|~r)}(e,o,i),a),u)),n(r(t,c),e)}function u(t){var e,r="",n="";for(e=0;e<=3;e++)r+=(n="0".concat((t>>>8*e&255).toString(16))).substr(n.length-2,2);return r}var s,l,f,h,p,y,d,v,m,b;for(s=function(t){for(var e,r=t.length,n=r+8,o=16*((n-n%64)/64+1),i=Array(o-1),a=0,c=0;c<r;)a=c%4*8,i[e=(c-c%4)/4]=i[e]|t.charCodeAt(c)<<a,c++;return a=c%4*8,i[e=(c-c%4)/4]=i[e]|128<<a,i[o-2]=r<<3,i[o-1]=r>>>29,i}(t=function(t){for(var e="",r=0,n=(t=t.replace(/\r\n/g,"\n")).length;r<n;r++){var o=t.charCodeAt(r);o<128?e+=String.fromCharCode(o):o>127&&o<2048?(e+=String.fromCharCode(o>>6|192),e+=String.fromCharCode(63&o|128)):(e+=String.fromCharCode(o>>12|224),e+=String.fromCharCode(o>>6&63|128),e+=String.fromCharCode(63&o|128))}return e}(t)),d=1732584193,v=4023233417,m=2562383102,b=271733878,l=0;l<s.length;l+=16)f=d,h=v,p=m,y=b,d=o(d,v,m,b,s[l+0],7,3614090360),b=o(b,d,v,m,s[l+1],12,3905402710),m=o(m,b,d,v,s[l+2],17,606105819),v=o(v,m,b,d,s[l+3],22,3250441966),d=o(d,v,m,b,s[l+4],7,4118548399),b=o(b,d,v,m,s[l+5],12,1200080426),m=o(m,b,d,v,s[l+6],17,2821735955),v=o(v,m,b,d,s[l+7],22,4249261313),d=o(d,v,m,b,s[l+8],7,1770035416),b=o(b,d,v,m,s[l+9],12,2336552879),m=o(m,b,d,v,s[l+10],17,4294925233),v=o(v,m,b,d,s[l+11],22,2304563134),d=o(d,v,m,b,s[l+12],7,1804603682),b=o(b,d,v,m,s[l+13],12,4254626195),m=o(m,b,d,v,s[l+14],17,2792965006),d=i(d,v=o(v,m,b,d,s[l+15],22,1236535329),m,b,s[l+1],5,4129170786),b=i(b,d,v,m,s[l+6],9,3225465664),m=i(m,b,d,v,s[l+11],14,643717713),v=i(v,m,b,d,s[l+0],20,3921069994),d=i(d,v,m,b,s[l+5],5,3593408605),b=i(b,d,v,m,s[l+10],9,38016083),m=i(m,b,d,v,s[l+15],14,3634488961),v=i(v,m,b,d,s[l+4],20,3889429448),d=i(d,v,m,b,s[l+9],5,568446438),b=i(b,d,v,m,s[l+14],9,3275163606),m=i(m,b,d,v,s[l+3],14,4107603335),v=i(v,m,b,d,s[l+8],20,1163531501),d=i(d,v,m,b,s[l+13],5,2850285829),b=i(b,d,v,m,s[l+2],9,4243563512),m=i(m,b,d,v,s[l+7],14,1735328473),d=a(d,v=i(v,m,b,d,s[l+12],20,2368359562),m,b,s[l+5],4,4294588738),b=a(b,d,v,m,s[l+8],11,2272392833),m=a(m,b,d,v,s[l+11],16,1839030562),v=a(v,m,b,d,s[l+14],23,4259657740),d=a(d,v,m,b,s[l+1],4,2763975236),b=a(b,d,v,m,s[l+4],11,1272893353),m=a(m,b,d,v,s[l+7],16,4139469664),v=a(v,m,b,d,s[l+10],23,3200236656),d=a(d,v,m,b,s[l+13],4,681279174),b=a(b,d,v,m,s[l+0],11,3936430074),m=a(m,b,d,v,s[l+3],16,3572445317),v=a(v,m,b,d,s[l+6],23,76029189),d=a(d,v,m,b,s[l+9],4,3654602809),b=a(b,d,v,m,s[l+12],11,3873151461),m=a(m,b,d,v,s[l+15],16,530742520),d=c(d,v=a(v,m,b,d,s[l+2],23,3299628645),m,b,s[l+0],6,4096336452),b=c(b,d,v,m,s[l+7],10,1126891415),m=c(m,b,d,v,s[l+14],15,2878612391),v=c(v,m,b,d,s[l+5],21,4237533241),d=c(d,v,m,b,s[l+12],6,1700485571),b=c(b,d,v,m,s[l+3],10,2399980690),m=c(m,b,d,v,s[l+10],15,4293915773),v=c(v,m,b,d,s[l+1],21,2240044497),d=c(d,v,m,b,s[l+8],6,1873313359),b=c(b,d,v,m,s[l+15],10,4264355552),m=c(m,b,d,v,s[l+6],15,2734768916),v=c(v,m,b,d,s[l+13],21,1309151649),d=c(d,v,m,b,s[l+4],6,4149444226),b=c(b,d,v,m,s[l+11],10,3174756917),m=c(m,b,d,v,s[l+2],15,718787259),v=c(v,m,b,d,s[l+9],21,3951481745),d=n(d,f),v=n(v,h),m=n(m,p),b=n(b,y);return 32===e?(u(d)+u(v)+u(m)+u(b)).toLowerCase():(u(v)+u(m)).toLowerCase()}(t,32).toUpperCase()}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var n={};r.d(n,{N:()=>T});var o=r(778),i={},a=typeof window<"u"&&window?.localStorage||{length:0,clear:()=>{i={}},removeItem:t=>{delete i[t]},getItem:t=>i[t],setItem:(t,e)=>{i[t]=e},key:()=>"locaCache"},c=(t,e)=>a.setItem(t,e),u=t=>a.getItem(t),s=t=>a.removeItem(t),l=[];try{let t=u("_cacheNameList");if(t&&"string"==typeof t){let e=JSON.parse(t);l.push(...e)}}catch(U){console.error("%c [ cacheNameList JSON.parse error ]",U)}var f=(t,e)=>{try{return"object"==typeof e&&(e=JSON.stringify(e)),c(t,e),!0}catch(r){return console.error(`%c [ setCacheLoca JSON.stringify ${t} error ]`,r),!1}},h=(t,e,r=0,n="mm")=>{n||(n="mm");let o=f(t,e);if(o&&r>0){let e="mm"===n?60:1,o=(new Date).getTime()+r*e*1e3;c(`${t}_time`,`${o}`)}return(t=>{new Promise((e=>{l.includes(t)||(l.push(t),f("_cacheNameList",l)),e()}))})(t),o},p=t=>{let e=u(`${t}_time`),r=(t=>{let e=u(t);if("string"!=typeof e||!e)return e;let r=e.toString()||"";try{return r&&"string"==typeof e&&(r.includes("{")&&r.includes("}")||r.includes("[")&&r.includes("]"))?JSON.parse(e):e}catch(n){return console.error(`%c [ getCacheLoca JSON.parse error ${t}: ]`,e,n),e}})(t);return!!(e&&Number.parseInt(e)-(new Date).getTime()>1||!e&&r)&&r},y=t=>{s(t),s(`${t}_time`)};var d=r(758),v=r.n(d),m=r(882);function b(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */b=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=e&&e.prototype instanceof m?e:m,a=Object.create(i.prototype),c=new I(n||[]);return o(a,"_invoke",{value:_(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",y="executing",d="completed",v={};function m(){}function g(){}function w(){}var j={};s(j,a,(function(){return this}));var O=Object.getPrototypeOf,S=O&&O(O(U([])));S&&S!==r&&n.call(S,a)&&(j=S);var P=w.prototype=m.prototype=Object.create(j);function x(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==k(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return r("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function _(e,r,n){var o=h;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===d){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=C(c,n);if(u){if(u===v)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===h)throw o=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var s=f(e,r,n);if("normal"===s.type){if(o=n.done?d:p,s.arg===v)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=d,n.method="throw",n.arg=s.arg)}}}function C(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,C(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function U(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o<e.length;)if(n.call(e,o))return r.value=e[o],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(k(e)+" is not iterable")}return g.prototype=w,o(P,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:g,configurable:!0}),g.displayName=s(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,s(t,u,"GeneratorFunction")),t.prototype=Object.create(P),t},e.awrap=function(t){return{__await:t}},x(L.prototype),s(L.prototype,c,(function(){return this})),e.AsyncIterator=L,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new L(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(P),s(P,u,"Generator"),s(P,a,(function(){return this})),s(P,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=U,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:U(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function g(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function w(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?g(Object(r),!0).forEach((function(e){L(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function j(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function O(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){j(i,n,o,a,c,"next",t)}function c(t){j(i,n,o,a,c,"throw",t)}a(void 0)}))}}function S(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return P(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function P(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function x(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_(n.key),n)}}function L(t,e,r){return(e=_(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(t){var e=function(t,e){if("object"!=k(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==k(e)?e:e+""}function k(t){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},k(t)}var C=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"#41b883";return new Promise((function(n){console.log("%c ".concat(t),"font-size:14px; background:".concat(r,"; color:#ffffff;"),e),n()}))},E=function(t,e){return k(t)===e},T=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),L(this,"baseURL",""),L(this,"timeout",3e4),L(this,"header",{"content-type":"application/json;charset=UTF-8"}),L(this,"headers",{}),L(this,"recordUrl",{}),L(this,"interceptors",new o.l),L(this,"cacheBool",!0),L(this,"cacheUnit","mm"),L(this,"repeatMergeBool",!0),L(this,"retryBool",!0),L(this,"retryCount",1),L(this,"retryInterval",3),L(this,"retryUrlCount",{}),L(this,"pageKey",["page","size"]),L(this,"printMD5",!1),L(this,"printConsole",!0),this.setObjectVal(e),this.defaultInterceptor()},e=[{key:"setObjectVal",value:function(t){var e=this;return t?(Object.entries(t).forEach((function(t){var r=S(t,2),n=r[0],o=r[1];n&&!E(o,"undefined")&&(e[n]=o)})),this):this}},{key:"defaultInterceptor",value:function(){var t=this;this.interceptors.request.use((function(e){return t.dataFactory(e,e.inject||{})})),this.interceptors.response.use((function(t){return t}))}},{key:"dataFactory",value:function(t,e){var r,n;if(t.headers&&(t.header=Object.assign(t.header||{},t.headers),delete t.headers),!e)return t;var o,i,a=e||{},c=a._noToken,u=a._formData,s=a._header,l=a._method,f=a._page,h=a._pageKey,p=a._cache,y=a._cacheUnit,d=a._id,v=a._idnext,m=a._param,b=a._body,g=a._baseURL,w=a._url,j=a._timeout,O=a._retryCount,S=a._retryInterval,P=a._repeatMergeBool,x=a._printMD5,L=a._printConsole;if(g&&(t.baseURL=g),w&&(t.url=w),E(j,"number")&&(t.timeout=j),E(O,"number")&&(t.retryCount=O),E(S,"number")&&(t.retryInterval=S),E(P,"boolean")&&(t.repeatMergeBool=P),E(x,"boolean")&&(t.printMD5=x),E(L,"boolean")&&(t.repeatMergeBool=L),null!==(r=t.url)&&void 0!==r&&r.includes(":id")){var _;if(E(d,"undefined"))return C("".concat(t.url," 没有传参数ID 格式 -> { _id: 123 }")),Promise.resolve(t);t.url=null===(_=t.url)||void 0===_?void 0:_.replace(":id",d)}if(null!==(n=t.url)&&void 0!==n&&n.includes(":idnext")){var k;if(E(v,"undefined"))return C("".concat(t.url," 没有传参数ID 格式 -> { _idnext: 456 }")),Promise.resolve(t);t.url=null===(k=t.url)||void 0===k?void 0:k.replace(":idnext",v)}if(l&&(t.method=l),h&&(t.pageKey=h),f){var T=this.setPageSize(f,t.pageKey||this.pageKey),I="GET"===t.method?"param":"body";t[I]=Object.assign(t[I]||{},T)}return E(p,"number")&&(t.cacheTime=p),y&&(t.cacheUnit=y),E(c,"boolean")&&(null===(o=t.header)||void 0===o||delete o["x-access-token"],null===(i=t.header)||void 0===i||delete i.Authorization),t.header=u?Object.assign(t.header||{},{"content-type":"application/x-www-form-urlencoded"}):Object.assign(t.header||{},{"content-type":"application/json;charset=UTF-8"}),s&&(t.header=Object.assign(t.header||{},s)),m&&(t.param=Object.assign(t.param||{},m)),b&&(t.body=Object.assign(t.body||{},b)),Promise.resolve(this.clone(t))}},{key:"clone",value:function(t){var e=this;if("object"!==k(t)||null===t)return t;if(Array.isArray(t))return t.map((function(t){return e.clone(t)}));var r={},n=Object.prototype.hasOwnProperty;for(var o in t)n.call(t,o)&&(r[o]=this.clone(t[o]));return r}},{key:"comCacheStrify",value:function(t){var e=((t,e="ss")=>{let r=Number.parseInt(u(`${t}_time`));if(null==r)return-1;let n=r-(new Date).getTime();if(n<1)return 0;switch(e){case"ss":return Math.round(n/1e3);case"mm":return Math.round(n/1e3/60);default:return 0}})(t);return"剩余".concat(e,"秒过期!")}},{key:"setPageSize",value:function(){var t=arguments.length>1?arguments[1]:void 0,e=S(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[1,10],2),r=e[0],n=e[1],o=S(t,2),i=o[0],a=o[1];return L(L({},i,r<=0?1:r),a,n<=0?1:n)}},{key:"request",value:(n=O(b().mark((function t(e){var r,n,o,i,a,c,u,s,l,f,d,g,j,P,x,L,_=this,k=arguments;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=k.length>1&&void 0!==k[1]?k[1]:{},n=k.length>2?k[2]:void 0,o="",i="GET",a=-1,Array.isArray(e)?(c=S(e,3),u=c[0],s=c[1],l=c[2],u&&(o=u),s&&(i=s),l&&(a=l||-1)):o=e,t.next=8,this.dataFactory({baseURL:this.baseURL,url:this.baseURL+(o||e),method:i,header:Object.assign(this.header,this.headers),timeout:this.timeout},r);case 8:for(f=t.sent,r&&(f.inject=Object.assign(f.inject||{},r)),d={id:"appPromise",resolved:function(){var t=O(b().mark((function t(e){var r,o,i,c,u,s,l,f,g,j,O,P,x,L,k,T,I,U,N;return b().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=w({},n),o=w({},e),i=e.param||{},c=e.body||{},u=Object.keys(i).length>0?"?".concat(v()(i)):"",s=Object.keys(c).length>0?"".concat(u?"&body=right&":"").concat(v()(c)):"",l="".concat(e.url).concat(u),f="GET"===e.method,g=E(e.printMD5,"boolean")?e.printMD5:_.printMD5,j=E(e.printConsole,"boolean")?e.printConsole:_.printConsole,O="".concat(e.url).concat(""===u?"":u).concat(f?"":""===u&&s?"?".concat(s):""),g&&(O=(0,m.A)(O)),f||(e.data=Object.assign(e.data||{},e.body||{})),e.headers=E(e.headers,"undefined")?_.headers:e.headers,e.url=l,P="".concat(e.method," ").concat(O),x=E(e.cacheBool,"boolean")?e.cacheBool:_.cacheBool,L="cache_".concat(P),k=E(e.cacheTime,"number")?e.cacheTime:a,!x||0!==k&&-1!==k||y(L),T=E(e.repeatMergeBool,"boolean")?e.repeatMergeBool:_.repeatMergeBool,I=_.recordUrl[P],!T||!I){t.next=27;break}return j&&C("[ ".concat(P," ]-重复请求,列入集中请求↓"),I,"#f5bd30"),t.next=26,I;case 26:case 33:case 38:return t.abrupt("return",t.sent);case 27:if(!x){t.next=34;break}if(!(U=p(L))){t.next=34;break}return j&&C("[ ".concat(P," ]-接口缓存↓ ").concat(_.comCacheStrify(L)),U),t.next=33,U;case 34:return N=new Promise((function(t,n){e.success=function(r){var n=!E(r,"undefined")&&!E(r,"boolean")&&200===(null==r?void 0:r.statusCode);x&&k>0&&n&&h(L,r,k,e.cacheUnit||_.cacheUnit),n&&j&&C("[ ".concat(P," ]-请求成功↓"),r),t(r)},e.fail=function(r){if(E(e.retryBool,"boolean")?e.retryBool:_.retryBool){var i=E(e.retryInterval,"number")?e.retryInterval:_.retryInterval,a=E(e.retryCount,"number")?e.retryCount:_.retryCount,c=[0,(new Date).getTime()+1e3*i],u=S(_.retryUrlCount[P]||c,2),s=u[0],l=u[1],f=l-(new Date).getTime();if(s>=a)return t(r),void n(r);if(f<=0)return t(r),void n(r);_.recordUrl[P]=null,_.retryUrlCount[P]=[s+1,l],j&&C("[ ".concat(P," ]-请求失败,重试请求").concat(_.retryUrlCount[P][0],"↓"),r,"#eb3941"),d.resolved(o).then((function(e){return t(e)}))}else j&&C("[ ".concat(P," ]-请求失败"),r,"#eb3941"),t(r),n(r)},e.complete=function(){_.recordUrl[P]=null},uni.request(Object.assign(e,r))})),_.recordUrl[P]=N,t.next=38,N;case 39:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),rejected:function(){return Promise.reject("错误异常...")}},g=[d],this.interceptors.request.call((function(t){g.unshift(t)})),this.interceptors.response.call((function(t){g.push(t)})),j=Promise.resolve(f);g.length;)P=g.shift(),x=P.resolved,L=P.rejected,j=j.then(x,L);return t.abrupt("return",j);case 17:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"get",value:function(t,e,r){return this.request([t,"GET"],e,r)}},{key:"post",value:function(t,e,r){return this.request([t,"POST"],e,r)}},{key:"put",value:function(t,e,r){return this.request([t,"PUT"],e,r)}},{key:"delete",value:function(t,e,r){return this.request([t,"DELETE"],e,r)}}],e&&x(t.prototype,e),r&&x(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n}(),I=n.N;export{I as ImbaUniRequest};