Files
陈誉午 994b267f5c feat: 电子药箱小程序 - 4Tab药品管理
- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡
- 药品百科: 搜索 + 分类筛选 + 20种药品静态数据
- 惠教中心: 4条药品使用指南课程
- 我的: 家庭成员信息管理
- 自定义TabBar + navigation-bar组件
- SVG药品分类插图
2026-07-29 11:20:52 +08:00

1 line
17 KiB
JavaScript

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.initReservationModule=exports.getReservationService=exports.destroyReservationService=exports.default=void 0;var _events=_interopRequireDefault(require("../utils/events")),_constant=require("../utils/constant");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _regeneratorRuntime(){_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function c(e,t,r,o){var i=t&&t.prototype instanceof f?t:f,a=Object.create(i.prototype),s=new O(o||[]);return n(a,"_invoke",{value:m(e,r,s)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var v={};function f(){}function h(){}function d(){}var p={};u(p,i,function(){return this});var y=Object.getPrototypeOf,g=y&&y(y(T([])));g&&g!==t&&r.call(g,i)&&(p=g);var R=d.prototype=f.prototype=Object.create(p);function _(e){["next","throw","return"].forEach(function(t){u(e,t,function(e){return this._invoke(t,e)})})}function E(e,t){function o(n,i,a,s){var u=l(e[n],e,i);if("throw"!==u.type){var c=u.arg,v=c.value;return v&&"object"==_typeof(v)&&r.call(v,"__await")?t.resolve(v.__await).then(function(e){o("next",e,a,s)},function(e){o("throw",e,a,s)}):t.resolve(v).then(function(e){c.value=e,a(c)},function(e){return o("throw",e,a,s)})}s(u.arg)}var i;n(this,"_invoke",{value:function(e,r){function n(){return new t(function(t,n){o(e,r,t,n)})}return i=i?i.then(n,n):n()}})}function m(e,t,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 s=b(a,r);if(s){if(s===v)continue;return s}}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 u=l(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function b(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),v;var o=l(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,v;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,v):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,v)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function S(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function T(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return h.prototype=d,n(R,"constructor",{value:d,configurable:!0}),n(d,"constructor",{value:h,configurable:!0}),h.displayName=u(d,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===h||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,u(e,s,"GeneratorFunction")),e.prototype=Object.create(R),e},e.awrap=function(e){return{__await:e}},_(E.prototype),u(E.prototype,a,function(){return this}),e.AsyncIterator=E,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new E(c(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})},_(R),u(R,s,"Generator"),u(R,i,function(){return this}),u(R,"toString",function(){return"[object Generator]"}),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=T,O.prototype={constructor:O,reset:function(e){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),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.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 s=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){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"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,v):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),S(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),v}},e}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var s=e[i](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,o)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){asyncGeneratorStep(i,n,o,a,s,"next",e)}function s(e){asyncGeneratorStep(i,n,o,a,s,"throw",e)}a(void 0)})}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}var serviceMap=new Map,getSdkInstanceId=function(e){return(null==e?void 0:e.uuid)||e},getReservationErrorMessage=function(e){var t,r,n,o,i,a=null==e||null===(t=e.raw)||void 0===t||null===(r=t.data)||void 0===r||null===(n=r.ResponseMetadata)||void 0===n?void 0:n.Error;return(null==e?void 0:e.message)||(null==a?void 0:a.Message)||(null==a?void 0:a.Code)||(null==e||null===(o=e.result)||void 0===o?void 0:o.Message)||(null==e||null===(i=e.result)||void 0===i?void 0:i.message)||""},getContextFromSdk=function(e){return e&&"object"===_typeof(e)?{store:e.store,request:e.requestStrict||e.request,reportTea:e.reportTea,emitEvent:e.emitEvent,getDeviceId:function(){return e.deviceId}}:{}},ReservationService=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_classCallCheck(this,e),this.updateContext(t)}var t,r,n,o;return _createClass(e,[{key:"updateContext",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.store,r=e.request,n=e.reportTea,o=e.emitEvent,i=e.getDeviceId;t&&(this.store=t),r&&(this.request=r),n&&(this.reportTea=n),o&&(this.emitEvent=o),i&&(this.getDeviceId=i)}},{key:"isReady",value:function(){return!!(this.store&&this.request&&this.reportTea&&this.emitEvent)}},{key:"init",value:function(e){var t,r;if(this.isReady()){var n=(e||{}).Basic;if(n){var o=1===n.IsReservationEnable,i=null!==(t=n.IsReservationSmsEnable)&&void 0!==t?t:0,a=null!==(r=n.AutoReservationWindowEnable)&&void 0!==r?r:0;this.store.set("reservation.isReservationEnable",o),this.store.set("reservation.isReservationSmsEnable",i),this.store.set("reservation.autoReservationWindowEnable",a),o||this.store.set("reservation.isReserved",!1),o&&n.Status===_constant.LIVE_STATUS.预告&&this.getReservationStatus()}}}},{key:"getReservationStatus",value:(o=_asyncToGenerator(_regeneratorRuntime().mark(function e(){var t,r,n,o,i,a,s,u=this;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isReady()){e.next=2;break}return e.abrupt("return",!1);case 2:if(t=this.store.get("liveInfo")||{},r=t.ActivityId,n=t.Basic,o=this.store.get("userInfo")||{},i=function(){return u.store.set("reservation.isReserved",!1),u.store.set("reservation.statusLoaded",!0),!1},1===(null==n?void 0:n.IsReservationEnable)&&(null==n?void 0:n.Status)===_constant.LIVE_STATUS.预告&&o.userId){e.next=9;break}return e.abrupt("return",i());case 9:return e.next=11,this.request(_constant.REQUEST_URL_MAP.RESERVATION_STATUS_GET,{method:"GET",data:{ActivityId:r}}).catch(function(e){console.log("getReservationStatus error",e)});case 11:if(a=e.sent){e.next=14;break}return e.abrupt("return",i());case 14:return s=(null==a?void 0:a.IsReserved)||!1,this.store.set("reservation.isReserved",s),this.store.set("reservation.statusLoaded",!0),e.abrupt("return",s);case 18:case"end":return e.stop()}},e,this)})),function(){return o.apply(this,arguments)})},{key:"submitReservationLogin",value:(n=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r,n,o,i,a,s,u;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isReady()){e.next=2;break}return e.abrupt("return");case 2:return r=this.store.get("liveInfo")||{},n=this.store.get("userInfo")||{},o=r.ActivityId,i={ActivityId:o,ReservationType:1,RegisterType:Number(n.typeRegister||0)},a=!1,e.next=9,this.request(_constant.REQUEST_URL_MAP.RESERVATION_LOGIN,{method:"GET",data:i}).catch(function(e){var t=getReservationErrorMessage(e);"请勿重复预约"===t||t===_constant.MESSAGE_ERROR.REPEAT_RESERVATION?a=!0:wx.showToast({title:"预约失败,请重试",icon:"none"})});case 9:((s=e.sent)&&s.Validity||a)&&(a?wx.showToast({title:"已预约过此直播间",icon:"none"}):(wx.showToast({title:"预约成功",icon:"success"}),this.store.set("reservation.isReserved",!0),this.emitEvent(_events.default.PUBLIC.reservation.attend,{tel:""})),this.reportTea("appointment_success",{isRepeat:a,uid:null===(u=this.getDeviceId)||void 0===u?void 0:u.call(this),aid:o}),t&&t(!0));case 11:case"end":return e.stop()}},e,this)})),function(e){return n.apply(this,arguments)})},{key:"sendVerifyCode",value:(r=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r,n,o,i=this;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isReady()){e.next=2;break}return e.abrupt("return");case 2:return r=this.store.get("liveInfo")||{},n=r.ActivityId,e.next=6,this.request(_constant.REQUEST_URL_MAP.VERIFY_CODE_SEND,{method:"GET",data:{ActivityId:n,Tel:t}}).catch(function(e){var t=getReservationErrorMessage(e);return t===_constant.MESSAGE_ERROR.NOTIFY_TOO_FREQUENCY?{error:"发送验证码太频繁"}:(i.reportTea("captcha_send_fail",{error:t,evModule:"RESERVATION"}),{error:"请求失败,请重试"})});case 6:return o=e.sent,e.abrupt("return",o);case 8:case"end":return e.stop()}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"submitSmsReservation",value:(t=_asyncToGenerator(_regeneratorRuntime().mark(function e(t,r){var n,o,i,a,s,u,c;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(this.isReady()){e.next=2;break}return e.abrupt("return",{success:!1,errMsg:"请求失败,请重试"});case 2:return n=this.store.get("liveInfo")||{},o=this.store.get("userInfo")||{},i=n.ActivityId,a={ActivityId:i,Tel:t.tel,VerifyCode:t.verifyCode,ReservationType:1,RegisterType:Number(o.typeRegister||0)},s=!1,e.next=9,this.request(_constant.REQUEST_URL_MAP.VERIFY_CODE_CHECK,{method:"GET",data:a}).catch(function(e){var t=getReservationErrorMessage(e);return t===_constant.MESSAGE_ERROR.NOTIFY_TOO_FREQUENCY?{error:"发送验证码太频繁"}:t===_constant.MESSAGE_ERROR.VERIFICATION_CODE_ERROR?{error:"验证码错误,请重新输入"}:t===_constant.MESSAGE_ERROR.VERIFICATION_CODE_EXPIRATION?{error:"验证码超时,请重新获取"}:t===_constant.MESSAGE_ERROR.REPEAT_RESERVATION?(s=!0,{}):t===_constant.MESSAGE_ERROR.WHITE_LIST_PHONE?{error:"请输入白名单内手机号"}:{error:"请求失败,请重试"}});case 9:if(null==(u=e.sent)||!u.error){e.next=12;break}return e.abrupt("return",{success:!1,errMsg:u.error});case 12:if(!(u&&u.Validity||s)){e.next=17;break}return s?wx.showToast({title:"该手机号预约过此直播间",icon:"none"}):(wx.showToast({title:"预约成功",icon:"success"}),this.store.set("reservation.isReserved",!0),this.emitEvent(_events.default.PUBLIC.reservation.attend,{tel:t.tel})),this.reportTea("appointment_success",{isRepeat:s,uid:null===(c=this.getDeviceId)||void 0===c?void 0:c.call(this),aid:i,evModule:"RESERVATION"}),r&&r(!0),e.abrupt("return",{success:!0});case 17:return e.abrupt("return",{success:!1,errMsg:"请求失败,请重试"});case 18:case"end":return e.stop()}},e,this)})),function(e,r){return t.apply(this,arguments)})},{key:"showReservationModal",value:function(){var e;this.isReady()&&(null!==(e=(this.store.get("mainInfo")||{}).options)&&void 0!==e&&e.disableReservationCell||(this.store.set("reservation.modalVisible",!0),this.reportTea("appointment_click",{evModule:"RESERVATION"})))}},{key:"hideReservationModal",value:function(){this.isReady()&&this.store.set("reservation.modalVisible",!1)}}]),e}(),getReservationService=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=getSdkInstanceId(e);if(!r)return null;var n=_objectSpread(_objectSpread({},getContextFromSdk(e)),t),o=serviceMap.get(r);return o?(o.updateContext(n),o):(o=new ReservationService(n),serviceMap.set(r,o),o)};exports.getReservationService=getReservationService;var initReservationModule=function(e,t){var r=getReservationService(e);return null==r||r.init(t),r};exports.initReservationModule=initReservationModule;var destroyReservationService=function(e){var t=getSdkInstanceId(e);t&&serviceMap.delete(t)};exports.destroyReservationService=destroyReservationService;var _default=ReservationService;exports.default=_default;