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

1 line
15 KiB
JavaScript

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.submitQuestionnaire=exports.getQuestionnaire=exports.checkQuestionnaire=exports.QUESTIONNAIRE_ERROR_CODE=void 0;var _request=_interopRequireDefault(require("../utils/request")),_constant=require("../utils/constant"),_excluded=["sdkInstance","token","sdkUserOptions","QuestionnaireId","questionnaireId","extraData"],_excluded2=["sdkInstance","token","sdkUserOptions","QuestionnaireId","questionnaireId","extraData"];function _interopRequireDefault(e){return e&&e.__esModule?e:{default: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)}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",u=o.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function s(e,t,r,o){var i=t&&t.prototype instanceof p?t:p,a=Object.create(i.prototype),u=new w(o||[]);return n(a,"_invoke",{value:O(e,r,u)}),a}function l(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var d={};function p(){}function f(){}function h(){}var v={};c(v,i,function(){return this});var y=Object.getPrototypeOf,_=y&&y(y(k([])));_&&_!==t&&r.call(_,i)&&(v=_);var m=h.prototype=p.prototype=Object.create(v);function g(e){["next","throw","return"].forEach(function(t){c(e,t,function(e){return this._invoke(t,e)})})}function b(e,t){function o(n,i,a,u){var c=l(e[n],e,i);if("throw"!==c.type){var s=c.arg,d=s.value;return d&&"object"==_typeof(d)&&r.call(d,"__await")?t.resolve(d.__await).then(function(e){o("next",e,a,u)},function(e){o("throw",e,a,u)}):t.resolve(d).then(function(e){s.value=e,a(s)},function(e){return o("throw",e,a,u)})}u(c.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 O(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 u=E(a,r);if(u){if(u===d)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=l(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(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,E(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var o=l(n,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,d;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,d):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function S(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 I(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function w(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function k(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:j}}function j(){return{value:void 0,done:!0}}return f.prototype=h,n(m,"constructor",{value:h,configurable:!0}),n(h,"constructor",{value:f,configurable:!0}),f.displayName=c(h,u,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,c(e,u,"GeneratorFunction")),e.prototype=Object.create(m),e},e.awrap=function(e){return{__await:e}},g(b.prototype),c(b.prototype,a,function(){return this}),e.AsyncIterator=b,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new b(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then(function(e){return e.done?e.value:a.next()})},g(m),c(m,u,"Generator"),c(m,i,function(){return this}),c(m,"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=k,w.prototype={constructor:w,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(I),!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 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(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,d):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),d},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),I(r),d}},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;I(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:k(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,o=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var u=e[i](a),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).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,u,"next",e)}function u(e){asyncGeneratorStep(i,n,o,a,u,"throw",e)}a(void 0)})}}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 _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)}var QUESTIONNAIRE_ERROR_CODE={NEED_LOGIN:"QUESTIONNAIRE_NEED_LOGIN",SUBMIT_ERROR:"QUESTIONNAIRE_SUBMIT_ERROR"};exports.QUESTIONNAIRE_ERROR_CODE=QUESTIONNAIRE_ERROR_CODE;var requestWithSdk=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{})||{},i=o.token,a=o.sdkUserOptions;return e&&"function"==typeof e.requestStrict?e.requestStrict(t,n):e&&"function"==typeof e.request?e.request(t,n):(0,_request.default)(t,_objectSpread(_objectSpread({},n),{},{header:_objectSpread(_objectSpread({},null!==(r=n.header)&&void 0!==r?r:{}),i?{jwttoken:i}:{}),sdkUserOptions:_objectSpread(_objectSpread({},a||{}),n.sdkUserOptions||{})}))},normalizeMode=function(e){if(null!=e){var t=Number(e);return Number.isNaN(t)?void 0:t}},getNicknameFromSdkStore=function(e){var t=null==e?void 0:e.store;return t&&"function"==typeof t.get&&(t.get("userInfo")||{}).username||""},checkGuestSubmitGating=function(e){var t,r=e.sdkInstance,n=e.mode,o=e.debugInfo,i=normalizeMode(n);if(!i&&r&&r.store&&"function"==typeof r.store.get&&(i=normalizeMode(r.store.get("mainInfo.mode"))),2===i)return null;var a={success:!1,code:QUESTIONNAIRE_ERROR_CODE.NEED_LOGIN,message:"当前为游客模式,请登录后再提交问卷",needLogin:!0,mode:i};return null==r||null===(t=r.reportTea)||void 0===t||t.call(r,"mini_sdk_questionnaire_submit_fail",_objectSpread(_objectSpread({},o),{},{reason:"guest_mode",error:a})),a},getQuestionnaire=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r,n,o,i,a,u,c,s,l,d,p,f,h,v,y,_,m=arguments;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return o=(n=(m.length>1&&void 0!==m[1]?m[1]:{})||{}).sdkInstance,i=n.token,a=n.sdkUserOptions,u=n.QuestionnaireId,c=n.questionnaireId,s=n.extraData,l=_objectWithoutProperties(n,_excluded),d=t||l.ActivityId||l.activityId,p=_objectSpread({ActivityId:d},s),null!=(f=null!=u?u:c)&&(p.QuestionnaireId=f),h={ActivityId:d,QuestionnaireId:f},null==o||null===(r=o.reportTea)||void 0===r||r.call(o,"mini_sdk_questionnaire_get_start",h),e.prev=8,e.next=11,requestWithSdk(o,_constant.REQUEST_URL_MAP.QUESTIONNAIRE_GET,{method:"GET",data:p},{token:i,sdkUserOptions:a});case 11:return y=e.sent,null==o||null===(v=o.reportTea)||void 0===v||v.call(o,"mini_sdk_questionnaire_get_success",_objectSpread(_objectSpread({},h),{},{response:y})),e.abrupt("return",y);case 16:throw e.prev=16,e.t0=e.catch(8),null==o||null===(_=o.reportTea)||void 0===_||_.call(o,"mini_sdk_questionnaire_get_fail",_objectSpread(_objectSpread({},h),{},{error:e.t0})),e.t0;case 20:case"end":return e.stop()}},e,null,[[8,16]])}));return function(t){return e.apply(this,arguments)}}();exports.getQuestionnaire=getQuestionnaire;var checkQuestionnaire=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r,n,o,i,a,u,c,s,l,d,p,f,h,v,y,_,m=arguments;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return o=(n=(m.length>1&&void 0!==m[1]?m[1]:{})||{}).sdkInstance,i=n.token,a=n.sdkUserOptions,u=n.QuestionnaireId,c=n.questionnaireId,s=n.extraData,l=_objectWithoutProperties(n,_excluded2),d=t||l.ActivityId||l.activityId,p=_objectSpread({ActivityId:d},s),null!=(f=null!=u?u:c)&&(p.QuestionnaireId=f),h={ActivityId:d,QuestionnaireId:f},null==o||null===(r=o.reportTea)||void 0===r||r.call(o,"mini_sdk_questionnaire_check_start",h),e.prev=8,e.next=11,requestWithSdk(o,_constant.REQUEST_URL_MAP.QUESTIONNAIRE_CHECK,{method:"GET",data:p},{token:i,sdkUserOptions:a});case 11:return y=e.sent,null==o||null===(v=o.reportTea)||void 0===v||v.call(o,"mini_sdk_questionnaire_check_success",_objectSpread(_objectSpread({},h),{},{response:y})),e.abrupt("return",y);case 16:throw e.prev=16,e.t0=e.catch(8),null==o||null===(_=o.reportTea)||void 0===_||_.call(o,"mini_sdk_questionnaire_check_fail",_objectSpread(_objectSpread({},h),{},{error:e.t0})),e.t0;case 20:case"end":return e.stop()}},e,null,[[8,16]])}));return function(t){return e.apply(this,arguments)}}();exports.checkQuestionnaire=checkQuestionnaire;var submitQuestionnaire=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark(function e(t){var r,n,o,i,a,u,c,s,l,d,p,f,h,v,y,_,m,g,b,O,E,S,I,w,k,j,R,x,N,T,Q,P,L;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(s=(c=t||{}).sdkInstance,l=c.token,d=c.sdkUserOptions,p=c.mode,f=c.ActivityId,h=c.activityId,v=c.trigger,y=c.QuestionnaireAnswer,_=c.questionnaireId,m=c.questionAnswers,g=c.Extra,b=c.Nickname,O=c.Source,E=c.Ch,S=c.RegisterType,I=f||h||(s&&s.store&&"function"==typeof s.store.get?s.store.get("liveInfo.ActivityId"):void 0),w=null!==(r=null!==(n=null==y?void 0:y.QuestionnaireId)&&void 0!==n?n:null==t?void 0:t.QuestionnaireId)&&void 0!==r?r:_,k=null!==(o=null!==(i=null==y?void 0:y.QuestionAnswers)&&void 0!==i?i:null==t?void 0:t.QuestionAnswers)&&void 0!==o?o:m,j={ActivityId:I,QuestionnaireId:w},null==s||null===(a=s.reportTea)||void 0===a||a.call(s,"mini_sdk_questionnaire_submit_start",j),!(R=checkGuestSubmitGating({sdkInstance:s,mode:p,debugInfo:j}))){e.next=9;break}return e.abrupt("return",R);case 9:return x=getNicknameFromSdkStore(s),N=_objectSpread(_objectSpread({ActivityId:I},v?{trigger:v}:{}),{},{QuestionnaireAnswer:{QuestionnaireId:w,QuestionAnswers:k||[]},Nickname:null!==(u=null!=b?b:x)&&void 0!==u?u:"",Source:null!=O?O:0,Extra:null!=g?g:"",Ch:null!=E?E:"",RegisterType:null!=S?S:9}),e.prev=11,e.next=14,requestWithSdk(s,_constant.REQUEST_URL_MAP.QUESTIONNAIRE_SUBMIT,{method:"POST",data:N},{token:l,sdkUserOptions:d});case 14:return Q=e.sent,null==s||null===(T=s.reportTea)||void 0===T||T.call(s,"mini_sdk_questionnaire_submit_success",_objectSpread(_objectSpread({},j),{},{response:Q})),e.abrupt("return",Q);case 19:return e.prev=19,e.t0=e.catch(11),L={success:!1,code:QUESTIONNAIRE_ERROR_CODE.SUBMIT_ERROR,message:"问卷提交失败,请稍后重试",error:e.t0},null==s||null===(P=s.reportTea)||void 0===P||P.call(s,"mini_sdk_questionnaire_submit_fail",_objectSpread(_objectSpread({},j),{},{reason:"request_error",error:e.t0})),e.abrupt("return",L);case 24:case"end":return e.stop()}},e,null,[[11,19]])}));return function(t){return e.apply(this,arguments)}}();exports.submitQuestionnaire=submitQuestionnaire;