- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
1 line
18 KiB
JavaScript
1 line
18 KiB
JavaScript
"use strict";var _FLOATING_ICON_TYPE_K,_socket=require("../../utils/socket"),_constant=require("../../utils/constant"),_util=require("./util"),_coupon=require("../../utils/coupon"),_logger=require("../../utils/logger"),_luckymoney=require("../../utils/luckymoney"),_luckymoneyStore=require("../../store/luckymoney-store"),_featureProcess=require("../../utils/feature-process"),_vote=require("../../utils/vote"),_theme=require("../../utils/theme"),_utils=require("../../utils/utils"),_storage=require("../../utils/storage");function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach(function(t){_defineProperty(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return 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 _defineProperty(e,t,n){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,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 n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var FLOATING_ICON_TYPE_KEY_MAP=(_defineProperty(_FLOATING_ICON_TYPE_K={},_constant.ImageTextTypes.QUESTION,_featureProcess.FloatingInteractionIconSystemKey.QUESTION),_defineProperty(_FLOATING_ICON_TYPE_K,_constant.ImageTextTypes.QUESTIONNAIRE,_featureProcess.FloatingInteractionIconSystemKey.QUESTIONNAIRE),_defineProperty(_FLOATING_ICON_TYPE_K,_constant.ImageTextTypes.CHECKIN,_featureProcess.FloatingInteractionIconSystemKey.CHECKIN),_defineProperty(_FLOATING_ICON_TYPE_K,_constant.ImageTextTypes.LOTTERY,_featureProcess.FloatingInteractionIconSystemKey.LOTTERY),_defineProperty(_FLOATING_ICON_TYPE_K,_constant.ImageTextTypes.LUCKMONEY,_featureProcess.FloatingInteractionIconSystemKey.LUCKYMONEY),_defineProperty(_FLOATING_ICON_TYPE_K,_constant.ImageTextTypes.COUPON,_featureProcess.FloatingInteractionIconSystemKey.COUPON),_FLOATING_ICON_TYPE_K);Component({properties:{sdkInstance:{type:Object,value:null},isLandScape:{type:Boolean,value:!1},floatIconNum:{type:Number,value:3}},data:{visibleIconList:[],hasMoreVisibleIcon:!1,showImageCard:!1,useDarkTheme:!1},lifetimes:{detached:function(){"function"==typeof this.unsubMain&&this.unsubMain(),this.unsubMain=null,"function"==typeof this.unsubLuckymoney&&this.unsubLuckymoney(),this.unsubLuckymoney=null}},observers:{floatIconNum:function(){var e;null===(e=this.syncVisibleFloatingIconList)||void 0===e||e.call(this)},sdkInstance:function(e){var t,n=this;if(e){"function"==typeof this.unsubMain&&this.unsubMain(),this.unsubMain=null,"function"==typeof this.unsubLuckymoney&&this.unsubLuckymoney(),this.unsubLuckymoney=null,this.floatImage=(_defineProperty(t={},_constant.ImageTextTypes.QUESTION,{field:"QuizContext",idField:"QuizID",filter:function(e){return![_util.QuizStatus.DELETE,_util.QuizStatus.REVOKE].includes(null==e?void 0:e.QuizStatus)},img:function(e){return(null==e?void 0:e.QuizType)===_util.QuizType.SIMPLE?_constant.SIMPLE_QUIZ_ICON_URL:_constant.QUESTION_ICON_URL},onClick:this.onQuestionIconClick.bind(this),statusRules:[{checker:function(e){return[_util.QuizStatus.INIT,_util.QuizStatus.SEND].includes(null==e?void 0:e.QuizStatus)},text:function(e){return e.QuizResultType===_util.IQuizResultType.MANUAL?"去参加":"showCountDown"},timeOverText:"去参加"},{checker:function(e){return(0,_util.isEndStatus)(e)},text:"看结果"},{checker:!0,text:"去参加"}]}),_defineProperty(t,_constant.ImageTextTypes.QUESTIONNAIRE,{field:"QuestionnaireContext",idField:"QuestionnaireId",filter:function(e){return Number(null==e?void 0:e.PublishStatus)===_constant.PUBLISH_STATUS.PUBLISHED},img:_constant.QUESTIONNAIRE_ICON_URL,onClick:this.onQuestionnaireIconClick.bind(this),statusRules:[{checker:!0,text:"问卷"}]}),_defineProperty(t,_constant.ImageTextTypes.CHECKIN,{field:"CheckInContext",idField:"CheckInId",filter:function(e){return n.isCheckInChecked(e)||"Export"===(null==e?void 0:e.Status)},img:"https://mediaservice-fe.volccdn.com/obj/vcloud-fe/livesaas-client/static/media/checkIn_v1.690ce8ea.png",onClick:this.onCheckInIconClick.bind(this),statusRules:[{checker:!0,text:"签到"}]}),_defineProperty(t,_constant.ImageTextTypes.IMAGE,{field:"ImageTextContext",idField:"ImageTextContext",filter:function(e){return!(null==e||!e.ImageTextContext)},img:function(e){return e.ImageTextContext},onClick:this.onImageIconClick.bind(this),statusRules:[{checker:!0,text:"查看图片"}]}),_defineProperty(t,_constant.ImageTextTypes.LOTTERY,{field:"AwardContext",idField:"ID",filter:function(e){var t=e.Status;return[_util.LotteryServerStatus.Ing,_util.LotteryServerStatus.BeforeOpen,_util.LotteryServerStatus.Opening,_util.LotteryServerStatus.Opened].includes(t)},img:function(e){return e.AwardFloatingIcon||"https://mediaservice-fe.volccdn.com/obj/vcloud-fe/livesaas-client/static/media/lottery_v1.fce45899.png"},onClick:this.onLotteryIconClick.bind(this),statusRules:[{checker:function(e){return[_util.LotteryServerStatus.Ing].includes(null==e?void 0:e.Status)&&e.AwardType!==_util.AwardType.AdminOpen},text:"showCountDown",timeOverText:"抽奖"},{checker:function(e){return[_util.LotteryServerStatus.Ing].includes(null==e?void 0:e.Status)},text:"抽奖"},{checker:function(e){return[_util.LotteryServerStatus.BeforeOpen,_util.LotteryServerStatus.Opening].includes(null==e?void 0:e.Status)},text:"开奖中"},{checker:function(e){return[_util.LotteryServerStatus.Opened].includes(null==e?void 0:e.Status)},text:"已开奖"}]}),_defineProperty(t,_constant.ImageTextTypes.COUPON,{field:"CouponContext",idField:"Id",filter:function(e){return(null==e?void 0:e.couponStatus)!==_coupon.CouponStatusType.Delete},img:"https://mediaservice-fe.volccdn.com/obj/vcloud-fe/livesaas-client/static/media/coupon.73712991.png",onClick:this.onCouponIconClick.bind(this),statusRules:[{checker:!0,text:"领券"}]}),_defineProperty(t,_constant.ImageTextTypes.LUCKMONEY,{field:"RedPacket",idField:"RedPacketID",filter:function(e){return n.shouldShowLuckymoneyIcon(e)},img:function(e){return(null==e?void 0:e.RedPacketCoverImage)||"https://mediaservice-fe.volccdn.com/obj/vcloud-fe/livesaas-client/static/media/luckyMoney_v1.e749e9f3.png"},onClick:this.onLuckymoneyIconClick.bind(this),statusRules:[{checker:function(e){return[_luckymoney.RedPacketStatus.INIT,_luckymoney.RedPacketStatus.SENT].includes(n.getLuckymoneyStatus(e))},text:function(e){return(null==e?void 0:e.OpenRedPacketType)===_luckymoney.OpenRedPacketType.MANUAL?"等待开启":"showCountDown"}},{checker:function(e){return n.getLuckymoneyStatus(e)===_luckymoney.RedPacketStatus.OPENING},text:"开启中"},{checker:!0,text:"红包"}]}),_defineProperty(t,_constant.ImageTextTypes.VOTE,{field:"VoteContext",idField:"VoteId",filter:function(e){var t,o,i=(null===(t=n.store)||void 0===t||null===(o=t.get)||void 0===o?void 0:o.call(t,"voteUserStatus"))||{};return"Delete"!==(null==e?void 0:e.Status)&&((0,_vote.isVoteSubmitted)(e,i)||!(0,_vote.isVoteEnded)(e))},img:"https://p1-live.byteimg.com/tos-cn-i-gjr78lqtd0/5423219c9cb240febe1ccff6554ae09e~tplv-gjr78lqtd0-image.image",onClick:this.onVoteIconClick.bind(this),statusRules:[{checker:function(e){var t,o;return(0,_vote.isVoteSubmitted)(e,(null===(t=n.store)||void 0===t||null===(o=t.get)||void 0===o?void 0:o.call(t,"voteUserStatus"))||{})},text:"投票"},{checker:function(e){return(0,_vote.isVoteEnded)(e)},text:"已结束"},{checker:!0,text:"投票"}]}),_defineProperty(t,_constant.ImageTextTypes.ANNOUNCEMENT,{field:"AnnouncementContext",idField:"AnnouncementId",filter:function(e){return!(null==e||!e.AnnouncementId)},img:_constant.ANNOUNCEMENT_ICON_URL,onClick:this.onAnnouncementIconClick.bind(this),statusRules:[{checker:!0,text:"公告"}]}),_defineProperty(t,_constant.ImageTextTypes.LIVEBONUS,{field:"ActivityBonusTaskContext",idField:"Id",filter:function(e){return!(null==e||!e.Id)},img:function(e){return e.Icon||"https://mediaservice-fe.volccdn.com/obj/vcloud-fe/livesaas-client/static/media/liveBonus.9771435f.png"},onClick:this.onLiveBonusIconClick.bind(this),statusRules:[{checker:!0,text:function(e){return(null==e?void 0:e.Name)||"直播福利"}}]}),t),this.store=e.store,this.sdkInstance=e,this.sdkInstanceId=(null==e?void 0:e.uuid)||e,this.luckymoneyStore=(0,_luckymoneyStore.getLuckymoneyStore)(this.sdkInstanceId);var o=this;e.on(_constant.EVENTS.INNER.socket.init,function(e){o.socket=e,o.bindSocketEvents()}),this.unsubMain=this.store.get({imageTextInfo:function(e){o.setIconList((null==e?void 0:e.imageText)||[])},userInfo:function(){var e=n.store.get("imageTextInfo.imageText")||[];n.setIconList(e)},voteUserStatus:function(){var e=n.store.get("imageTextInfo.imageText")||[];n.setIconList(e)},pollingInfo:function(){var e=n.store.get("imageTextInfo.imageText")||[];(0,_vote.hasVoteContext)(e)&&n.setIconList(e)},liveInfo:function(e){var t,n,i;if(e){var r=(null==e||null===(t=e.Menus)||void 0===t||null===(n=t.Menus)||void 0===n?void 0:n.some(function(e){return e.Type===_constant.MENU_TYPE.InteractiveTool}))&&2!==(null===(i=e.ImageTextConfig)||void 0===i?void 0:i.DisplayEnable);(0,_utils.setDataIfChanged)(o,{showImageCard:r,useDarkTheme:(0,_theme.isUseDarkTheme)(null==e?void 0:e.Basic)})}}}),this.unsubLuckymoney=this.luckymoneyStore.subscribe({userStatusMap:function(){var e=n.store.get("imageTextInfo.imageText")||[];n.setIconList(e)},rainingRedPacketID:function(){var e=n.store.get("imageTextInfo.imageText")||[];n.setIconList(e)},noAnimationFlowMap:function(){var e=n.store.get("imageTextInfo.imageText")||[];n.setIconList(e)},activeNoAnimationRevealRedPacketID:function(){var e=n.store.get("imageTextInfo.imageText")||[];n.setIconList(e)}})}}},methods:{syncVisibleFloatingIconList:function(){var e=(this._floatingIconList||[]).filter(function(e){return e.visible}),t=e.length>0,n={visibleIconList:e.slice(0,this.data.floatIconNum),hasMoreVisibleIcon:t};(0,_utils.isSmallPlainDataEqual)({visibleIconList:this.data.visibleIconList,hasMoreVisibleIcon:this.data.hasMoreVisibleIcon},n)||this.setData(n)},openImageTextCardDrawer:function(){this.triggerEvent("openImageTextCardDrawer")},notifyAttentionInteraction:function(){this.triggerEvent("attentionInteraction")},openMore:function(){this.data.isLandScape?this.triggerEvent("openImageTextTab"):this.openImageTextCardDrawer()},setIconList:function(e){var t=this,n=[],o=this._floatingIconList||[];e.forEach(function(e){var i;null===(i=e.Context)||void 0===i||i.forEach(function(i,r){var s,u,c,a,l=i.ImageTextType;if(!t.floatImage[l]&&null!=i&&i.CouponContext&&(l=_constant.ImageTextTypes.COUPON),l!==_constant.ImageTextTypes.LUCKMONEY||(0,_luckymoney.isLuckymoneyEnabled)(null===(s=t.store)||void 0===s||null===(u=s.get)||void 0===u?void 0:u.call(s,"liveInfo"))){if(t.floatImage[l]){var d=t.floatImage[l],f=d.field,I=d.idField,y=d.filter,m=d.statusRules,_=d.img,v=(null==i?void 0:i[f])||(l===_constant.ImageTextTypes.COUPON?null==i?void 0:i.CouponContext:null),g=v&&"object"===_typeof(v)?_objectSpread({},v):v?_defineProperty({},f,v):null;if(g&&l===_constant.ImageTextTypes.COUPON&&void 0!==i.AllowCloseIcon&&(g.AllowCloseIcon=i.AllowCloseIcon),!g)return;var p=FLOATING_ICON_TYPE_KEY_MAP[l];if(p&&!(0,_featureProcess.isFloatingInteractionIconVisible)(t.sdkInstance,p))return;if(l===_constant.ImageTextTypes.COUPON&&void 0===g.couponStatus){var k=(t.store.get("liveInfo")||{}).ActivityId,h=(t.store.get("userInfo")||{}).userId,T=h&&k&&(0,_coupon.isCouponPicked)(k,h,g.Id)?1:0;g.couponStatus=(0,_coupon.calcCouponStatus)(g,T)}if(l===_constant.ImageTextTypes.COUPON){var C=(t.store.get("userInfo")||{}).levelId;if(!(0,_coupon.isCouponLevelEligible)(null!=C?C:"",g))return}if(l===_constant.ImageTextTypes.QUESTION&&(g.Deadline=g.Deadline/60),g&&y(g)){var b,S,L=m.find(function(e){return"function"==typeof e.checker?e.checker(g):e.checker}),P=L.text,x=L.timeOverText,O=[e.ImageTextId||e.CreateTime||"",r,l,g[I]||""].join("_"),E=null===(b=null===(S=o.filter(function(e){return e.stableKey===O})[0])||void 0===S?void 0:S.visible)||void 0===b||b;n.push({stableKey:O,type:l,visible:E,img:"function"==typeof _?_(g):_,text:"function"==typeof P?P(g):P,timeOverText:x,current:g})}}}else null===(c=t.sdkInstance)||void 0===c||null===(a=c.reportLogger)||void 0===a||a.call(c,"".concat(_logger.LoggerPrefixObj.luckymoney,"_feature_disabled"),{from:"image-text-float"})})}),this._floatingIconList=n,this.syncVisibleFloatingIconList()},bindSocketEvents:function(){},onQuestionIconClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Question)||this.store.set("QuizInfo",{visible:!0,currentId:e.QuizID})},onQuestionnaireIconClick:function(e){if(!(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Questionnaire)){var t=null==e?void 0:e.QuestionnaireId,n={questionnaireId:t,from:"float"};this.sdkInstance&&"function"==typeof this.sdkInstance.reportLogger?this.sdkInstance.reportLogger("mini_sdk_questionnaire_entry_click",n):console.log("[mini-sdk] Questionnaire open via float",n),t&&this.store.set("QuestionnaireInfo",{visible:!0,currentId:t,triggerTime:"image_text",from:"float",isAuto:!1,isBlocking:!1})}},onCheckInIconClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.CheckIn)||this.store.set("CheckInInfo",{visible:!0,currentId:e.CheckInId})},onImageIconClick:function(e){this.triggerEvent("previewimage",{src:null==e?void 0:e.ImageTextContext})},onLotteryIconClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Lottery)||this.store.set("AwardInfo",{visible:!0,currentId:e.ID})},onCouponIconClick:function(e){var t,n;(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Coupon)||(this.sdkInstance.setShowCouponId(e.Id,"interactiveIcon"),this.sdkInstance&&null!==(t=this.sdkInstance.EVENTS)&&void 0!==t&&null!==(n=t.coupon)&&void 0!==n&&n.entryClick&&this.sdkInstance.emit(this.sdkInstance.EVENTS.coupon.entryClick,{couponId:e.Id,coupon:e}))},onLuckymoneyIconClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Luckymoney)||this.isLogin(!0)&&this.sdkInstance.openLuckymoneyModal(e.RedPacketID)},onVoteIconClick:function(e){var t=null==e?void 0:e.VoteId;t&&this.store.set("VoteInfo",{visible:!0,currentId:t,triggerTime:"image_text",from:"float",isAuto:!1})},onAnnouncementIconClick:function(e){null!=e&&e.AnnouncementId&&this.store.set("AnnouncementInfo",{visible:!0,currentId:e.AnnouncementId,triggerTime:"image_text",from:"float",isAuto:!1})},onLiveBonusIconClick:function(e){var t,n;this.isLogin(!0)&&null!=e&&e.Id&&(null===(t=(n=this.sdkInstance).openLiveBonusPanel)||void 0===t||t.call(n,e.Id,"floatIcon"))},getLuckymoneyUserStatus:function(e){var t;return((null===(t=this.luckymoneyStore.state)||void 0===t?void 0:t.userStatusMap)||{})[null==e?void 0:e.RedPacketID]||(0,_luckymoney.getUserStatusByStatus)(null==e?void 0:e.RedPacketStatus)},getLuckymoneyStatus:function(e){return(0,_luckymoney.getVisibleRedPacketStatus)(e,this.luckymoneyStore.state)},shouldShowLuckymoneyIcon:function(e){var t=this.getLuckymoneyStatus(e),n=this.getLuckymoneyUserStatus(e);return[_luckymoney.RedPacketStatus.SENT,_luckymoney.RedPacketStatus.INIT,_luckymoney.RedPacketStatus.OPENING].includes(t)||[_luckymoney.LuckyMoneyResult.ATTENDED,_luckymoney.LuckyMoneyResult.WIN,_luckymoney.LuckyMoneyResult.LOSE].includes(n)},isCheckInChecked:function(e){var t,n,o,i;if(null==e||!e.CheckInId)return!1;if(e.IsChecked)return!0;var r=((null===(t=this.store)||void 0===t||null===(n=t.get)||void 0===n?void 0:n.call(t,"mainInfo"))||{}).activityId,s=((null===(o=this.store)||void 0===o||null===(i=o.get)||void 0===i?void 0:i.call(o,"userInfo"))||{}).userId;if(!r||!s)return!1;var u=(0,_storage.safeGetStorageJSON)("checkedId",{}),c=r+"_"+s;return Array.isArray(u[c])&&u[c].includes(e.CheckInId)},isLogin:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return 2===((null===(e=this.store)||void 0===e?void 0:e.get("mainInfo"))||{}).mode||(t&&this.triggerEvent("commentCheck"),!1)},commentCheck:function(){this.triggerEvent("commentCheck")},previewImage:function(e){this.triggerEvent("previewimage",e.detail)},onClick:function(e){var t,n,o=null==e||null===(t=e.currentTarget)||void 0===t||null===(n=t.dataset)||void 0===n?void 0:n.item;o&&o.type&&this.floatImage[o.type]&&this.floatImage[o.type].onClick(o.current)},onClose:function(e){var t,n,o=null==e||null===(t=e.currentTarget)||void 0===t||null===(n=t.dataset)||void 0===n?void 0:n.item;if(o&&o.type&&this.floatImage[o.type]){var i=this._floatingIconList||[],r=i.findIndex(function(e){return e.stableKey===o.stableKey});if(!(r<0)){var s=_toConsumableArray(i);s[r]=_objectSpread(_objectSpread({},s[r]),{},{visible:!1}),this._floatingIconList=s,this.syncVisibleFloatingIconList()}}}}}); |