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

1 line
13 KiB
JavaScript

"use strict";var _contants=require("./contants"),_index=_interopRequireDefault(require("./logic/index"));function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}function _regeneratorRuntime(){_regeneratorRuntime=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,n){return t[e]=n}}function s(t,e,n,o){var i=e&&e.prototype instanceof h?e:h,a=Object.create(i.prototype),c=new P(o||[]);return r(a,"_invoke",{value:b(t,n,c)}),a}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=s;var f={};function h(){}function p(){}function d(){}var y={};u(y,i,function(){return this});var v=Object.getPrototypeOf,g=v&&v(v(j([])));g&&g!==e&&n.call(g,i)&&(y=g);var m=d.prototype=h.prototype=Object.create(y);function w(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function _(t,e){function o(r,i,a,c){var u=l(t[r],t,i);if("throw"!==u.type){var s=u.arg,f=s.value;return f&&"object"==_typeof(f)&&n.call(f,"__await")?e.resolve(f.__await).then(function(t){o("next",t,a,c)},function(t){o("throw",t,a,c)}):e.resolve(f).then(function(t){s.value=t,a(s)},function(t){return o("throw",t,a,c)})}c(u.arg)}var i;r(this,"_invoke",{value:function(t,n){function r(){return new e(function(e,r){o(t,n,e,r)})}return i=i?i.then(r,r):r()}})}function b(t,e,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return{value:void 0,done:!0}}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=L(a,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=l(t,e,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===f)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function L(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,L(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var o=l(r,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 x(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 P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function j(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 r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return p.prototype=d,r(m,"constructor",{value:d,configurable:!0}),r(d,"constructor",{value:p,configurable:!0}),p.displayName=u(d,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===p||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(_.prototype),u(_.prototype,a,function(){return this}),t.AsyncIterator=_,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new _(s(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then(function(t){return t.done?t.value:a.next()})},w(m),u(m,c,"Generator"),u(m,i,function(){return this}),u(m,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=j,P.prototype={constructor:P,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)&&n.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 r(n,r){return a.type="throw",a.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,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 n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;S(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:j(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}function asyncGeneratorStep(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function _asyncToGenerator(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){asyncGeneratorStep(i,r,o,a,c,"next",t)}function c(t){asyncGeneratorStep(i,r,o,a,c,"throw",t)}a(void 0)})}}function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,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 n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!==_typeof(r))return r;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 defaultConnectLivePlayerAttrs={"object-fit":"fillCrop","picture-in-picture-mode":[]};Component({properties:{sdkInstance:{type:Object,value:null},isPortrait:{type:Boolean,value:!0}},data:{connectStatus:_contants.ConnectStatus.Init,renderList:[],hasVideo:!1,hasAudio:!1,connectLivePlayerAttrs:defaultConnectLivePlayerAttrs},observers:{sdkInstance:function(t){var e=this;if(t){this.sdkInstance=t,this.store=t.store;var n=this;this.connectLogic=new _index.default(this,this.handleStateChange.bind(this)),"function"==typeof this._unsub&&this._unsub(),this._unsub=null,this._unsub=this.store.get({mainInfo:function(t){e.syncConnectLivePlayerAttrs(t),null!=t&&t.autoConnect&&n.showPanel()}})}},connectStatus:function(t){var e=t!==_contants.ConnectStatus.Connecting;this.triggerEvent("changePlayerStatus",e)}},lifetimes:{detached:function(){"function"==typeof this._unsub&&this._unsub(),this._unsub=null,this.connectLogic&&this.connectLogic.leaveConnect()}},methods:{syncConnectLivePlayerAttrs:function(t){var e=(((null==t?void 0:t.options)||{}).mediaComponentsAttr||{}).connectLivePlayer,n=e&&"object"===_typeof(e)?_objectSpread({},e):null;n&&delete n.muted;var r=_objectSpread(_objectSpread({},defaultConnectLivePlayerAttrs),n||{});this.setData({connectLivePlayerAttrs:r})},handleStateChange:function(t,e){this.setData(_defineProperty({},t,e))},showPanel:function(){2!==this.store.get("mainInfo").mode&&(console.log("未完成注册,无法初始化连麦"),this.triggerEvent("commentCheck")),this.selectComponent("#volc-connect-drawer").showFrame()},applyConnect:function(t){var e=this;return _asyncToGenerator(_regeneratorRuntime().mark(function n(){var r,o,i,a,c;return _regeneratorRuntime().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(e.store.get("userInfo.userId")){n.next=5;break}return console.log("未完成注册,无法初始化连麦"),e.triggerEvent("commentCheck"),n.abrupt("return");case 5:if(r=t.currentTarget.dataset.type,o=!1,"audio"!==r){n.next=13;break}return n.next=10,e.authorize("record");case 10:i=n.sent,o=i,e.setData({hasVideo:!1,hasAudio:i});case 13:if("video"!==r){n.next=22;break}return n.next=16,e.authorize("camera");case 16:return a=n.sent,n.next=19,e.authorize("record");case 19:c=n.sent,o=a&&c,e.setData({hasAudio:c,hasVideo:a});case 22:o?(e.connectLogic.updateApplyConnectStatus(_contants.ApplyStatus.Apply),setTimeout(function(){e.selectComponent("#volc-connect-drawer").hideFrame()},5e3)):wx.showToast({title:"授权未通过,开启连麦失败",icon:"none"}),e.sdkInstance.reportLogger("mini_sdk_connect_apply",{type:r,isComplete:o});case 24:case"end":return n.stop()}},n)}))()},authorize:function(t){return new Promise(function(e){wx.getSetting({success:function(n){n.authSetting["scope.".concat(t)]?e(!0):wx.authorize({scope:"scope.".concat(t),success:function(){e(!0)},fail:function(){wx.showModal({content:"检测到您没打开此小程序的麦克风和摄像头权限,是否去设置打开?",confirmText:"确认",cancelText:"取消",success:function(t){t.confirm?(wx.openSetting(),e(!1)):e(!1)}})}})},fail:function(){e(!1)}})})},cancelApply:function(){this.connectLogic.updateApplyConnectStatus(_contants.ApplyStatus.Cancel),this.sdkInstance.reportLogger("mini_sdk_connect_cancel_apply",{})},switchCamera:function(){var t,e=null===(t=this.selectComponent("#connect-layout"))||void 0===t?void 0:t.selectComponent("#v-pusher");this.sdkInstance.reportLogger("mini_sdk_connect_switchCamera",{hasPusher:Boolean(e)}),e&&e.switchCamera()},changeAudioStatus:function(){var t=this.data.hasAudio;this.setData({hasAudio:!t}),this.connectLogic.updateMediaStatus(),this.sdkInstance.reportLogger("mini_sdk_connect_changeAudio",{hasAudio:!t})},changeVideoStatus:function(){var t=this.data.hasVideo;this.setData({hasVideo:!t}),this.connectLogic.updateMediaStatus(),this.sdkInstance.reportLogger("mini_sdk_connect_changeVideo",{hasVideo:!t})},hangUpConnect:function(){var t=this;wx.showModal({title:"确认退出观众连麦吗",content:"当前正在连麦中,关闭直播连麦将退出当前连麦",success:function(e){e.confirm?(t.connectLogic.leaveConnect(),t.selectComponent("#volc-connect-drawer").hideFrame(),t.sdkInstance.reportLogger("mini_sdk_connect_hangup",{}),console.log("用户断开连麦"),t.triggerEvent("hangUpConnect")):e.cancel&&console.log("用户点击取消")}})}}});