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

1 line
8.1 KiB
JavaScript

"use strict";var _theme=require("../../utils/theme"),_index=_interopRequireDefault(require("../../index")),_singleLogin=require("../../utils/singleLogin"),_questionnaireManager=require("../../utils/questionnaire-manager"),_liveDescription=require("../../utils/live-description"),_constant=require("../../utils/constant"),_utils=require("../../utils/utils"),_peopleCount=require("../../utils/people-count");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 ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}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 i=n.call(e,t||"default");if("object"!==_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var LinkOpenStatus={NO:0,OPEN:1,CLOSE:2},INITIAL_CONTAINER_STYLE="background-color: #000;",PORTRAIT_STATUS_VALUES=new Set([_constant.LIVE_STATUS.预告,_constant.LIVE_STATUS.结束]),count=0,timer=null,waitTime=200,lastTime=(new Date).getTime();Component({properties:{style:{type:String,value:"width: 100vw; height: 100vh;"},sdkInstance:{type:Object,value:null},configs:{type:Object,value:null}},data:{containerStyle:INITIAL_CONTAINER_STYLE,MobileBackgroundColor:"#000",MobileBackImage:"",isMobileBackgroundBlur:!1,showHeaderImage:!1,HeaderImageUrl:"",headerBannerClosed:!1,openConnect:!1,showPlayer:!0,userID:"",debug:!1,showImageFloat:!1,sdkInitLoading:!1,questionnaireBlocking:!1,colorThemeIndex:"",themeColor:{Fill_7:"#E5E8EF",Background_1:"#ffffff",FontColor:"#1D2129",BackFontColor:"#202124",InteractionColor:"#F2F3F8",PresenterChatColor:"#FA9600"},previewImageVisible:!1,previewImageSrc:"",hasLiveDescription:!1,showPortraitStatusTag:!1,portraitStatusText:"",imageTextCardDrawerReady:!1,showPeopleCount:!1},observers:{sdkInstance:function(e){e&&this.initSDK(e)},configs:function(e){if(e&&!this.data.sdkInstance){var t=new _index.default(e);this.setData({sdkInstance:t}),this.initSDK(t)}}},lifetimes:{attached:function(){console.log("volc-live-portrait attached")},ready:function(){this.initSDK(this.properties.sdkInstance)},detached:function(){"function"==typeof this._unsub&&this._unsub(),this._unsub=null,this._initializedSdk=null,this.unbindImageTextIconClick()}},methods:{initSDK:function(e){if(e&&this._initializedSdk!==e){this._initializedSdk=e,this.sdkInstance=e;var t=e.store,n=this;n._questionnaireBlockingReleased=!1,this.bindImageTextIconClick(e),this._unsub=t.get({liveInfo:function(e){var t,i,o;if(e){var a={};n._questionnaireBlockingReleased||(0,_questionnaireManager.shouldBlockLivePageInQuestionnaire)(e)&&(a.questionnaireBlocking=!0);var r=(0,_theme.resolveMobileAppearanceConfig)(null==e?void 0:e.Basic,{isPortrait:!0}),l=r.ColorThemeIndex,s=r.MobileBackgroundColor,c=r.MobileBackImage,u=r.isMobileBackgroundBlur,d=r.HeaderImageUrl,g=r.themeColor,h=!!d&&!n.data.headerBannerClosed,m=_objectSpread(_objectSpread({},r),{},{showHeaderImage:h});(0,_theme.isMobileAppearanceConfigChanged)(m,n.data)&&Object.assign(a,{MobileBackgroundColor:s,MobileBackImage:c,isMobileBackgroundBlur:u,showHeaderImage:h,HeaderImageUrl:d,containerStyle:c?INITIAL_CONTAINER_STYLE:"background-color: ".concat(s,";"),themeColor:g,colorThemeIndex:l});var I=e.IsAudienceLinkEnabled===LinkOpenStatus.OPEN;a.openConnect=I;var f=!!(0,_liveDescription.resolveLiveDescription)(e);a.hasLiveDescription=f;var p=Number(null==e||null===(t=e.Basic)||void 0===t?void 0:t.Status),v=PORTRAIT_STATUS_VALUES.has(p),_=_constant.LIVE_STATUS_TEXT_MAP[p]||"";Object.assign(a,{showPortraitStatusTag:v,portraitStatusText:v?_:"",showPeopleCount:(0,_peopleCount.shouldShowPeopleCount)(e)}),a.showImageFloat=null==e||null===(i=e.Menus)||void 0===i||null===(o=i.Menus)||void 0===o?void 0:o.some(function(e){return 4===e.Type}),(0,_utils.setDataIfChanged)(n,a)}},userInfo:function(e){void 0!==(null==e?void 0:e.userId)&&(0,_utils.setDataIfChanged)(n,{userID:null==e?void 0:e.userId})},"ui.sdkInitLoading":function(e){(0,_utils.setDataIfChanged)(n,{sdkInitLoading:!!e})},LiveBonusInfo:function(e){null!=e&&e.visible&&n.closeImageTextCardDrawer()},banStatus:function(e){(0,_singleLogin.handleBanStatusChange)(n,e)}})}},commentCheck:function(){this.triggerEvent("commentCheck")},openChatInput:function(){var e,t;null===(e=this.selectComponent("#portraitChat"))||void 0===e||null===(t=e.openChatInput)||void 0===t||t.call(e)},openImageTextCardDrawer:function(){var e=this,t=function(){var t,n;return null===(t=e.selectComponent("#portrait-image-text-card-drawer"))||void 0===t||null===(n=t.showFrame)||void 0===n?void 0:n.call(t)};this.data.imageTextCardDrawerReady?t():this.setData({imageTextCardDrawerReady:!0},t)},bindImageTextIconClick:function(e){var t=this;e&&this._imageTextIconClickSdk!==e&&(this.unbindImageTextIconClick(),this._imageTextIconClickSdk=e,this._onImageTextIconClick=function(e){var n;"IMAGE_TEXT_LIVE"===(null==e||null===(n=e.icon)||void 0===n?void 0:n.key)&&t.openImageTextCardDrawer()},e.on(_constant.EVENTS.PUBLIC.bottomIcon.click,this._onImageTextIconClick))},unbindImageTextIconClick:function(){this._imageTextIconClickSdk&&this._onImageTextIconClick&&this._imageTextIconClickSdk.off(_constant.EVENTS.PUBLIC.bottomIcon.click,this._onImageTextIconClick),this._imageTextIconClickSdk=null,this._onImageTextIconClick=null},closeImageTextCardDrawer:function(){var e,t;null===(e=this.selectComponent("#portrait-image-text-card-drawer"))||void 0===e||null===(t=e.hideFrame)||void 0===t||t.call(e,{silent:!0}),this.cancelImageTextCardDrawer()},cancelImageTextCardDrawer:function(){var e,t,n=null===(e=this.data.sdkInstance)||void 0===e?void 0:e.store,i=null==n||null===(t=n.get)||void 0===t?void 0:t.call(n,"imageTextInfo");n&&i&&n.set("imageTextInfo",_objectSpread(_objectSpread({},i),{},{countUnreadImageTextLive:0,arrUnreadImageTextLive:[]}))},onQuestionnaireBlockingChange:function(e){var t=!!(e&&e.detail&&e.detail.blocking);(0,_utils.setDataIfChanged)(this,{questionnaireBlocking:t}),t||(this._questionnaireBlockingReleased=!0)},hangUpConnect:function(){this.triggerEvent("hangUpConnect")},changePlayerStatus:function(e){this.setData({showPlayer:e.detail})},debugClick:function(){var e=this,t=(new Date).getTime();count=t-lastTime<waitTime?count+1:1,lastTime=(new Date).getTime(),clearTimeout(timer),timer=setTimeout(function(){clearTimeout(timer),console.log(count),count>4&&(e.setData({debug:!0}),clearTimeout(timer))},waitTime+10)},copyText:function(){wx.setClipboardData({data:this.data.userID,success:function(){wx.getClipboardData({success:function(){wx.showToast({title:"复制成功"})}})}})},openPreviewImage:function(e){var t,n=null===(t=e.detail)||void 0===t?void 0:t.src;n&&this.setData({previewImageVisible:!0,previewImageSrc:n})},closePreviewImage:function(){this.data.previewImageVisible&&this.setData({previewImageVisible:!1,previewImageSrc:""})},onAttentionInteraction:function(){var e,t;null===(e=this.selectComponent("#attentionDetection"))||void 0===e||null===(t=e.recordInteraction)||void 0===t||t.call(e)},closeHeaderBanner:function(){this.data.headerBannerClosed||this.setData({headerBannerClosed:!0,showHeaderImage:!1})},catchNone:function(){},onBanContinue:function(e){(0,_singleLogin.handleBanContinue)(this,this.data.sdkInstance,e.detail)}}});