| | |
| | | <div class="content-wrapper mb-[20px]"> |
| | | <!-- 720菜单 --> |
| | | <div class="side-menu z-[100]" v-if="currentView === '720'"> |
| | | <el-cascader popper-class="custom-dropdown" v-model="panoValue" :options="panoList" @change="handlePanoChange" :props="{ value: 'id',label: 'label',children: 'Children'}"> |
| | | </el-cascader> |
| | | <el-cascader popper-class="custom-dropdown" v-model="panoValue" :options="panoList" @change="handlePanoChange" :props="{ value: 'id',label: 'label',children: 'Children'}"/> |
| | | </div> |
| | | <!-- 项目实况--> |
| | | <div class="side-menu z-[100]" v-if="currentView === 'project'"> |
| | | <el-cascader popper-class="custom-dropdown" v-model="liveValue" :options="liveList" @change="handleLiveChange" :props="{ value: 'id',label: 'label',children: 'JSCProjectMonitorList'}"/> |
| | | </div> |
| | | |
| | | <!-- 主要内容区域 --> |
| | | |
| | | <!-- 主要内容区域 --> |
| | | <div class="main-content" :style="isFullScreen ? fullScreenStyle : ''" v-loading="isLoading"> |
| | | <!-- 模型 / 720 --> |
| | | <div class="w-full h-full" :style="isFullScreen ? fullScreenStyle : 'width: 100%; height: 100%;'" v-if="currentView === '720' || currentView === 'model'"> |
| | | <iframe id="model-iframe" class="content-frame w-full h-full" src="" frameborder="0" :style="isFullScreen ? fullScreenModelStyle : ''" v-if="currentView === 'model'"></iframe> |
| | | <div id="panoviewpreview" class="pano-frame w-full h-full" :style="isFullScreen ? fullScreenPanoStyle : ''" v-if="currentView === '720'"></div> |
| | | </div> |
| | | <iframe ref="panoiframe" id="panoviewpreview" class="pano-frame w-full h-full" :style="isFullScreen ? fullScreenPanoStyle : ''" v-if="currentView === '720'"></iframe> |
| | | </div> |
| | | <!-- 720全景图版本选择 --> |
| | | <!--<div class="w-full h-[120px] bg-[rgba(19,40,64,0.8)] absolute bottom-0 left-0 right-0 flex items-center py-[10px]" :style="isFullScreen ? 'z-index: 100; height:' : ''" v-if="currentView === '720'"> |
| | | <div v-for="item in panoVersionList" :key="item.value" :style="isFullScreen ? 'z-index: 100;' : ''"> |
| | |
| | | </div> |
| | | <!-- 项目 --> |
| | | <div class="w-full h-full" v-if="currentView === 'project'"> |
| | | <iframe id="scene-iframe" frameborder='0' allowfullscreen class="scene-frame w-full h-full"></iframe> |
| | | <video controls muted controlslist="nodownload" autoplay class="video-box" ref="videoElement" style="width: 100%; height: 100%; background-color: #000;"></video> |
| | | </div> |
| | | </div> |
| | | |
| | | </div> |
| | | <div class="chart-content"> |
| | | <div class="w-full h-[4vh] mb-[1vh]" :style="{ |
| | | <div |
| | | class="w-full h-[4vh] mb-[1vh]" :style="{ |
| | | backgroundImage: `url(${bottomImage})`, |
| | | backgroundRepeat: 'no-repeat', |
| | | backgroundPosition: 'center center', |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import flvjs from 'flv.js' |
| | | import { |
| | | nextTick |
| | | } from 'vue' |
| | |
| | | export default { |
| | | name: 'Home', |
| | | components: {}, |
| | | props: { |
| | | selectedId: { |
| | | type: String, |
| | | default: "", |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | liveValue:[], |
| | | playerStatus: '未就绪', |
| | | errorMessage:'', |
| | | flvPlayer:null, |
| | | videoSrc: "", |
| | | currentView: 'model', |
| | | chartOptions: { |
| | | id: 'shigongjinduChart', |
| | |
| | | }], |
| | | }], |
| | | panoValue: [], |
| | | backgroundImage: new URL('@/assets/images/backgrounds/cover_bg.png', |
| | | liveList: [], |
| | | backgroundImage: new URL('@/assets/images/backgrounds/cover_bg.png', |
| | | import.meta.url).href, |
| | | endDate: 0, |
| | | } |
| | | }, |
| | | watch: { |
| | | projectEndDate:{ |
| | | deep: true, |
| | | handler (newVal) { |
| | | console.log('newVal', newVal) |
| | | const date = new Date(newVal); |
| | | // 获取当前日期作为Date对象 |
| | | const now = new Date(); |
| | | // 计算两个日期的差异(毫秒) |
| | | const diffTime = Math.abs(now - date); |
| | | // 将毫秒转换为天数 |
| | | const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); |
| | | this.endDate = diffDays |
| | | } |
| | | } |
| | | }, |
| | | computed: { |
| | |
| | | return getProjectEndDate() |
| | | } |
| | | }, |
| | | watch: { |
| | | projectEndDate:{ |
| | | deep: true, |
| | | handler (newVal) { |
| | | console.log('newVal', newVal) |
| | | const date = new Date(newVal); |
| | | // 获取当前日期作为Date对象 |
| | | const now = new Date(); |
| | | // 计算两个日期的差异(毫秒) |
| | | const diffTime = Math.abs(now - date); |
| | | // 将毫秒转换为天数 |
| | | const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); |
| | | this.endDate = diffDays |
| | | } |
| | | }, |
| | | selectedId: { |
| | | handler(newVal) { |
| | | console.log("实况界面接收到的数据:", newVal); |
| | | // 处理数据变化的逻辑 |
| | | this.getProjectLive(newVal); |
| | | }, |
| | | deep: true, // 深度监听对象内部变化 |
| | | immediate: true, // 立即执行一次 |
| | | }, |
| | | }, |
| | | mounted() { |
| | | setTimeout(() => { |
| | | console.log('projectEndDate', getProjectEndDate()) |
| | | this.modelShow() |
| | | }, 1000) |
| | | }, |
| | | updated() { |
| | | if (this.$refs.panoiframe) { |
| | | // IE |
| | | if (this.$refs.panoiframe.attachEvent) { |
| | | this.$refs.panoiframe.attachEvent('onload', () => { |
| | | console.log('loading') |
| | | // 加载成功 |
| | | this.isLoading = false; |
| | | }); |
| | | } else { |
| | | this.$refs.panoiframe.onload = () => { |
| | | console.log('loading2') |
| | | // 加载成功 |
| | | this.isLoading = false; |
| | | }; |
| | | } |
| | | } |
| | | }, |
| | | |
| | | methods: { |
| | | getItemImg (item) { |
| | |
| | | if (this.isFullScreen) { |
| | | const clientX = document.documentElement.clientWidth || document.body.clientWidth |
| | | const clientY = document.documentElement.clientHeight || document.body.clientHeight |
| | | this.fullScreenPanoStyle = `width: 100%; height: 100%; z-index: 100; ` |
| | | this.fullScreenStyle = `width: ${clientX - 40}px; height: ${clientY - 120}px; margin:20px; position: fixed; top: 80px; left: 0;z-index: 100;background-color: #fff;overflow: hidden;` |
| | | if (this.currentView === '720') { |
| | | this.fullScreenStyle = `width: ${clientX - 40}px; height: ${clientY - 120}px; margin:20px; position: fixed; top: 80px; left: 0;z-index: 100;background-color: #fff;overflow: hidden;` |
| | | this.fullScreenPanoStyle = `width: 100%; height: 100%; z-index: 100; ` |
| | | } else if(this.currentView === 'model'){ |
| | | this.fullScreenModelStyle = `width: ${clientX - 40}px; height: ${clientY - 120}px; margin:20px; position: fixed; top: 80px; left: 0;z-index: 100;background-color: #fff;overflow: hidden;` |
| | | } |
| | |
| | | this.isLoading = true |
| | | this.currentView = view |
| | | if (view === 'model') { |
| | | removepano('krpanoSWFObject') |
| | | nextTick(() => { |
| | | this.modelShow() |
| | | }) |
| | |
| | | }) |
| | | } else if (view === 'project') { |
| | | nextTick(() => { |
| | | removepano('krpanoSWFObject') |
| | | this.sceneShow() |
| | | this.getProjectLive(this.selectedId) |
| | | }) |
| | | } |
| | | }, |
| | | handlePanoChange(value) { |
| | | console.log('value', value) |
| | | this.isLoading = true |
| | | this.panoList.forEach(item => { |
| | | if (item.LabelId === value[0]) { |
| | | item.Children.forEach(item2 => { |
| | |
| | | const projectId = this.projectId |
| | | let ifrSrc = '' |
| | | console.log('模型中查看') |
| | | // ifrSrc = `${window.ProjectConfig.modelUrl}?token=${token}&projectId=${projectId}&isPreview=1&edit=false` |
| | | // ifrSrc = `${window.ProjectConfig.modelUrl}?token=${token}&projectId=${projectId}&isPreview=1&edit=false` |
| | | ifrSrc = window.ProjectConfig.modelUrl |
| | | iframe.src = ifrSrc |
| | | console.log('加载iframe地址', ifrSrc) |
| | | this.isLoading = false |
| | | }, |
| | | panoShow() { |
| | | this.isLoading = false |
| | | const data = { |
| | | projectId: this.projectId |
| | | } |
| | |
| | | }) |
| | | }, |
| | | panoPreview(item, scene) { |
| | | removepano('krpanoSWFObject') |
| | | const basepath = `${window.ProjectConfig.panoUrl}/Panorama${item.PbUrl}/vtour/` |
| | | const xmlurl = `${basepath}tour.xml?r=${(Math.random() * 100000 + 1)}` |
| | | let setting = {} |
| | | if (scene) { |
| | | const scenename = 'scene_' + scene.PsScenename |
| | | setting = { |
| | | startscene: scenename |
| | | } |
| | | } |
| | | this.$nextTick(() => { |
| | | embedpano({ |
| | | xml: xmlurl, |
| | | target: 'panoviewpreview', |
| | | basepath, |
| | | vars: setting, |
| | | html5: 'auto', |
| | | passQueryParameters: true, |
| | | // /LinkShare/PanoShare/:PanoId/:organizeId/:StartScene |
| | | // PanoId:全景图的id,organizeId:项目id,StartScene:初始场景id |
| | | const panoFrame = document.getElementById('panoviewpreview') |
| | | nextTick(() => { |
| | | if(panoFrame.src){ |
| | | panoFrame.removeAttribute("src"); //先移除上一次的src地址 |
| | | } |
| | | setTimeout(()=>{ |
| | | let ifrSrc = '' |
| | | ifrSrc = `${window.ProjectConfig.panoUrl}/#/LinkShare/PanoShare/${scene.PbGuid}/${this.projectId}/${scene.PsScenename}` |
| | | panoFrame.setAttribute("src",ifrSrc); |
| | | }, 300) |
| | | |
| | | }) |
| | | }) |
| | | // removepano('krpanoSWFObject') |
| | | // const basepath = `${window.ProjectConfig.panoUrl}/Panorama${item.PbUrl}/vtour/` |
| | | // const xmlurl = `${basepath}tour.xml?r=${(Math.random() * 100000 + 1)}` |
| | | // let setting = {} |
| | | // if (scene) { |
| | | // const scenename = 'scene_' + scene.PsScenename |
| | | // setting = { |
| | | // startscene: scenename |
| | | // } |
| | | // } |
| | | // this.$nextTick(() => { |
| | | // embedpano({ |
| | | // xml: xmlurl, |
| | | // target: 'panoviewpreview', |
| | | // basepath, |
| | | // vars: setting, |
| | | // html5: 'auto', |
| | | // passQueryParameters: true, |
| | | // }) |
| | | // }) |
| | | }, |
| | | sceneShow() { |
| | | const iframe = document.getElementById('scene-iframe') |
| | |
| | | mounted() { |
| | | this.isLoading = true |
| | | this.modelShow() |
| | | } |
| | | }, |
| | | /** |
| | | * 获取项目实况数据 |
| | | * @param {string} bindId - 标段ID |
| | | */ |
| | | getProjectLive(bindId) { |
| | | const params = { |
| | | bindId, |
| | | }; |
| | | HomeAPI.GetJSCProjectMonitor(params).then(res => { |
| | | if (res.Ret === 1) { |
| | | const result = res.Data |
| | | if (result.length > 0) { |
| | | console.log('实况数据', result); |
| | | result.forEach(element => { |
| | | element.id = element.BindId |
| | | element.label = element.BindName |
| | | element.JSCProjectMonitorList.forEach(item => { |
| | | item.id = item.MonitorUrl |
| | | item.label = item.MonitorName |
| | | }); |
| | | }); |
| | | } |
| | | this.isLoading = false |
| | | this.liveList = result |
| | | this.liveValue = [result[0].id, result[0].JSCProjectMonitorList[0].id] |
| | | this.videoSrc = this.liveList[0].JSCProjectMonitorList[0].MonitorUrl |
| | | this.loadVideo(); |
| | | } |
| | | }) |
| | | }, |
| | | /** |
| | | * 处理实况的实时变化 |
| | | * @param value |
| | | */ |
| | | handleLiveChange(value) { |
| | | console.log('实况变化', value); |
| | | this.videoSrc = value[1] |
| | | this.loadVideo(); |
| | | }, |
| | | // 检查FLV支持 |
| | | checkFlvSupport() { |
| | | if (!flvjs.isSupported()) { |
| | | this.errorMessage = '当前浏览器不支持FLV播放' |
| | | this.playerStatus = '不支持' |
| | | return false |
| | | } |
| | | this.playerStatus = '已就绪' |
| | | return true |
| | | }, |
| | | /** |
| | | * 销毁播放器实例 |
| | | */ |
| | | destroyPlayer() { |
| | | if (this.flvPlayer) { |
| | | try { |
| | | this.flvPlayer.pause() |
| | | this.flvPlayer.unload() |
| | | this.flvPlayer.detachMediaElement() |
| | | this.flvPlayer.destroy() |
| | | this.flvPlayer = null |
| | | } catch (error) { |
| | | console.error('销毁播放器时出错:', error) |
| | | } |
| | | } |
| | | this.isReady = false |
| | | }, |
| | | /** |
| | | * 加载视频 |
| | | */ |
| | | loadVideo() { |
| | | if (!this.videoSrc.trim()) { |
| | | this.errorMessage = '请播放有效的视频URL' |
| | | return |
| | | } |
| | | |
| | | if (!this.checkFlvSupport()) { |
| | | return |
| | | } |
| | | this.errorMessage = '' |
| | | this.playerStatus = '加载中...' |
| | | |
| | | try { |
| | | // 销毁旧的播放器实例 |
| | | this.destroyPlayer() |
| | | |
| | | // 创建FLV播放器 |
| | | this.flvPlayer = flvjs.createPlayer({ |
| | | type: 'flv', |
| | | url: this.videoSrc, |
| | | isLive: false, // 如果是直播流,设置为true |
| | | cors: true, |
| | | withCredentials: false |
| | | }, { |
| | | enableWorker: false, |
| | | enableStashBuffer: true, |
| | | stashInitialSize: 128, |
| | | autoCleanupSourceBuffer: true |
| | | }) |
| | | |
| | | // 绑定事件监听器 |
| | | // this.bindPlayerEvents() |
| | | |
| | | // 绑定到video元素 |
| | | this.flvPlayer.attachMediaElement(this.$refs.videoElement) |
| | | |
| | | // 开始加载 |
| | | this.flvPlayer.load() |
| | | |
| | | } catch (error) { |
| | | console.error('加载视频失败:', error) |
| | | this.errorMessage = '视频加载失败: ' + error.message |
| | | this.playerStatus = '加载失败' |
| | | } |
| | | }, |
| | | } |
| | | |
| | | } |
| | | </script> |
| | | |