- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
"use strict";var _constant=require("../../utils/constant"),_util=require("../image-text-float/util"),_utils=require("../../utils/utils"),_jump=require("../../utils/jump"),_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"),_richTextParser=require("../../utils/rich-text-parser"),_theme=require("../../utils/theme");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 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 _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)}Component({properties:{sdkInstance:{type:Object,value:null},forceLightTheme:{type:Boolean,value:!1}},data:{iconList:[],useDarkTheme:!1},lifetimes:{detached:function(){"function"==typeof this.unsubMain&&this.unsubMain(),this.unsubMain=null,"function"==typeof this.unsubLuckymoney&&this.unsubLuckymoney(),this.unsubLuckymoney=null}},observers:{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.sdkInstance=e,this.sdkInstanceId=(null==e?void 0:e.uuid)||e,this.store=e.store,this.luckymoneyStore=(0,_luckymoneyStore.getLuckymoneyStore)(this.sdkInstanceId),this.socket=e.socket,this.floatImage=(_defineProperty(t={},_constant.ImageTextTypes.QUESTION,{field:"QuizContext",idField:"QuizID",fieldTitle:"QuizTitle",describe:"",img:function(e){return(null==e?void 0:e.QuizType)===_util.QuizType.SIMPLE?_constant.SIMPLE_QUIZ_ICON_URL:_constant.QUESTION_ICON_URL},onClick:this.onQuestionClick.bind(this),statusRules:[{checker:function(e){return(0,_util.isEndStatus)(e)},describe:"已结束",buttonText:"查看详情",buttonType:"ghost"},{checker:function(e){return!(0,_util.isEndStatus)(e)},describe:"进行中",buttonText:"立即参与",buttonType:"primary"}]}),_defineProperty(t,_constant.ImageTextTypes.QUESTIONNAIRE,{field:"QuestionnaireContext",idField:"QuestionnaireId",fieldTitle:"Title",describe:function(e){return(0,_utils.getBySplit)((null==e?void 0:e.Description)||"")},img:_constant.QUESTIONNAIRE_ICON_URL,onClick:this.onQuestionnaireClick.bind(this),statusRules:[{checker:!0,buttonText:"查看详情",buttonType:"ghost"}]}),_defineProperty(t,_constant.ImageTextTypes.CHECKIN,{field:"CheckInContext",idField:"CheckInId",fieldTitle:"CheckInName",describe:"",img:"https://mediaservice-fe.volccdn.com/obj/vcloud-fe/livesaas-client/static/media/checkIn_v1.690ce8ea.png",onClick:this.onCheckInClick.bind(this),statusRules:[{checker:function(e){return e.IsChecked&&"Export"===e.Status},describe:"进行中",buttonText:"查看详情",buttonType:"ghost"},{checker:function(e){return e.IsChecked&&"Deadline"===e.Status},describe:"已结束",buttonText:"查看详情",buttonType:"ghost"},{checker:function(e){return!e.IsChecked&&"Export"===e.Status},describe:"进行中",buttonText:"立即参与",buttonType:"primary"},{checker:function(e){return!e.IsChecked&&"Deadline"===e.Status},describe:"已结束",buttonText:"查看详情",buttonType:"ghost"}]}),_defineProperty(t,_constant.ImageTextTypes.LOTTERY,{field:"AwardContext",idField:"ID",fieldTitle:"Name",describe:function(e){var t=e.ShowPeopleNumber,n=e.TotalCount;return 0===t?"已参与:"+n+"人":""},img:function(e){return e.AwardFloatingIcon||"../../../assets/card_lottery.svg"},onClick:this.onLotteryClick.bind(this),statusRules:[{checker:function(e){return(0,_util.getLotteryUserStatus)(e,n.store)===_util.LotteryStatus.WAITING},buttonText:"开奖中",buttonType:"minor"},{checker:function(e){return(0,_util.getLotteryUserStatus)(e,n.store)===_util.LotteryStatus.CLOSED},buttonText:"已结束",buttonType:"ghost"},{checker:function(e){return(0,_util.getLotteryUserStatus)(e,n.store)===_util.LotteryStatus.ENROLLED},buttonText:"已参与",buttonType:"minor"},{checker:function(e){return(0,_util.getLotteryUserStatus)(e,n.store)===_util.LotteryStatus.OPEN},showCountDown:function(e){return e.AwardType===_util.AwardType.AutoOpen},buttonText:"立即参与",buttonType:"primary"},{checker:function(e){return[_util.LotteryStatus.UNATTEND,_util.LotteryStatus.WIN,_util.LotteryStatus.LOSE].includes((0,_util.getLotteryUserStatus)(e,n.store))},buttonText:"中奖结果",buttonType:"ghost"}]}),_defineProperty(t,_constant.ImageTextTypes.COUPON,{field:"CouponContext",idField:"Id",fieldTitle:function(e){var t=(null==e?void 0:e.Coupon)||e;return(0,_utils.getBySplit)((null==t?void 0:t.Name)||"")},describe:function(e){if((null==e?void 0:e.couponStatus)===_coupon.CouponStatusType.End)return"已结束";var t=(null==e?void 0:e.Coupon)||e;return(0,_utils.getBySplit)((null==t?void 0:t.Description)||"")},img:"https://mediaservice-fe.volccdn.com/obj/vcloud-fe/livesaas-client/static/media/coupon.73712991.png",onClick:this.onCouponClick.bind(this),statusRules:[{checker:function(e){return(null==e?void 0:e.couponStatus)===_coupon.CouponStatusType.Sending},buttonText:"立即领取",buttonType:"primary"},{checker:function(e){return(null==e?void 0:e.couponStatus)===_coupon.CouponStatusType.SendCompleted},buttonText:"已领完",buttonType:"ghost"},{checker:function(e){return(null==e?void 0:e.couponStatus)===_coupon.CouponStatusType.Pickup},buttonText:"已领取",buttonType:"minor"},{checker:function(e){return(null==e?void 0:e.couponStatus)===_coupon.CouponStatusType.End},buttonText:"已结束",buttonType:"ghost"},{checker:!0,buttonText:"立即领取",buttonType:"primary"}]}),_defineProperty(t,_constant.ImageTextTypes.LUCKMONEY,{field:"RedPacket",idField:"RedPacketID",fieldTitle:"Name",getTitle:this.getLuckymoneyTitle.bind(this),describe:function(e){return n.getLuckymoneyStatusText(e)},img:"https://mediaservice-fe.volccdn.com/obj/vcloud-fe/livesaas-client/static/media/luckyMoney_v1.e749e9f3.png",onClick:this.onLuckymoneyClick.bind(this),statusRules:[{checker:function(e){return[_luckymoney.RedPacketStatus.SUCCESS,_luckymoney.RedPacketStatus.FAILED].includes(n.getLuckymoneyStatus(e))},buttonText:"查看结果",buttonType:"minor"},{checker:function(e){return n.getLuckymoneyStatus(e)===_luckymoney.RedPacketStatus.OPENING},buttonText:"开启中",buttonType:"minor"},{checker:function(e){return[_luckymoney.RedPacketStatus.INIT,_luckymoney.RedPacketStatus.SENT].includes(n.getLuckymoneyStatus(e))&&n.getLuckymoneyUserStatus(e)===_luckymoney.LuckyMoneyResult.ATTENDED},buttonText:"已参与",buttonType:"minor"},{checker:function(e){return[_luckymoney.RedPacketStatus.INIT,_luckymoney.RedPacketStatus.SENT].includes(n.getLuckymoneyStatus(e))&&n.getLuckymoneyUserStatus(e)!==_luckymoney.LuckyMoneyResult.ATTENDED},buttonText:"立即参与",buttonType:"primary"}]}),_defineProperty(t,_constant.ImageTextTypes.VOTE,{field:"VoteContext",idField:"VoteId",fieldTitle:"Title",describe:function(e){return(0,_vote.isVoteEnded)(e)?"已结束":"进行中"},img:"https://p1-live.byteimg.com/tos-cn-i-gjr78lqtd0/5423219c9cb240febe1ccff6554ae09e~tplv-gjr78lqtd0-image.image",onClick:this.onVoteClick.bind(this),statusRules:[{checker:function(e){var t,o;return(0,_vote.isVoteEnded)(e)||(0,_vote.isVoteSubmitted)(e,(null===(t=n.store)||void 0===t||null===(o=t.get)||void 0===o?void 0:o.call(t,"voteUserStatus"))||{})},buttonText:"查看详情",buttonType:"ghost"},{checker:!0,buttonText:"立即参与",buttonType:"primary"}]}),_defineProperty(t,_constant.ImageTextTypes.ANNOUNCEMENT,{field:"AnnouncementContext",idField:"AnnouncementId",fieldTitle:function(e){return(null==e?void 0:e.Title)||(null==e?void 0:e.AnnouncementTitle)||"公告"},describe:function(e){return(0,_richTextParser.getRichTextPlainText)((null==e?void 0:e.Content)||"")},img:_constant.ANNOUNCEMENT_ICON_URL,onClick:this.onAnnouncementClick.bind(this),statusRules:[{checker:function(e){return!(null==e||!e.AnnouncementId)},buttonText:"查看详情",buttonType:"ghost"}]}),_defineProperty(t,_constant.ImageTextTypes.LIVEBONUS,{field:"ActivityBonusTaskContext",idField:"Id",fieldTitle:function(e){return(null==e?void 0:e.Name)||"直播福利"},describe:"看直播 做任务 赢好礼",img:function(e){return e.Icon||"https://mediaservice-fe.volccdn.com/obj/vcloud-fe/livesaas-client/static/media/liveBonus.9771435f.png"},onClick:this.onLiveBonusClick.bind(this),statusRules:[{checker:function(e){return!(null==e||!e.Id)},buttonText:"立即参与",buttonType:"primary"}]}),t);var o=this;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){(0,_utils.setDataIfChanged)(n,{useDarkTheme:!n.data.forceLightTheme&&(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:{openMore:function(){this.selectComponent("#float-more").showFrame()},normalizeTextContext:function(e){return String((null==e?void 0:e.ImageTextContext)||"")},getMessageImages:function(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).filter(function(e){return(null==e?void 0:e.ImageTextType)===_constant.ImageTextTypes.IMAGE&&(null==e?void 0:e.ImageTextContext)}).map(function(e){return e.ImageTextContext})},normalizeDisplayContext:function(e,t){if((null==e?void 0:e.ImageTextType)===_constant.ImageTextTypes.TEXT){var n=this.normalizeTextContext(e);return{type:_constant.ImageTextTypes.TEXT,renderType:"text",text:n,segments:(0,_utils.parseTextWithLinks)(n)}}if((null==e?void 0:e.ImageTextType)===_constant.ImageTextTypes.IMAGE&&null!=e&&e.ImageTextContext){var o=this.getMessageImages(t),i=Math.max(o.findIndex(function(t){return t===e.ImageTextContext}),0);return{type:_constant.ImageTextTypes.IMAGE,renderType:"image",src:e.ImageTextContext,images:o,imageIndex:i,multiImages:o.length>1}}return null},setIconList:function(e){var t=this,n=[];e.forEach(function(e){var o=[],i=e.Context||[];i.forEach(function(e){var n=t.normalizeDisplayContext(e,i);if(n)o.push(n);else{var u=e.ImageTextType;if(!t.floatImage[u]&&null!=e&&e.CouponContext&&(u=_constant.ImageTextTypes.COUPON),u===_constant.ImageTextTypes.LUCKMONEY){var r,s,c,a,l=(null===(r=t.store)||void 0===r||null===(s=r.get)||void 0===s?void 0:s.call(r,"liveInfo"))||{};if(!(0,_luckymoney.isLuckymoneyEnabled)(l))return void(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-card"}))}if(t.floatImage[u]){var d=t.floatImage[u],y=d.field,f=d.fieldTitle,m=d.describe,p=d.statusRules,T=d.img,k=d.onClick,g=d.getTitle,h=(null==e?void 0:e[y])||(u===_constant.ImageTextTypes.COUPON?null==e?void 0:e.CouponContext:null);if(h){if(u===_constant.ImageTextTypes.COUPON){var I=(t.store.get("userInfo")||{}).levelId;if(!(0,_coupon.isCouponLevelEligible)(null!=I?I:"",h))return}var v=p.find(function(e){return"function"==typeof e.checker?e.checker(h):e.checker});if(!v)return;var b=v.buttonText,_=v.showCountDown,x=v.describe||m,C=("function"==typeof g?g(h):"")||(null==h?void 0:h[f])||(null==h?void 0:h.CouponName)||(null==h?void 0:h.Name)||(null==h?void 0:h.Title)||"";o.push({type:u,icon:"function"==typeof T?T(h):T,describeText:"function"==typeof x?x(h):x,title:"function"==typeof f?f(h):(0,_utils.getBySplit)(C),buttonText:b,buttonType:v.buttonType,onClick:function(){(k||v.onClick||function(){})(h)},showCountDown:"function"==typeof _?_(h):_,current:h})}}}}),o.length&&n.push(_objectSpread(_objectSpread({},e),{},{Context:o}))}),this.setData({iconList:n})},onQuestionClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Question)||this.store.set("QuizInfo",{visible:!0,currentId:e.QuizID})},onQuestionnaireClick:function(e){if(!(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Questionnaire)){var t=null==e?void 0:e.QuestionnaireId,n={questionnaireId:t,from:"card"};this.sdkInstance&&"function"==typeof this.sdkInstance.reportLogger?this.sdkInstance.reportLogger("mini_sdk_questionnaire_entry_click",n):console.log("[mini-sdk] Questionnaire open via card",n),t&&this.store.set("QuestionnaireInfo",{visible:!0,currentId:t,triggerTime:"image_text",from:"card",isAuto:!1,isBlocking:!1})}},onCheckInClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.CheckIn)||this.store.set("CheckInInfo",{visible:!0,currentId:e.CheckInId})},onLotteryClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Lottery)||this.store.set("AwardInfo",{visible:!0,currentId:e.ID})},onCouponClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Coupon)||this.sdkInstance.setShowCouponId(e.Id,"interactiveTool")},onLuckymoneyClick:function(e){(0,_featureProcess.lockFeatureProcess)(this.sdkInstance,_featureProcess.LockFeatureMap.Luckymoney)||this.isLogin(!0)&&this.sdkInstance.openLuckymoneyModal(e.RedPacketID)},onVoteClick:function(e){var t=null==e?void 0:e.VoteId;t&&this.store.set("VoteInfo",{visible:!0,currentId:t,triggerTime:"image_text",from:"card",isAuto:!1})},onAnnouncementClick:function(e){null!=e&&e.AnnouncementId&&this.store.set("AnnouncementInfo",{visible:!0,currentId:e.AnnouncementId,triggerTime:"image_text",from:"card",isAuto:!1})},onLiveBonusClick: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,"cardList"))},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)},getLuckymoneyStatusText:function(e){switch(this.getLuckymoneyStatus(e)){case _luckymoney.RedPacketStatus.OPENING:return"开启中";case _luckymoney.RedPacketStatus.SUCCESS:case _luckymoney.RedPacketStatus.FAILED:return"已结束";case _luckymoney.RedPacketStatus.INIT:case _luckymoney.RedPacketStatus.SENT:return"进行中";default:return""}},getLuckymoneyTitle:function(e){if(null!=e&&e.Name)return e.Name;var t=(null==e?void 0:e.TotalAmount)||0,n=(null==e?void 0:e.RedPacketType)===_luckymoney.RedPacketType.POINT;return null!=e&&e.HasNoLimit?n?"积分红包":"现金红包":n?"红包".concat(t).concat((null==e?void 0:e.RewardsPointsUnit)||""):"红包".concat((t||0)/100,"元")},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")},onClick:function(e){var t,n,o;null==e||null===(t=e.currentTarget)||void 0===t||null===(n=t.dataset)||void 0===n||null===(o=n.item)||void 0===o||o.onClick()},previewImage:function(e){var t,n=((null==e||null===(t=e.currentTarget)||void 0===t?void 0:t.dataset)||{}).src;n&&this.triggerEvent("previewimage",{src:n})},onTextLinkClick:function(e){var t,n,o=(null==e||null===(t=e.currentTarget)||void 0===t?void 0:t.dataset)||{},i=o.url,u=o.text;i&&(null===(n=this.sdkInstance)||void 0===n||n.emitEvent(_constant.EVENTS.PUBLIC.imageText.linkClick,{url:i,text:u||i}),(0,_jump.navigateToConfiguredWebview)(this.sdkInstance,_jump.JUMP_FEATURES.IMAGE_TEXT_LINK,i))}}}); |