HotSpotList.vue 18 KB

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