HotSpotList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. <template>
  2. <div class="hot-spot-list" app-border dir-left>
  3. <div class="title">
  4. {{$i18n.t('hotspot.add_hotspot')}}
  5. <i class="iconfont icon-material_prompt tool-tip-for-editor" v-tooltip="$i18n.t('hotspot.hotspot_tips')" />
  6. </div>
  7. <ul class="hotspot-type-list">
  8. <li
  9. class="hotspot-type-item"
  10. v-for="(item, index) in hotspotTypeList"
  11. :key="index"
  12. @click="open({
  13. isAdd: true,
  14. hotspotType: item.id,
  15. idxInSystemIconList: item.idxInSystemIconList
  16. })"
  17. >
  18. <img class="icon" :src="item.icon" alt="" draggable="false">
  19. <div class="type-name">{{item.name}}</div>
  20. <img
  21. v-if="item.isExperience"
  22. class="exp-tag"
  23. src="@/assets/img/experience.png"
  24. alt=""
  25. draggable="false"
  26. >
  27. </li>
  28. </ul>
  29. <div class="total-count">{{$i18n.t('hotspot.current_hotspots')}}
  30. <span class="number">({{ someData.hotspots.length }})</span>
  31. </div>
  32. <div class="hots">
  33. <ul v-if="someData.hotspots.length > 0">
  34. <li v-for="(item, key) in someData.hotspots" :key="key" @click="open(item)">
  35. <img class="hot-spot-thumb" :src="item.img" alt="">
  36. <span class="hot-spot-title" v-title="item.hotspotTitle">{{ item.hotspotTitle }}</span>
  37. <i
  38. class="iconfont icon-editor_list_delete icon-delete"
  39. v-tooltip="$i18n.t('hotspot.delete')"
  40. @click.stop="deleIndex = key"
  41. />
  42. <div class="deletion-confirm-wrap">
  43. <div class="deletion-confirm" :class="deleIndex == key ? 'show' : 'hide'" v-clickoutside="clickoutside"
  44. @click.stop="deleteHot(item)">
  45. {{$i18n.t('hotspot.delete')}}
  46. </div>
  47. </div>
  48. </li>
  49. </ul>
  50. <div v-else class="empty-tip">
  51. <img src="@/assets/images/default/empty_hotspot_list.png" alt="">
  52. <div>{{$i18n.t('hotspot.no_hotspot')}}</div>
  53. </div>
  54. </div>
  55. <EditPanel
  56. class="adding-hotspot-panel"
  57. v-if="showPanel"
  58. :editTitle="editTitle"
  59. :show="showPanel"
  60. @save="save"
  61. @close="close"
  62. />
  63. </div>
  64. </template>
  65. <script>
  66. import EditPanel from "./EditPanel"
  67. import { mapGetters } from "vuex"
  68. import browser from "@/utils/browser"
  69. import hotspotTypeList from "./hotspotTypeList.js";
  70. let mapFontSize = {
  71. 12: 0.5,
  72. 17: 1.5,
  73. 20: 2,
  74. }
  75. export default {
  76. name: 'HotSpotList',
  77. components: {
  78. EditPanel,
  79. },
  80. data() {
  81. return {
  82. hotspotTypeList,
  83. showPanel: false,
  84. someData: { hotspots: [] },
  85. deleIndex: -1,
  86. editTitle: '',
  87. }
  88. },
  89. computed: {
  90. ...mapGetters({
  91. currentScene: "scene/currentScene",
  92. hotspot: 'hotspot',
  93. info: "info",
  94. }),
  95. },
  96. watch: {
  97. "$route.name": function () {
  98. this.showPanel = false
  99. },
  100. currentScene: {
  101. immediate: true,
  102. handler: function (newVal) {
  103. this.someData = newVal.someData || ""
  104. if (this.someData) {
  105. if (typeof this.someData == 'string') {
  106. try {
  107. this.someData = JSON.parse(this.someData)
  108. } catch (e) {
  109. console.error(e)
  110. return false
  111. }
  112. }
  113. if (!this.someData.hotspots) {
  114. this.someData.hotspots = []
  115. }
  116. }
  117. else {
  118. this.someData = { hotspots: [] }
  119. }
  120. },
  121. },
  122. showPanel(newVal) {
  123. this.$store.commit("UpdateIsEditingState", newVal)
  124. this.$store.commit("tags/setIsConfirmingPosi", false);
  125. },
  126. },
  127. mounted() {
  128. this.$bus.on("updateHotSpotHV", (data) => {
  129. let hptarget = this.someData.hotspots.find((item) => item.name.toLowerCase() == data.hpname.toLowerCase())
  130. console.log(hptarget);
  131. hptarget.ath = data.ath
  132. hptarget.atv = data.atv
  133. })
  134. this.$bus.on("openHotspot", (data) => {
  135. let idx = this.someData.hotspots.findIndex((item) => item.name == data)
  136. console.log(data);
  137. if (data == this.hotspot.name) {
  138. window.__krfn.utils.looktohotspot(this.$getKrpano(), this.hotspot.name)
  139. if (!this.showPanel) {
  140. this.open(this.someData.hotspots[idx])
  141. }
  142. return
  143. }
  144. if (this.editTitle == '新增' || this.editTitle == this.$i18n.t('hotspot.add')) {
  145. if (this.showPanel) {
  146. return this.$confirm({
  147. content: this.$i18n.t('hotspot.close_dialog'),
  148. ok: () => {
  149. this.deleteKRHotspot(this.hotspot)
  150. this.open(this.someData.hotspots[idx])
  151. }
  152. })
  153. }
  154. }
  155. this.open(this.someData.hotspots[idx])
  156. })
  157. },
  158. methods: {
  159. deleteKRHotspot(data) {
  160. this.$getKrpano().call("removehotspot(" + data.name + ",true);")
  161. this.$getKrpano().call("removeplugin(" + ("tooltip_" + data.name) + ",true);")
  162. },
  163. close(data) {
  164. if (data) {
  165. if (data.type == 'edit') {
  166. this.deleteKRHotspot(data.data)
  167. this.$bus.emit('addhotspot', data.data)
  168. let idx = this.someData.hotspots.findIndex(item => item.name == data.data.name)
  169. this.someData.hotspots[idx] = data.data
  170. }
  171. else {
  172. this.deleteKRHotspot(data.data)
  173. }
  174. }
  175. this.showPanel = false
  176. },
  177. updateInfo() {
  178. let iidx = this.info.scenes.findIndex(item => this.currentScene.sceneCode == item.sceneCode)
  179. if (iidx > -1) {
  180. this.info.scenes[iidx] = {
  181. ...this.currentScene
  182. }
  183. }
  184. this.$store.commit("SetInfo", this.info)
  185. },
  186. save(data) {
  187. let HV = window.__krfn.utils.getHotspotHV(this.$getKrpano(), data.name)
  188. data.ath = HV.ath
  189. data.atv = HV.atv
  190. let idx = this.someData.hotspots.findIndex((item) => item.name === data.name)
  191. if (idx <= -1) {
  192. this.someData.hotspots.push(data)
  193. }
  194. else {
  195. this.someData.hotspots[idx] = data
  196. }
  197. this.currentScene.someData = this.someData
  198. this.$msg.success(this.editTitle + this.$i18n.t('hotspot.success'))
  199. window.g_hotspotCurrentScale = mapFontSize[data.fontSize] || 1
  200. let iidx = this.info.scenes.findIndex(item => this.currentScene.sceneCode == item.sceneCode)
  201. if (iidx > -1) {
  202. this.info.scenes[iidx] = {
  203. ...this.currentScene
  204. }
  205. }
  206. this.updateInfo()
  207. },
  208. deleteHot(data) {
  209. this.someData.hotspots.splice(
  210. this.someData.hotspots.findIndex((item) => item.name === data.name),
  211. 1
  212. )
  213. this.deleteKRHotspot(data)
  214. this.currentScene.someData = this.someData
  215. this.updateInfo()
  216. this.$msg.success(this.$i18n.t('hotspot.delete')+this.$i18n.t('hotspot.success'))
  217. },
  218. open(data) {
  219. let hotspotData = null
  220. if (data.isAdd) {
  221. this.editTitle = this.$i18n.t('hotspot.add')
  222. hotspotData = {
  223. hotspotType: data.hotspotType, // 热点类型,切换场景、图片、视频、音频、链接、文本等等
  224. hotspotIconType: 'system_icon', // 热点图标的类型,系统图标(system_icon)、自定义图片(custom_image)、序列帧(serial_frame)、个性标签(personalized_tag)
  225. img: this.$config.getStaticResource('/panoassets/images/hotspot/icon/') + `img_doticon_${String(data.idxInSystemIconList).padStart(2, '0')}.svg`, // 热点图标类型为系统图标时,图标在展时段使用的url
  226. icontype: 'icon' + data.idxInSystemIconList, // 热点图标类型为系统图标时,图标的id
  227. customIconInfo: { // 热点图标类型为自定义图标时,图标的数据
  228. img: '',
  229. },
  230. serialFrameInfo: { // 热点图标类型为序列帧时,序列帧的数据
  231. url: '',
  232. frameNumber: 0, // 总帧数
  233. duration: 0, // 总播放时长(秒)
  234. },
  235. personalizedTagInfo: { // 热点图标类型为个性标签时,个性标签的数据
  236. isShowLine: true,
  237. lineDirection: 'left-top',
  238. fillColor: 'rgba(0, 0, 0, 1)',
  239. borderColor: 'rgba(0, 0, 0, 1)',
  240. textColor: 'rgba(0, 0, 0, 1)',
  241. textDirection: 'left-right',
  242. isTextWrap: false,
  243. textNumPerLine: 10,
  244. },
  245. name: "_" + this.$randomWord(true, 8, 8),
  246. hotspotTitle: this.$i18n.t('hotspot.click_to_comfirm'),
  247. fontSize: 12,
  248. type: '',
  249. link: '',
  250. titleDisplayMode: 'always', // 'always' | 'never' | 'hover' 标题显示方式
  251. titlePosition: 'top', // 'top' | 'bottom' | 'left' | 'right' | 'custom' 标题相对图标位置
  252. ath: '',
  253. atv: '',
  254. size: 1,
  255. secne: null,
  256. hyperlink: '',
  257. textarea: '',
  258. image: [], // 热点类型为图片时,图片列表
  259. audio: '',
  260. video: '',
  261. imageTextInfo: { // 热点类型为图文时,图文内容
  262. imageList: [],
  263. text: '',
  264. isApplyToAll: true,
  265. audio: {
  266. // ancestors: "",
  267. // createTime: "2022-08-01 14:30",
  268. // dirId: 1,
  269. // dirName: "根目录",
  270. // dpi: "0",
  271. // fileName: "20220801_143047668.mp3",
  272. // fileSize: "2.08MB",
  273. // icon: "0",
  274. // id: 2594,
  275. // materialType: "audio",
  276. // name: "谢海清 - 清平乐",
  277. // ossPath: "https://ossxiaoan.4dage.com/720yun_fd_manage/fodder/20220801_143047668.mp3",
  278. // previewIcon: "",
  279. // sceneCode: "0",
  280. // status: 0,
  281. // tempId: "u_4zK9YIFW",
  282. // type: "audio",
  283. // updateTime: "2022-11-01 19:49",
  284. // userId: "13825625448",
  285. }
  286. },
  287. phoneInfo: { // 热点类型为电话时,对应数据
  288. phone: '',
  289. },
  290. pdfInfo: { // 热点类型为pdf时,对应数据
  291. name: '',
  292. url: '',
  293. },
  294. articleInfo: {
  295. html: '',
  296. }
  297. }
  298. } else {
  299. hotspotData = browser.CloneObject(data)
  300. /**
  301. * v1.3新增
  302. */
  303. if (!hotspotData.hotspotIconType) {
  304. hotspotData.hotspotIconType = 'system_icon'
  305. }
  306. if (!hotspotData.customIconInfo) {
  307. hotspotData.customIconInfo = {
  308. img: '',
  309. }
  310. }
  311. if (!hotspotData.serialFrameInfo) {
  312. hotspotData.serialFrameInfo = {
  313. url: '',
  314. frameNumber: 0,
  315. duration: 0,
  316. }
  317. }
  318. hotspotData.personalizedTagInfo = {
  319. isShowLine: true,
  320. lineDirection: 'left-top',
  321. fillColor: 'rgba(0, 0, 0, 1)',
  322. borderColor: 'rgba(0, 0, 0, 1)',
  323. textColor: 'rgba(0, 0, 0, 1)',
  324. textDirection: 'left-right',
  325. isTextWrap: false,
  326. textNumPerLine: 10,
  327. }
  328. // v1.3把visible: Boolean换成了titleDisplayMode
  329. if (hotspotData.visible) {
  330. hotspotData.titleDisplayMode = 'always'
  331. } else if (hotspotData.visible === false) {
  332. hotspotData.titleDisplayMode = 'never'
  333. }
  334. if (!hotspotData.titlePosition) {
  335. hotspotData.titlePosition = 'top'
  336. }
  337. if (!hotspotData.imageTextInfo) {
  338. hotspotData.imageTextInfo = {
  339. imageList: [],
  340. text: '',
  341. isApplyToAll: true,
  342. audio: {}
  343. }
  344. }
  345. if (!hotspotData.phoneInfo) {
  346. hotspotData.phoneInfo = {
  347. phone: '',
  348. }
  349. }
  350. if (!hotspotData.pdfInfo) {
  351. hotspotData.pdfInfo = {
  352. name: '',
  353. url: '',
  354. }
  355. }
  356. if (!hotspotData.articleInfo) {
  357. hotspotData.articleInfo = {
  358. html: '',
  359. }
  360. }
  361. /**
  362. * end of v1.3新增
  363. */
  364. }
  365. this.$store.commit("SetHotspot", hotspotData)
  366. this.showPanel = true
  367. if (!data.isAdd) {
  368. this.editTitle = this.$i18n.t('hotspot.edit')
  369. window.__krfn.utils.looktohotspot(this.$getKrpano(), data.name)
  370. }
  371. },
  372. clickoutside() {
  373. if (this.deleIndex > -1) {
  374. this.deleIndex = -1
  375. }
  376. },
  377. },
  378. }
  379. </script>
  380. <style lang="less" scoped>
  381. .hot-spot-list {
  382. padding: 20px;
  383. display: flex;
  384. flex-direction: column;
  385. background: #252526;
  386. position: relative;
  387. > .title {
  388. flex: 0 0 auto;
  389. font-size: 18px;
  390. color: #fff;
  391. flex: 0 0 auto;
  392. margin-bottom: 24px;
  393. >i {
  394. font-size: 12px;
  395. position: relative;
  396. top: -2px;
  397. }
  398. }
  399. > .hotspot-type-list {
  400. flex: 0 0 auto;
  401. margin-right: -10px;
  402. > .hotspot-type-item {
  403. position: relative;
  404. display: inline-flex;
  405. flex-direction: column;
  406. justify-content: center;
  407. align-items: center;
  408. width: 72px;
  409. height: 72px;
  410. background: #313131;
  411. border-radius: 2px;
  412. border: 1px solid #404040;
  413. margin-right: 9px;
  414. margin-bottom: 9px;
  415. cursor: pointer;
  416. > .icon {
  417. width: 28px;
  418. height: 28px;
  419. margin-bottom: 3px;
  420. }
  421. > .type-name {
  422. font-size: 12px;
  423. color: #FFFFFF;
  424. }
  425. > .exp-tag {
  426. position: absolute;
  427. top: 0;
  428. right: 0;
  429. width: 30px;
  430. height: 30px;
  431. }
  432. }
  433. }
  434. .total-count {
  435. flex: 0 0 auto;
  436. margin-top: 24px;
  437. font-size: 18px;
  438. color: #FFFFFF;
  439. .number {
  440. font-size: 14px;
  441. color: rgba(255, 255, 255, 0.6);
  442. position: relative;
  443. top: -1px;
  444. }
  445. }
  446. .hots {
  447. flex: 1 0 1px;
  448. margin-top: 16px;
  449. background: available;
  450. background: #1A1B1D;
  451. border-radius: 4px;
  452. border: 1px solid #404040;
  453. position: relative;
  454. overflow: auto;
  455. ul {
  456. padding: 10px;
  457. li {
  458. position: relative;
  459. height: 40px;
  460. border-radius: 2px;
  461. display: flex;
  462. align-items: center;
  463. padding: 0 5px 0 10px;
  464. &:hover {
  465. background: #252526;
  466. .icon-delete {
  467. display: block;
  468. }
  469. }
  470. >.hot-spot-thumb {
  471. width: 18px;
  472. }
  473. >.hot-spot-title {
  474. flex: 1 1 auto;
  475. margin-left: 10px;
  476. text-overflow: ellipsis;
  477. overflow: hidden;
  478. white-space: nowrap;
  479. }
  480. >.icon-delete {
  481. margin-left: 12px;
  482. display: none;
  483. cursor: pointer;
  484. padding: 5px;
  485. &:hover {
  486. color: #fa5555;
  487. }
  488. }
  489. >.deletion-confirm-wrap {
  490. position: absolute;
  491. top: 0;
  492. bottom: 0;
  493. right: 0;
  494. width: 44px;
  495. overflow: hidden;
  496. pointer-events: none;
  497. border-top-right-radius: 2px;
  498. border-bottom-right-radius: 2px;
  499. >.deletion-confirm {
  500. position: absolute;
  501. top: 0;
  502. bottom: 0;
  503. width: 100%;
  504. background: #FA5555;
  505. transition: right 0.3s;
  506. cursor: pointer;
  507. text-align: center;
  508. font-size: 12px;
  509. color: #fff;
  510. pointer-events: auto;
  511. &::after {
  512. content: '';
  513. height: 100%;
  514. vertical-align: middle;
  515. display: inline-block;
  516. }
  517. &.show {
  518. right: 0;
  519. }
  520. &.hide {
  521. right: -44px;
  522. }
  523. }
  524. }
  525. }
  526. }
  527. .empty-tip {
  528. text-align: center;
  529. position: absolute;
  530. text-align: center;
  531. width: 100%;
  532. top: 50%;
  533. transform: translateY(-50%);
  534. img {
  535. width: 125px;
  536. }
  537. div {
  538. margin-top: 20px;
  539. color: rgba(255, 255, 255, 0.6);
  540. font-size: 14px;
  541. }
  542. }
  543. }
  544. .ui-button {
  545. width: 100%;
  546. }
  547. .adding-hotspot-panel {
  548. position: absolute;
  549. top: 0;
  550. height: 100%;
  551. right: 0;
  552. width: 100%;
  553. }
  554. }
  555. </style>