HotSpotList.vue 18 KB

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