HotSpotList.vue 15 KB

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