HotSpotList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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: '', // 热点图标
  225. serialFrameInfo: { // 热点图标类型为序列帧时,序列帧的数据
  226. frameNumber: 0, // 总帧数
  227. duration: 0, // 总播放时长(秒)
  228. },
  229. personalizedTagInfo: { // 热点图标类型为个性标签时,个性标签的数据
  230. isShowLine: true,
  231. lineDirection: '',
  232. },
  233. name: "_" + this.$randomWord(true, 8, 8),
  234. hotspotTitle: this.$i18n.t('hotspot.click_to_comfirm'),
  235. fontSize: 12,
  236. type: '',
  237. link: '',
  238. titleDisplayMode: 'always', // 'always' | 'never' | 'hover' 标题显示方式
  239. titlePosition: 'top', // 'top' | 'bottom' | 'left' | 'right' | 'custom' 标题相对图标位置
  240. ath: '',
  241. atv: '',
  242. size: 1,
  243. secne: '',
  244. hyperlink: '',
  245. textarea: '',
  246. image: [],
  247. audio: '',
  248. video: ''
  249. }
  250. } else {
  251. hotspotData = browser.CloneObject(data)
  252. // v1.3新增了“热点图标类型”
  253. if (!hotspotData.hotspotIconType) {
  254. hotspotData.hotspotIconType = 'system_icon'
  255. }
  256. // v1.3针对序列帧类型的热点图标,新增了序列帧信息
  257. if (!hotspotData.serialFrameInfo) {
  258. hotspotData.serialFrameInfo = {
  259. frameNumber: 0,
  260. duration: 0,
  261. }
  262. hotspotData.personalizedTagInfo = {
  263. isShowLine: true,
  264. lineDirection: '',
  265. }
  266. }
  267. // v1.3把visible: Boolean换成了titleDisplayMode
  268. if (hotspotData.visible) {
  269. hotspotData.titleDisplayMode = 'always'
  270. } else if (hotspotData.visible === false) {
  271. hotspotData.titleDisplayMode = 'never'
  272. }
  273. // v1.3新增了titlePosition
  274. if (!hotspotData.titlePosition) {
  275. hotspotData.titlePosition = 'top'
  276. }
  277. }
  278. this.$store.commit("SetHotspot", hotspotData)
  279. this.showPanel = true
  280. if (!data.isAdd) {
  281. this.editTitle = this.$i18n.t('hotspot.edit')
  282. window.__krfn.utils.looktohotspot(this.$getKrpano(), data.name)
  283. }
  284. },
  285. clickoutside() {
  286. if (this.deleIndex > -1) {
  287. this.deleIndex = -1
  288. }
  289. },
  290. },
  291. }
  292. </script>
  293. <style lang="less" scoped>
  294. .hot-spot-list {
  295. padding: 20px;
  296. display: flex;
  297. flex-direction: column;
  298. background: #252526;
  299. position: relative;
  300. > .title {
  301. flex: 0 0 auto;
  302. font-size: 18px;
  303. color: #fff;
  304. flex: 0 0 auto;
  305. margin-bottom: 24px;
  306. >i {
  307. font-size: 12px;
  308. position: relative;
  309. top: -2px;
  310. }
  311. }
  312. > .hotspot-type-list {
  313. flex: 0 0 auto;
  314. margin-right: -10px;
  315. > .hotspot-type-item {
  316. position: relative;
  317. display: inline-flex;
  318. flex-direction: column;
  319. justify-content: center;
  320. align-items: center;
  321. width: 72px;
  322. height: 72px;
  323. background: #313131;
  324. border-radius: 2px;
  325. border: 1px solid #404040;
  326. margin-right: 9px;
  327. margin-bottom: 9px;
  328. cursor: pointer;
  329. > .icon {
  330. width: 28px;
  331. height: 28px;
  332. margin-bottom: 3px;
  333. }
  334. > .type-name {
  335. font-size: 12px;
  336. color: #FFFFFF;
  337. }
  338. > .exp-tag {
  339. position: absolute;
  340. top: 0;
  341. right: 0;
  342. width: 30px;
  343. height: 30px;
  344. }
  345. }
  346. }
  347. .total-count {
  348. flex: 0 0 auto;
  349. margin-top: 24px;
  350. font-size: 18px;
  351. color: #FFFFFF;
  352. .number {
  353. font-size: 14px;
  354. color: rgba(255, 255, 255, 0.6);
  355. position: relative;
  356. top: -1px;
  357. }
  358. }
  359. .hots {
  360. flex: 1 0 1px;
  361. margin-top: 16px;
  362. background: available;
  363. background: #1A1B1D;
  364. border-radius: 4px;
  365. border: 1px solid #404040;
  366. position: relative;
  367. overflow: auto;
  368. ul {
  369. padding: 10px;
  370. li {
  371. position: relative;
  372. height: 40px;
  373. border-radius: 2px;
  374. display: flex;
  375. align-items: center;
  376. padding: 0 5px 0 10px;
  377. &:hover {
  378. background: #252526;
  379. .icon-delete {
  380. display: block;
  381. }
  382. }
  383. >.hot-spot-thumb {
  384. width: 18px;
  385. }
  386. >.hot-spot-title {
  387. flex: 1 1 auto;
  388. margin-left: 10px;
  389. text-overflow: ellipsis;
  390. overflow: hidden;
  391. white-space: nowrap;
  392. }
  393. >.icon-delete {
  394. margin-left: 12px;
  395. display: none;
  396. cursor: pointer;
  397. padding: 5px;
  398. &:hover {
  399. color: #fa5555;
  400. }
  401. }
  402. >.deletion-confirm-wrap {
  403. position: absolute;
  404. top: 0;
  405. bottom: 0;
  406. right: 0;
  407. width: 44px;
  408. overflow: hidden;
  409. pointer-events: none;
  410. border-top-right-radius: 2px;
  411. border-bottom-right-radius: 2px;
  412. >.deletion-confirm {
  413. position: absolute;
  414. top: 0;
  415. bottom: 0;
  416. width: 100%;
  417. background: #FA5555;
  418. transition: right 0.3s;
  419. cursor: pointer;
  420. text-align: center;
  421. font-size: 12px;
  422. color: #fff;
  423. pointer-events: auto;
  424. &::after {
  425. content: '';
  426. height: 100%;
  427. vertical-align: middle;
  428. display: inline-block;
  429. }
  430. &.show {
  431. right: 0;
  432. }
  433. &.hide {
  434. right: -44px;
  435. }
  436. }
  437. }
  438. }
  439. }
  440. .empty-tip {
  441. text-align: center;
  442. position: absolute;
  443. text-align: center;
  444. width: 100%;
  445. top: 50%;
  446. transform: translateY(-50%);
  447. img {
  448. width: 125px;
  449. }
  450. div {
  451. margin-top: 20px;
  452. color: rgba(255, 255, 255, 0.6);
  453. font-size: 14px;
  454. }
  455. }
  456. }
  457. .ui-button {
  458. width: 100%;
  459. }
  460. .adding-hotspot-panel {
  461. position: absolute;
  462. top: 0;
  463. height: 100%;
  464. right: 0;
  465. width: 100%;
  466. }
  467. }
  468. </style>