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

1 line
16 KiB
JavaScript

"use strict";var _utils=require("../../../utils/utils"),_util=require("../util"),_constant=require("../../../utils/constant"),_socket=require("../../../utils/socket"),_theme=require("../../../utils/theme");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)}function _createForOfIteratorHelper(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=_unsupportedIterableToArray(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw o}}}}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}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},i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function c(t,e,r,i){var o=e&&e.prototype instanceof h?e:h,a=Object.create(o.prototype),u=new x(i||[]);return n(a,"_invoke",{value:w(t,r,u)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f={};function h(){}function p(){}function d(){}var y={};s(y,o,function(){return this});var v=Object.getPrototypeOf,m=v&&v(v(D([])));m&&m!==e&&r.call(m,o)&&(y=m);var g=d.prototype=h.prototype=Object.create(y);function b(t){["next","throw","return"].forEach(function(e){s(t,e,function(t){return this._invoke(e,t)})})}function _(t,e){function i(n,o,a,u){var s=l(t[n],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==_typeof(f)&&r.call(f,"__await")?e.resolve(f.__await).then(function(t){i("next",t,a,u)},function(t){i("throw",t,a,u)}):e.resolve(f).then(function(t){c.value=t,a(c)},function(t){return i("throw",t,a,u)})}u(s.arg)}var o;n(this,"_invoke",{value:function(t,r){function n(){return new e(function(e,n){i(t,r,e,n)})}return o=o?o.then(n,n):n()}})}function w(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var u=S(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 s=l(t,e,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}function S(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,S(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=l(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,f;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function D(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=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 i.next=i}}return{next:Q}}function Q(){return{value:void 0,done:!0}}return p.prototype=d,n(g,"constructor",{value:d,configurable:!0}),n(d,"constructor",{value:p,configurable:!0}),p.displayName=s(d,u,"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,s(t,u,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},b(_.prototype),s(_.prototype,a,function(){return this}),t.AsyncIterator=_,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new _(c(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then(function(t){return t.done?t.value:a.next()})},b(g),s(g,u,"Generator"),s(g,o,function(){return this}),s(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=D,x.prototype={constructor:x,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(T),!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 i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var u=r.call(o,"catchLoc"),s=r.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.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),T(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 i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:D(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function asyncGeneratorStep(t,e,r,n,i,o,a){try{var u=t[o](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,i)}function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(t){asyncGeneratorStep(o,n,i,a,u,"next",t)}function u(t){asyncGeneratorStep(o,n,i,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)}Component({options:{styleIsolation:"shared"},properties:{sdkInstance:{type:Object,value:null}},data:{visible:!1,loading:!1,data:null,isShowResult:!1,isDisableForm:!1,isSubmitting:!1,isSubmitted:!1,statusDisabled:!1,statusText:"",formValue:[],userStatusMap:{},isDownWarn:!1,useDarkTheme:!1},lifetimes:{detached:function(){"function"==typeof this.unsub&&this.unsub(),this.unsub=null}},observers:{sdkInstance:function(t){var e=this;if(t){this.store=t.store,this.sdkInstance=t;var r=this;t.on(_constant.EVENTS.INNER.socket.init,function(t){r.socket=t,r.bindSocketEvents()}),"function"==typeof this.unsub&&this.unsub(),this.unsub=null,this.unsub=this.store.get({QuizInfo:function(t){var n=t||{},i=n.visible,o=n.currentId;i&&o&&r.openQuestion(o),i||r.selectComponent("#quiz-drawer").hideFrame(),(0,_utils.setDataIfChanged)(e,{visible:!!i})},liveInfo:function(t){(0,_utils.setDataIfChanged)(e,{useDarkTheme:(0,_theme.isUseDarkTheme)(null==t?void 0:t.Basic)})}})}}},methods:{openQuizDrawer:function(){this.selectComponent("#quiz-drawer").showFrame()},closeQuizDrawer:function(){this.selectComponent("#quiz-drawer").hideFrame(),this.myCancel()},myCancel:function(){(this.store.get("QuizInfo")||{}).visible&&this.store.set("QuizInfo",{visible:!1,currentId:null})},valueChange:function(t){this.setData({formValue:"string"==typeof t.detail.value?[t.detail.value]:t.detail.value})},onCountDown:function(){this.setData({isDisableForm:!0,statusText:this.isLogin()?"答题已截止":"查看结果",isDownWarn:!0})},onCountDownWarn:function(){this.setData({isDownWarn:!0})},isLogin:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return 2===this.store.get("mainInfo").mode||(t&&this.triggerEvent("commentCheck"),!1)},setCurrentData:function(t){var e=t.QuizTitle,r=t.QuizResultType,n=t.QuizOptions,i=t.RightOptions,o=t.SubmitOptions,a=t.IsRight,u=t.QuizStatus,s=t.QuizAnalysis,c=t.SendTime,l=t.Deadline,f=t.QuizTitleType,h=!(null==i||!i.length),p=!(null==o||!o.length),d=p||p&&!h||h,y=!0,v="";switch(!0){case!this.isLogin():v=(0,_util.isEndStatus)(u)?"查看结果":"参与答题",y=!1;break;case h:v="继续观看直播",y=!1;break;case p:v="已提交";break;default:v="确认提交",y=!1}this.setData({data:{QuizTitle:(0,_utils.getBySplit)(e),QuizResultType:r,QuizOptions:null==n?void 0:n.map(function(t){return _objectSpread(_objectSpread({},t),{},{OptionName:(0,_utils.getBySplit)(t.OptionName)})}),RightOptions:(i||[]).join("、")||"-",SubmitOptions:null!=o&&o.length?"".concat((o||[]).join("、")," (").concat(a?"回答正确":"回答错误",")"):"未作答",IsRight:a,QuizStatus:u,QuizAnalysis:s,Deadline:l,QuizTitleType:f,SendTime:c},formValue:o||[],isShowResult:h,isDisableForm:d,isSubmitted:p,statusText:v,statusDisabled:y})},openQuestion:function(t){var e=this;return _asyncToGenerator(_regeneratorRuntime().mark(function r(){var n,i,o,a,u,s;return _regeneratorRuntime().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(e.setData({isDownWarn:!1}),n=e.store.get("imageTextInfo")||{},i=n.imageText,o=null,null==i||i.forEach(function(e){null==e||e.Context.forEach(function(e){var r;e.ImageTextType===_constant.ImageTextTypes.QUESTION&&(null===(r=e.QuizContext)||void 0===r?void 0:r.QuizID)===t&&(o=e.QuizContext)})}),o){r.next=7;break}return e.sdkInstance.reportLogger("mini_sdk_quiz_no_current_data",{imageText:i,QuizID:t}),r.abrupt("return");case 7:if(e.setCurrentData(o),setTimeout(function(){e.openQuizDrawer()},500),e.isLogin()){r.next=12;break}return e.sdkInstance.reportLogger("mini_sdk_quiz_no_login",{QuizID:t}),r.abrupt("return");case 12:return a=e.store.get("mainInfo"),u=a.activityId,e.setData({loading:!0}),r.next=16,e.sdkInstance.request(_constant.REQUEST_URL_MAP.GET_QUIZ_RESULT,{method:"GET",data:{ActivityID:u,QuizID:t}});case 16:if(s=r.sent,e.setData({loading:!1}),s&&s.Status){r.next=21;break}return e.sdkInstance.reportLogger("mini_sdk_quiz_get_result_fail",{ActivityID:u,QuizID:t}),r.abrupt("return");case 21:e.setCurrentData(_objectSpread(_objectSpread({},o),s));case 22:case"end":return r.stop()}},r)}))()},formSubmit:function(){var t=this;return _asyncToGenerator(_regeneratorRuntime().mark(function e(){var r,n,i,o,a,u,s;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t.isLogin(!0)){e.next=2;break}return e.abrupt("return");case 2:if(!t.data.isShowResult){e.next=5;break}return t.closeQuizDrawer(),e.abrupt("return");case 5:if(null!=(r=[].concat(t.data.formValue).filter(Boolean))&&r.length){e.next=9;break}return wx.showToast({title:"请选择您的选项",icon:"none"}),e.abrupt("return");case 9:return t.setData({isSubmitting:!0}),n=t.store.get("mainInfo"),i=n.activityId,o=t.store.get("QuizInfo"),a=o.currentId,e.next=14,t.sdkInstance.request(_constant.REQUEST_URL_MAP.QUIZ_SUBMIT,{method:"POST",data:{ActivityID:i,QuizID:a,SubmitOptions:r}});case 14:if(u=e.sent,t.setData({isSubmitting:!1}),u&&u.Status){e.next=20;break}return wx.showToast({title:"提交失败",icon:"none"}),t.sdkInstance.reportLogger("mini_sdk_quiz_join_error",{ActivityID:i,QuizID:a,SubmitOptions:r}),e.abrupt("return");case 20:t.sdkInstance.reportLogger("mini_sdk_quiz_join_success",{ActivityID:i,QuizID:a,SubmitOptions:r}),t.setCurrentData(_objectSpread(_objectSpread({},t.data.data),u)),(s=t.data.userStatusMap).QuizID=_util.QuizUserStatus.SUBMITTED,t.setData({userStatusMap:s}),u.QuizResultType!==_util.IQuizResultType.SUBMIT&&(wx.showToast({title:"请等待公布答案",icon:"none"}),setTimeout(function(){t.closeQuizDrawer()},300));case 26:case"end":return e.stop()}},e)}))()},bindSocketEvents:function(){var t,e=this;null===(t=this.socket)||void 0===t||t.on(_socket.WsMethod.imageTextQuizUpdate,function(t){e.sdkInstance.reportLogger("mini_sdk_quiz_update",{data:t});var r=t.QuizID,n=t.QuizStatus;n>0&&e.updateOneQuestion(t);var i,o=e.store.get("imageTextInfo")||{},a=o.imageText,u=void 0===a?[]:a,s=_createForOfIteratorHelper(u);try{for(s.s();!(i=s.n()).done;){var c,l=_createForOfIteratorHelper(i.value.Context);try{for(l.s();!(c=l.n()).done;){var f=c.value;if((null==f?void 0:f.ImageTextType)===_constant.ImageTextTypes.QUESTION){var h=f.QuizContext;if(h&&h.QuizID===r)return n>0&&(h.QuizStatus=n),void e.store.set("imageTextInfo",_objectSpread(_objectSpread({},o),{},{imageText:u}))}}}catch(t){l.e(t)}finally{l.f()}}}catch(t){s.e(t)}finally{s.f()}})},updateOneQuestion:function(t){var e=this;if(this.isLogin()){var r=t.QuizID,n=t.QuizStatus,i=t.QuizResultType,o=_util.IQuizResultType.SUBMIT===i,a=this.data.userStatusMap.QuizID===_util.QuizUserStatus.SUBMITTED;!(0,_util.isEndStatus)(n)||o&&a||setTimeout(function(){var t=e.store.get("QuizInfo")||{},n=t.visible,i=t.currentId;(n&&i===r||!n)&&e.openQuestion(r)},5e3)}}}});