EditPanel.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. <template>
  2. <transition
  3. appear
  4. name="custom-classes-transition"
  5. enter-active-class="animated slideInRight speed"
  6. leave-active-class="animated slideOutRight speed"
  7. >
  8. <div class="hots-panel" v-show="show">
  9. <div class="ui-between header">
  10. <span>{{ editTitle }}{{ $i18n.t("hotspot.hotspot_name") }}</span>
  11. <i class="iconfont icon_close" @click="cancel"></i>
  12. </div>
  13. <div class="content" ref="content">
  14. <div class="type-setting">
  15. <div class="remark">{{ $i18n.t("hotspot.hotspot_type") }}</div>
  16. <combox
  17. class="combox"
  18. :data="hotspotTypeList"
  19. :selected-id="hotspot.hotspotType"
  20. @change="onHotSpotTypeChange"
  21. />
  22. </div>
  23. <div class="icon-setting">
  24. <div class="remark">{{ $i18n.t("hotspot.hotspot_icon") }}</div>
  25. <combox
  26. class="combox"
  27. :data="hotspotIconTypeList"
  28. :selected-id="hotspot.hotspotIconType"
  29. @change="onHotspotIconTypeChange"
  30. />
  31. <component
  32. class="icon-setting-component"
  33. :is="iconTypeComponent"
  34. ref="icon-setting-component"
  35. />
  36. <div
  37. class="bars"
  38. v-if="hotspot.hotspotIconType !== 'personalized_tag'"
  39. >
  40. <RangeItem :value="rang" @input="onRangeChange" />
  41. </div>
  42. </div>
  43. <div
  44. class="title-setting"
  45. v-if="hotspot.hotspotIconType !== 'personalized_tag'"
  46. >
  47. <div class="remark-highlight">
  48. {{ $i18n.t("hotspot.hotspot_title") }}
  49. </div>
  50. <div class="title-input-wrapper">
  51. <input
  52. v-model.trim="hotspot.hotspotTitle"
  53. type="text"
  54. maxlength="15"
  55. :placeholder="$i18n.t('hotspot.title_placeholder')"
  56. />
  57. <span class="count">{{ hotspot.hotspotTitle.length }}/15</span>
  58. </div>
  59. <div class="remark">
  60. {{ $i18n.t("hotspot.title_show_mode") }}
  61. </div>
  62. <TabbarSwitcher
  63. class="display-mode-selector"
  64. :tabList="[
  65. $i18n.t('hotspot.show_on_hover'),
  66. $i18n.t('hotspot.always_show'),
  67. $i18n.t('hotspot.never_show'),
  68. ]"
  69. :activeIdx="currentTitleDispayModeIdx"
  70. @select="onSelectTitleDisplayMode"
  71. />
  72. <div class="remark">
  73. {{ $i18n.t("hotspot.title_position") }}
  74. </div>
  75. <TabbarSwitcherIcon
  76. class="display-mode-selector"
  77. :tabList="[
  78. {
  79. icon: 'icon-up',
  80. tip: $i18n.t('hotspot.title_top'),
  81. },
  82. {
  83. icon: 'icon-down',
  84. tip: $i18n.t('hotspot.title_bottom'),
  85. },
  86. {
  87. icon: 'icon-left',
  88. tip: $i18n.t('hotspot.title_left'),
  89. },
  90. {
  91. icon: 'icon-right',
  92. tip: $i18n.t('hotspot.title_right'),
  93. },
  94. {
  95. icon: 'icon-mobile',
  96. tip: $i18n.t('hotspot.title_custom'),
  97. },
  98. ]"
  99. :activeIdx="currentTitlePositionIdx"
  100. @select="onSelectTitlePosition"
  101. />
  102. </div>
  103. <div class="effect-setting">
  104. <div class="title-line">
  105. <div
  106. class="remark-highlight"
  107. v-if="
  108. $i18n.t(
  109. `hotspot.hotspot_type_specific_settings_title.${hotspot.hotspotType}`
  110. )
  111. "
  112. >
  113. {{
  114. $i18n.t(
  115. `hotspot.hotspot_type_specific_settings_title.${hotspot.hotspotType}`
  116. )
  117. }}
  118. </div>
  119. <div class="tip" v-if="currentHotspotTypeConfigData.tip">
  120. {{ currentHotspotTypeConfigData.tip }}
  121. </div>
  122. </div>
  123. <component
  124. class="effect-setting-component"
  125. @sceneSelect="handleSceneSelect"
  126. :scene="hotspot.secne"
  127. @imageChange="
  128. (data) => {
  129. hotspot.image = data;
  130. }
  131. "
  132. :image="hotspot.image"
  133. @linkChange="
  134. (data) => {
  135. hotspot.hyperlink = data;
  136. }
  137. "
  138. :link="hotspot.hyperlink"
  139. @linkOpenType="
  140. (data) => {
  141. hotspot.linkOpenType = data;
  142. }
  143. "
  144. :linkOpenType="hotspot.linkOpenType"
  145. @textChange="
  146. (data) => {
  147. hotspot.textarea = data;
  148. }
  149. "
  150. :textarea="hotspot.textarea"
  151. @audioChange="
  152. (data) => {
  153. hotspot.audio = data;
  154. }
  155. "
  156. :audio="hotspot.audio"
  157. @videoChange="
  158. (data) => {
  159. hotspot.video = data;
  160. }
  161. "
  162. :video="hotspot.video"
  163. :is="effectSettingComponent"
  164. />
  165. </div>
  166. </div>
  167. <div class="ui-between footer" app-border dir-top>
  168. <button
  169. class="ui-button deepcancel"
  170. :class="{ disable: false }"
  171. @click="cancel"
  172. >
  173. {{ $i18n.t("hotspot.cancel") }}
  174. </button>
  175. <button
  176. class="ui-button submit"
  177. :class="{ disable: !canSubmit }"
  178. @click="save"
  179. >
  180. {{ $i18n.t("hotspot.finish") }}
  181. </button>
  182. </div>
  183. </div>
  184. </transition>
  185. </template>
  186. <script>
  187. import RangeItem from "@/components/rangeItem/index.vue";
  188. import Combox from "@/components/shared/Combox";
  189. import { mapGetters } from "vuex";
  190. import Switcher from "@/components/shared/Switcher.vue";
  191. import TabbarSwitcher from "@/components/shared/TabbarSwitcher.vue";
  192. import TabbarSwitcherIcon from "@/components/shared/TabbarSwitcherIcon.vue";
  193. import hotspotTypeList from "./hotspotTypeList.js";
  194. import { isValidPhoneNumber } from "libphonenumber-js/max";
  195. export default {
  196. props: ["show", "data", "editTitle"],
  197. components: {
  198. RangeItem,
  199. Combox,
  200. Switcher,
  201. TabbarSwitcher,
  202. TabbarSwitcherIcon,
  203. },
  204. data() {
  205. return {
  206. hotspotTypeList,
  207. hotspotIconTypeList: [
  208. {
  209. name: this.$i18n.t("hotspot.hotspot_icon_type.system_icon"),
  210. id: "system_icon",
  211. },
  212. {
  213. name: this.$i18n.t("hotspot.hotspot_icon_type.custom_image"),
  214. id: "custom_image",
  215. },
  216. {
  217. name: this.$i18n.t("hotspot.hotspot_icon_type.serial_frame"),
  218. id: "serial_frame",
  219. },
  220. {
  221. name: this.$i18n.t("hotspot.hotspot_icon_type.personalized_tag"),
  222. id: "personalized_tag",
  223. },
  224. ],
  225. rang: {
  226. label: this.$i18n.t("hotspot.icon_size"),
  227. unit: this.$i18n.t("hotspot.unit"),
  228. gradient: 0.1,
  229. value: 1,
  230. min: 0.5,
  231. max: 2,
  232. },
  233. };
  234. },
  235. watch: {
  236. hotspot: {
  237. handler(val) {
  238. // console.error("this.hotspot", val);
  239. console.error("hotspot", val);
  240. this.$bus.emit("edithotspot", val);
  241. console.log("this.$bus", this.$bus);
  242. // this.$getKrpano().call("removeJQHotspot(" + val.name + ");");
  243. // this.$bus.emit("addhotspot", val);
  244. },
  245. deep: true,
  246. },
  247. // hotspotIcon: {
  248. // handler(val) {
  249. // console.error("this.hotspotIcon", val);
  250. // val.img.length > 0 &&
  251. // this.$getKrpano().set(`hotspot[${this.hotspot.name}].url`, val.img);
  252. // },
  253. // deep: true,
  254. // },
  255. // "hotspot.img": function () {
  256. // console.log("this.hotspot.img", this.hotspot.img);
  257. // this.$getKrpano().set(
  258. // `hotspot[${this.hotspot.name}].url`,
  259. // this.hotspot.img
  260. // );
  261. // },
  262. // "hotspot.titlePosition": function (val) {
  263. // console.log("111", val);
  264. // if (val === "bottom") {
  265. // this.$getKrpano().set("layer[tooltip_" + this.hotspot.name + "].css");
  266. // }
  267. // },
  268. // "hotspot.hotspotTitle": function () {
  269. // this.$getKrpano().set(
  270. // "layer[tooltip_" + this.hotspot.name + "].html",
  271. // `<span style="color:white">${this.hotspot.hotspotTitle}</span>`
  272. // );
  273. // },
  274. // 'hotspot.visible': function () {
  275. // this.$getKrpano().set('layer[tooltip_' + this.hotspot.name + '].visible', this.hotspot.visible)
  276. // },
  277. // "hotspot.size": {
  278. // immediate: true,
  279. // handler: function (newVal) {
  280. // let h = 52;
  281. // let scaleH = h * newVal;
  282. // let offset = "-130%";
  283. // this.rang = { ...this.rang, value: newVal };
  284. // this.$getKrpano().set(`hotspot[${this.hotspot.name}].height`, scaleH);
  285. // if (newVal < 1) {
  286. // offset = "-200%";
  287. // }
  288. // if (newVal > 1) {
  289. // offset = "-100%";
  290. // }
  291. // this.$getKrpano().set(
  292. // "layer[tooltip_" + this.hotspot.name + "].y",
  293. // `${offset}`
  294. // );
  295. // },
  296. // },
  297. // "hotspot.fontSize": {
  298. // handler: function (newVal) {
  299. // this.$getKrpano().set(
  300. // "layer[tooltip_" + this.hotspot.name + "].css",
  301. // `text-align:center; color:#FFFFFF;
  302. // font-family:STXihei;font-size:${newVal}px;`
  303. // );
  304. // },
  305. // },
  306. },
  307. beforeDestroy() {
  308. this.$bus.removeListener("resethotspotTitle", this.listerFnReset);
  309. },
  310. computed: {
  311. ...mapGetters({
  312. hotspot: "hotspot",
  313. backupHotSpot: "backupHotSpot",
  314. hotspotIcon: "hotspotIcon",
  315. }),
  316. iconTypeComponent() {
  317. let tmp = this.hotspot.hotspotIconType;
  318. return () => import(`./hotspotIconType/${tmp}.vue`);
  319. },
  320. currentTitleDispayModeIdx() {
  321. switch (this.hotspot.titleDisplayMode) {
  322. case "hover":
  323. return 0;
  324. case "always":
  325. return 1;
  326. case "never":
  327. return 2;
  328. default:
  329. return 0;
  330. }
  331. },
  332. currentTitlePositionIdx() {
  333. switch (this.hotspot.titlePosition) {
  334. case "top":
  335. return 0;
  336. case "bottom":
  337. return 1;
  338. case "left":
  339. return 2;
  340. case "right":
  341. return 3;
  342. case "custom":
  343. return 4;
  344. default:
  345. return 0;
  346. }
  347. },
  348. effectSettingComponent() {
  349. let tmp = this.hotspot.hotspotType;
  350. return () => import(`./hotspotType/${tmp}.vue`);
  351. },
  352. canSubmit() {
  353. // 热点类型相关设置项
  354. switch (this.hotspot.hotspotType) {
  355. case "scene":
  356. if (!this.hotspot.secne) {
  357. return false;
  358. }
  359. break;
  360. case "image":
  361. if (!this.hotspot.image || this.hotspot.image.length === 0) {
  362. return false;
  363. }
  364. break;
  365. case "video":
  366. if (!this.hotspot.video) {
  367. return false;
  368. }
  369. break;
  370. case "audio":
  371. if (!this.hotspot.audio) {
  372. return false;
  373. }
  374. break;
  375. case "link":
  376. if (!this.hotspot.hyperlink) {
  377. return false;
  378. }
  379. break;
  380. case "textarea":
  381. if (!this.hotspot.textarea) {
  382. return false;
  383. }
  384. break;
  385. case "tag":
  386. break;
  387. case "imageText":
  388. if (
  389. this.hotspot.imageTextInfo.imageList.length === 0 &&
  390. !this.hotspot.imageTextInfo.text
  391. ) {
  392. return false;
  393. }
  394. break;
  395. case "article":
  396. if (!this.hotspot.articleInfo.html) {
  397. return false;
  398. }
  399. break;
  400. case "pdf":
  401. if (!this.hotspot.pdfInfo.name || !this.hotspot.pdfInfo.url) {
  402. return false;
  403. }
  404. break;
  405. case "phone":
  406. if (
  407. !isValidPhoneNumber(this.hotspot.phoneInfo.phone) &&
  408. !isValidPhoneNumber("+86" + this.hotspot.phoneInfo.phone)
  409. ) {
  410. return false;
  411. }
  412. break;
  413. default:
  414. break;
  415. }
  416. // 热点图标类型相关设置项
  417. switch (this.hotspot.hotspotIconType) {
  418. case "system_icon":
  419. break;
  420. case "custom_image":
  421. if (!this.hotspot.customIconInfo.img) {
  422. return false;
  423. }
  424. break;
  425. case "serial_frame":
  426. // if (
  427. // !this.hotspot.serialFrameInfo.img ||
  428. // this.hotspot.serialFrameInfo.frameNumber <= 0 ||
  429. // this.hotspot.serialFrameInfo <= 0
  430. // ) {
  431. // return false;
  432. // }
  433. if (
  434. !this.hotspot.serialFrameInfo.img
  435. ) {
  436. return false;
  437. }
  438. break;
  439. case "personalized_tag":
  440. if (
  441. this.hotspot.personalizedTagInfo.isTextWrap &&
  442. this.hotspot.personalizedTagInfo.textNumPerLine <= 0
  443. ) {
  444. return false;
  445. }
  446. break;
  447. default:
  448. break;
  449. }
  450. // 其他设置项
  451. if (!this.hotspot.hotspotTitle) {
  452. return false;
  453. }
  454. return true;
  455. },
  456. currentHotspotTypeConfigData() {
  457. return hotspotTypeList.find((item) => {
  458. return item.id === this.hotspot.hotspotType;
  459. });
  460. },
  461. },
  462. beforeDestroy() {
  463. this.$bus.off("edithotspot", this.handleEditHotspot);
  464. this.$bus.off("delhotspot", this.cancel);
  465. },
  466. mounted() {
  467. this.$bus.on("resethotspotTitle", this.listerFnReset);
  468. this.$bus.on("delhotspot", this.cancel);
  469. this.$bus.on("edithotspot", this.handleEditHotspot);
  470. setTimeout(() => {
  471. if (
  472. this.editTitle != "编辑" &&
  473. this.editTitle != this.$i18n.t("hotspot.edit")
  474. ) {
  475. this.rang.value = window.g_hotspotCurrentScale;
  476. this.onRangeChange({ value: window.g_hotspotCurrentScale });
  477. }
  478. }, 300);
  479. },
  480. methods: {
  481. handleEditHotspot(data) {
  482. const krpano = document.getElementById("krpanoSWFObject");
  483. __krfn.utils.edithotspot(krpano, data);
  484. },
  485. handleSceneSelect(data) {
  486. this.hotspot.secne = {
  487. ...data,
  488. someData: {},
  489. };
  490. },
  491. onHotSpotTypeChange(data) {
  492. this.hotspot.hotspotType = data.id;
  493. },
  494. onHotspotIconTypeChange(data) {
  495. this.hotspot.hotspotIconType = data.id;
  496. },
  497. onRangeChange(data) {
  498. console.log(data);
  499. this.rang = { ...this.rang, value: data.value };
  500. this.hotspot.size = data.value;
  501. switch (data.value) {
  502. case 0.5:
  503. case 0.6:
  504. case 0.7:
  505. this.hotspot.fontSize = 12;
  506. break;
  507. case 0.8:
  508. case 0.9:
  509. case 1.0:
  510. case 1.1:
  511. case 1.2:
  512. this.hotspot.fontSize = 14;
  513. break;
  514. case 1.3:
  515. case 1.4:
  516. case 1.5:
  517. case 1.6:
  518. case 1.7:
  519. this.hotspot.fontSize = 17;
  520. break;
  521. case 1.8:
  522. case 1.9:
  523. case 2:
  524. this.hotspot.fontSize = 20;
  525. break;
  526. default:
  527. break;
  528. }
  529. },
  530. onSelectTitleDisplayMode(idx) {
  531. switch (idx) {
  532. case 0:
  533. this.hotspot.titleDisplayMode = "hover";
  534. break;
  535. case 1:
  536. this.hotspot.titleDisplayMode = "always";
  537. break;
  538. case 2:
  539. this.hotspot.titleDisplayMode = "never";
  540. break;
  541. default:
  542. break;
  543. }
  544. },
  545. onSelectTitlePosition(idx) {
  546. switch (idx) {
  547. case 0:
  548. this.hotspot.titlePosition = "top";
  549. break;
  550. case 1:
  551. this.hotspot.titlePosition = "bottom";
  552. break;
  553. case 2:
  554. this.hotspot.titlePosition = "left";
  555. break;
  556. case 3:
  557. this.hotspot.titlePosition = "right";
  558. break;
  559. case 4:
  560. this.hotspot.titlePosition = "custom";
  561. break;
  562. default:
  563. break;
  564. }
  565. },
  566. listerFnReset() {
  567. if (
  568. this.hotspot.hotspotTitle == "单击确定热点位置" ||
  569. this.hotspot.hotspotTitle == this.$i18n.t("hotspot.click_to_comfirm")
  570. ) {
  571. this.hotspot.hotspotTitle = "";
  572. }
  573. },
  574. cancel() {
  575. this.$store.commit("SetHotspot", this.backupHotSpot);
  576. this.$emit("close", {
  577. type: this.editTitle == this.$i18n.t("hotspot.edit") ? "edit" : "add",
  578. data: this.backupHotSpot,
  579. });
  580. },
  581. reset(data) {
  582. this.$bus.emit("edithotspotTitle", data);
  583. this.$bus.emit("edithotspotTitleisShow", data);
  584. // this.$getKrpano().set(`hotspot[${data.name}].url`, data.img);
  585. },
  586. save() {
  587. this.$store.commit("SetHotspot", this.hotspot);
  588. this.$emit("close");
  589. this.$emit("save", this.hotspot);
  590. },
  591. },
  592. };
  593. </script>
  594. <style lang="less" scoped>
  595. .hots-panel {
  596. background: #252526;
  597. z-index: 10;
  598. display: flex;
  599. flex-direction: column;
  600. .header {
  601. padding: 20px;
  602. display: flex;
  603. font-size: 18px;
  604. color: #fff;
  605. flex: 0 0 auto;
  606. .icon_close {
  607. color: rgba(255, 255, 255, 0.6);
  608. cursor: pointer;
  609. }
  610. }
  611. .content {
  612. padding: 0 20px 14px 20px;
  613. flex: 1 0 1px;
  614. overflow: auto;
  615. .type-setting {
  616. .remark {
  617. font-size: 14px;
  618. color: #ababab;
  619. }
  620. .combox {
  621. margin-top: 16px;
  622. }
  623. }
  624. .icon-setting {
  625. .icon-setting-title {
  626. font-size: 18px;
  627. color: #ffffff;
  628. }
  629. .remark {
  630. margin-top: 16px;
  631. font-size: 14px;
  632. color: #ababab;
  633. }
  634. .combox {
  635. margin-top: 16px;
  636. }
  637. .icon-setting-component {
  638. margin-top: 16px;
  639. }
  640. .bars {
  641. margin-top: 16px;
  642. }
  643. }
  644. .title-setting {
  645. .remark-highlight {
  646. margin-top: 16px;
  647. font-size: 18px;
  648. color: #ffffff;
  649. }
  650. > .title-input-wrapper {
  651. position: relative;
  652. border: 1px solid rgba(151, 151, 151, 0.2);
  653. padding: 0 16px;
  654. background: #1a1b1d;
  655. border-radius: 2px;
  656. height: 36px;
  657. width: 100%;
  658. margin-top: 18px;
  659. &:focus-within {
  660. border-color: #0076f6;
  661. }
  662. > input {
  663. border: none;
  664. background: transparent;
  665. outline: none;
  666. height: 100%;
  667. width: calc(100% - 50px);
  668. padding: 0;
  669. color: #fff;
  670. letter-spacing: 1px;
  671. font-size: 14px;
  672. }
  673. > .count {
  674. position: absolute;
  675. top: 50%;
  676. transform: translateY(-50%);
  677. right: 16px;
  678. font-size: 14px;
  679. color: rgba(255, 255, 255, 0.2);
  680. }
  681. }
  682. .remark {
  683. margin-top: 18px;
  684. color: rgba(255, 255, 255, 0.6);
  685. font-size: 14px;
  686. }
  687. .display-mode-selector {
  688. margin-top: 18px;
  689. }
  690. }
  691. .effect-setting {
  692. margin-top: 16px;
  693. > .title-line {
  694. margin-top: 16px;
  695. display: flex;
  696. justify-content: space-between;
  697. align-items: center;
  698. > .remark-highlight {
  699. font-size: 18px;
  700. color: #ffffff;
  701. }
  702. > .tip {
  703. font-size: 14px;
  704. color: #ffffff;
  705. opacity: 0.6;
  706. }
  707. }
  708. .combox {
  709. margin-top: 16px;
  710. }
  711. .effect-setting-component {
  712. margin-top: 16px;
  713. }
  714. }
  715. }
  716. .footer {
  717. flex: 0 0 auto;
  718. padding: 15px;
  719. background: #252526;
  720. .deepcancel {
  721. margin-right: 10px;
  722. }
  723. .ui-button {
  724. width: 112px;
  725. }
  726. }
  727. }
  728. </style>