123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633 |
- <template>
- <div class="hot-spot-list" app-border dir-left>
- <div class="title">
- {{ $i18n.t("hotspot.add_hotspot") }}
- <i class="iconfont icon-help_i tool-tip-for-editor" v-tooltip="$i18n.t('hotspot.hotspot_tips')" />
- </div>
- <template v-if="currentScene.type !== '4dkk'">
- <ul class="hotspot-type-list">
- <li
- class="hotspot-type-item"
- v-for="(item, index) in hotspotTypeList"
- :key="index"
- @click="
- open({
- isAdd: true,
- hotspotType: item.id,
- idxInSystemIconList: item.idxInSystemIconList,
- })
- "
- >
- <img class="icon" :src="item.icon" alt="" draggable="false" />
- <div class="type-name">{{ item.name }}</div>
- <img v-if="item.isExperience" class="exp-tag" :src="experience_icon" alt="" draggable="false" />
- </li>
- </ul>
- <div class="total-count">
- {{ $i18n.t("hotspot.current_hotspots") }}
- <span class="number">({{ someData.hotspots.length }})</span>
- </div>
- <div class="hots">
- <ul v-if="someData.hotspots.length > 0">
- <li v-for="(item, key) in someData.hotspots" :key="key" @click="open(item)">
- <img class="hot-spot-thumb" :src="item.img" alt="" />
- <span class="hot-spot-title" v-title="item.hotspotTitle">{{ item.hotspotTitle }}</span>
- <i class="iconfont icon-editor_list_delete icon-delete" v-tooltip="$i18n.t('hotspot.delete')" @click.stop="deleIndex = key" />
- <div class="deletion-confirm-wrap">
- <div class="deletion-confirm" :class="deleIndex == key ? 'show' : 'hide'" v-clickoutside="clickoutside" @click.stop="deleteHot(item)">
- {{ $i18n.t("hotspot.delete") }}
- </div>
- </div>
- </li>
- </ul>
- <div v-else class="empty-tip">
- <img src="@/assets/images/default/empty_hotspot_list.png" alt="" />
- <div>{{ $i18n.t("hotspot.no_hotspot") }}</div>
- </div>
- </div>
- </template>
- <div class="goto-4dkk-tip" v-if="currentScene.type === '4dkk'">
- <div class="img-wrap">
- <img class="" src="@/assets/images/default/goto-4dage.png" alt="" draggable="false" />
- <div class="tip-text">
- {{ $i18n.t("screen.goto_4dkk_edit_tips") }}
- </div>
- </div>
- <button class="ui-button submit" @click="onClickGo4dkk">
- {{ $i18n.t("navigation.go_scene_editor") }}
- </button>
- </div>
- <EditPanel class="adding-hotspot-panel" v-if="showPanel" :editTitle="editTitle" :show="showPanel" @save="save" @close="close" />
- </div>
- </template>
- <script>
- import EditPanel from "./EditPanel";
- import { mapGetters } from "vuex";
- import browser from "@/utils/browser";
- import hotspotTypeList from "./hotspotTypeList.js";
- let mapFontSize = {
- 12: 0.5,
- 17: 1.5,
- 20: 2,
- };
- export default {
- name: "HotSpotList",
- components: {
- EditPanel,
- },
- data() {
- return {
- hotspotTypeList,
- showPanel: false,
- someData: { hotspots: [] },
- deleIndex: -1,
- editTitle: "",
- };
- },
- computed: {
- ...mapGetters({
- currentScene: "scene/currentScene",
- hotspot: "hotspot",
- info: "info",
- }),
- experience_icon() {
- const lang = browser.urlQueryValue("lang");
- if (lang == "en") {
- return require("@/assets/img/experience_en.png");
- } else {
- return require("@/assets/img/experience_zh.png");
- }
- },
- },
- watch: {
- "$route.name": function () {
- this.showPanel = false;
- },
- currentScene: {
- immediate: true,
- handler: function (newVal) {
- this.someData = newVal.someData || "";
- if (this.someData) {
- if (typeof this.someData == "string") {
- try {
- this.someData = JSON.parse(this.someData);
- } catch (e) {
- console.error(e);
- return false;
- }
- }
- if (!this.someData.hotspots) {
- this.someData.hotspots = [];
- }
- } else {
- this.someData = { hotspots: [] };
- }
- },
- },
- showPanel(newVal) {
- this.$store.commit("UpdateIsEditingState", newVal);
- this.$store.commit("tags/setIsConfirmingPosi", false);
- },
- },
- mounted() {
- this.$bus.on("updateHotSpotHV", (data) => {
- let hptarget = this.someData.hotspots.find((item) => item.name.toLowerCase() == data.hpname.toLowerCase());
- if (hptarget) {
- console.log("hptarget", hptarget);
- hptarget.ath = data.ath;
- hptarget.atv = data.atv;
- }
- });
- this.$bus.on("openHotspot", (data) => {
- let idx = this.someData.hotspots.findIndex((item) => item.name.toLowerCase() == data.toLowerCase());
- // console.log(data);
- if (data == this.hotspot.name) {
- // window.__krfn.utils.looktohotspot(this.$getKrpano(), this.hotspot.name);
- if (!this.showPanel) {
- this.open(this.someData.hotspots[idx]);
- }
- return;
- }
- if (this.editTitle == "新增" || this.editTitle == this.$i18n.t("hotspot.add")) {
- if (this.showPanel) {
- return this.$confirm({
- content: this.$i18n.t("hotspot.close_dialog"),
- ok: () => {
- this.deleteKRHotspot(this.hotspot);
- this.showPanel = false;
- },
- });
- }
- }
- this.open(this.someData.hotspots[idx]);
- });
- },
- methods: {
- deleteKRHotspot(data) {
- this.$getKrpano().call("removeJQHotspot(" + data.name + ");");
- // this.$getKrpano().call(
- // "removeplugin(" + ("tooltip_" + data.name) + ",true);"
- // );
- },
- close(data) {
- if (data) {
- if (data.type == "edit") {
- this.deleteKRHotspot(data.data);
- this.$bus.emit("addhotspot", data.data);
- let idx = this.someData.hotspots.findIndex((item) => item.name == data.data.name);
- this.someData.hotspots[idx] = data.data;
- } else {
- this.deleteKRHotspot(data.data);
- }
- }
- this.showPanel = false;
- },
- updateInfo() {
- let iidx = this.info.scenes.findIndex((item) => this.currentScene.sceneCode == item.sceneCode);
- if (iidx > -1) {
- this.info.scenes[iidx] = {
- ...this.currentScene,
- };
- }
- this.$store.commit("SetInfo", this.info);
- },
- save(data) {
- let HV = window.__krfn.utils.getHotspotHV(this.$getKrpano(), data.name);
- data.ath = HV.ath;
- data.atv = HV.atv;
- let idx = this.someData.hotspots.findIndex((item) => item.name === data.name);
- if (idx <= -1) {
- this.someData.hotspots.push(data);
- } else {
- this.someData.hotspots[idx] = data;
- }
- this.currentScene.someData = this.someData;
- this.$msg.success(this.editTitle + this.$i18n.t("hotspot.success"));
- // window.g_hotspotCurrentScale = mapFontSize[data.fontSize] || 1;
- window.g_hotspotCurrentScale = Math.ceil((data.fontSize * 10) / 12) / 10 || 1;
- console.log("g_hotspotCurrentScale", g_hotspotCurrentScale);
- let iidx = this.info.scenes.findIndex((item) => this.currentScene.sceneCode == item.sceneCode);
- if (iidx > -1) {
- this.info.scenes[iidx] = {
- ...this.currentScene,
- };
- }
- this.updateInfo();
- },
- deleteHot(data) {
- this.someData.hotspots.splice(
- this.someData.hotspots.findIndex((item) => item.name === data.name),
- 1
- );
- this.deleteKRHotspot(data);
- this.currentScene.someData = this.someData;
- this.updateInfo();
- this.$msg.success(this.$i18n.t("hotspot.delete") + this.$i18n.t("hotspot.success"));
- },
- open(data) {
- let hotspotData = null;
- if (data.isAdd) {
- console.error(this.currentScene);
- this.editTitle = this.$i18n.t("hotspot.add");
- hotspotData = {
- hotspotType: data.hotspotType, // 热点类型,切换场景、图片、视频、音频、链接、文本等等
- navigationId: this.currentScene.id,
- hotspotIconType: "system_icon", // 热点图标的类型,系统图标(system_icon)、自定义图片(custom_image)、序列帧(serial_frame)、个性标签(personalized_tag)
- img: this.$config.getStaticResource("/panoassets/images/hotspot/icon/") + `img_doticon_${String(data.idxInSystemIconList).padStart(2, "0")}.svg`, // 热点图标类型为系统图标时,图标在展时段使用的url
- icontype: "icon" + data.idxInSystemIconList, // 热点图标类型为系统图标时,图标的id
- customIconInfo: {
- // 热点图标类型为自定义图标时,图标的数据
- img: "",
- },
- serialFrameInfo: {
- // 热点图标类型为序列帧时,序列帧的数据
- img: "",
- frameNumber: 0, // 总帧数
- duration: 0, // 总播放时长(秒)
- },
- personalizedTagInfo: {
- // 热点图标类型为个性标签时,个性标签的数据
- isShowLine: true,
- lineDirection: "left-top",
- fillColor: "rgba(0, 0, 0, 0.5)",
- borderColor: "rgba(255, 255, 255, 0.8)",
- textColor: "rgba(255, 255, 255, 1)",
- textDirection: "left-right",
- isTextWrap: false,
- textNumPerLine: 10,
- },
- name: "_" + this.$randomWord(true, 8, 8),
- hotspotTitle: this.$i18n.t("hotspot.click_to_comfirm"),
- fontSize: 12,
- type: "",
- link: "",
- titleDisplayMode: "always", // 'always' | 'never' | 'hover' 标题显示方式
- titlePosition: "top", // 'top' | 'bottom' | 'left' | 'right' | 'custom' 标题相对图标位置
- ath: "",
- atv: "",
- size: 1,
- secne: null,
- hyperlink: "",
- textarea: "",
- image: [], // 热点类型为图片时,图片列表
- audio: "",
- video: "",
- imageTextInfo: {
- // 热点类型为图文时,图文内容
- imageList: [],
- text: "",
- isApplyToAll: true,
- audio: {},
- },
- phoneInfo: {
- // 热点类型为电话时,对应数据
- phone: "",
- },
- pdfInfo: {
- // 热点类型为pdf时,对应数据
- name: "",
- url: "",
- },
- articleInfo: {
- html: "",
- },
- };
- this.$bus.emit("addhotspot", hotspotData);
- this.$getKrpano().set("layer[tooltip_" + hotspotData.name + "].visible", true);
- // debugger;
- setTimeout(() => {
- this.$store.commit("tags/setIsConfirmingPosi", hotspotData.name);
- }, 0);
- console.log("hotspotData", hotspotData);
- } else {
- hotspotData = browser.CloneObject(data);
- /**
- * v1.3新增
- */
- if (!hotspotData.hotspotIconType) {
- hotspotData.hotspotIconType = "system_icon";
- }
- if (!hotspotData.customIconInfo) {
- hotspotData.customIconInfo = {
- img: "",
- };
- }
- if (!hotspotData.serialFrameInfo) {
- hotspotData.serialFrameInfo = {
- url: "",
- frameNumber: 0,
- duration: 0,
- };
- }
- if (!hotspotData.personalizedTagInfo) {
- hotspotData.personalizedTagInfo = {
- isShowLine: true,
- lineDirection: "left-top",
- fillColor: "rgba(0, 0, 0, 0.5)",
- borderColor: "rgba(255, 255, 255, 0.8)",
- textColor: "rgba(255, 255, 255, 1)",
- textDirection: "left-right",
- isTextWrap: false,
- textNumPerLine: 10,
- };
- }
- // v1.3把visible: Boolean换成了titleDisplayMode
- if (hotspotData.visible) {
- hotspotData.titleDisplayMode = "always";
- } else if (hotspotData.visible === false) {
- hotspotData.titleDisplayMode = "never";
- }
- if (!hotspotData.titlePosition) {
- hotspotData.titlePosition = "top";
- }
- if (!hotspotData.imageTextInfo) {
- hotspotData.imageTextInfo = {
- imageList: [],
- text: "",
- isApplyToAll: true,
- audio: {},
- };
- }
- if (!hotspotData.phoneInfo) {
- hotspotData.phoneInfo = {
- phone: "",
- };
- }
- if (!hotspotData.pdfInfo) {
- hotspotData.pdfInfo = {
- name: "",
- url: "",
- };
- }
- if (!hotspotData.articleInfo) {
- hotspotData.articleInfo = {
- html: "",
- };
- }
- /**
- * end of v1.3新增
- */
- }
- this.$store.commit("SetHotspot", hotspotData);
- this.showPanel = true;
- if (!data.isAdd) {
- this.editTitle = this.$i18n.t("hotspot.edit");
- window.__krfn.utils.looktohotspot(this.$getKrpano(), data.name);
- }
- },
- clickoutside() {
- if (this.deleIndex > -1) {
- this.deleIndex = -1;
- }
- },
- onClickGo4dkk() {
- window.open("/#/scene");
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .hot-spot-list {
- padding: 20px;
- display: flex;
- flex-direction: column;
- background: #252526;
- position: relative;
- > .title {
- flex: 0 0 auto;
- font-size: 18px;
- color: #fff;
- flex: 0 0 auto;
- margin-bottom: 24px;
- > i {
- font-size: 12px;
- position: relative;
- top: -2px;
- }
- }
- > .hotspot-type-list {
- flex: 0 0 auto;
- margin-right: -10px;
- > .hotspot-type-item {
- position: relative;
- display: inline-flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- width: 72px;
- height: 72px;
- background: #313131;
- border-radius: 2px;
- border: 1px solid #404040;
- margin-right: 9px;
- margin-bottom: 9px;
- cursor: pointer;
- > .icon {
- width: 28px;
- height: 28px;
- margin-bottom: 3px;
- }
- > .type-name {
- font-size: 12px;
- color: #ffffff;
- }
- > .exp-tag {
- position: absolute;
- top: 0;
- right: 0;
- width: 30px;
- height: 30px;
- }
- }
- }
- .total-count {
- flex: 0 0 auto;
- margin-top: 24px;
- font-size: 18px;
- color: #ffffff;
- .number {
- font-size: 14px;
- color: rgba(255, 255, 255, 0.6);
- position: relative;
- top: -1px;
- }
- }
- .hots {
- flex: 1 0 1px;
- margin-top: 16px;
- background: available;
- background: #1a1b1d;
- border-radius: 4px;
- border: 1px solid #404040;
- position: relative;
- overflow: auto;
- ul {
- padding: 10px;
- li {
- position: relative;
- height: 40px;
- border-radius: 2px;
- display: flex;
- align-items: center;
- padding: 0 5px 0 10px;
- &:hover {
- background: #252526;
- .icon-delete {
- display: block;
- }
- }
- > .hot-spot-thumb {
- width: 18px;
- }
- > .hot-spot-title {
- flex: 1 1 auto;
- margin-left: 10px;
- text-overflow: ellipsis;
- overflow: hidden;
- white-space: nowrap;
- }
- > .icon-delete {
- margin-left: 12px;
- display: none;
- cursor: pointer;
- padding: 5px;
- &:hover {
- color: #fa5555;
- }
- }
- > .deletion-confirm-wrap {
- position: absolute;
- top: 0;
- bottom: 0;
- right: 0;
- width: 44px;
- overflow: hidden;
- pointer-events: none;
- border-top-right-radius: 2px;
- border-bottom-right-radius: 2px;
- > .deletion-confirm {
- position: absolute;
- top: 0;
- bottom: 0;
- width: 100%;
- background: #fa5555;
- transition: right 0.3s;
- cursor: pointer;
- text-align: center;
- font-size: 12px;
- color: #fff;
- pointer-events: auto;
- &::after {
- content: "";
- height: 100%;
- vertical-align: middle;
- display: inline-block;
- }
- &.show {
- right: 0;
- }
- &.hide {
- right: -44px;
- }
- }
- }
- }
- }
- .empty-tip {
- text-align: center;
- position: absolute;
- text-align: center;
- width: 100%;
- top: 50%;
- transform: translateY(-50%);
- img {
- width: 125px;
- }
- div {
- margin-top: 20px;
- color: rgba(255, 255, 255, 0.6);
- font-size: 14px;
- }
- }
- }
- .ui-button {
- width: 100%;
- }
- .adding-hotspot-panel {
- position: absolute;
- top: 0;
- height: 100%;
- right: 0;
- width: 100%;
- }
- .goto-4dkk-tip {
- > .img-wrap {
- position: relative;
- width: 100%;
- > .img {
- width: 100%;
- }
- > .tip-text {
- position: absolute;
- left: 50%;
- bottom: 32px;
- transform: translateX(-50%);
- font-size: 14px;
- color: #fff;
- opacity: 0.6;
- white-space: pre;
- }
- }
- > button {
- margin-top: 16px;
- width: 100%;
- }
- }
- }
- </style>
|