- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _times=require("./times"),_constant=require("./constant");function _regeneratorRuntime(){_regeneratorRuntime=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function l(t,e,r,o){var i=e&&e.prototype instanceof p?e:p,a=Object.create(i.prototype),u=new j(o||[]);return n(a,"_invoke",{value:_(t,r,u)}),a}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var f={};function p(){}function d(){}function y(){}var h={};c(h,i,function(){return this});var v=Object.getPrototypeOf,m=v&&v(v(E([])));m&&m!==e&&r.call(m,i)&&(h=m);var g=y.prototype=p.prototype=Object.create(h);function b(t){["next","throw","return"].forEach(function(e){c(t,e,function(t){return this._invoke(e,t)})})}function w(t,e){function o(n,i,a,u){var c=s(t[n],t,i);if("throw"!==c.type){var l=c.arg,f=l.value;return f&&"object"==_typeof(f)&&r.call(f,"__await")?e.resolve(f.__await).then(function(t){o("next",t,a,u)},function(t){o("throw",t,a,u)}):e.resolve(f).then(function(t){l.value=t,a(l)},function(t){return o("throw",t,a,u)})}u(c.arg)}var i;n(this,"_invoke",{value:function(t,r){function n(){return new e(function(e,n){o(t,r,e,n)})}return i=i?i.then(n,n):n()}})}function _(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=x(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function x(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,x(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=s(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function O(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 S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function E(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:R}}function R(){return{value:void 0,done:!0}}return d.prototype=y,n(g,"constructor",{value:y,configurable:!0}),n(y,"constructor",{value:d,configurable:!0}),d.displayName=c(y,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,c(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},b(w.prototype),c(w.prototype,a,function(){return this}),t.AsyncIterator=w,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new w(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},b(g),c(g,u,"Generator"),c(g,i,function(){return this}),c(g,"toString",function(){return"[object Generator]"}),t.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}},t.values=E,j.prototype={constructor:j,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.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,f):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),f},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),S(r),f}},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;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:E(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function asyncGeneratorStep(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){asyncGeneratorStep(i,n,o,a,u,"next",t)}function u(t){asyncGeneratorStep(i,n,o,a,u,"throw",t)}a(void 0)})}}function ownKeys(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 _objectSpread(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(r),!0).forEach(function(e){_defineProperty(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"===_typeof(e)?e:String(e)}function _toPrimitive(t,e){if("object"!==_typeof(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function _typeof(t){return _typeof="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},_typeof(t)}var urlAddQueryDeal=function(t,e){var r="",n=t;return"object"===_typeof(e)&&Object.keys(e).length&&(Object.keys(e).forEach(function(t){var n=e[t];if(Array.isArray(n)){if(!n.length)return;n.forEach(function(e){r+="&".concat(t,"=").concat(e)})}else r+="&".concat(t,"=").concat(n)}),n=t.includes("?")?"".concat(t).concat(r):"".concat(t,"?").concat(r.substring(1))),n},defaultShouldRetry=function(t){var e,r,n,o=(null==t||null===(e=t.raw)||void 0===e?void 0:e.statusCode)||0;if(404===o||o>=500&&o<600)return!0;if(200===o)return!1;var i=String((null==t||null===(r=t.raw)||void 0===r?void 0:r.errMsg)||(null==t||null===(n=t.raw)||void 0===n?void 0:n.message)||(null==t?void 0:t.message)||"");return/timeout|abort|cancel|fail|network/i.test(i)},normalizeRetryConfig=function(t){return!0===t?{max:2}:"number"==typeof t&&Number.isFinite(t)?{max:t}:t&&"object"===_typeof(t)&&!Array.isArray(t)?t:null},pickRetryOrigin=function(t,e,r,n){return n&&t===_constant.REQUEST_ORIGIN_PRIMARY?e<=Math.ceil(r/2)?_constant.REQUEST_ORIGIN_PRIMARY:_constant.REQUEST_ORIGIN_BACKUP:t},requestOnce=function(t,e){var r,n=e.method,o=void 0===n?"GET":n,i=e.query,a=e.data,u=e.sdkUserOptions,c=void 0===u?{}:u,l=e.header,s=t;if(t.startsWith("/live")||t.startsWith("/apiservice")||t.startsWith("/open-api")){var f=c.origin||_constant.REQUEST_ORIGIN_PRIMARY;s=f+t}return i&&(s=urlAddQueryDeal(s,i)),l=_objectSpread(_objectSpread({},null!==(r=l)&&void 0!==r?r:{}),{},{os:wx.getSystemInfoSync().platform,"usage-type":"miniprogram","usage-mode":"portrait"},c.headers||{}),new Promise(function(t,e){wx.request({url:s,method:o,data:a,header:l,success:function(r){var n,o,i,a,u;if(r.statusCode<200||r.statusCode>=300)e({url:s,result:r.data&&r.data.Result||{},raw:r});else if(null!=r&&null!==(n=r.data)&&void 0!==n&&null!==(o=n.ResponseMetadata)&&void 0!==o&&o.Error){var c=r.data.ResponseMetadata.Error||{};e({url:s,code:c.Code,message:c.Message||(null==r?void 0:r.errMsg)||"request failed",raw:r})}else null!=r&&null!==(i=r.data)&&void 0!==i&&null!==(a=i.ResponseMetadata)&&void 0!==a&&a.SystemTime&&(0,_times.setTime)(r.data.ResponseMetadata.SystemTime),t(_objectSpread(_objectSpread({},r.data&&r.data.Result||{}),{},{__responseMetaData:null==r||null===(u=r.data)||void 0===u?void 0:u.ResponseMetadata}))},fail:function(t){e({url:s,raw:t})}})})},request=function(){var t=_asyncToGenerator(_regeneratorRuntime().mark(function t(e,r){var n,o,i,a,u,c,l,s,f,p,d,y,h,v,m,g,b,w,_,x,O,S,j,E;return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:n=(null==r?void 0:r.sdkUserOptions)||{},o=normalizeRetryConfig(null==r?void 0:r.retry),i=null==r?void 0:r.requestHooks,a=o?Math.max(1,Number(o.max)||1):1,u=n.origin||_constant.REQUEST_ORIGIN_PRIMARY,c=!!o&&!1!==o.switchToBackup,l=o?"function"==typeof o.shouldRetry?o.shouldRetry:defaultShouldRetry:null,f=1;case 8:if(!(f<=a)){t.next=39;break}return y=pickRetryOrigin(u,f,a,c),h=Date.now(),m={reqUrl:e,option:r,attempt:f,max:a,retryIndex:v=f-1,origin:y,time:h},null==o||null===(p=o.onStart)||void 0===p||p.call(o,m),null==i||null===(d=i.onStart)||void 0===d||d.call(i,m),t.prev=15,t.next=18,requestOnce(e,_objectSpread(_objectSpread({},r),{},{sdkUserOptions:_objectSpread(_objectSpread({},n),{},{origin:y})}));case 18:return w=t.sent,_={reqUrl:e,option:r,attempt:f,max:a,retryIndex:v,origin:y,time:h,durationMs:Date.now()-h,response:w},null==o||null===(g=o.onSuccess)||void 0===g||g.call(o,_),null==i||null===(b=i.onSuccess)||void 0===b||b.call(i,_),t.abrupt("return",w);case 25:if(t.prev=25,t.t0=t.catch(15),s=t.t0,S=!!l&&l(t.t0),j=!!(o&&S&&f<a),E={reqUrl:e,option:r,attempt:f,max:a,retryIndex:v,origin:y,time:h,durationMs:Date.now()-h,error:t.t0,retryable:S,willRetry:j},null==o||null===(x=o.onError)||void 0===x||x.call(o,E),null==i||null===(O=i.onError)||void 0===O||O.call(i,E),j){t.next=36;break}throw s&&"object"===_typeof(s)&&(s.retryInfo={attempt:f,max:a,retryIndex:v,origin:y,time:h,durationMs:Date.now()-h,retryable:S}),s;case 36:f+=1,t.next=8;break;case 39:throw s;case 40:case"end":return t.stop()}},t,null,[[15,25]])}));return function(e,r){return t.apply(this,arguments)}}(),_default=request;exports.default=_default; |