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

1 line
26 KiB
JavaScript

"use strict";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 _utils=require("../../../utils/utils"),_constant=require("../../../utils/constant"),_socket=require("../../../utils/socket"),_util=require("../util"),_theme=require("../../../utils/theme"),_utils2=require("./utils");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,a=function(){};return{s:a,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:a}}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,i=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){s=!0,o=t},f:function(){try{i||null==r.return||r.return()}finally{if(s)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 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 _regeneratorRuntime(){_regeneratorRuntime=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},o=a.iterator||"@@iterator",i=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,a){var o=e&&e.prototype instanceof f?e:f,i=Object.create(o.prototype),s=new A(a||[]);return n(i,"_invoke",{value:I(t,r,s)}),i}function c(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var d={};function f(){}function p(){}function y(){}var h={};u(h,o,function(){return this});var v=Object.getPrototypeOf,m=v&&v(v(b([])));m&&m!==e&&r.call(m,o)&&(h=m);var g=y.prototype=f.prototype=Object.create(h);function w(t){["next","throw","return"].forEach(function(e){u(t,e,function(t){return this._invoke(e,t)})})}function _(t,e){function a(n,o,i,s){var u=c(t[n],t,o);if("throw"!==u.type){var l=u.arg,d=l.value;return d&&"object"==_typeof(d)&&r.call(d,"__await")?e.resolve(d.__await).then(function(t){a("next",t,i,s)},function(t){a("throw",t,i,s)}):e.resolve(d).then(function(t){l.value=t,i(l)},function(t){return a("throw",t,i,s)})}s(u.arg)}var o;n(this,"_invoke",{value:function(t,r){function n(){return new e(function(e,n){a(t,r,e,n)})}return o=o?o.then(n,n):n()}})}function I(t,e,r){var n="suspendedStart";return function(a,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===a)throw o;return{value:void 0,done:!0}}for(r.method=a,r.arg=o;;){var i=r.delegate;if(i){var s=L(i,r);if(s){if(s===d)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=c(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function L(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,L(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),d;var a=c(n,t.iterator,e.arg);if("throw"===a.type)return e.method="throw",e.arg=a.arg,e.delegate=null,d;var o=a.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,d):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function T(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 A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function b(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,a=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 a.next=a}}return{next:E}}function E(){return{value:void 0,done:!0}}return p.prototype=y,n(g,"constructor",{value:y,configurable:!0}),n(y,"constructor",{value:p,configurable:!0}),p.displayName=u(y,s,"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,y):(t.__proto__=y,u(t,s,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},w(_.prototype),u(_.prototype,i,function(){return this}),t.AsyncIterator=_,t.async=function(e,r,n,a,o){void 0===o&&(o=Promise);var i=new _(l(e,r,n,a),o);return t.isGeneratorFunction(r)?i:i.next().then(function(t){return t.done?t.value:i.next()})},w(g),u(g,s,"Generator"),u(g,o,function(){return this}),u(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=b,A.prototype={constructor:A,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 i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],i=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)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 a=this.tryEntries[n];if(a.tryLoc<=this.prev&&r.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(i)},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),d},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),d}},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 a=n.arg;S(r)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:b(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},t}function asyncGeneratorStep(t,e,r,n,a,o,i){try{var s=t[o](i),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,a)}function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise(function(n,a){var o=t.apply(e,r);function i(t){asyncGeneratorStep(o,n,a,i,s,"next",t)}function s(t){asyncGeneratorStep(o,n,a,i,s,"throw",t)}i(void 0)})}}var teaEventMap={attend_lottery_success:_constant.EVENTS.PUBLIC.lottery.attend,lottery_result_modal:_constant.EVENTS.PUBLIC.lottery.result,lottery_win_info:_constant.EVENTS.PUBLIC.lottery.winInfo,open_lottery_modal:_constant.EVENTS.PUBLIC.lottery.click};Component({properties:{sdkInstance:{type:Object,value:null}},data:{visible:!1,type:"",data:null,useDarkTheme:!1,isDeadline:!1,undoLotteryMap:{},lotteryQueue:[],animationendAwardId:[],openResultAwardId:[],animationAwardId:0,status:0},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()});var n=1;"function"==typeof this.unsub&&this.unsub(),this.unsub=null,this.unsub=this.store.get({AwardInfo:function(t){var n=t||{},a=n.visible,o=n.currentId,i=n.isAuto;e.setData({visible:a}),i&&"detail"===e.data.type||(a&&o?r.openLottery(o):e.setData({type:""}))},liveInfo:function(t){e.setData({useDarkTheme:(0,_theme.isUseDarkTheme)(null==t?void 0:t.Basic)})},mainInfo:function(t){2===(t||{}).mode&&1===n&&r.setCheckedCheckIn()},userInfo:function(t){(t||{}).userId&&1===n&&r.setCheckedCheckIn()},imageTextInfo:function(t){((null==t?void 0:t.imageText)||[]).length&&1===n&&(n++,r.imageTextUpdateList())}})}}},methods:{createLotteryRequestId:function(){return this.lotteryRequestId=(this.lotteryRequestId||0)+1,this.lotteryRequestId},isLatestLotteryRequest:function(t,e){var r,n=(this.store.get("AwardInfo")||{}).visible,a=null===(r=this.data.data)||void 0===r?void 0:r.ID;return n&&a===e&&this.lotteryRequestId===t},setAwardInfo:function(t,e){var r=this.store.get("AwardInfo")||{},n=r.visible,a=r.currentId;n===t&&a===e||this.store.set("AwardInfo",{visible:t,currentId:e})},updateLotteryUserStatus:function(t){var e=(this.store.get("lotteriesUserStatus")||{}).lotteriesUserStatus,r=void 0===e?{}:e;(t||[]).forEach(function(t){if(r[t.lotteryId]){var e=r[t.lotteryId];[_util.LotteryStatus.WIN,_util.LotteryStatus.LOSE].includes(e)&&t.status!==_util.LotteryServerStatus.Delete||_util.LotteryStatus.ENROLLED===e&&_util.LotteryServerStatus.Ing===t.status||(e=(0,_util.getLotteryStatus)(t.status)),r[t.lotteryId]=e}else r[t.lotteryId]=(0,_util.getLotteryStatus)(t.status)}),this.store.set("lotteriesUserStatus",{lotteriesUserStatus:r})},updateLotteryUserStatusNoTrans:function(t,e){var r=(this.store.get("lotteriesUserStatus")||{}).lotteriesUserStatus,n=void 0===r?{}:r;n[t]=e,this.store.set("lotteriesUserStatus",{lotteriesUserStatus:n})},syncVisibleDetailOnLotteryStateChange:function(t,e){var r=this.store.get("AwardInfo")||{},n=r.visible,a=r.currentId;n&&a===t&&"detail"===this.data.type&&e!==_util.LotteryServerStatus.Ing&&this.setAwardInfo(!1,null)},updateOneLottery:function(t,e){var r=this,n=this.getCurrentLottery(t);if(n)if(n.Status!==e&&this.sdkInstance.reportLogger("lottery_status_change",{params:{awardId:t,oldStatus:n.Status,newStatus:e,evModule:"LOTTERY"}}),this.syncVisibleDetailOnLotteryStateChange(t,e),this.updateLotteryUserStatus([{lotteryId:t,status:e}]),n.Status!==_util.LotteryServerStatus.Opened&&e===_util.LotteryServerStatus.Opened)if(this.isLogin()){var a={ActivityID:this.store.get("mainInfo").activityId,AwardID:t};setTimeout(_asyncToGenerator(_regeneratorRuntime().mark(function e(){var n,o;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,r.sdkInstance.request(_constant.REQUEST_URL_MAP.GET_AWARD_RECORD_INFO,{method:"POST",data:a});case 3:return n=e.sent,e.next=6,r.stopAnimation(t);case 6:n.AwardResult!==_util.AwardResult.WIN&&n.AwardResult!==_util.AwardResult.LOSE||(r.updateLotteryUserStatusNoTrans(t,n.AwardResult===_util.AwardResult.WIN?_util.LotteryStatus.WIN:_util.LotteryStatus.LOSE),null!==(o=r.data.openResultAwardId)&&void 0!==o&&o.includes(t)?r.sdkInstance.reportLogger("lottery_openResultModalCancel_repeat",{params:{AwardID:t,openResultAwardId:openResultAwardId,evModule:"LOTTERY"}}):(r.data.openResultAwardId.push(t),r.data.visible?r.data.lotteryQueue.push(t):r.setAwardInfo(!0,t))),r.reportTea("lottery_result_modal",{awardId:t,LoginTel:user.userTel,ifWin:4===n.AwardResult,evModule:"LOTTERY"}),callBack(),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(0),r.stopAnimation(t);case 14:case"end":return e.stop()}},e,null,[[0,11]])})),5e3)}else this.stopAnimation(t);else if(n.Status!==_util.LotteryServerStatus.Opened&&n.Status!==_util.LotteryServerStatus.Opening&&e===_util.LotteryServerStatus.Opening){var o;if(null!==(o=this.data.animationendAwardId)&&void 0!==o&&o.includes(t))this.sdkInstance.reportLogger("lottery_animationCancel_repeat",{params:{AwardID:t,animationendAwardId:this.data.animationendAwardId,evModule:"LOTTERY"}});else{if(this.data.animationendAwardId.push(t),this.updateLotteryUserStatusNoTrans(t,_util.LotteryStatus.WAITING),"noAnimation"===n.AwardThemeUrl)return;setTimeout(function(){r.startAnimation(t)},5e3)}}else callBack()},startAnimation:function(t){var e=this,r=this.data.animationAwardId,n=this.getCurrentLottery(t);n?r||(this.setAwardInfo(!1,null),this.setData({animationAwardId:t,animationDowTime:(new Date).getTime(),AwardThemeUrl:n.AwardThemeUrl}),setTimeout(function(){e.data.animationAwardId===t&&(e.stopAnimation(t),e.sdkInstance.reportLogger("lottery_stopAnimation_manual",{params:{animationAwardId:r,evModule:"LOTTERY"}}))},1e4),this.sdkInstance.reportLogger("lottery_startAnimation_success",{params:_objectSpread(_objectSpread({},n),{},{evModule:"LOTTERY"})})):this.sdkInstance.reportLogger("lottery_startAnimation_failed",{params:{AwardID:t,evModule:"LOTTERY"}})},stopAnimation:function(t){var e=this;return _asyncToGenerator(_regeneratorRuntime().mark(function r(){var n,a,o,i;return _regeneratorRuntime().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(n=e.data,a=n.animationAwardId,o=n.animationDowTime,i=(new Date).getTime()-(o||0),!(a&&i<3e3)){r.next=5;break}return r.next=5,(0,_utils.waitNumSeconds)(3e3-i);case 5:e.setData({animationAwardId:0}),e.sdkInstance.reportLogger("lottery_stopAnimation_success",{params:{AwardID:t,animationAwardId:a,evModule:"LOTTERY"}});case 7:case"end":return r.stop()}},r)}))()},onCountDown:function(){this.setData({isDeadline:!0,errMsg:""})},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,e){try{var r=t.ID,n=this.data.undoLotteryMap[r],a=(this.store.get("lotteriesUserStatus")||{}).lotteriesUserStatus,o=e||(void 0===a?{}:a)[r]||(0,_util.getLotteryStatus)(t.Status),i=(0,_util.formatConditionDetails)(t.BarragePwd,t.AwardCondition,n,o===_util.LotteryStatus.ENROLLED),s=_objectSpread(_objectSpread(_objectSpread({},this.data.data),t),{},{formatDataList:i,hasCondition:!!i.length,showCountDown:t.AwardType===_util.AwardType.AutoOpen,UndoAwardCondition:n});s.status=o;var u=(0,_utils2.getDisplayAwardItemConfigs)(s,o),l=u[0]||{};s.displayAwardItemConfigs=u,s.displayAwardItemConfig=l,s.attendFailFlag=o===_util.LotteryStatus.OPEN&&!!n,s.attendedFlag=_util.AttendedStatus.includes(o),s.isTicket=l.AwardItemType===_util.AwardItemType.TICKET;var c=l.WinnerInfoType||s.WinnerInfoType||[];s.AwardLotteryTicketAddr=l.AwardLotteryTicketAddr||s.AwardLotteryTicketAddr,s.showReceiverName=null==c?void 0:c.includes(_util.EnumWinnerInfoType.ReceiverName),s.showAddress=c.includes(_util.EnumWinnerInfoType.Address),s.showMobile=c.includes(_util.EnumWinnerInfoType.Tel),s.showEmail=c.includes(_util.EnumWinnerInfoType.Email),s.showSubmit=s.showMobile||s.showAddress||s.showReceiverName||s.showEmail,s.ifAward=o===_util.LotteryStatus.WIN,s.fulfilled=!0,(s.showReceiverName&&!s.ReceiverName||s.showAddress&&!s.AwardAddress||s.showMobile&&!s.AwardTel||s.showEmail&&!s.AwardEmail)&&(s.fulfilled=!1),this.setData({data:s,status:s.status})}catch(t){console.error(t)}},getCurrentLottery:function(t){var e=(this.store.get("imageTextInfo")||{}).imageText,r=null;return null==e||e.forEach(function(e){null==e||e.Context.forEach(function(e){var n;e.ImageTextType!==_constant.ImageTextTypes.LOTTERY||(null===(n=e.AwardContext)||void 0===n?void 0:n.ID)!==t||(r=e.AwardContext)})}),r},openLottery:function(t){var e=this;return _asyncToGenerator(_regeneratorRuntime().mark(function r(){var n,a,o;return _regeneratorRuntime().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(n=e.store.get("imageTextInfo")||{},a=n.imageText,o=e.getCurrentLottery(t)){r.next=6;break}return e.sdkInstance.reportLogger("mini_sdk_lottery_no_current_data",{imageText:a,lotteryId:t}),e.setAwardInfo(!1,null),r.abrupt("return");case 6:if(e.setCurrentData(o),e.reportTea("open_lottery_modal",{awardId:t}),![_util.LotteryServerStatus.BeforeOpen,_util.LotteryServerStatus.Opening].includes(o.Status)){r.next=11;break}return wx.showToast({title:"开奖中",icon:"none"}),r.abrupt("return");case 11:if(![_util.LotteryServerStatus.Opened].includes(o.Status)){r.next=14;break}return e.attendLottery(t),r.abrupt("return");case 14:if(![_util.LotteryServerStatus.Delete,_util.LotteryServerStatus.UnOpened,_util.LotteryServerStatus.Retract].includes(o.Status)){r.next=18;break}return wx.showToast({title:"该抽奖已结束",icon:"none"}),e.setAwardInfo(!1,null),r.abrupt("return");case 18:e.checkHasUnCompletedConditions(e.data.undoLotteryMap[t])&&e.attendLottery(t,!1,!0),e.setData({type:"detail"}),e.setAwardInfo(!0,t);case 21:case"end":return r.stop()}},r)}))()},checkHasUnCompletedConditions:function(t){return t&&Boolean(Object.keys(t).some(function(e){return t[e]===_util.ConditionCompleteFlag.NOT_COMPLETED}))},attendLotteryTrigger:function(t){this.attendLottery(t.detail.lotteryId,!0)},attendLottery:function(t){var e=arguments,r=this;return _asyncToGenerator(_regeneratorRuntime().mark(function n(){var a,o,i,s,u,l,c,d,f,p;return _regeneratorRuntime().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(a=e.length>1&&void 0!==e[1]&&e[1],o=e.length>2&&void 0!==e[2]&&e[2],r.isLogin(!0)){n.next=5;break}return!a&&r.setAwardInfo(!1,null),n.abrupt("return");case 5:return i=r.store.get("mainInfo"),s=i.activityId,u=r.createLotteryRequestId(),n.prev=7,r.setData({isAttendLoading:!0}),n.next=11,r.sdkInstance.request(_constant.REQUEST_URL_MAP.GET_AWARD_RECORD_INFO,{method:"POST",data:{ActivityID:s,AwardID:t}});case 11:if(l=n.sent,r.isLatestLotteryRequest(u,t)){n.next=14;break}return n.abrupt("return");case 14:if(r.setData({isAttendLoading:!1}),!l){n.next=37;break}n.t0=l.AwardResult,n.next=n.t0===_util.AwardResult.ATTEND?19:n.t0===_util.AwardResult.LOSE?23:n.t0===_util.AwardResult.WIN?28:n.t0===_util.AwardResult.INIT?33:34;break;case 19:return r.updateLotteryUserStatusNoTrans(t,_util.LotteryStatus.ENROLLED),r.setAwardInfo(!1,null),wx.showToast({title:"已参与本次抽奖",icon:"none"}),n.abrupt("return");case 23:return r.updateLotteryUserStatusNoTrans(t,_util.LotteryStatus.LOSE),r.setCurrentData(l,_util.LotteryStatus.LOSE),r.setData({type:"result"}),r.setAwardInfo(!0,t),n.abrupt("return");case 28:return r.updateLotteryUserStatusNoTrans(t,_util.LotteryStatus.WIN),r.setCurrentData(l,_util.LotteryStatus.WIN),r.setData({type:"result"}),r.setAwardInfo(!0,t),n.abrupt("return");case 33:throw new Error("");case 34:return r.setAwardInfo(!1,null),wx.showToast({title:"请稍后再试",icon:"none"}),n.abrupt("return");case 37:n.next=55;break;case 39:if(n.prev=39,n.t1=n.catch(7),r.isLatestLotteryRequest(u,t)){n.next=43;break}return n.abrupt("return");case 43:if(r.setData({isAttendLoading:!1}),c=r.getCurrentLottery(t),_util.LotteryServerStatus.Opened!==c.Status){n.next=53;break}return r.updateLotteryUserStatusNoTrans(t,_util.LotteryStatus.UNATTEND),r.setData({type:"result"}),r.setAwardInfo(!0,t),r.sdkInstance.reportLogger("lottery_show_win_result",{params:{awardId:t,Status:_util.LotteryStatus.UNATTEND,evModule:"LOTTERY"}}),n.abrupt("return");case 53:p={ActivityID:s,AwardID:t,BarragePwd:(0,_utils.getBySplit)(null!==(d=c.BarragePwd)&&void 0!==d?d:""),RegisterType:null===(f=r.store.get("userInfo"))||void 0===f?void 0:f.typeRegister},r.sdkInstance.request(_constant.REQUEST_URL_MAP.ATTEND_LOTTERY,{method:"POST",data:p}).then(function(e){if(r.isLatestLotteryRequest(u,t)){if(r.setData({isAttendLoading:!1}),e.Status)return r.data.undoLotteryMap[t]=null,r.updateLotteryUserStatusNoTrans(t,_util.LotteryStatus.ENROLLED),o?r.setCurrentData(r.data.data):(r.setAwardInfo(!1,null),wx.showToast({title:"参与成功",icon:"none"})),void r.reportTea("attend_lottery_success",{awardId:t});if(e.UndoAwardCondition)throw r.data.undoLotteryMap[t]=e.UndoAwardCondition,r.setCurrentData(r.data.data),new Error("抽奖条件未满足");throw new Error(e.Message||"参与失败,请稍后再试")}}).catch(function(e){r.isLatestLotteryRequest(u,t)&&(r.setData({isAttendLoading:!1}),"抽奖条件未满足"!==e.message&&(r.setAwardInfo(!1,null),wx.showToast({title:e.message,icon:"none"}),r.sdkInstance.reportLogger("attend_lottery_failed",{params:{awardId:t,error:e.message,evModule:"LOTTERY"}})))});case 55:case"end":return n.stop()}},n,null,[[7,39]])}))()},imageTextUpdate:function(t){var e=t.AwardID,r=t.Status,n=t.TotalCount;r>0&&this.updateOneLottery(e,r,n);var a,o=this.store.get("imageTextInfo")||{},i=o.imageText,s=void 0===i?[]:i,u=_createForOfIteratorHelper(s);try{for(u.s();!(a=u.n()).done;){var l,c=_createForOfIteratorHelper(a.value.Context);try{for(c.s();!(l=c.n()).done;){var d=l.value;if((null==d?void 0:d.ImageTextType)===_constant.ImageTextTypes.LOTTERY){var f,p=d.AwardContext;if(p&&p.ID===e)return r>0&&(p.Status=r),n>0&&(p.TotalCount||(p.TotalCount=n),p.TotalCount<n&&(p.TotalCount=n)),this.store.set("imageTextInfo",_objectSpread(_objectSpread({},o),{},{imageText:s})),void(this.data.visible&&"detail"===this.data.type&&(null===(f=this.data.data)||void 0===f?void 0:f.ID)===e&&this.setCurrentData(p))}}}catch(t){c.e(t)}finally{c.f()}}}catch(t){u.e(t)}finally{u.f()}},imageTextUpdateList:function(){var t=this;return _asyncToGenerator(_regeneratorRuntime().mark(function e(){var r,n,a,o,i,s,u,l,c,d,f,p,y,h;return _regeneratorRuntime().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.store.get("imageTextInfo")||{},n=r.imageText,(a=void 0===n?[]:n).length){e.next=4;break}return e.abrupt("return");case 4:o=[],i=[],s=_createForOfIteratorHelper(a);try{for(s.s();!(u=s.n()).done;){l=u.value,c=_createForOfIteratorHelper(l.Context);try{for(c.s();!(d=c.n()).done;)(null==(f=d.value)?void 0:f.ImageTextType)===_constant.ImageTextTypes.LOTTERY&&(p=f.AwardContext,y=p.ID,(h=p.Status)>0&&(o.push({lotteryId:y,status:h}),h===_util.LotteryServerStatus.Ing&&i.push(y)))}catch(t){c.e(t)}finally{c.f()}}}catch(t){s.e(t)}finally{s.f()}if(o.length&&t.updateLotteryUserStatus(o),!i.length){e.next=13;break}return e.next=12,t.syncUserStatus(i);case 12:t.store.set("imageTextInfo",_objectSpread(_objectSpread({},r),{},{imageText:a}));case 13:case"end":return e.stop()}},e)}))()},syncUserStatus:function(t){var e=this;return _asyncToGenerator(_regeneratorRuntime().mark(function r(){var n,a,o,i;return _regeneratorRuntime().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(e.isLogin()){r.next=2;break}return r.abrupt("return");case 2:return n=[],r.next=5,Promise.all(t.map(function(){var t=_asyncToGenerator(_regeneratorRuntime().mark(function t(r){var a,o,i;return _regeneratorRuntime().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.store.get("mainInfo"),o=a.activityId,t.prev=1,t.next=4,e.sdkInstance.request(_constant.REQUEST_URL_MAP.GET_AWARD_RECORD_INFO,{method:"POST",data:{ActivityID:o,AwardID:r}});case 4:(i=t.sent).AwardResult&&i.AwardResult===_util.AwardResult.ATTEND&&n.push(r),t.next=11;break;case 8:t.prev=8,t.t0=t.catch(1),console.error(t.t0);case 11:case"end":return t.stop()}},t,null,[[1,8]])}));return function(e){return t.apply(this,arguments)}}()));case 5:n.length>0&&(a=e.store.get("lotteriesUserStatus")||{},o=a.lotteriesUserStatus,i=void 0===o?{}:o,n.forEach(function(t){return i[t]=_util.LotteryStatus.ENROLLED}),e.store.set("lotteriesUserStatus",{lotteriesUserStatus:i}));case 6:case"end":return r.stop()}},r)}))()},bindSocketEvents:function(){var t,e=this;null===(t=this.socket)||void 0===t||t.on(_socket.WsMethod.imageTextLotteryOrCheckInUpdate,function(t){t.SendType!==_constant.ImageTextTypes.CHECKIN&&(e.sdkInstance.reportLogger("mini_sdk_lottery_update",{data:t}),e.imageTextUpdate(t))})},setCheckedCheckIn:function(){var t=this.store.get("mainInfo").activityId,e=(this.store.get("userInfo")||{}).userId,r=wx.getStorageSync("checkedId");if(e&&r&&JSON.parse(r)[t+"_"+e]){var n=JSON.parse(r)[t+"_"+e].slice(1);this.setData({checkedCheckIn:n})}},reportTea:function(t){var e,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};null===(e=this.sdkInstance)||void 0===e||null===(r=e.reportTea)||void 0===r||r.call(e,t,_objectSpread(_objectSpread({},n),{},{terminal:"miniprogram",evModule:"LOTTERY"})),teaEventMap[t]&&this.sdkInstance.emit(teaEventMap[t],_objectSpread({},n))}}});