123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590 |
- <template>
- <div class="hot-spot-list" app-border dir-left>
- <div class="title">
- {{$i18n.t('hotspot.add_hotspot')}}
- <i class="iconfont icon-material_prompt tool-tip-for-editor" v-tooltip="$i18n.t('hotspot.hotspot_tips')" />
- </div>
- <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,
- })"
- >
- <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="@/assets/img/experience.png"
- 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>
- <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",
- }),
- },
- 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())
- console.log(hptarget);
- hptarget.ath = data.ath
- hptarget.atv = data.atv
- })
- this.$bus.on("openHotspot", (data) => {
- let idx = this.someData.hotspots.findIndex((item) => item.name == data)
- 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.open(this.someData.hotspots[idx])
- }
- })
- }
- }
- this.open(this.someData.hotspots[idx])
- })
- },
- methods: {
- deleteKRHotspot(data) {
- this.$getKrpano().call("removehotspot(" + data.name + ",true);")
- 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
- 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) {
- this.editTitle = this.$i18n.t('hotspot.add')
- hotspotData = {
- hotspotType: data.hotspotType, // 热点类型,切换场景、图片、视频、音频、链接、文本等等
-
- hotspotIconType: 'system_icon', // 热点图标的类型,系统图标(system_icon)、自定义图片(custom_image)、序列帧(serial_frame)、个性标签(personalized_tag)
- img: 'static/panoassets/images/hotspot/icon/img_doticon_01.svg', // 热点图标类型为系统图标时,,图标的url
- icontype: 'icon1', // 热点图标类型为系统图标时,图标的id
- customIconInfo: { // 热点图标类型为自定义图标时,图标的数据
- img: '',
- },
- serialFrameInfo: { // 热点图标类型为序列帧时,序列帧的数据
- url: '',
- frameNumber: 0, // 总帧数
- duration: 0, // 总播放时长(秒)
- },
- personalizedTagInfo: { // 热点图标类型为个性标签时,个性标签的数据
- isShowLine: true,
- lineDirection: 'left-top',
- fillColor: 'rgba(0, 0, 0, 1)',
- borderColor: 'rgba(0, 0, 0, 1)',
- textColor: 'rgba(0, 0, 0, 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: '',
- hyperlink: '',
- textarea: '',
- image: [],
- audio: '',
- video: '',
- imageTextInfo: { // 热点类型为图文时,图文内容
- imageList: [],
- text: '',
- isApplyToAll: true,
- audio: {
- // ancestors: "",
- // createTime: "2022-08-01 14:30",
- // dirId: 1,
- // dirName: "根目录",
- // dpi: "0",
- // fileName: "20220801_143047668.mp3",
- // fileSize: "2.08MB",
- // icon: "0",
- // id: 2594,
- // materialType: "audio",
- // name: "谢海清 - 清平乐",
- // ossPath: "https://ossxiaoan.4dage.com/720yun_fd_manage/fodder/20220801_143047668.mp3",
- // previewIcon: "",
- // sceneCode: "0",
- // status: 0,
- // tempId: "u_4zK9YIFW",
- // type: "audio",
- // updateTime: "2022-11-01 19:49",
- // userId: "13825625448",
- }
- },
- phoneInfo: { // 热点类型为电话时,对应数据
- phone: '',
- },
- pdfInfo: { // 热点类型为pdf时,对应数据
- name: '',
- url: '',
- },
- }
- } 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,
- }
- }
- hotspotData.personalizedTagInfo = {
- isShowLine: true,
- lineDirection: 'left-top',
- fillColor: 'rgba(0, 0, 0, 1)',
- borderColor: 'rgba(0, 0, 0, 1)',
- textColor: 'rgba(0, 0, 0, 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: '',
- }
- }
- /**
- * 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
- }
- },
- },
- }
- </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%;
- }
- }
- </style>
|