@chunpu/http
Advanced tools
Comparing version 2.1.0 to 3.0.0
[![CircleCI](https://circleci.com/gh/chunpu/http.svg?style=svg)](https://circleci.com/gh/chunpu/http) | ||
Features | ||
--- | ||
- [Largely axios-compatible API](#api) | ||
- Support More platforms like [微信小程序](#微信小程序), [快应用](#快应用) | ||
- Support the Promise API | ||
- [Intercept request and response](#interceptors) | ||
- [More Automatic Transform request and response data](#automatic-transform-request-data) | ||
- [Batch Cancel requests](#cancel-requests) | ||
- More adapters inside: [axios](#axios-nodejs), [jQuery](#jquery--zepto), XMLHttpRequest | ||
Inspired by [axios](https://github.com/axios/axios) | ||
@@ -69,5 +80,5 @@ | ||
### Auto Handle Request Data | ||
### Automatic Transform Request Data | ||
data will be handled by the value of `headers['content-type']`, Plain Object data will be auto stringify | ||
Respect the request `headers['content-type']` setting, data will be transform by the content type, Plain Object data will be auto stringify | ||
@@ -83,3 +94,3 @@ - `application/json` will `JSON.stringify` the data object | ||
- `data` response data, will always try to `JSON.parse`, because most server not respect the response mime | ||
- `data` response data | ||
- `headers` `name: value` headers, all header names are lower cased | ||
@@ -89,3 +100,5 @@ - `status` status code, number | ||
Not Respect the response `headers['content-type']` value, will always try to `JSON.parse` the data, because most server not respect the response mime | ||
Platform Support | ||
@@ -136,3 +149,3 @@ --- | ||
### axios | ||
### axios (node.js) | ||
@@ -149,2 +162,4 @@ ```js | ||
Please use http with `axios mode` in Node.js platform | ||
### jQuery / Zepto | ||
@@ -193,3 +208,3 @@ | ||
Interceptors / Hook | ||
Interceptors | ||
--- | ||
@@ -221,3 +236,3 @@ | ||
source is sth like deferred | ||
For easy understanding, `cancelToken` equals `deferred` equals `source.token` | ||
@@ -230,3 +245,3 @@ ```js | ||
}).catch(err => { | ||
console.error(err) // too slow, abort it | ||
console.error(err) // error: cancel request | ||
}) | ||
@@ -237,7 +252,7 @@ | ||
}).catch(err => { | ||
console.error(err) // too slow, abort it | ||
console.error(err) // error: cancel request | ||
}) | ||
setTimeout(() => { | ||
source.cancel('too slow, abort it') // will cancel all requests with this source | ||
source.cancel('cancel request') // will cancel all requests with this source | ||
}, 1000) | ||
@@ -244,0 +259,0 @@ ``` |
/*! | ||
* @chunpu/http@1.2.0 by chunpu | ||
* 2018-10-22T07:25:51.141Z | ||
* @chunpu/http@2.1.0 by chunpu | ||
* 2018-10-31T03:54:43.944Z | ||
*/ | ||
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.http=t():n.http=t()}(window,function(){return function(n){var t={};function e(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return n[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:r})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var i in n)e.d(r,i,function(t){return n[t]}.bind(null,i));return r},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e(e.s=4)}([function(n,t,e){n.exports=e(6)},function(n,t,e){const r=e(0),i=new RegExp("Content-Type","i");t.CONTENT_TYPE_KEY="Content-Type",t.getContentType=function(n){var t=r.keys(n);return n[r.find(t,n=>i.test(n))]},t.parseHeadersFromXhr=function(n){return r.chain(n.getAllResponseHeaders()).trim().split("\n").reduce((n,t)=>{var e=r.indexOf(t,":"),i=r.toLower(r.trim(r.slice(t,0,e))),u=r.trim(r.slice(t,e+1));return n[i]?n[i]=","+u:n[i]=u,n},{}).value()},t.isFormData=function(n){return"undefined"!=typeof FormData&&n instanceof FormData},t.timeout=function n(t){return new Promise((e,r)=>{n&&setTimeout(()=>{r(new Error("timeout"))},t)})},t.clearTimer=function(n){n&&clearTimeout(n)},t.createError=function(n,t){var e=new Error(n);return r.extend(e,t),e}},function(n,t,e){var r=e(7),i=[].slice,u=t;u.is=r,u.extend=u.assign=function(n){if(n){var t=i.call(arguments,1);c(t,function(t){h(t,function(t,e){r.undef(t)||(n[e]=t)})})}return n},u.each=c,u.map=function(n,t){var e=[];return c(n,function(n,r,i){e[r]=t(n,r,i)}),e},u.filter=function(n,t){var e=[];return c(n,function(n,r,i){t(n,r,i)&&e.push(n)}),e},u.some=function(n,t){return-1!=f(n,t)},u.every=function(n,t){return-1==f(n,l(t))},u.reduce=function(n,t,e){return c(n,function(r,i){e=t(e,r,i,n)}),e},u.findIndex=f,u.find=function(n,t){var e=u.findIndex(n,t);if(-1!=e)return n[e]},u.indexOf=p,u.includes=function(n,t){return-1!=p(n,t)},u.toArray=s,u.slice=function(n,t,e){var i=[],u=a(n);return u>=0&&(t=t||0,0!==e&&(e=e||u),r.fn(n.slice)||(n=s(n)),i=n.slice(t,e)),i},u.negate=l,u.forIn=h,u.keys=function(n){var t=[];return h(n,function(n,e){t.push(e)}),t};var o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function a(n){if(null!=n)return n.length}function c(n,t){var e=a(n);if(e&&r.fn(t))for(var i=0;i<e&&!1!==t(n[i],i,n);i++);return n}function f(n,t){var e=-1;return c(n,function(n,r,i){if(t(n,r,i))return e=r,!1}),e}function s(n){var t=[];return c(n,function(n){t.push(n)}),t}function l(n){return function(){return!n.apply(this,arguments)}}function p(n,t){return r.string(n)?n.indexOf(t):f(n,function(n){return t===n})}function h(n,t){if(n)for(var e in n)if(r.owns(n,e)&&!1===t(n[e],e,n))break;return n}u.trim=function(n){return null==n?"":(""+n).replace(o,"")},u.noop=function(){},u.len=a},function(n,t,e){var r=e(0),i=r.is,u={sep:"&",eq:"=",encode:encodeURIComponent,decode:decodeURIComponent,keepRaw:!1,sort:null,ignoreValues:[void 0]};function o(n,t,e){return e=r.find(arguments,function(n){return i.object(n)}),n=i.nos(n)?n:void 0,t=i.nos(t)?t:void 0,e=r.extend({},u,e,{sep:n,eq:t})}t.parse=function(n,t,e,i){n+="";var u=(i=o(t,e,i)).decode;return n=n.split(i.sep),r.reduce(n,function(n,t){if(2==(t=t.split(i.eq)).length){var e=t[0],r=t[1];if(!i.keepRaw)try{e=u(e),r=u(r)}catch(n){}n[e]=r}return n},{})},t.stringify=function(n,t,e,u){u=o(t,e,u);var a=r.keys(n),c=u.sort;c&&(i.fn(c)?a.sort(c):a.sort());var f=u.encode,s=[];return r.each(a,function(t){var e=n[t];r.includes(u.ignoreValues,e)||((i.nan(e)||null==e)&&(e=""),u.keepRaw||(t=f(t),e=f(e)),s.push(t+u.eq+e))}),s.join(u.sep)}},function(n,t,e){n.exports=e(5)},function(n,t,e){e(0);const r=new(e(17));n.exports=r},function(n,t,e){var r=e(2);function i(n){if(!(this instanceof i))return new i(n);this.__value=n,this.__chain=!1}n.exports=r.extend(i,r),e(9)(i),e(10)(i),e(11)(i),e(12)(i),e(13)(i),e(15)(i),e(16)(i),i.mixin(i,i)},function(n,t,e){(function(n){var e=t,r=Object.prototype,i=(n=n||{}).navigator;function u(n){var t=r.toString.call(n);return t.substring(8,t.length-1).toLowerCase()}function o(n){return typeof n}function a(n,t){return r.hasOwnProperty.call(n,t)}e.browser=function(){return!(e.wechatApp()||!i||n.window!=n)},e.h5=function(){return!(!e.browser()||!i.geolocation)},e.mobile=function(){return!(!e.browser()||!/mobile/i.test(i.userAgent))},e.wechatApp=function(){return!("object"!=typeof wx||!wx||!e.fn(wx.createVideoContext))},e._class=u,e._type=o,e.owns=a,e.nan=function(n){return n!=n},e.bool=function(n){return"boolean"==u(n)},e.infinite=function(n){return n==1/0||n==-1/0},e.number=function(n){return!isNaN(n)&&"number"==u(n)},e.iod=function(n){return!(!e.number(n)||e.infinite(n))},e.decimal=function(n){return!!e.iod(n)&&0!=n%1},e.integer=function(n){return!!e.iod(n)&&0==n%1},e.oof=function(n){if(n){var t=o(n);return"object"==t||"function"==t}return!1},e.object=function(n){return e.oof(n)&&"function"!=u(n)},e.hash=e.plainObject=function(n){return!(!n||"object"!=u(n))&&(!n.nodeType&&!n.setInterval)},e.undef=function(n){return"undefined"==o(n)},e.fn=function(n){return"function"==u(n)},e.string=function(n){return"string"==u(n)},e.nos=function(n){return e.iod(n)||e.string(n)},e.array=function(n){return"array"==u(n)},e.arraylike=function(n){if(!e.window(n)&&e.object(n)){var t=n.length;if(e.integer(t)&&t>=0)return!0}return!1},e.window=function(n){return!(!n||n.window!=n)},e.empty=function(n){if(e.string(n)||e.arraylike(n))return 0===n.length;if(e.hash(n))for(var t in n)if(a(n,t))return!1;return!0},e.element=function(n){return!(!n||1!==n.nodeType)},e.regexp=function(n){return"regexp"==u(n)}}).call(this,e(8))},function(n,t){var e;e=function(){return this}();try{e=e||Function("return this")()||(0,eval)("this")}catch(n){"object"==typeof window&&(e=window)}n.exports=e},function(n,t){n.exports=function(n){var t=n.is;n.isString=t.string,n.isArray=t.array,n.isArrayLike=t.arraylike,n.isBoolean=t.bool,n.isElement=t.element,n.isEmpty=t.empty,n.isFunction=t.fn,n.isInteger=t.integer,n.isNaN=t.nan,n.isNumber=t.number,n.isObject=t.object,n.isPlainObject=t.plainObject,n.isRegExp=t.regexp,n.isString=t.string,n.isUndefined=t.undef}},function(n,t){n.exports=function(n){var t=n.is;n.now=function(){return+new Date},n.constant=function(n){return function(){return n}},n.identity=function(n){return n},n.random=function(n,t){return n+Math.floor(Math.random()*(t-n+1))},n.mixin=function(e,r,i){var u=n.functions(r);if(e)if(t.fn(e)){(i=i||{}).chain;var o=e.prototype;n.each(u,function(n){var t=r[n];o[n]=function(){var n=this,e=[n.__value];e.push.apply(e,arguments);var r=t.apply(n,e);return n.__chain?(n.__value=r,n):r}})}else n.each(u,function(n){e[n]=r[n]});return e},n.chain=function(t){var e=n(t);return e.__chain=!0,e},n.value=function(){return this.__chain=!1,this.__value}}},function(n,t){n.exports=function(n){var t=n.forEach=n.each,e=n.includes,r=n.is,i=Array.prototype;function u(t,e){var r=n.size(e);return t<0&&(t+=r),t<0&&(t=0),t>r&&(t=r),t||0}function o(t,e){var r=[],u=n.len(e);if(u)for(e=e.sort(function(n,t){return n-t});u--;){var o=e[u];r.push(i.splice.call(t,o,1)[0])}return r.reverse(),r}n.reject=function(t,e){return n.filter(t,function(n,t,r){return!e(n,t,r)})},n.without=function(t){var e=n.slice(arguments,1);return n.difference(t,e)},n.difference=function(t,r){var i=[];return n.each(t,function(n){e(r,n)||i.push(n)}),i},n.pluck=function(t,e){return n.map(t,function(n){if(n)return n[e]})},n.nth=function(t,e){return e=(e=u(e,t))||0,n.isString(t)?t.charAt(e):t[e]},n.first=function(t){if(t)return n.nth(t,0)},n.last=function(t){var e=n.len(t);if(e)return n.nth(t,e-1)},n.asyncMap=function(n,e,r){var i,u,o=[],a=0;t(n,function(t,c){u=!0,e(t,function(t,e){if(!i){if(a++,t)return i=!0,r(t);o[c]=e,a==n.length&&(i=!0,r(null,o))}})}),u||r(null)},n.uniq=function(t){return n.uniqBy(t)},n.uniqBy=function(n,i){var u=[],o=[];return r.fn(i)||(i=null),t(n,function(n){var t=n;i&&(t=i(n)),e(o,t)||(o.push(t),u.push(n))}),u},n.flatten=function(n){var e=[];return t(n,function(n){r.arraylike(n)?t(n,function(n){e.push(n)}):e.push(n)}),e},n.union=function(){return n.uniq(n.flatten(arguments))},n.sample=function(t,e){for(var r=n.toArray(t),i=r.length,u=Math.min(e||1,i),o=0;o<i;o++){var a=n.random(o,i-1),c=r[a];r[a]=r[o],r[o]=c}return r.length=u,null==e?r[0]:r},n.shuffle=function(t){return n.sample(t,1/0)},n.compact=function(t){return n.filter(t,n.identity)},n.rest=function(t){return n.slice(t,1)},n.invoke=function(){var t=arguments,e=t[0],i=t[1],u=r.fn(i);return t=n.slice(t,2),n.map(e,function(n){if(u)return i.apply(n,t);if(null!=n){var e=n[i];if(r.fn(e))return e.apply(n,t)}})},n.partition=function(t,e){var r=n.groupBy(t,function(n,t,r){return e(n,t,r)?1:2});return[r[1]||[],r[2]||[]]},n.groupBy=function(t,e){var r={};return n.each(t,function(n,t,i){var u=e(n,t,i);r[u]=r[u]||[],r[u].push(n)}),r},n.range=function(){var t=arguments;if(t.length<2)return n.range(t[1],t[0]);var e=t[0]||0,i=t[1]||0,u=t[2];r.number(u)||(u=1);var o=i-e;0!=u&&(o/=u);for(var a=[],c=e,f=0;f<o;f++)a.push(c),c+=u;return a},n.pullAt=function(t){return o(t,n.slice(arguments,1))},n.remove=function(t,e){for(var r=n.len(t)||0,i=[];r--;)e(t[r],r,t)&&i.push(r);return o(t,i)},n.fill=function(t,e,r,i){var o=n.size(t);r=u(r,t)||0,i=u(i,t)||o;for(var a=r;a<i;a++)t[a]=e;return t},n.size=function(t){var e=0;if(t){var r=t.length;n.isInteger(r)&&r>=0?e=r:n.isObject(t)&&(e=n.keys(t).length)}return e}}},function(n,t){n.exports=function(n){var t=n.is,e=(n.each,n.forIn);n.only=function(e,r){return e=e||{},t.string(r)&&(r=r.split(/ +/)),n.reduce(r,function(n,t){return null!=e[t]&&(n[t]=e[t]),n},{})},n.values=function(t){return n.map(n.keys(t),function(n){return t[n]})},n.pick=function(r,i){if(!t.fn(i))return n.pick(r,function(n,t){return t==i});var u={};return e(r,function(n,t,e){i(n,t,e)&&(u[t]=n)}),u},n.functions=function(e){return n.keys(n.pick(e,function(n){return t.fn(n)}))},n.mapKeys=function(n,t){var r={};return e(n,function(n,e,i){var u=t(n,e,i);r[u]=n}),r},n.mapObject=n.mapValues=function(n,t){var r={};return e(n,function(n,e,i){r[e]=t(n,e,i)}),r},n.get=function(t,e){if((e=u(e)).length&&n.every(e,function(n){if(null!=t)return t=t[n],!0}))return t},n.has=function(e,r){if((r=u(r)).length&&n.every(r,function(n){if(null!=e&&t.owns(e,n))return e=e[n],!0}))return!0;return!1},n.set=function(e,r,i){r=u(r);var o=e;return n.every(r,function(n,e){if(t.oof(o)){if(e+1!=r.length){if(null==(u=o[n])){var u={};~~n==n&&(u=[])}return o=o[n]=u,!0}o[n]=i}}),e},n.create=function(){function t(){}return function(e,r){return"object"!=typeof e&&(e=null),t.prototype=e,n.extend(new t,r)}}(),n.defaults=function(){var e=arguments,r=e[0],i=n.slice(e,1);return r&&n.each(i,function(e){n.mapObject(e,function(n,e){t.undef(r[e])&&(r[e]=n)})}),r},n.isMatch=function(n,t){var r=!0;return n=n||{},e(t,function(t,e){if(t!==n[e])return r=!1,!1}),r},n.toPlainObject=function(n){var t={};return e(n,function(n,e){t[e]=n}),t},n.invert=function(n){var t={};return e(n,function(n,e){t[n]=e}),t};var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,i=/\\(\\)?/g;function u(e){if(t.array(e))return e;var u=[];return n.toString(e).replace(r,function(n,t,e,r){var o=t||n;e&&(o=r.replace(i,"$1")),u.push(o)}),u}}},function(n,t,e){n.exports=function(n){var t=n.is,r=n.slice;function i(n){var t=new i.Cache;function e(){var e=arguments,r=e[0];if(!t.has(r)){var i=n.apply(this,e);t.set(r,i)}return t.get(r)}return e.cache=t,e}n.bind=function(e,i){if(t.string(i)){var u=e;e=u[i],i=u}if(!t.fn(e))return e;var o=r(arguments,2);return i=i||this,function(){return e.apply(i,n.flatten([o,arguments]))}},n.inherits=function(t,e){t.super_=e,t.prototype=n.create(e.prototype,{constructor:t})},n.delay=function(t,e){var r=n.slice(arguments,2);return setTimeout(function(){t.apply(this,r)},e)},n.before=function(n,t){return function(){if(n>1)return n--,t.apply(this,arguments)}},n.once=function(t){return n.before(2,t)},n.after=function(n,t){return function(){if(!(n>1))return t.apply(this,arguments);n--}},n.throttle=function(t,e,r){return e=e||0,r=n.extend({leading:!0,trailing:!0,maxWait:e},r),n.debounce(t,e,r)},n.debounce=function(t,e,r){e=e||0;var i,u=(r=n.extend({leading:!1,trailing:!0},r)).maxWait,o=0,a=0,c=n.now();function f(t,e,r){return o=n.now(),t.apply(e,r)}function s(){i&&(clearTimeout(i),i=null)}function l(){var l=!((c=n.now())-o>e||u&&c-a>u);a=c;var p=this,h=arguments;s(),l?r.trailing&&(i=n.delay(function(){f(t,p,h)},e)):f(t,p,h)}return r.leading||(o=c),l.cancel=s,l},i.Cache=e(14),n.memoize=i,n.wrap=function(n,t){return function(){var e=[n];return e.push.apply(e,arguments),t.apply(this,e)}},n.curry=function(t){var e=t.length;return function r(i){return function(){var u=i.concat(n.slice(arguments));return u.length>=e?(u.length=e,t.apply(this,u)):r(u)}}([])}}},function(n,t,e){var r=e(2).is;function i(){this.data={}}n.exports=i;var u=i.prototype;u.has=function(n){return r.owns(this.data,n)},u.get=function(n){return this.data[n]},u.set=function(n,t){this.data[n]=t},u.delete=function(n){delete this.data[n]}},function(n,t){n.exports=function(n){n.tostr=n.toString=i;var t=n.indexOf;n.split=function(n,t,e){return(n=i(n)).split(t,e)},n.capitalize=function(n){return(n=i(n)).charAt(0).toUpperCase()+n.substr(1)},n.decapitalize=function(n){return(n=i(n)).charAt(0).toLowerCase()+n.substr(1)},n.camelCase=function(t){var e=(t=i(t)).split(/[^\w]|_+/);return e=n.map(e,function(t){return n.capitalize(t)}),n.decapitalize(e.join(""))},n.startsWith=function(n,e){return 0==t(n,e)},n.endsWith=function(t,e){return(e+="")==n.slice(t,n.len(t)-n.len(e))},n.toLower=n.lower=function(n){return i(n).toLowerCase()},n.toUpper=n.upper=function(n){return i(n).toUpperCase()},n.repeat=function(t,e){return n.map(n.range(e),function(){return t}).join("")},n.padStart=function(n,t,e){return n=i(n),r(e,(t=t||0)-n.length)+n},n.padEnd=function(n,t,e){return(n=i(n))+r(e,(t=t||0)-n.length)};var e={"&":"&","<":"<",">":">",'"':""","'":"'"};function r(t,e){t=i(t)||" ";var r=Math.floor(e/t.length)+1;return n.repeat(t,r).slice(0,e)}function i(n){return n||0==n?n+"":""}n.escape=function(n){return i(n).replace(/[&<>"']/g,function(n){return e[n]||n})},n.template=function(t){var e=['with(data) {var ret = ""'];n.each(n.split(t,"<%"),function(t,r){var i=t.split("%>");if(i[1])return function(t){var r=n.first(t);if("="===r||"-"===r){var i=n.slice(t,1);"-"===r&&(i="_.escape("+i+")"),e.push("ret += "+i)}else e.push(t)}(n.trim(i[0])),u(i[1]);u(i[0])}),e.push("return ret}");var r=new Function("data",e.join("\n")),i={_:n};return function(t){return r(n.extend({},i,t))};function u(n){e.push('ret += "'+n.replace(/('|"|\\)/g,"\\$1").replace(/\r/g,"\\r").replace(/\n/g,"\\n")+'"')}}}},function(n,t){n.exports=function(n){n.sum=function(t){return n.reduce(t,function(n,t){return n+t},0)},n.max=function(t,e){var r=-1,i=-1/0;return e=e||n.identity,n.each(t,function(n,t){(n=e(n))>i&&(i=n,r=t)}),r>-1?t[r]:i},n.min=function(t,e){var r=-1,i=1/0;return e=e||n.identity,n.each(t,function(n,t){(n=e(n))<i&&(i=n,r=t)}),r>-1?t[r]:i}}},function(n,t,e){const r=e(0),i=e(18),u=e(3),o=e(19),a=e(1),c=e(20),f=e(26),s="application/json",l="application/x-www-form-urlencoded",p=a.CONTENT_TYPE_KEY,h=["get","head","delete","options"],d=["post","put","patch"],v=[...h,...d];function m(n){this.defaults={baseURL:"",timeout:0,headers:{common:{}},withCredentials:!1},r.each(v,n=>{var t=this.defaults.headers[n]={};r.includes(d,"method")&&(t[n]=s)}),this.interceptors={request:new o,response:new o},this.qs=u,this.CancelToken=f,this.init(n)}m.qs=u;var y=m.prototype;y.init=function(n){n=r.extend({},n),this.defaults.headers.common=n.headers||{},delete n.headers,r.extend(this.defaults,n)},y.create=function(n){return new m(n)},y.request=function(n,t){if(r.isString(n))return this.request(r.extend({url:n},t));var e=n||{};e.headers=e.headers||{};var o=(e=r.extend({},this.defaults,e)).baseURL+e.url;o=i.appendQuery(o,e.params);var c=r.toLower(e.method)||"get",f=this.defaults.headers,h=r.extend({},f.common,f[c],e.headers),d=a.getContentType(h),v=d,m=e.data;r.isPlainObject(m)?(d===l?m=u.stringify(m):d===s&&(m=JSON.stringify(m)),v||r.isString(m)&&(v=l),r.isString(m)||(m=JSON.stringify(m),v=v||s),!d&&v&&(h[p]=v)):a.isFormData(m)&&delete h[p];var y=e.timeout;e={url:o,data:m,headers:h,method:r.toUpper(c),cancelToken:e.cancelToken,withCredentials:e.withCredentials},y&&(e.timeout=y);var g=Promise.resolve(e);return g=this.interceptors.request.intercept(g).then(n=>this.adapter.call(this,n)).then(n=>{if(r.isString(n.data)&&!this.axios){var t=n.data;try{n.data=JSON.parse(n.data)}catch(e){n.data=t}}return n.config=e,n.headers=r.mapKeys(n.headers,(n,t)=>r.toLower(t)),n}),g=this.interceptors.response.intercept(g)},y.adapter=function(n){var t=this.defaults;return t.wx?c.wx.call(this,n):t.axios?c.axios.call(this,n):t.jQuery?c.jquery.call(this,n):t.quickapp?c.quickapp.call(this,n):"function"==typeof XMLHttpRequest?c.xhr.call(this,n):void 0},r.each(h,n=>{y[n]=function(t,e){return this.request(r.extend({method:n,url:t},e))}}),r.each(d,n=>{y[n]=function(t,e,i){return this.request(r.extend({url:t,method:n,data:e},i))}}),n.exports=m},function(n,t,e){var r=e(3),i=e(0);t.parse=function(n,t){if("string"!=typeof n)return n;var e,u,a={};a.href=n,u=(e=o(n,"#"))[0],e[1]&&(a.hash="#"+e[1]),u=(e=function(n,t){var e="";return n=n.replace(t,function(n){return e=n,""}),[e,n]}(u,/^[a-zA-Z][a-zA-Z0-9+-.]*:/))[1],a.protocol=e[0].toLowerCase(),u=(e=o(u,"?"))[0];var c=e[1];if(t&&(c=r.parse(c)),a.query=c,"/"!=u.charAt(0)&&a.schema)return a.opaque=u,a;i.startsWith(u,"//")&&(e=o(u=u.slice(2),"/"),a.pathname="/"+unescape(e[1]||""),e=function(n){var t=o(n,"@"),e=t[0],r=t[1];r||(r=t[0],e=null);return[e,r]}(e[0]),a.auth=e[0],e=o(e[1],":"),a.hostname=e[0],a.port=~~e[1]);return a};var u="http https ftp gopher file".split(" ");function o(n,t){var e=[],r=i.indexOf(n,t);return-1==r?e[0]=n:(e[0]=n.slice(0,r),e[1]=n.slice(r+t.length)),e}t.format=function(n){if(!n||"object"!=typeof n)return n;var t=n.protocol,e=[t];t&&!i.includes(u,t.slice(0,t.length-1))||e.push("//"),n.auth&&e.push(n.auth,"@"),e.push(n.hostname),n.port&&e.push(":",n.port),e.push(n.pathname);var o=n.query;o&&("string"!=typeof o&&(o=r.stringify(o)),o&&e.push("?",o)),e.push(n.hash);for(var a=[],c=0;c<e.length;c++)e[c]&&a.push(e[c]);return a.join("")},t.appendQuery=function(n,t){var e=o(n,"#");n=e[0];var u=e[1];return i.isObject(t)&&(t=r.stringify(t)),i.includes(n,"?")?i.endsWith(n,"&")||i.endsWith(n,"?")||t&&(t="&"+t):t&&(t="?"+t),t&&(n+=t),u&&(n+="#"+u),n}},function(n,t,e){const r=e(0);function i(){this.queue=[]}n.exports=i,r.extend(i.prototype,{use(...n){return this.queue.push(n),this},intercept(n){return r.reduce(this.queue,(n,t)=>n.then(...t),n)}})},function(n,t,e){const r=e(21),i=e(22),u=e(23),o=e(24),a=e(25);t.wx=r,t.quickapp=i,t.axios=u,t.jquery=o,t.xhr=a},function(n,t,e){const r=e(1);n.exports=function(n){var t,e=this.defaults;if(e&&e.wx)return new Promise((i,u)=>{var o=e.wx.request({url:n.url,data:n.data,header:n.headers,method:n.method,success(n){r.clearTimer(t);var{data:e,statusCode:u,header:o}=n;i({data:e,status:u,headers:o})},fail(n){r.clearTimer(t),u(n)}});n.timeout&&(t=setTimeout(()=>{o&&o.abort&&o.abort,u(r.createError("timeout"))},n.timeout))})}},function(n,t,e){const r=e(1);n.exports=function(n){var t=this.defaults;if(t&&t.quickapp)return new Promise((e,i)=>{t.quickapp.fetch({url:n.url,data:n.data,header:n.headers,method:n.method,success(n){r.clearTimer(timer);var{data:t,code:i,headers:u}=n;e({data:t,status:i,headers:u})},fail(n,t){r.clearTimer(timer),i({data:n,code:t})}}),n.timeout&&(timer=setTimeout(()=>{i(r.createError("timeout"))},n.timeout))})}},function(n,t){n.exports=function(n){var t=this.defaults;if(t&&t.axios)return t.axios.request(n).then(n=>n)}},function(n,t,e){const r=e(1);n.exports=function(n){var t=this.defaults;if(t&&t.jQuery)return new Promise((e,i)=>{t.jQuery.ajax({url:n.url,data:n.data,headers:n.headers,method:n.method,timeout:n.timeout,withCredentials:n.withCredentials,success(n,t,i){e({data:n,status:200,headers:r.parseHeadersFromXhr(i)})},error(n,t,e){i(r.createError(e,{response:n,textStatus:t}))}})})}},function(n,t,e){const r=e(1),i=e(0);n.exports=function(n){return new Promise((t,e)=>{var u=new XMLHttpRequest;u.onload=(n=>{t({status:u.status,data:u.responseText,headers:r.parseHeadersFromXhr(u)})}),u.ontimeout=(n=>{e(r.createError("timeout"))}),u.onerror=(n=>{e(r.createError("error"))}),u.open(n.method,n.url,!0),n.timeout&&(u.timeout=n.timeout),n.withCredentials&&(u.withCredentials=n.withCredentials),i.forIn(n.headers,(n,t)=>{u.setRequestHeader(t,n)}),n.cancelToken&&n.cancelToken.promise.then(function(n){u&&(u.abort(),e(n),u=null)}),u.send(n.data)})}},function(n,t){function e(){this.promise=new Promise((n,t)=>{this.resolve=n,this.reject=t})}n.exports=e,e.source=(()=>{var n=new e;return{token:n,cancel(t){n.resolve(new Error(t))}}}),e.prototype.throwIfRequested=function(){}}])}); | ||
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.http=t():n.http=t()}(window,function(){return function(n){var t={};function e(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return n[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:r})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var i in n)e.d(r,i,function(t){return n[t]}.bind(null,i));return r},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="",e(e.s=8)}([function(n,t,e){n.exports=e(10)},function(n,t,e){var r=e(6),i=e(4);i.resolve=e(31),i.reject=e(32),i.prototype.catch=i.prototype.caught=function(n){return this.then(null,n)},i.prototype.delay=function(n){var t;return this.then(function(e){return t=e,i.delay(n)}).then(function(){return t})},i.delay=function(n){return new i(function(t){setTimeout(t,n)})},i.all=function(n){var t=[],e=r.size(n),u=0;return new i(function(o,c){0===e&&o(t),r.each(n,function(n,r){i.resolve(n).then(function(n){t[r]=n,++u===e&&o(t)},function(n){c(n)})})})},i.race=function(n){return new i(function(t,e){r.each(n,function(n){i.resolve(n).then(function(n){t(n)},function(n){e(n)})})})},n.exports=i},function(n,t,e){(function(n){var r=e(0),i=new RegExp("Content-Type","i");t.CONTENT_TYPE_KEY="Content-Type",t.getContentType=function(n){var t=r.keys(n);return n[r.find(t,function(n){return i.test(n)})]},t.parseHeadersFromXhr=function(n){return r.chain(n.getAllResponseHeaders()).trim().split("\n").reduce(function(n,t){var e=r.indexOf(t,":"),i=r.toLower(r.trim(r.slice(t,0,e))),u=r.trim(r.slice(t,e+1));return n[i]?n[i]=","+u:n[i]=u,n},{}).value()},t.isFormData=function(n){return"undefined"!=typeof FormData&&n instanceof FormData},t.timeout=function t(e){return new n(function(n,r){t&&setTimeout(function(){r(new Error("timeout"))},e)})},t.clearTimer=function(n){n&&clearTimeout(n)},t.createError=function(n,t){var e=new Error(n);return r.extend(e,t),e}}).call(this,e(1))},function(n,t,e){var r=e(11),i=[].slice,u=t;u.is=r,u.extend=u.assign=function(n){if(n){var t=i.call(arguments,1);a(t,function(t){h(t,function(t,e){r.undef(t)||(n[e]=t)})})}return n},u.each=a,u.map=function(n,t){var e=[];return a(n,function(n,r,i){e[r]=t(n,r,i)}),e},u.filter=function(n,t){var e=[];return a(n,function(n,r,i){t(n,r,i)&&e.push(n)}),e},u.some=function(n,t){return-1!=f(n,t)},u.every=function(n,t){return-1==f(n,l(t))},u.reduce=function(n,t,e){return a(n,function(r,i){e=t(e,r,i,n)}),e},u.findIndex=f,u.find=function(n,t){var e=u.findIndex(n,t);if(-1!=e)return n[e]},u.indexOf=p,u.includes=function(n,t){return-1!=p(n,t)},u.toArray=s,u.slice=function(n,t,e){var i=[],u=c(n);return u>=0&&(t=t||0,0!==e&&(e=e||u),r.fn(n.slice)||(n=s(n)),i=n.slice(t,e)),i},u.negate=l,u.forIn=h,u.keys=function(n){var t=[];return h(n,function(n,e){t.push(e)}),t};var o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function c(n){if(null!=n)return n.length}function a(n,t){var e=c(n);if(e&&r.fn(t))for(var i=0;i<e&&!1!==t(n[i],i,n);i++);return n}function f(n,t){var e=-1;return a(n,function(n,r,i){if(t(n,r,i))return e=r,!1}),e}function s(n){var t=[];return a(n,function(n){t.push(n)}),t}function l(n){return function(){return!n.apply(this,arguments)}}function p(n,t){return r.string(n)?n.indexOf(t):f(n,function(n){return t===n})}function h(n,t){if(n)for(var e in n)if(r.owns(n,e)&&!1===t(n[e],e,n))break;return n}u.trim=function(n){return null==n?"":(""+n).replace(o,"")},u.noop=function(){},u.len=c},function(n,t,e){(function(t,r){var i=e(6),u=i.is,o=0,c=1,a=-1;function f(n){var t=this;t.handlers={},t.children=[],t.state=o,t.spread=!1;var e=l(t,c),r=h(t,a);if(!u.fn(n))throw new TypeError("expecting a function");try{n(function(n){e(n)},function(n){r(n)})}catch(n){r(n)}}n.exports=f,f.prototype.then=function(n,t){var e=new f(i.noop);e.spread=this.spread;var r=e.handlers;return r[c]=n,r[a]=t,o==this.state?this.children.push(e):d(e,this.state,this.result),e};var s=function(n,t,e){if(n===e)return s(n,a,new TypeError("circle promise"));var r;if(u.oof(e))try{r=e.then}catch(t){return p(n,a,t)}if(u.fn(r)){var o=i.once(function(t,e){t==a?p(n,t,e):s(n,t,e)});try{r.call(e,function(n){o(c,n)},function(n){o(a,n)})}catch(n){o(a,n)}}else p(n,t,e)},l=i.curry(s),p=function(n,t,e){n.state==o&&(n.state=t,n.result=e,i.each(n.children,function(n){d(n,t,e)}))},h=i.curry(p);function d(n,e,i){!function(n){t.process&&r.nextTick?r.nextTick(n):setTimeout(n)}(function(){var t=n.handlers[e];if(u.fn(t)){var r;try{r=n.spread?t.apply(null,i):t(i)}catch(t){return p(n,a,t)}s(n,c,r)}else s(n,e,i)})}}).call(this,e(5),e(30))},function(n,t){var e;e=function(){return this}();try{e=e||Function("return this")()||(0,eval)("this")}catch(n){"object"==typeof window&&(e=window)}n.exports=e},function(n,t,e){n.exports=e(21)},function(n,t,e){var r=e(0),i=r.is,u={sep:"&",eq:"=",encode:encodeURIComponent,decode:decodeURIComponent,keepRaw:!1,sort:null,ignoreValues:[void 0]};function o(n,t,e){return e=r.find(arguments,function(n){return i.object(n)}),n=i.nos(n)?n:void 0,t=i.nos(t)?t:void 0,e=r.extend({},u,e,{sep:n,eq:t})}t.parse=function(n,t,e,i){n+="";var u=(i=o(t,e,i)).decode;return n=n.split(i.sep),r.reduce(n,function(n,t){if(2==(t=t.split(i.eq)).length){var e=t[0],r=t[1];if(!i.keepRaw)try{e=u(e),r=u(r)}catch(n){}n[e]=r}return n},{})},t.stringify=function(n,t,e,u){u=o(t,e,u);var c=r.keys(n),a=u.sort;a&&(i.fn(a)?c.sort(a):c.sort());var f=u.encode,s=[];return r.each(c,function(t){var e=n[t];r.includes(u.ignoreValues,e)||((i.nan(e)||null==e)&&(e=""),u.keepRaw||(t=f(t),e=f(e)),s.push(t+u.eq+e))}),s.join(u.sep)}},function(n,t,e){n.exports=e(9)},function(n,t,e){e(0);var r=new(e(20));n.exports=r},function(n,t,e){var r=e(3);function i(n){if(!(this instanceof i))return new i(n);this.__value=n,this.__chain=!1}n.exports=r.extend(i,r),e(12)(i),e(13)(i),e(14)(i),e(15)(i),e(16)(i),e(18)(i),e(19)(i),i.mixin(i,i)},function(n,t,e){(function(n){var e=t,r=Object.prototype,i=(n=n||{}).navigator;function u(n){var t=r.toString.call(n);return t.substring(8,t.length-1).toLowerCase()}function o(n){return typeof n}function c(n,t){return r.hasOwnProperty.call(n,t)}e.browser=function(){return!(e.wechatApp()||!i||n.window!=n)},e.h5=function(){return!(!e.browser()||!i.geolocation)},e.mobile=function(){return!(!e.browser()||!/mobile/i.test(i.userAgent))},e.wechatApp=function(){return!("object"!=typeof wx||!wx||!e.fn(wx.createVideoContext))},e._class=u,e._type=o,e.owns=c,e.nan=function(n){return n!=n},e.bool=function(n){return"boolean"==u(n)},e.infinite=function(n){return n==1/0||n==-1/0},e.number=function(n){return!isNaN(n)&&"number"==u(n)},e.iod=function(n){return!(!e.number(n)||e.infinite(n))},e.decimal=function(n){return!!e.iod(n)&&0!=n%1},e.integer=function(n){return!!e.iod(n)&&0==n%1},e.oof=function(n){if(n){var t=o(n);return"object"==t||"function"==t}return!1},e.object=function(n){return e.oof(n)&&"function"!=u(n)},e.hash=e.plainObject=function(n){return!(!n||"object"!=u(n))&&(!n.nodeType&&!n.setInterval)},e.undef=function(n){return"undefined"==o(n)},e.fn=function(n){return"function"==u(n)},e.string=function(n){return"string"==u(n)},e.nos=function(n){return e.iod(n)||e.string(n)},e.array=function(n){return"array"==u(n)},e.arraylike=function(n){if(!e.window(n)&&e.object(n)){var t=n.length;if(e.integer(t)&&t>=0)return!0}return!1},e.window=function(n){return!(!n||n.window!=n)},e.empty=function(n){if(e.string(n)||e.arraylike(n))return 0===n.length;if(e.hash(n))for(var t in n)if(c(n,t))return!1;return!0},e.element=function(n){return!(!n||1!==n.nodeType)},e.regexp=function(n){return"regexp"==u(n)}}).call(this,e(5))},function(n,t){n.exports=function(n){var t=n.is;n.isString=t.string,n.isArray=t.array,n.isArrayLike=t.arraylike,n.isBoolean=t.bool,n.isElement=t.element,n.isEmpty=t.empty,n.isFunction=t.fn,n.isInteger=t.integer,n.isNaN=t.nan,n.isNumber=t.number,n.isObject=t.object,n.isPlainObject=t.plainObject,n.isRegExp=t.regexp,n.isString=t.string,n.isUndefined=t.undef}},function(n,t){n.exports=function(n){var t=n.is;n.now=function(){return+new Date},n.constant=function(n){return function(){return n}},n.identity=function(n){return n},n.random=function(n,t){return n+Math.floor(Math.random()*(t-n+1))},n.mixin=function(e,r,i){var u=n.functions(r);if(e)if(t.fn(e)){(i=i||{}).chain;var o=e.prototype;n.each(u,function(n){var t=r[n];o[n]=function(){var n=this,e=[n.__value];e.push.apply(e,arguments);var r=t.apply(n,e);return n.__chain?(n.__value=r,n):r}})}else n.each(u,function(n){e[n]=r[n]});return e},n.chain=function(t){var e=n(t);return e.__chain=!0,e},n.value=function(){return this.__chain=!1,this.__value}}},function(n,t){n.exports=function(n){var t=n.forEach=n.each,e=n.includes,r=n.is,i=Array.prototype;function u(t,e){var r=n.size(e);return t<0&&(t+=r),t<0&&(t=0),t>r&&(t=r),t||0}function o(t,e){var r=[],u=n.len(e);if(u)for(e=e.sort(function(n,t){return n-t});u--;){var o=e[u];r.push(i.splice.call(t,o,1)[0])}return r.reverse(),r}n.reject=function(t,e){return n.filter(t,function(n,t,r){return!e(n,t,r)})},n.without=function(t){var e=n.slice(arguments,1);return n.difference(t,e)},n.difference=function(t,r){var i=[];return n.each(t,function(n){e(r,n)||i.push(n)}),i},n.pluck=function(t,e){return n.map(t,function(n){if(n)return n[e]})},n.nth=function(t,e){return e=(e=u(e,t))||0,n.isString(t)?t.charAt(e):t[e]},n.first=function(t){if(t)return n.nth(t,0)},n.last=function(t){var e=n.len(t);if(e)return n.nth(t,e-1)},n.asyncMap=function(n,e,r){var i,u,o=[],c=0;t(n,function(t,a){u=!0,e(t,function(t,e){if(!i){if(c++,t)return i=!0,r(t);o[a]=e,c==n.length&&(i=!0,r(null,o))}})}),u||r(null)},n.uniq=function(t){return n.uniqBy(t)},n.uniqBy=function(n,i){var u=[],o=[];return r.fn(i)||(i=null),t(n,function(n){var t=n;i&&(t=i(n)),e(o,t)||(o.push(t),u.push(n))}),u},n.flatten=function(n){var e=[];return t(n,function(n){r.arraylike(n)?t(n,function(n){e.push(n)}):e.push(n)}),e},n.union=function(){return n.uniq(n.flatten(arguments))},n.sample=function(t,e){for(var r=n.toArray(t),i=r.length,u=Math.min(e||1,i),o=0;o<i;o++){var c=n.random(o,i-1),a=r[c];r[c]=r[o],r[o]=a}return r.length=u,null==e?r[0]:r},n.shuffle=function(t){return n.sample(t,1/0)},n.compact=function(t){return n.filter(t,n.identity)},n.rest=function(t){return n.slice(t,1)},n.invoke=function(){var t=arguments,e=t[0],i=t[1],u=r.fn(i);return t=n.slice(t,2),n.map(e,function(n){if(u)return i.apply(n,t);if(null!=n){var e=n[i];if(r.fn(e))return e.apply(n,t)}})},n.partition=function(t,e){var r=n.groupBy(t,function(n,t,r){return e(n,t,r)?1:2});return[r[1]||[],r[2]||[]]},n.groupBy=function(t,e){var r={};return n.each(t,function(n,t,i){var u=e(n,t,i);r[u]=r[u]||[],r[u].push(n)}),r},n.range=function(){var t=arguments;if(t.length<2)return n.range(t[1],t[0]);var e=t[0]||0,i=t[1]||0,u=t[2];r.number(u)||(u=1);var o=i-e;0!=u&&(o/=u);for(var c=[],a=e,f=0;f<o;f++)c.push(a),a+=u;return c},n.pullAt=function(t){return o(t,n.slice(arguments,1))},n.remove=function(t,e){for(var r=n.len(t)||0,i=[];r--;)e(t[r],r,t)&&i.push(r);return o(t,i)},n.fill=function(t,e,r,i){var o=n.size(t);r=u(r,t)||0,i=u(i,t)||o;for(var c=r;c<i;c++)t[c]=e;return t},n.size=function(t){var e=0;if(t){var r=t.length;n.isInteger(r)&&r>=0?e=r:n.isObject(t)&&(e=n.keys(t).length)}return e}}},function(n,t){n.exports=function(n){var t=n.is,e=(n.each,n.forIn);n.only=function(e,r){return e=e||{},t.string(r)&&(r=r.split(/ +/)),n.reduce(r,function(n,t){return null!=e[t]&&(n[t]=e[t]),n},{})},n.values=function(t){return n.map(n.keys(t),function(n){return t[n]})},n.pick=function(r,i){if(!t.fn(i))return n.pick(r,function(n,t){return t==i});var u={};return e(r,function(n,t,e){i(n,t,e)&&(u[t]=n)}),u},n.functions=function(e){return n.keys(n.pick(e,function(n){return t.fn(n)}))},n.mapKeys=function(n,t){var r={};return e(n,function(n,e,i){var u=t(n,e,i);r[u]=n}),r},n.mapObject=n.mapValues=function(n,t){var r={};return e(n,function(n,e,i){r[e]=t(n,e,i)}),r},n.get=function(t,e){if((e=u(e)).length&&n.every(e,function(n){if(null!=t)return t=t[n],!0}))return t},n.has=function(e,r){if((r=u(r)).length&&n.every(r,function(n){if(null!=e&&t.owns(e,n))return e=e[n],!0}))return!0;return!1},n.set=function(e,r,i){r=u(r);var o=e;return n.every(r,function(n,e){if(t.oof(o)){if(e+1!=r.length){if(null==(u=o[n])){var u={};~~n==n&&(u=[])}return o=o[n]=u,!0}o[n]=i}}),e},n.create=function(){function t(){}return function(e,r){return"object"!=typeof e&&(e=null),t.prototype=e,n.extend(new t,r)}}(),n.defaults=function(){var e=arguments,r=e[0],i=n.slice(e,1);return r&&n.each(i,function(e){n.mapObject(e,function(n,e){t.undef(r[e])&&(r[e]=n)})}),r},n.isMatch=function(n,t){var r=!0;return n=n||{},e(t,function(t,e){if(t!==n[e])return r=!1,!1}),r},n.toPlainObject=function(n){var t={};return e(n,function(n,e){t[e]=n}),t},n.invert=function(n){var t={};return e(n,function(n,e){t[n]=e}),t};var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,i=/\\(\\)?/g;function u(e){if(t.array(e))return e;var u=[];return n.toString(e).replace(r,function(n,t,e,r){var o=t||n;e&&(o=r.replace(i,"$1")),u.push(o)}),u}}},function(n,t,e){n.exports=function(n){var t=n.is,r=n.slice;function i(n){var t=new i.Cache;function e(){var e=arguments,r=e[0];if(!t.has(r)){var i=n.apply(this,e);t.set(r,i)}return t.get(r)}return e.cache=t,e}n.bind=function(e,i){if(t.string(i)){var u=e;e=u[i],i=u}if(!t.fn(e))return e;var o=r(arguments,2);return i=i||this,function(){return e.apply(i,n.flatten([o,arguments]))}},n.inherits=function(t,e){t.super_=e,t.prototype=n.create(e.prototype,{constructor:t})},n.delay=function(t,e){var r=n.slice(arguments,2);return setTimeout(function(){t.apply(this,r)},e)},n.before=function(n,t){return function(){if(n>1)return n--,t.apply(this,arguments)}},n.once=function(t){return n.before(2,t)},n.after=function(n,t){return function(){if(!(n>1))return t.apply(this,arguments);n--}},n.throttle=function(t,e,r){return e=e||0,r=n.extend({leading:!0,trailing:!0,maxWait:e},r),n.debounce(t,e,r)},n.debounce=function(t,e,r){e=e||0;var i,u=(r=n.extend({leading:!1,trailing:!0},r)).maxWait,o=0,c=0,a=n.now();function f(t,e,r){return o=n.now(),t.apply(e,r)}function s(){i&&(clearTimeout(i),i=null)}function l(){var l=!((a=n.now())-o>e||u&&a-c>u);c=a;var p=this,h=arguments;s(),l?r.trailing&&(i=n.delay(function(){f(t,p,h)},e)):f(t,p,h)}return r.leading||(o=a),l.cancel=s,l},i.Cache=e(17),n.memoize=i,n.wrap=function(n,t){return function(){var e=[n];return e.push.apply(e,arguments),t.apply(this,e)}},n.curry=function(t){var e=t.length;return function r(i){return function(){var u=i.concat(n.slice(arguments));return u.length>=e?(u.length=e,t.apply(this,u)):r(u)}}([])}}},function(n,t,e){var r=e(3).is;function i(){this.data={}}n.exports=i;var u=i.prototype;u.has=function(n){return r.owns(this.data,n)},u.get=function(n){return this.data[n]},u.set=function(n,t){this.data[n]=t},u.delete=function(n){delete this.data[n]}},function(n,t){n.exports=function(n){n.tostr=n.toString=i;var t=n.indexOf;n.split=function(n,t,e){return(n=i(n)).split(t,e)},n.capitalize=function(n){return(n=i(n)).charAt(0).toUpperCase()+n.substr(1)},n.decapitalize=function(n){return(n=i(n)).charAt(0).toLowerCase()+n.substr(1)},n.camelCase=function(t){var e=(t=i(t)).split(/[^\w]|_+/);return e=n.map(e,function(t){return n.capitalize(t)}),n.decapitalize(e.join(""))},n.startsWith=function(n,e){return 0==t(n,e)},n.endsWith=function(t,e){return(e+="")==n.slice(t,n.len(t)-n.len(e))},n.toLower=n.lower=function(n){return i(n).toLowerCase()},n.toUpper=n.upper=function(n){return i(n).toUpperCase()},n.repeat=function(t,e){return n.map(n.range(e),function(){return t}).join("")},n.padStart=function(n,t,e){return n=i(n),r(e,(t=t||0)-n.length)+n},n.padEnd=function(n,t,e){return(n=i(n))+r(e,(t=t||0)-n.length)};var e={"&":"&","<":"<",">":">",'"':""","'":"'"};function r(t,e){t=i(t)||" ";var r=Math.floor(e/t.length)+1;return n.repeat(t,r).slice(0,e)}function i(n){return n||0==n?n+"":""}n.escape=function(n){return i(n).replace(/[&<>"']/g,function(n){return e[n]||n})},n.template=function(t){var e=['with(data) {var ret = ""'];n.each(n.split(t,"<%"),function(t,r){var i=t.split("%>");if(i[1])return function(t){var r=n.first(t);if("="===r||"-"===r){var i=n.slice(t,1);"-"===r&&(i="_.escape("+i+")"),e.push("ret += "+i)}else e.push(t)}(n.trim(i[0])),u(i[1]);u(i[0])}),e.push("return ret}");var r=new Function("data",e.join("\n")),i={_:n};return function(t){return r(n.extend({},i,t))};function u(n){e.push('ret += "'+n.replace(/('|"|\\)/g,"\\$1").replace(/\r/g,"\\r").replace(/\n/g,"\\n")+'"')}}}},function(n,t){n.exports=function(n){n.sum=function(t){return n.reduce(t,function(n,t){return n+t},0)},n.max=function(t,e){var r=-1,i=-1/0;return e=e||n.identity,n.each(t,function(n,t){(n=e(n))>i&&(i=n,r=t)}),r>-1?t[r]:i},n.min=function(t,e){var r=-1,i=1/0;return e=e||n.identity,n.each(t,function(n,t){(n=e(n))<i&&(i=n,r=t)}),r>-1?t[r]:i}}},function(n,t,e){(function(t){var r=e(0),i=e(33),u=e(7),o=e(34),c=e(2),a=e(35),f=e(41),s="application/json",l="application/x-www-form-urlencoded",p=c.CONTENT_TYPE_KEY,h=["get","head","delete","options"],d=["post","put","patch"],v=[].concat(h,d);function m(n){var e=this;this.defaults={baseURL:"",timeout:0,headers:{common:{}},withCredentials:!1},r.each(v,function(n){var t=e.defaults.headers[n]={};r.includes(d,"method")&&(t[n]=s)}),this.interceptors={request:new o,response:new o},this.qs=u,this.Promise=t,this.CancelToken=f,this.init(n)}m.qs=u;var y=m.prototype;y.init=function(n){n=r.extend({},n),this.defaults.headers.common=n.headers||{},delete n.headers,r.extend(this.defaults,n)},y.create=function(n){return new m(n)},y.request=function(n,e){var o=this;if(r.isString(n))return this.request(r.extend({url:n},e));var a=n||{};a.headers=a.headers||{};var f=(a=r.extend({},this.defaults,a)).baseURL+a.url;f=i.appendQuery(f,a.params);var h=r.toLower(a.method)||"get",d=this.defaults.headers,v=r.extend({},d.common,d[h],a.headers),m=c.getContentType(v),y=m,g=a.data;r.isPlainObject(g)?(m===l?g=u.stringify(g):m===s&&(g=JSON.stringify(g)),y||r.isString(g)&&(y=l),r.isString(g)||(g=JSON.stringify(g),y=y||s),!m&&y&&(v[p]=y)):c.isFormData(g)&&delete v[p];var w=a.timeout;a={url:f,data:g,headers:v,method:r.toUpper(h),cancelToken:a.cancelToken,withCredentials:a.withCredentials},w&&(a.timeout=w);var x=t.resolve(a);return x=o.interceptors.request.intercept(x).then(function(n){return o.adapter.call(o,n)}).then(function(n){if(r.isString(n.data)&&!o.axios){var t=n.data;try{n.data=JSON.parse(n.data)}catch(e){n.data=t}}return n.config=a,n.headers=r.mapKeys(n.headers,function(n,t){return r.toLower(t)}),n}),x=o.interceptors.response.intercept(x)},y.adapter=function(n){var t=this.defaults;return t.wx?a.wx.call(this,n):t.axios?a.axios.call(this,n):t.jQuery?a.jquery.call(this,n):t.quickapp?a.quickapp.call(this,n):"function"==typeof XMLHttpRequest?a.xhr.call(this,n):void 0},r.each(h,function(n){y[n]=function(t,e){return this.request(r.extend({method:n,url:t},e))}}),r.each(d,function(n){y[n]=function(t,e,i){return this.request(r.extend({url:t,method:n,data:e},i))}}),n.exports=m}).call(this,e(1))},function(n,t,e){var r=e(3);function i(n){if(!(this instanceof i))return new i(n);this.__value=n,this.__chain=!1}n.exports=r.extend(i,r),e(22)(i),e(23)(i),e(24)(i),e(25)(i),e(26)(i),e(28)(i),e(29)(i),i.mixin(i,i)},function(n,t){n.exports=function(n){var t=n.is;n.isString=t.string,n.isArray=t.array,n.isArrayLike=t.arraylike,n.isBoolean=t.bool,n.isElement=t.element,n.isEmpty=t.empty,n.isFunction=t.fn,n.isInteger=t.integer,n.isNaN=t.nan,n.isNumber=t.number,n.isObject=t.object,n.isPlainObject=t.plainObject,n.isRegExp=t.regexp,n.isString=t.string,n.isUndefined=t.undef}},function(n,t){n.exports=function(n){var t=n.is;n.now=function(){return+new Date},n.constant=function(n){return function(){return n}},n.identity=function(n){return n},n.random=function(n,t){return n+Math.floor(Math.random()*(t-n+1))},n.mixin=function(e,r,i){var u=n.functions(r);if(e)if(t.fn(e)){i=i||{};var o=e.prototype;n.each(u,function(n){var t=r[n];o[n]=function(){var n=this,e=[n.__value];e.push.apply(e,arguments);var r=t.apply(n,e);return n.__chain?(n.__value=r,n):r}})}else n.each(u,function(n){e[n]=r[n]});return e},n.chain=function(t){var e=n(t);return e.__chain=!0,e},n.value=function(){return this.__chain=!1,this.__value};var e=0;n.uniqueId=function(t){return e++,n.toString(t)+e}}},function(n,t){n.exports=function(n){var t=n.forEach=n.each,e=n.includes,r=n.is,i=Array.prototype;function u(t,e){var r=n.size(e);return t<0&&(t+=r),t<0&&(t=0),t>r&&(t=r),t||0}function o(t,e){var r=[],u=n.len(e);if(u)for(e=e.sort(function(n,t){return n-t});u--;){var o=e[u];r.push(i.splice.call(t,o,1)[0])}return r.reverse(),r}n.reject=function(t,e){return n.filter(t,function(n,t,r){return!e(n,t,r)})},n.without=function(t){var e=n.slice(arguments,1);return n.difference(t,e)},n.difference=function(t,r){var i=[];return n.each(t,function(n){e(r,n)||i.push(n)}),i},n.pluck=function(t,e){return n.map(t,function(n){if(n)return n[e]})},n.nth=function(t,e){return e=(e=u(e,t))||0,n.isString(t)?t.charAt(e):t[e]},n.first=function(t){if(t)return n.nth(t,0)},n.last=function(t){var e=n.len(t);if(e)return n.nth(t,e-1)},n.asyncMap=function(n,e,r){var i,u,o=[],c=0;t(n,function(t,a){u=!0,e(t,function(t,e){if(!i){if(c++,t)return i=!0,r(t);o[a]=e,c==n.length&&(i=!0,r(null,o))}})}),u||r(null)},n.uniq=function(t){return n.uniqBy(t)},n.uniqBy=function(n,i){var u=[],o=[];return r.fn(i)||(i=null),t(n,function(n){var t=n;i&&(t=i(n)),e(o,t)||(o.push(t),u.push(n))}),u},n.flatten=function(n){var e=[];return t(n,function(n){r.arraylike(n)?t(n,function(n){e.push(n)}):e.push(n)}),e},n.union=function(){return n.uniq(n.flatten(arguments))},n.sampleSize=function(t,e){for(var r=n.toArray(t),i=r.length,u=Math.min(e||1,i),o=0;o<i;o++){var c=n.random(o,i-1),a=r[c];r[c]=r[o],r[o]=a}return r.length=u,r},n.sample=function(t){return n.first(n.sampleSize(t,1))},n.shuffle=function(t){return n.sampleSize(t,1/0)},n.compact=function(t){return n.filter(t,n.identity)},n.rest=function(t){return n.slice(t,1)},n.invoke=function(){var t=arguments,e=t[0],i=t[1],u=r.fn(i);return t=n.slice(t,2),n.map(e,function(n){if(u)return i.apply(n,t);if(null!=n){var e=n[i];if(r.fn(e))return e.apply(n,t)}})},n.partition=function(t,e){var r=n.groupBy(t,function(n,t,r){return e(n,t,r)?1:2});return[r[1]||[],r[2]||[]]},n.groupBy=function(t,e){var r={};return n.each(t,function(n,t,i){var u=e(n,t,i);r[u]=r[u]||[],r[u].push(n)}),r},n.range=function(){var t=arguments;if(t.length<2)return n.range(t[1],t[0]);var e=t[0]||0,i=t[1]||0,u=t[2];r.number(u)||(u=1);var o=i-e;0!=u&&(o/=u);for(var c=[],a=e,f=0;f<o;f++)c.push(a),a+=u;return c},n.pullAt=function(t){return o(t,n.slice(arguments,1))},n.remove=function(t,e){for(var r=n.len(t)||0,i=[];r--;)e(t[r],r,t)&&i.push(r);return o(t,i)},n.fill=function(t,e,r,i){var o=n.size(t);r=u(r,t)||0,i=u(i,t)||o;for(var c=r;c<i;c++)t[c]=e;return t},n.size=function(t){var e=0;if(t){var r=t.length;n.isInteger(r)&&r>=0?e=r:n.isObject(t)&&(e=n.keys(t).length)}return e}}},function(n,t){n.exports=function(n){var t=n.is,e=n.forIn;n.only=function(e,r){return e=e||{},t.string(r)&&(r=r.split(/ +/)),n.reduce(r,function(n,t){return null!=e[t]&&(n[t]=e[t]),n},{})},n.values=function(t){return n.map(n.keys(t),function(n){return t[n]})},n.pick=function(r,i){if(!t.fn(i))return n.pick(r,function(n,t){return t==i});var u={};return e(r,function(n,t,e){i(n,t,e)&&(u[t]=n)}),u},n.functions=function(e){return n.keys(n.pick(e,function(n){return t.fn(n)}))},n.mapKeys=function(n,t){var r={};return e(n,function(n,e,i){var u=t(n,e,i);r[u]=n}),r},n.mapObject=n.mapValues=function(n,t){var r={};return e(n,function(n,e,i){r[e]=t(n,e,i)}),r},n.get=function(t,e){if((e=u(e)).length&&n.every(e,function(n){if(null!=t)return t=t[n],!0}))return t},n.has=function(e,r){if((r=u(r)).length&&n.every(r,function(n){if(null!=e&&t.owns(e,n))return e=e[n],!0}))return!0;return!1},n.set=function(e,r,i){r=u(r);var o=e;return n.every(r,function(n,e){if(t.oof(o)){if(e+1!=r.length){if(null==(u=o[n])){var u={};~~n==n&&(u=[])}return o=o[n]=u,!0}o[n]=i}}),e},n.create=function(){function t(){}return function(e,r){return"object"!=typeof e&&(e=null),t.prototype=e,n.extend(new t,r)}}(),n.defaults=function(){var e=arguments,r=e[0],i=n.slice(e,1);return r&&n.each(i,function(e){n.mapObject(e,function(n,e){t.undef(r[e])&&(r[e]=n)})}),r},n.isMatch=function(n,t){var r=!0;return n=n||{},e(t,function(t,e){if(t!==n[e])return r=!1,!1}),r},n.toPlainObject=function(n){var t={};return e(n,function(n,e){t[e]=n}),t},n.invert=function(n){var t={};return e(n,function(n,e){t[n]=e}),t};var r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,i=/\\(\\)?/g;function u(e){if(t.array(e))return e;var u=[];return n.toString(e).replace(r,function(n,t,e,r){var o=t||n;e&&(o=r.replace(i,"$1")),u.push(o)}),u}}},function(n,t,e){n.exports=function(n){var t=n.is,r=n.slice;function i(n){var t=new i.Cache;function e(){var e=arguments,r=e[0];if(!t.has(r)){var i=n.apply(this,e);t.set(r,i)}return t.get(r)}return e.cache=t,e}n.bind=function(e,i){if(t.string(i)){var u=e;e=u[i],i=u}if(!t.fn(e))return e;var o=r(arguments,2);return i=i||this,function(){return e.apply(i,n.flatten([o,arguments]))}},n.inherits=function(t,e){t.super_=e,t.prototype=n.create(e.prototype,{constructor:t})},n.delay=function(t,e){var r=n.slice(arguments,2);return setTimeout(function(){t.apply(this,r)},e)},n.before=function(n,t){return function(){if(n>1)return n--,t.apply(this,arguments)}},n.once=function(t){return n.before(2,t)},n.after=function(n,t){return function(){if(!(n>1))return t.apply(this,arguments);n--}},n.throttle=function(t,e,r){return e=e||0,r=n.extend({leading:!0,trailing:!0,maxWait:e},r),n.debounce(t,e,r)},n.debounce=function(t,e,r){e=e||0;var i,u=(r=n.extend({leading:!1,trailing:!0},r)).maxWait,o=0,c=0,a=n.now();function f(t,e,r){return o=n.now(),t.apply(e,r)}function s(){i&&(clearTimeout(i),i=null)}function l(){var l=!((a=n.now())-o>e||u&&a-c>u);c=a;var p=this,h=arguments;s(),l?r.trailing&&(i=n.delay(function(){f(t,p,h)},e)):f(t,p,h)}return r.leading||(o=a),l.cancel=s,l},i.Cache=e(27),n.memoize=i,n.wrap=function(n,t){return function(){var e=[n];return e.push.apply(e,arguments),t.apply(this,e)}},n.curry=function(t){var e=t.length;return function r(i){return function(){var u=i.concat(n.slice(arguments));return u.length>=e?(u.length=e,t.apply(this,u)):r(u)}}([])}}},function(n,t,e){var r=e(3).is;function i(){this.data={}}n.exports=i;var u=i.prototype;u.has=function(n){return r.owns(this.data,n)},u.get=function(n){return this.data[n]},u.set=function(n,t){this.data[n]=t},u.delete=function(n){delete this.data[n]}},function(n,t){n.exports=function(n){n.tostr=n.toString=i;var t=n.indexOf;n.split=function(n,t,e){return(n=i(n)).split(t,e)},n.capitalize=function(n){return(n=i(n)).charAt(0).toUpperCase()+n.substr(1).toLowerCase()},n.upperFirst=function(n){return(n=i(n)).charAt(0).toUpperCase()+n.substr(1)},n.lowerFirst=function(n){return(n=i(n)).charAt(0).toLowerCase()+n.substr(1)},n.camelCase=function(t){var e=(t=i(t)).split(/[^\w]|_+/);return e=n.map(e,function(t){return n.capitalize(t)}),n.lowerFirst(e.join(""))},n.startsWith=function(n,e){return 0==t(n,e)},n.endsWith=function(t,e){return(e+="")==n.slice(t,n.len(t)-n.len(e))},n.toLower=n.lower=function(n){return i(n).toLowerCase()},n.toUpper=n.upper=function(n){return i(n).toUpperCase()},n.repeat=function(t,e){return n.map(n.range(e),function(){return t}).join("")},n.padStart=function(n,t,e){return n=i(n),r(e,(t=t||0)-n.length)+n},n.padEnd=function(n,t,e){return(n=i(n))+r(e,(t=t||0)-n.length)};var e={"&":"&","<":"<",">":">",'"':""","'":"'"};function r(t,e){t=i(t)||" ";var r=Math.floor(e/t.length)+1;return n.repeat(t,r).slice(0,e)}function i(n){return n||0==n?n+"":""}n.escape=function(n){return i(n).replace(/[&<>"']/g,function(n){return e[n]||n})},n.template=function(t){var e=['with(data) {var ret = ""'];n.each(n.split(t,"<%"),function(t,r){var i=t.split("%>");if(i[1])return function(t){var r=n.first(t);if("="===r||"-"===r){var i=n.slice(t,1);"-"===r&&(i="_.escape("+i+")"),e.push("ret += "+i)}else e.push(t)}(n.trim(i[0])),u(i[1]);u(i[0])}),e.push("return ret}");var r=new Function("data",e.join("\n")),i={_:n};return function(t){return r(n.extend({},i,t))};function u(n){e.push('ret += "'+n.replace(/('|"|\\)/g,"\\$1").replace(/\r/g,"\\r").replace(/\n/g,"\\n")+'"')}}}},function(n,t){n.exports=function(n){n.sum=function(t){return n.reduce(t,function(n,t){return n+t},0)},n.max=function(t,e){var r=-1,i=-1/0;return e=e||n.identity,n.each(t,function(n,t){(n=e(n))>i&&(i=n,r=t)}),r>-1?t[r]:i},n.min=function(t,e){var r=-1,i=1/0;return e=e||n.identity,n.each(t,function(n,t){(n=e(n))<i&&(i=n,r=t)}),r>-1?t[r]:i}}},function(n,t){var e,r,i=n.exports={};function u(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function c(n){if(e===setTimeout)return setTimeout(n,0);if((e===u||!e)&&setTimeout)return e=setTimeout,setTimeout(n,0);try{return e(n,0)}catch(t){try{return e.call(null,n,0)}catch(t){return e.call(this,n,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:u}catch(n){e=u}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(n){r=o}}();var a,f=[],s=!1,l=-1;function p(){s&&a&&(s=!1,a.length?f=a.concat(f):l=-1,f.length&&h())}function h(){if(!s){var n=c(p);s=!0;for(var t=f.length;t;){for(a=f,f=[];++l<t;)a&&a[l].run();l=-1,t=f.length}a=null,s=!1,function(n){if(r===clearTimeout)return clearTimeout(n);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(n);try{r(n)}catch(t){try{return r.call(null,n)}catch(t){return r.call(this,n)}}}(n)}}function d(n,t){this.fun=n,this.array=t}function v(){}i.nextTick=function(n){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];f.push(new d(n,t)),1!==f.length||s||c(h)},d.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=v,i.addListener=v,i.once=v,i.off=v,i.removeListener=v,i.removeAllListeners=v,i.emit=v,i.prependListener=v,i.prependOnceListener=v,i.listeners=function(n){return[]},i.binding=function(n){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(n){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},function(n,t,e){var r=e(4);n.exports=function(n){return new r(function(t,e){t(n)})}},function(n,t,e){var r=e(4);n.exports=function(n){return new r(function(t,e){e(n)})}},function(n,t,e){var r=e(7),i=e(0);t.parse=function(n,t){if("string"!=typeof n)return n;var e,u,c={};c.href=n,u=(e=o(n,"#"))[0],e[1]&&(c.hash="#"+e[1]),u=(e=function(n,t){var e="";return n=n.replace(t,function(n){return e=n,""}),[e,n]}(u,/^[a-zA-Z][a-zA-Z0-9+-.]*:/))[1],c.protocol=e[0].toLowerCase(),u=(e=o(u,"?"))[0];var a=e[1];if(t&&(a=r.parse(a)),c.query=a,"/"!=u.charAt(0)&&c.schema)return c.opaque=u,c;i.startsWith(u,"//")&&(e=o(u=u.slice(2),"/"),c.pathname="/"+unescape(e[1]||""),e=function(n){var t=o(n,"@"),e=t[0],r=t[1];r||(r=t[0],e=null);return[e,r]}(e[0]),c.auth=e[0],e=o(e[1],":"),c.hostname=e[0],c.port=~~e[1]);return c};var u="http https ftp gopher file".split(" ");function o(n,t){var e=[],r=i.indexOf(n,t);return-1==r?e[0]=n:(e[0]=n.slice(0,r),e[1]=n.slice(r+t.length)),e}t.format=function(n){if(!n||"object"!=typeof n)return n;var t=n.protocol,e=[t];t&&!i.includes(u,t.slice(0,t.length-1))||e.push("//"),n.auth&&e.push(n.auth,"@"),e.push(n.hostname),n.port&&e.push(":",n.port),e.push(n.pathname);var o=n.query;o&&("string"!=typeof o&&(o=r.stringify(o)),o&&e.push("?",o)),e.push(n.hash);for(var c=[],a=0;a<e.length;a++)e[a]&&c.push(e[a]);return c.join("")},t.appendQuery=function(n,t){var e=o(n,"#");n=e[0];var u=e[1];return i.isObject(t)&&(t=r.stringify(t)),i.includes(n,"?")?i.endsWith(n,"&")||i.endsWith(n,"?")||t&&(t="&"+t):t&&(t="?"+t),t&&(n+=t),u&&(n+="#"+u),n}},function(n,t,e){var r=e(0);function i(){this.queue=[]}n.exports=i,r.extend(i.prototype,{use:function(){return this.queue.push(arguments),this},intercept:function(n){return r.reduce(this.queue,function(n,t){return n.then.apply(n,t)},n)}})},function(n,t,e){var r=e(36),i=e(37),u=e(38),o=e(39),c=e(40);t.wx=r,t.quickapp=i,t.axios=u,t.jquery=o,t.xhr=c},function(n,t,e){(function(t){var r=e(2);n.exports=function(n){var e,i=this.defaults;if(i&&i.wx)return new t(function(t,u){var o=i.wx.request({url:n.url,data:n.data,header:n.headers,method:n.method,success:function(n){r.clearTimer(e),t({data:n.data,status:n.statusCode,headers:n.header})},fail:function(n){r.clearTimer(e),u(n)}});n.timeout&&(e=setTimeout(function(){o&&o.abort&&o.abort,o=null,u(r.createError("timeout"))},n.timeout)),n.cancelToken&&n.cancelToken.promise.then(function(n){o&&o.abort&&(o.abort(),u(n),o=null)})})}}).call(this,e(1))},function(n,t,e){(function(t){var r=e(2);n.exports=function(n){var e=this.defaults;if(e&&e.quickapp)return new t(function(t,i){e.quickapp.fetch({url:n.url,data:n.data,header:n.headers,method:n.method,success:function(n){r.clearTimer(timer),t({data:n.data,status:n.code,headers:n.headers})},fail:function(n,t){r.clearTimer(timer),i({data:n,code:t})}}),n.timeout&&(timer=setTimeout(function(){i(r.createError("timeout"))},n.timeout)),n.cancelToken&&n.cancelToken.promise.then(function(n){i(n)})})}}).call(this,e(1))},function(n,t){n.exports=function(n){var t=this.defaults;if(t&&t.axios)return t.axios.request(n).then(function(n){return n})}},function(n,t,e){(function(t){var r=e(2);n.exports=function(n){var e=this.defaults;if(e&&e.jQuery)return new t(function(t,i){var u=e.jQuery.ajax({url:n.url,data:n.data,headers:n.headers,method:n.method,timeout:n.timeout,withCredentials:n.withCredentials,success:function(n,e,i){t({data:n,status:200,headers:r.parseHeadersFromXhr(i)})},error:function(n,t,e){i(r.createError(e,{response:n,textStatus:t}))}});n.cancelToken&&n.cancelToken.promise.then(function(n){u&&(u.abort(),i(n),u=null)})})}}).call(this,e(1))},function(n,t,e){(function(t){var r=e(2),i=e(0);n.exports=function(n){return new t(function(t,e){var u=new XMLHttpRequest;u.onload=function(n){t({status:u.status,data:u.responseText,headers:r.parseHeadersFromXhr(u)})},u.ontimeout=function(n){e(r.createError("timeout"))},u.onerror=function(n){e(r.createError("error"))},u.open(n.method,n.url,!0),n.timeout&&(u.timeout=n.timeout),n.withCredentials&&(u.withCredentials=n.withCredentials),i.forIn(n.headers,function(n,t){u.setRequestHeader(t,n)}),n.cancelToken&&n.cancelToken.promise.then(function(n){u&&(u.abort(),e(n),u=null)}),u.send(n.data)})}}).call(this,e(1))},function(n,t,e){(function(t){function e(){var n=this;n.promise=new t(function(t,e){n.resolve=t,n.reject=e})}n.exports=e,e.source=function(){var n=new e;return{token:n,cancel:function(t){n.resolve(new Error(t))}}},e.prototype.throwIfRequested=function(){}}).call(this,e(1))}])}); |
{ | ||
"name": "@chunpu/http", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"description": "Promise Based request / fetch / http For Real Project, Support multiple platforms", | ||
@@ -32,2 +32,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"min-promise": "^5.0.0", | ||
"min-qs": "^1.4.0", | ||
@@ -34,0 +35,0 @@ "min-url": "^1.5.0", |
@@ -27,2 +27,13 @@ @chunpu/http | ||
Features | ||
--- | ||
- [Largely axios-compatible API](#api) | ||
- Support More platforms like [微信小程序](#微信小程序), [快应用](#快应用) | ||
- Support the Promise API | ||
- [Intercept request and response](#interceptors) | ||
- [More Automatic Transform request and response data](#automatic-transform-request-data) | ||
- [Batch Cancel requests](#cancel-requests) | ||
- More adapters inside: [axios](#axios-nodejs), [jQuery](#jquery--zepto), XMLHttpRequest | ||
Inspired by [axios](https://github.com/axios/axios) | ||
@@ -94,5 +105,5 @@ | ||
### Auto Handle Request Data | ||
### Automatic Transform Request Data | ||
data will be handled by the value of `headers['content-type']`, Plain Object data will be auto stringify | ||
Respect the request `headers['content-type']` setting, data will be transform by the content type, Plain Object data will be auto stringify | ||
@@ -108,3 +119,3 @@ - `application/json` will `JSON.stringify` the data object | ||
- `data` response data, will always try to `JSON.parse`, because most server not respect the response mime | ||
- `data` response data | ||
- `headers` `name: value` headers, all header names are lower cased | ||
@@ -114,3 +125,5 @@ - `status` status code, number | ||
Not Respect the response `headers['content-type']` value, will always try to `JSON.parse` the data, because most server not respect the response mime | ||
Platform Support | ||
@@ -161,3 +174,3 @@ --- | ||
### axios | ||
### axios (node.js) | ||
@@ -174,2 +187,4 @@ ```js | ||
Please use http with `axios mode` in Node.js platform | ||
### jQuery / Zepto | ||
@@ -218,3 +233,3 @@ | ||
Interceptors / Hook | ||
Interceptors | ||
--- | ||
@@ -246,3 +261,3 @@ | ||
source is sth like deferred | ||
For easy understanding, `cancelToken` equals `deferred` equals `source.token` | ||
@@ -255,3 +270,3 @@ ```js | ||
}).catch(err => { | ||
console.error(err) // too slow, abort it | ||
console.error(err) // error: cancel request | ||
}) | ||
@@ -262,7 +277,7 @@ | ||
}).catch(err => { | ||
console.error(err) // too slow, abort it | ||
console.error(err) // error: cancel request | ||
}) | ||
setTimeout(() => { | ||
source.cancel('too slow, abort it') // will cancel all requests with this source | ||
source.cancel('cancel request') // will cancel all requests with this source | ||
}, 1000) | ||
@@ -269,0 +284,0 @@ ``` |
@@ -5,3 +5,3 @@ module.exports = function(config) { | ||
// https://github.com/axios/axios | ||
return defaults.axios.request(config).then(response => { | ||
return defaults.axios.request(config).then(function(response) { | ||
return response | ||
@@ -8,0 +8,0 @@ }) |
@@ -1,6 +0,6 @@ | ||
const wx = require('./wx') | ||
const quickapp = require('./quickapp') | ||
const axios = require('./axios') | ||
const jquery = require('./jquery') | ||
const xhr = require('./xhr') | ||
var wx = require('./wx') | ||
var quickapp = require('./quickapp') | ||
var axios = require('./axios') | ||
var jquery = require('./jquery') | ||
var xhr = require('./xhr') | ||
@@ -7,0 +7,0 @@ exports.wx = wx |
@@ -1,2 +0,2 @@ | ||
const utils = require('../utils') | ||
var utils = require('../utils') | ||
@@ -7,3 +7,3 @@ module.exports = function(config) { | ||
// http://api.jquery.com/jquery.ajax/ | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function(resolve, reject) { | ||
var xhr = defaults.jQuery.ajax({ | ||
@@ -16,5 +16,5 @@ url: config.url, | ||
withCredentials: config.withCredentials, | ||
success (data, textStatus, jqXHR) { | ||
success: function(data, textStatus, jqXHR) { | ||
resolve({ | ||
data, | ||
data: data, | ||
status: 200, | ||
@@ -24,3 +24,3 @@ headers: utils.parseHeadersFromXhr(jqXHR) | ||
}, | ||
error (jqXHR, textStatus, errorThrown) { | ||
error: function(jqXHR, textStatus, errorThrown) { | ||
reject(utils.createError(errorThrown, { | ||
@@ -27,0 +27,0 @@ response: jqXHR, |
@@ -1,2 +0,2 @@ | ||
const utils = require('../utils') | ||
var utils = require('../utils') | ||
@@ -7,3 +7,3 @@ module.exports = function(config) { | ||
// https://doc.quickapp.cn/features/system/fetch.html | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function(resolve, reject) { | ||
defaults.quickapp.fetch({ | ||
@@ -14,14 +14,13 @@ url: config.url, | ||
method: config.method, | ||
success (response) { | ||
success: function(response) { | ||
utils.clearTimer(timer) | ||
var {data, code, headers} = response | ||
resolve({ | ||
data, | ||
status: code, | ||
headers | ||
data: response.data, | ||
status: response.code, | ||
headers: response.headers | ||
}) | ||
}, | ||
fail (data, code) { | ||
fail: function(data, code) { | ||
utils.clearTimer(timer) | ||
reject({data, code}) | ||
reject({data: data, code: code}) | ||
} | ||
@@ -31,3 +30,3 @@ }) | ||
if (config.timeout) { | ||
timer = setTimeout(() => { | ||
timer = setTimeout(function() { | ||
reject(utils.createError('timeout')) | ||
@@ -34,0 +33,0 @@ }, config.timeout) |
@@ -1,2 +0,2 @@ | ||
const utils = require('../utils') | ||
var utils = require('../utils') | ||
@@ -8,3 +8,3 @@ module.exports = function(config) { | ||
var timer | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function(resolve, reject) { | ||
var task = defaults.wx.request({ | ||
@@ -15,12 +15,11 @@ url: config.url, | ||
method: config.method, | ||
success (response) { | ||
success: function(response) { | ||
utils.clearTimer(timer) | ||
var {data, statusCode, header} = response | ||
resolve({ | ||
data, | ||
status: statusCode, | ||
headers: header | ||
data: response.data, | ||
status: response.statusCode, | ||
headers: response.header | ||
}) | ||
}, | ||
fail (err) { | ||
fail: function(err) { | ||
utils.clearTimer(timer) | ||
@@ -32,3 +31,3 @@ reject(err) | ||
if (config.timeout) { | ||
timer = setTimeout(() => { | ||
timer = setTimeout(function() { | ||
if (task && task.abort) { | ||
@@ -35,0 +34,0 @@ task.abort |
@@ -1,9 +0,9 @@ | ||
const utils = require('../utils') | ||
const _ = require('min-util') | ||
var utils = require('../utils') | ||
var _ = require('min-util') | ||
module.exports = function(config) { | ||
// default use XMLHttpRequest | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function(resolve, reject) { | ||
var xhr = new XMLHttpRequest() | ||
xhr.onload = ev => { | ||
xhr.onload = function(ev) { | ||
resolve({ | ||
@@ -15,6 +15,6 @@ status: xhr.status, | ||
} | ||
xhr.ontimeout = ev => { | ||
xhr.ontimeout = function(ev) { | ||
reject(utils.createError('timeout')) | ||
} | ||
xhr.onerror = ev => { | ||
xhr.onerror = function(ev) { | ||
reject(utils.createError('error')) | ||
@@ -29,3 +29,3 @@ } | ||
} | ||
_.forIn(config.headers, (value, key) => { | ||
_.forIn(config.headers, function(value, key) { | ||
xhr.setRequestHeader(key, value) | ||
@@ -32,0 +32,0 @@ }) |
module.exports = Deferred | ||
function Deferred() { | ||
this.promise = new Promise((resolve, reject) => { | ||
this.resolve = resolve | ||
this.reject = reject | ||
var me = this | ||
me.promise = new Promise(function(resolve, reject) { | ||
me.resolve = resolve | ||
me.reject = reject | ||
}) | ||
} | ||
Deferred.source = () => { | ||
Deferred.source = function() { | ||
var deferred = new Deferred() | ||
return { | ||
token: deferred, | ||
cancel (reason) { | ||
cancel: function(reason) { | ||
deferred.resolve(new Error(reason)) | ||
@@ -16,0 +17,0 @@ } |
@@ -1,17 +0,18 @@ | ||
const _ = require('min-util') | ||
const Url = require('min-url') | ||
const qs = require('min-qs') | ||
const Queue = require('./queue') | ||
const utils = require('./utils') | ||
const adapters = require('./adapters') | ||
const CancelToken = require('./canceltoken') | ||
var _ = require('min-util') | ||
var Url = require('min-url') | ||
var qs = require('min-qs') | ||
var Queue = require('./queue') | ||
var utils = require('./utils') | ||
var adapters = require('./adapters') | ||
var CancelToken = require('./canceltoken') | ||
const JSON_TYPE = 'application/json' | ||
const URL_TYPE = 'application/x-www-form-urlencoded' | ||
const CONTENT_TYPE_KEY = utils.CONTENT_TYPE_KEY | ||
const simpleMethods = ['get', 'head', 'delete', 'options'] | ||
const dataMethods = ['post', 'put', 'patch'] | ||
const httpMethods = [...simpleMethods, ...dataMethods] | ||
var JSON_TYPE = 'application/json' | ||
var URL_TYPE = 'application/x-www-form-urlencoded' | ||
var CONTENT_TYPE_KEY = utils.CONTENT_TYPE_KEY | ||
var simpleMethods = ['get', 'head', 'delete', 'options'] | ||
var dataMethods = ['post', 'put', 'patch'] | ||
var httpMethods = [].concat(simpleMethods, dataMethods) | ||
function HttpClient (opt) { | ||
var me = this | ||
this.defaults = { | ||
@@ -25,4 +26,4 @@ baseURL: '', | ||
} | ||
_.each(httpMethods, method => { | ||
var header = this.defaults.headers[method] = {} | ||
_.each(httpMethods, function(method) { | ||
var header = me.defaults.headers[method] = {} | ||
if (_.includes(dataMethods, 'method')) { | ||
@@ -39,2 +40,3 @@ header[method] = JSON_TYPE | ||
this.qs = qs | ||
this.Promise = Promise | ||
this.CancelToken = CancelToken | ||
@@ -61,2 +63,3 @@ this.init(opt) | ||
proto.request = function (arg1, arg2) { | ||
var me = this | ||
if (_.isString(arg1)) { | ||
@@ -108,7 +111,7 @@ return this.request(_.extend({url: arg1}, arg2)) | ||
// TODO auth... | ||
// TODO auth | ||
config = { | ||
url, | ||
data, | ||
headers, | ||
url: url, | ||
data: data, | ||
headers: headers, | ||
method: _.toUpper(method), | ||
@@ -124,8 +127,8 @@ cancelToken: config.cancelToken, | ||
var ret = Promise.resolve(config) | ||
ret = this.interceptors.request.intercept(ret) // after get config | ||
.then(config => this.adapter.call(this, config)) | ||
.then(response => { | ||
ret = me.interceptors.request.intercept(ret) // after get config | ||
.then(function(config) {return me.adapter.call(me, config)}) | ||
.then(function(response) { | ||
// 尝试解析 response.data, 总是尝试解析成 json(就像 axios 一样), 因为后端通常写不对 mime | ||
if (_.isString(response.data)) { | ||
if (!this.axios) { | ||
if (!me.axios) { | ||
var rawResponse = response.data | ||
@@ -140,3 +143,3 @@ try { | ||
response.config = config | ||
response.headers = _.mapKeys(response.headers, (value, key) => { | ||
response.headers = _.mapKeys(response.headers, function(value, key) { | ||
return _.toLower(key) // All header names are lower cased | ||
@@ -146,3 +149,3 @@ }) | ||
}) | ||
ret = this.interceptors.response.intercept(ret) // after parse data | ||
ret = me.interceptors.response.intercept(ret) // after parse data | ||
return ret | ||
@@ -169,7 +172,7 @@ } | ||
_.each(simpleMethods, method => { | ||
_.each(simpleMethods, function(method) { | ||
proto[method] = function (url, config) { | ||
return this.request(_.extend({ | ||
method, | ||
url | ||
method: method, | ||
url: url | ||
}, config)) | ||
@@ -179,8 +182,8 @@ } | ||
_.each(dataMethods, method => { | ||
_.each(dataMethods, function(method) { | ||
proto[method] = function (url, data, config) { | ||
return this.request(_.extend({ | ||
url, | ||
method, | ||
data | ||
url: url, | ||
method: method, | ||
data: data | ||
}, config)) | ||
@@ -187,0 +190,0 @@ } |
@@ -1,21 +0,6 @@ | ||
const _ = require('min-util') | ||
const HttpClient = require('./http') | ||
var _ = require('min-util') | ||
var HttpClient = require('./http') | ||
const instance = new HttpClient() | ||
var instance = new HttpClient() | ||
module.exports = instance | ||
// TODO sth wrong with quickapp, to be verified | ||
// module.exports = exports = http // always export a function | ||
// function http(...args) { | ||
// return instance.request(...args) | ||
// } | ||
// for (var key in instance) { | ||
// var val = instance[key] | ||
// if (_.isFunction(val)) { | ||
// val = _.bind(val, instance) // | ||
// } | ||
// http[key] = val | ||
// } |
@@ -1,2 +0,2 @@ | ||
const _ = require('min-util') | ||
var _ = require('min-util') | ||
@@ -10,11 +10,11 @@ module.exports = Queue | ||
_.extend(Queue.prototype, { | ||
use (...middleware) { | ||
this.queue.push(middleware) | ||
use: function() { | ||
this.queue.push(arguments) | ||
return this | ||
}, | ||
intercept (promise) { | ||
return _.reduce(this.queue, (prev, middleware) => { | ||
return prev.then(...middleware) | ||
intercept: function(promise) { | ||
return _.reduce(this.queue, function(prev, middlewares) { | ||
return prev.then.apply(prev, middlewares) | ||
}, promise) | ||
} | ||
}) |
@@ -1,9 +0,9 @@ | ||
const _ = require('min-util') | ||
var _ = require('min-util') | ||
const CONTENT_TYPE_KEY = 'Content-Type' | ||
const reContentType = new RegExp(CONTENT_TYPE_KEY, 'i') | ||
var CONTENT_TYPE_KEY = 'Content-Type' | ||
var reContentType = new RegExp(CONTENT_TYPE_KEY, 'i') | ||
function getContentType(headers) { | ||
var headerKeys = _.keys(headers) | ||
var typeKey = _.find(headerKeys, key => { | ||
var typeKey = _.find(headerKeys, function(key) { | ||
return reContentType.test(key) | ||
@@ -18,3 +18,3 @@ }) | ||
.split('\n') | ||
.reduce((ret, header) => { | ||
.reduce(function(ret, header) { | ||
var i = _.indexOf(header, ':') | ||
@@ -38,5 +38,5 @@ var key = _.toLower(_.trim(_.slice(header, 0, i))) | ||
function timeout(time) { | ||
return new Promise((resolve, reject) => { | ||
return new Promise(function(resolve, reject) { | ||
if (timeout) { | ||
setTimeout(() => { | ||
setTimeout(function() { | ||
reject(new Error('timeout')) | ||
@@ -43,0 +43,0 @@ }, time) |
@@ -17,2 +17,4 @@ var webpack = require('webpack') | ||
mode: 'production', | ||
// devtool: false, | ||
// mode: 'development', | ||
output: { | ||
@@ -28,2 +30,5 @@ path: path.join(__dirname, 'dist'), | ||
VERSION: JSON.stringify(pkg.version) | ||
}), | ||
new webpack.ProvidePlugin({ | ||
Promise: 'min-promise' | ||
}) | ||
@@ -30,0 +35,0 @@ ] |
Sorry, the diff of this file is not supported yet
81541
368
4
800
+ Addedmin-promise@^5.0.0
+ Addeddom-serializer@0.2.2(transitive)
+ Addeddomelementtype@1.3.12.3.0(transitive)
+ Addeddomhandler@2.4.2(transitive)
+ Addeddomutils@1.7.0(transitive)
+ Addedentities@1.1.22.2.0(transitive)
+ Addedeslint-plugin-html@4.0.6(transitive)
+ Addedhtmlparser2@3.10.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedmin-promise@5.0.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)