HotSpotList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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. }
  261. } else {
  262. hotspotData = browser.CloneObject(data)
  263. // v1.3新增了“热点图标类型”
  264. if (!hotspotData.hotspotIconType) {
  265. hotspotData.hotspotIconType = 'system_icon'
  266. }
  267. // v1.3针对类型为自定义图标的热点图标,新增的数据
  268. if (!hotspotData.customIconInfo) {
  269. hotspotData.customIconInfo = {
  270. img: '',
  271. }
  272. }
  273. // v1.3针对序列帧类型的热点图标,新增的数据
  274. if (!hotspotData.serialFrameInfo) {
  275. hotspotData.serialFrameInfo = {
  276. url: '',
  277. frameNumber: 0,
  278. duration: 0,
  279. }
  280. }
  281. // v1.3针对个性标签类型的热点图标,新增的数据
  282. hotspotData.personalizedTagInfo = {
  283. isShowLine: true,
  284. lineDirection: 'left-top',
  285. fillColor: 'rgba(0, 0, 0, 1)',
  286. borderColor: 'rgba(0, 0, 0, 1)',
  287. textColor: 'rgba(0, 0, 0, 1)',
  288. textDirection: 'left-right',
  289. isTextWrap: false,
  290. textNumPerLine: 10,
  291. }
  292. // v1.3把visible: Boolean换成了titleDisplayMode
  293. if (hotspotData.visible) {
  294. hotspotData.titleDisplayMode = 'always'
  295. } else if (hotspotData.visible === false) {
  296. hotspotData.titleDisplayMode = 'never'
  297. }
  298. // v1.3新增了titlePosition
  299. if (!hotspotData.titlePosition) {
  300. hotspotData.titlePosition = 'top'
  301. }
  302. }
  303. this.$store.commit("SetHotspot", hotspotData)
  304. this.showPanel = true
  305. if (!data.isAdd) {
  306. this.editTitle = this.$i18n.t('hotspot.edit')
  307. window.__krfn.utils.looktohotspot(this.$getKrpano(), data.name)
  308. }
  309. },
  310. clickoutside() {
  311. if (this.deleIndex > -1) {
  312. this.deleIndex = -1
  313. }
  314. },
  315. },
  316. }
  317. </script>
  318. <style lang="less" scoped>
  319. .hot-spot-list {
  320. padding: 20px;
  321. display: flex;
  322. flex-direction: column;
  323. background: #252526;
  324. position: relative;
  325. > .title {
  326. flex: 0 0 auto;
  327. font-size: 18px;
  328. color: #fff;
  329. flex: 0 0 auto;
  330. margin-bottom: 24px;
  331. >i {
  332. font-size: 12px;
  333. position: relative;
  334. top: -2px;
  335. }
  336. }
  337. > .hotspot-type-list {
  338. flex: 0 0 auto;
  339. margin-right: -10px;
  340. > .hotspot-type-item {
  341. position: relative;
  342. display: inline-flex;
  343. flex-direction: column;
  344. justify-content: center;
  345. align-items: center;
  346. width: 72px;
  347. height: 72px;
  348. background: #313131;
  349. border-radius: 2px;
  350. border: 1px solid #404040;
  351. margin-right: 9px;
  352. margin-bottom: 9px;
  353. cursor: pointer;
  354. > .icon {
  355. width: 28px;
  356. height: 28px;
  357. margin-bottom: 3px;
  358. }
  359. > .type-name {
  360. font-size: 12px;
  361. color: #FFFFFF;
  362. }
  363. > .exp-tag {
  364. position: absolute;
  365. top: 0;
  366. right: 0;
  367. width: 30px;
  368. height: 30px;
  369. }
  370. }
  371. }
  372. .total-count {
  373. flex: 0 0 auto;
  374. margin-top: 24px;
  375. font-size: 18px;
  376. color: #FFFFFF;
  377. .number {
  378. font-size: 14px;
  379. color: rgba(255, 255, 255, 0.6);
  380. position: relative;
  381. top: -1px;
  382. }
  383. }
  384. .hots {
  385. flex: 1 0 1px;
  386. margin-top: 16px;
  387. background: available;
  388. background: #1A1B1D;
  389. border-radius: 4px;
  390. border: 1px solid #404040;
  391. position: relative;
  392. overflow: auto;
  393. ul {
  394. padding: 10px;
  395. li {
  396. position: relative;
  397. height: 40px;
  398. border-radius: 2px;
  399. display: flex;
  400. align-items: center;
  401. padding: 0 5px 0 10px;
  402. &:hover {
  403. background: #252526;
  404. .icon-delete {
  405. display: block;
  406. }
  407. }
  408. >.hot-spot-thumb {
  409. width: 18px;
  410. }
  411. >.hot-spot-title {
  412. flex: 1 1 auto;
  413. margin-left: 10px;
  414. text-overflow: ellipsis;
  415. overflow: hidden;
  416. white-space: nowrap;
  417. }
  418. >.icon-delete {
  419. margin-left: 12px;
  420. display: none;
  421. cursor: pointer;
  422. padding: 5px;
  423. &:hover {
  424. color: #fa5555;
  425. }
  426. }
  427. >.deletion-confirm-wrap {
  428. position: absolute;
  429. top: 0;
  430. bottom: 0;
  431. right: 0;
  432. width: 44px;
  433. overflow: hidden;
  434. pointer-events: none;
  435. border-top-right-radius: 2px;
  436. border-bottom-right-radius: 2px;
  437. >.deletion-confirm {
  438. position: absolute;
  439. top: 0;
  440. bottom: 0;
  441. width: 100%;
  442. background: #FA5555;
  443. transition: right 0.3s;
  444. cursor: pointer;
  445. text-align: center;
  446. font-size: 12px;
  447. color: #fff;
  448. pointer-events: auto;
  449. &::after {
  450. content: '';
  451. height: 100%;
  452. vertical-align: middle;
  453. display: inline-block;
  454. }
  455. &.show {
  456. right: 0;
  457. }
  458. &.hide {
  459. right: -44px;
  460. }
  461. }
  462. }
  463. }
  464. }
  465. .empty-tip {
  466. text-align: center;
  467. position: absolute;
  468. text-align: center;
  469. width: 100%;
  470. top: 50%;
  471. transform: translateY(-50%);
  472. img {
  473. width: 125px;
  474. }
  475. div {
  476. margin-top: 20px;
  477. color: rgba(255, 255, 255, 0.6);
  478. font-size: 14px;
  479. }
  480. }
  481. }
  482. .ui-button {
  483. width: 100%;
  484. }
  485. .adding-hotspot-panel {
  486. position: absolute;
  487. top: 0;
  488. height: 100%;
  489. right: 0;
  490. width: 100%;
  491. }
  492. }
  493. </style>