|
|
@@ -0,0 +1,245 @@
|
|
|
+import { defineComponent, onMounted, ref } from 'vue';
|
|
|
+import { storeToRefs } from 'pinia';
|
|
|
+import { useRoute } from 'vue-router';
|
|
|
+import Other from './components/other';
|
|
|
+import Menu from './components/menu';
|
|
|
+import GuiLoading from './components/gui-loading';
|
|
|
+import Popup from './components/popup/index.vue';
|
|
|
+import HotSpotList from './components/hot-spot-list';
|
|
|
+import type { HotDataType } from '@/types';
|
|
|
+import useBaseStore from '@/store/module/base';
|
|
|
+import { CAMERA_TYPE_ENUM, CameraTypeMap, type HotResourceType } from '@/types/home';
|
|
|
+import './index.zgh.scss';
|
|
|
+
|
|
|
+export default defineComponent({
|
|
|
+ name: 'home',
|
|
|
+ components: {
|
|
|
+ Other,
|
|
|
+ GuiLoading,
|
|
|
+ Popup,
|
|
|
+ },
|
|
|
+ setup() {
|
|
|
+ const baseStore = useBaseStore();
|
|
|
+ const { checkedHotData, hotVisible } = storeToRefs(baseStore);
|
|
|
+ const route = useRoute();
|
|
|
+ const cameraMode = ref(CAMERA_TYPE_ENUM.PANORAMA);
|
|
|
+ let hotResources: HotResourceType[] = [];
|
|
|
+ let hotTagLoaded = false;
|
|
|
+
|
|
|
+ const init = () => {
|
|
|
+ // @ts-ignore
|
|
|
+ const kankan = new KanKan({
|
|
|
+ dom: '#player',
|
|
|
+ num: route.query.m,
|
|
|
+ server: 'https://www.4dkankan.com',
|
|
|
+ });
|
|
|
+
|
|
|
+ kankan.use('MinMap', {
|
|
|
+ theme: {
|
|
|
+ camera_fillStyle: '#fc7107',
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ // 全部热点数据
|
|
|
+ kankan.store.on('tags', (tags) => {
|
|
|
+ baseStore.setState('hotList', tags.tags);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 监听看看的模式
|
|
|
+ kankan.Camera.on('mode.beforeChange', ({ toMode }) => {
|
|
|
+ cameraMode.value = CameraTypeMap[toMode];
|
|
|
+ });
|
|
|
+
|
|
|
+ // 有关球幕视频控制背景音乐
|
|
|
+ kankan.Scene.on('panorama.videorenderer.startvideo', () => {
|
|
|
+ // 进入球幕视频
|
|
|
+ handleBgMusic(false);
|
|
|
+ });
|
|
|
+ kankan.Scene.on('panorama.videorenderer.resumerender', () => {
|
|
|
+ // 进入球幕视频
|
|
|
+ handleBgMusic(false);
|
|
|
+ });
|
|
|
+ kankan.Scene.on('panorama.videorenderer.suspendrender', () => {
|
|
|
+ // 退出球幕视频
|
|
|
+ handleBgMusic(true);
|
|
|
+ });
|
|
|
+
|
|
|
+ window.kankan = kankan;
|
|
|
+ baseStore.setState('kankanInited', true);
|
|
|
+ };
|
|
|
+
|
|
|
+ const initHot = () => {
|
|
|
+ console.log('热点初始化', typeof window.kankan);
|
|
|
+
|
|
|
+ // 热点
|
|
|
+ window.kankan
|
|
|
+ .use('TagView', {
|
|
|
+ // 自定义热点图标
|
|
|
+ render(data) {
|
|
|
+ const prefix = '彩蛋&';
|
|
|
+ const preIndex = data.title.indexOf(prefix);
|
|
|
+
|
|
|
+ console.log('初始化彩蛋:', preIndex, data.title);
|
|
|
+ if (preIndex === -1) return null;
|
|
|
+
|
|
|
+ const number = data.title.slice(preIndex + prefix.length);
|
|
|
+ const item = hotResources.find((i) => i.sort === Number(number));
|
|
|
+
|
|
|
+ if (item?.flag) return '<div></div>';
|
|
|
+
|
|
|
+ return `<div class='hot'></div>`;
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .then((TagView) => {
|
|
|
+ window.TagView = TagView;
|
|
|
+
|
|
|
+ // 监听手动点击事件
|
|
|
+ TagView.on('click', (e) => {
|
|
|
+ const prefix = '彩蛋&';
|
|
|
+ const preIndex = e.data.title.indexOf(prefix);
|
|
|
+
|
|
|
+ if (preIndex > -1) {
|
|
|
+ // 触发彩蛋
|
|
|
+ const number = e.data.title.slice(preIndex + prefix.length);
|
|
|
+ // @ts-ignore
|
|
|
+ window.parent?.FaStrikeEggFu?.(Number(number));
|
|
|
+
|
|
|
+ // const $tag = $('[data-tag-id="' + e.data.sid + '"]');
|
|
|
+ // $tag && $tag.addClass('hidden');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const isLink = e.data.title.startsWith('(link)');
|
|
|
+
|
|
|
+ if (isLink) {
|
|
|
+ const regex = new RegExp(`<\/?p[^>]*>`, 'g');
|
|
|
+ const link = e.data.content.replace(regex, '');
|
|
|
+ const isHttp = link.startsWith('http');
|
|
|
+ window.location.href = isHttp ? link : `https://scene.4dage.com${link}`;
|
|
|
+ } else {
|
|
|
+ // 隐藏工具栏
|
|
|
+ // @ts-ignore
|
|
|
+ window.parent?.FaIconStateFu?.(false);
|
|
|
+ baseStore.setState('checkedHotData', e.data);
|
|
|
+ baseStore.setState('hotVisible', true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ window.kankan.render();
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleBgMusic = (type = true) => {
|
|
|
+ if (type) {
|
|
|
+ baseStore.bgMusicDom?.play();
|
|
|
+ } else {
|
|
|
+ baseStore.bgMusicDom?.pause();
|
|
|
+ }
|
|
|
+ baseStore.setState('bgMusicPlaying', type);
|
|
|
+ };
|
|
|
+
|
|
|
+ const closeHotDetail = () => {
|
|
|
+ baseStore.setState('hotVisible', false);
|
|
|
+
|
|
|
+ // @ts-ignore
|
|
|
+ window.parent?.FaIconStateFu?.(true);
|
|
|
+ };
|
|
|
+
|
|
|
+ let once = false;
|
|
|
+ const handlePageClick = () => {
|
|
|
+ if (once) return;
|
|
|
+
|
|
|
+ handleBgMusic();
|
|
|
+ once = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ init();
|
|
|
+
|
|
|
+ // initHot();
|
|
|
+
|
|
|
+ // @ts-ignore
|
|
|
+ window.sonGetListFu = (val, code) => {
|
|
|
+ // 子页面接受父页面传过来的数据
|
|
|
+ hotResources = val;
|
|
|
+
|
|
|
+ console.log('热点初始化状态:', hotTagLoaded);
|
|
|
+ if (hotTagLoaded) {
|
|
|
+ $('[data-tag-id]').each(function (idx, el) {
|
|
|
+ const $current = $(this);
|
|
|
+ const tagId = $current.attr('data-tag-id');
|
|
|
+ const item = baseStore.hotList.find((i) => i.sid === tagId);
|
|
|
+ if (!item) return;
|
|
|
+ const item2 = hotResources.find((i) => item.title === '彩蛋&' + i.sort);
|
|
|
+ if (!item2 || item2.flag) {
|
|
|
+ const $tag = $('[data-tag-id="' + item.sid + '"]');
|
|
|
+ $tag && $tag.addClass('hidden');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ initHot();
|
|
|
+ hotTagLoaded = true;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // @ts-ignore
|
|
|
+ window.sonEggUpFu = (id) => {
|
|
|
+ // console.log('子页面接受父页面-关闭彩蛋', id)
|
|
|
+ const item = baseStore.hotList.find((i) => i.title === '彩蛋&' + id);
|
|
|
+ if (!item) return;
|
|
|
+ const $tag = $('[data-tag-id="' + item.sid + '"]');
|
|
|
+ $tag && $tag.addClass('hidden');
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
+ return {
|
|
|
+ hotVisible,
|
|
|
+ checkedHotData,
|
|
|
+ cameraMode,
|
|
|
+ closeHotDetail,
|
|
|
+ handlePageClick,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ render() {
|
|
|
+ return (
|
|
|
+ <div class="home" onClick={this.handlePageClick}>
|
|
|
+ {/* 进度条加载 */}
|
|
|
+ <GuiLoading />
|
|
|
+
|
|
|
+ {/* 加载初始页面 */}
|
|
|
+ <div id="gui-thumb" />
|
|
|
+
|
|
|
+ {/* 热点弹出框 */}
|
|
|
+ <Popup
|
|
|
+ hotData={this.checkedHotData}
|
|
|
+ visible={this.hotVisible}
|
|
|
+ onUpdate:visible={this.closeHotDetail}
|
|
|
+ />
|
|
|
+
|
|
|
+ {/* 场景canvs主容器 */}
|
|
|
+ <div id="player" />
|
|
|
+
|
|
|
+ {/* 底部菜单 */}
|
|
|
+ <div id="gui-parent">
|
|
|
+ {/* 热点气泡 */}
|
|
|
+ <div id="hot" />
|
|
|
+
|
|
|
+ <div id="gui">
|
|
|
+ {/* 热点列表 */}
|
|
|
+ <HotSpotList />
|
|
|
+
|
|
|
+ {/* 底部菜单 */}
|
|
|
+ <Menu mode={this.cameraMode} />
|
|
|
+
|
|
|
+ {/* <div class="home_logo">
|
|
|
+ <img src="images/btm_logo.png" />
|
|
|
+ <span>提供技术支持</span>
|
|
|
+ </div> */}
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <Other />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ },
|
|
|
+});
|