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

1 line
11 KiB
JavaScript

"use strict";var _theme=require("../../utils/theme"),_lodash=_interopRequireDefault(require("../../lib/lodash.isequal")),_index=_interopRequireDefault(require("../../index")),_singleLogin=require("../../utils/singleLogin"),_questionnaireManager=require("../../utils/questionnaire-manager"),_constant=require("../../utils/constant"),_liveDescription=require("../../utils/live-description"),_utils=require("../../utils/utils"),_notification=require("../../utils/notification"),_bottomIcon=require("../../utils/icons/bottom-icon");function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}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)}function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(n),!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(t,e,n){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,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 n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!==_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}var LinkOpenStatus={NO:0,OPEN:1,CLOSE:2},INITIAL_CONTAINER_STYLE="background-color: #000;",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:{colorThemeIndex:"",IsUseDarkTheme:!1,containerStyle:INITIAL_CONTAINER_STYLE,MobileBackgroundColor:"#000",MobileBackImage:"",isMobileBackgroundBlur:!1,showHeaderImage:!1,HeaderImageUrl:"",themeColor:{Fill_7:"#E5E8EF",Background_1:"#ffffff",FontColor:"#1D2129",BackFontColor:"#202124",InteractionColor:"#F2F3F8",PresenterChatColor:"#FA9600"},openConnect:!1,showPlayer:!0,userID:"",debug:!1,sdkInitLoading:!1,questionnaireBlocking:!1,activeTab:0,tabList:[],renderedTabMap:{0:!0},hasImageFloatConfig:!1,showFloatingContainer:!1,productCounts:{},adFloatingVisible:!1,floatCardVisible:!1,imageTextFloatIconNum:3,landscapeBottomIconBuckets:{toolbarIconList:[],playerIconList:[],playerDrawerIconList:[]},showCountdown:!1,previewImageVisible:!1,previewImageSrc:"",editorEntering:!1,externalEditorCloseSignal:0,hasLiveDescription:!1},observers:{activeTab:function(t){t<0||this.data.renderedTabMap[t]||this.setData(_defineProperty({},"renderedTabMap.".concat(t),!0))},sdkInstance:function(t){t&&this.initSDK(t)},configs:function(t){if(t&&!this.data.sdkInstance){var e=new _index.default(t);this.setData({sdkInstance:e}),this.initSDK(e)}}},lifetimes:{detached:function(){"function"==typeof this._unsub&&this._unsub(),this._unsub=null,this.unbindBottomIconClick()}},methods:{isCommentTab:function(t,e){return!(null==t||!t[e])&&"COMMENT"===t[e].key},initSDK:function(t){var e=t.store,n=this;n._questionnaireBlockingReleased=!1,"function"==typeof this._unsub&&this._unsub(),this._unsub=null,this._unsub=e.get({iconList:function(){n.syncLandscapeBottomIconBuckets()},liveInfo:function(t){var e,i,o,a,r,s;if(t){var l={};n._questionnaireBlockingReleased||(0,_questionnaireManager.shouldBlockLivePageInQuestionnaire)(t)&&(l.questionnaireBlocking=!0);var c=(0,_theme.resolveMobileAppearanceConfig)(null==t?void 0:t.Basic),u=(0,_theme.isUseDarkTheme)(null==t?void 0:t.Basic),d=c.ColorThemeIndex,h=c.MobileBackgroundColor,m=c.MobileBackImage,f=c.isMobileBackgroundBlur,b=c.showHeaderImage,I=c.HeaderImageUrl,g=c.themeColor,v=_objectSpread(_objectSpread({},c),{},{IsUseDarkTheme:u});(0,_theme.isMobileAppearanceConfigChanged)(v,n.data)&&Object.assign(l,{MobileBackgroundColor:h,MobileBackImage:m,isMobileBackgroundBlur:f,showHeaderImage:b,HeaderImageUrl:I,containerStyle:m?INITIAL_CONTAINER_STYLE:"background-color: ".concat(h,";"),themeColor:g,colorThemeIndex:d,IsUseDarkTheme:u});var p=t.IsAudienceLinkEnabled===LinkOpenStatus.OPEN;l.openConnect=p;var C=!!(0,_liveDescription.resolveLiveDescription)(t);l.hasLiveDescription=C;var _=null==t||null===(e=t.Menus)||void 0===e||null===(i=e.Menus)||void 0===i?void 0:i.some(function(t){return 4===t.Type}),T=1===(null==t||null===(o=t.Basic)||void 0===o?void 0:o.IsCountdownEnable)&&(null==t||null===(a=t.Basic)||void 0===a?void 0:a.Status)===_constant.LIVE_STATUS.预告&&Number(null==t||null===(r=t.Basic)||void 0===r?void 0:r.Countdown)>0;Object.assign(l,{hasImageFloatConfig:_,showCountdown:T});var k=(null==t||null===(s=t.Menus)||void 0===s?void 0:s.ProductV2)||{},y={};Object.keys(k).forEach(function(t){var e,n=(null===(e=k[t])||void 0===e?void 0:e.Product)||[];y[t]=n.length}),(0,_lodash.default)(y,n.data.productCounts)||(l.productCounts=y),(0,_utils.setDataIfChanged)(n,l)}},userInfo:function(t){void 0!==(null==t?void 0:t.userId)&&n.setData({userID:null==t?void 0:t.userId})},"ui.sdkInitLoading":function(t){(0,_utils.setDataIfChanged)(n,{sdkInitLoading:!!t})},tabList:function(t){var e=(Array.isArray(t)?t:[]).filter(function(t){return t.enable});if(e.sort(function(t,e){return t.index-e.index}),!(0,_lodash.default)(e,n.data.tabList)){var i=e[n.data.activeTab]?n.data.activeTab:0,o=n.isCommentTab(e,i);n.setData({tabList:e,activeTab:i,showFloatingContainer:o})}},banStatus:function(t){(0,_singleLogin.handleBanStatusChange)(n,t)}}),this.bindBottomIconClick(t)},syncLandscapeBottomIconBuckets:function(){var t,e,n=this.data.sdkInstance;if(n){var i=null===(t=n.store)||void 0===t||null===(e=t.get)||void 0===e?void 0:e.call(t,"iconList"),o=(0,_bottomIcon.buildBottomIconViewModel)(n,_bottomIcon.BOTTOM_ICON_ROOM_TYPE.LANDSCAPE,{defaultMaxVisibleCount:1,sourceIconList:Array.isArray(i)?i:[]}),a=o.outerIconList,r=o.innerIconList,s=r.slice(0,1),l=r.slice(1);(0,_utils.setDataIfChanged)(this,{landscapeBottomIconBuckets:{toolbarIconList:a,playerIconList:s,playerDrawerIconList:l}})}},openLandscapePlayerMoreDrawer:function(){var t,e;null===(t=this.selectComponent("#volc-landscape-player-more-drawer"))||void 0===t||null===(e=t.showFrame)||void 0===e||e.call(t)},handleLandscapePlayerMoreDrawerIconTap:function(t){var e,n,i=t.currentTarget.dataset.key,o=(this.data.landscapeBottomIconBuckets.playerDrawerIconList||[]).find(function(t){return t.key===i});null===(e=this.selectComponent("#volc-landscape-player-more-drawer"))||void 0===e||null===(n=e.hideFrame)||void 0===n||n.call(e),(0,_bottomIcon.dispatchBottomIconClick)({sdkInstance:this.data.sdkInstance,icon:o,roomType:_bottomIcon.BOTTOM_ICON_ROOM_TYPE.LANDSCAPE})},bindBottomIconClick:function(t){var e=this;t&&this._bottomIconClickSdk!==t&&(this.unbindBottomIconClick(),this._bottomIconClickSdk=t,this._onBottomIconClick=function(n){var i,o=null==n||null===(i=n.icon)||void 0===i?void 0:i.key;o!==_bottomIcon.BOTTOM_ICON_KEY.NOTIFICATION_SWITCH?"IMAGE_TEXT_LIVE"!==o?"RICHTEXT"===o&&e.openTabByKey("RICHTEXT"):e.openImageTextTab():(0,_notification.toggleNotificationStateWithToast)(t.store)},t.on(_constant.EVENTS.PUBLIC.bottomIcon.click,this._onBottomIconClick))},unbindBottomIconClick:function(){var t,e;this._bottomIconClickSdk&&this._onBottomIconClick&&(null===(t=(e=this._bottomIconClickSdk).off)||void 0===t||t.call(e,_constant.EVENTS.PUBLIC.bottomIcon.click,this._onBottomIconClick)),this._bottomIconClickSdk=null,this._onBottomIconClick=null},openTabByKey:function(t){var e=this.data.tabList.findIndex(function(e){return e.key===t});e<0||this.setData({activeTab:e,showFloatingContainer:"COMMENT"===t})},commentCheck:function(){this.triggerEvent("commentCheck")},openChatInput:function(){var t=this,e=this.data.tabList.findIndex(function(t){return"COMMENT"===t.key});if(!(e<0)){var n=function(){var e,n;return null===(e=t.selectComponent("#landscapeChat"))||void 0===e||null===(n=e.openChatInput)||void 0===n?void 0:n.call(e)};this.data.activeTab!==e?this.setData({activeTab:e,showFloatingContainer:!0},n):n()}},onQuestionnaireBlockingChange:function(t){var e=!!(t&&t.detail&&t.detail.blocking);(0,_utils.setDataIfChanged)(this,{questionnaireBlocking:e}),e||(this._questionnaireBlockingReleased=!0)},hangUpConnect:function(){this.triggerEvent("hangUpConnect")},changePlayerStatus:function(t){this.setData({showPlayer:t.detail})},debugClick:function(){var t=this,e=(new Date).getTime();count=e-lastTime<waitTime?count+1:1,lastTime=(new Date).getTime(),clearTimeout(timer),timer=setTimeout(function(){clearTimeout(timer),console.log(count),count>4&&(t.setData({debug:!0}),clearTimeout(timer))},waitTime+10)},copyText:function(){wx.setClipboardData({data:this.data.userID,success:function(){wx.getClipboardData({success:function(){wx.showToast({title:"复制成功"})}})}})},onTabClick:function(t){if(this.data.editorEntering)this.closeEditorFromMask();else{var e=t.detail.index,n=this.isCommentTab(this.data.tabList,e);this.setData({activeTab:e,showFloatingContainer:n})}},onTabChange:function(t){if(this.data.editorEntering)this.closeEditorFromMask();else{var e=t.detail.index,n=this.isCommentTab(this.data.tabList,e);this.setData({activeTab:e,showFloatingContainer:n})}},openImageTextTab:function(){var t=this.data.tabList.findIndex(function(t){return"IMAGETEXT"===t.key});t<0||this.setData({activeTab:t,showFloatingContainer:!1})},handleLandscapeBottomIconTap:function(t){var e,n=null===(e=t.detail)||void 0===e?void 0:e.icon;(0,_bottomIcon.dispatchBottomIconClick)({sdkInstance:this.data.sdkInstance,icon:n,roomType:_bottomIcon.BOTTOM_ICON_ROOM_TYPE.LANDSCAPE})},onAdFloatingChange:function(t){var e=t.detail.visible;if(this.data.adFloatingVisible!==e){var n=(e?1:0)+(this.data.floatCardVisible?1:0);this.setData({adFloatingVisible:e,imageTextFloatIconNum:Math.max(1,3-n)})}},onFloatCardChange:function(t){var e=t.detail.visible;if(this.data.floatCardVisible!==e){var n=(this.data.adFloatingVisible?1:0)+(e?1:0);this.setData({floatCardVisible:e,imageTextFloatIconNum:Math.max(1,3-n)})}},onBanContinue:function(t){(0,_singleLogin.handleBanContinue)(this,this.data.sdkInstance,t.detail)},openPreviewImage:function(t){var e,n=null===(e=t.detail)||void 0===e?void 0:e.src;n&&this.setData({previewImageVisible:!0,previewImageSrc:n})},closePreviewImage:function(){this.data.previewImageVisible&&this.setData({previewImageVisible:!1,previewImageSrc:""})},onEditorStateChange:function(t){var e,n=!(null===(e=t.detail)||void 0===e||!e.entering);this.data.editorEntering!==n&&this.setData({editorEntering:n})},onAttentionInteraction:function(){var t,e;null===(t=this.selectComponent("#attentionDetection"))||void 0===t||null===(e=t.recordInteraction)||void 0===e||e.call(t)},closeEditorFromMask:function(){this.data.editorEntering&&this.setData({editorEntering:!1,externalEditorCloseSignal:this.data.externalEditorCloseSignal+1})}}});