EditPanel.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  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-lineDirection", val.personalizedTagInfo.lineDirection);
  240. },
  241. deep: true,
  242. },
  243. // hotspotIcon: {
  244. // handler(val) {
  245. // console.error("this.hotspotIcon", val);
  246. // val.img.length > 0 &&
  247. // this.$getKrpano().set(`hotspot[${this.hotspot.name}].url`, val.img);
  248. // },
  249. // deep: true,
  250. // },
  251. // "hotspot.img": function () {
  252. // console.log("this.hotspot.img", this.hotspot.img);
  253. // this.$getKrpano().set(
  254. // `hotspot[${this.hotspot.name}].url`,
  255. // this.hotspot.img
  256. // );
  257. // },
  258. // "hotspot.titlePosition": function (val) {
  259. // console.log("111", val);
  260. // if (val === "bottom") {
  261. // this.$getKrpano().set("layer[tooltip_" + this.hotspot.name + "].css");
  262. // }
  263. // },
  264. // "hotspot.hotspotTitle": function () {
  265. // this.$getKrpano().set(
  266. // "layer[tooltip_" + this.hotspot.name + "].html",
  267. // `<span style="color:white">${this.hotspot.hotspotTitle}</span>`
  268. // );
  269. // },
  270. // 'hotspot.visible': function () {
  271. // this.$getKrpano().set('layer[tooltip_' + this.hotspot.name + '].visible', this.hotspot.visible)
  272. // },
  273. // "hotspot.size": {
  274. // immediate: true,
  275. // handler: function (newVal) {
  276. // let h = 52;
  277. // let scaleH = h * newVal;
  278. // let offset = "-130%";
  279. // this.rang = { ...this.rang, value: newVal };
  280. // this.$getKrpano().set(`hotspot[${this.hotspot.name}].height`, scaleH);
  281. // if (newVal < 1) {
  282. // offset = "-200%";
  283. // }
  284. // if (newVal > 1) {
  285. // offset = "-100%";
  286. // }
  287. // this.$getKrpano().set(
  288. // "layer[tooltip_" + this.hotspot.name + "].y",
  289. // `${offset}`
  290. // );
  291. // },
  292. // },
  293. // "hotspot.fontSize": {
  294. // handler: function (newVal) {
  295. // this.$getKrpano().set(
  296. // "layer[tooltip_" + this.hotspot.name + "].css",
  297. // `text-align:center; color:#FFFFFF;
  298. // font-family:STXihei;font-size:${newVal}px;`
  299. // );
  300. // },
  301. // },
  302. },
  303. beforeDestroy() {
  304. this.$bus.removeListener("resethotspotTitle", this.listerFnReset);
  305. },
  306. computed: {
  307. ...mapGetters({
  308. hotspot: "hotspot",
  309. backupHotSpot: "backupHotSpot",
  310. hotspotIcon: "hotspotIcon",
  311. }),
  312. iconTypeComponent() {
  313. let tmp = this.hotspot.hotspotIconType;
  314. return () => import(`./hotspotIconType/${tmp}.vue`);
  315. },
  316. currentTitleDispayModeIdx() {
  317. switch (this.hotspot.titleDisplayMode) {
  318. case "hover":
  319. return 0;
  320. case "always":
  321. return 1;
  322. case "never":
  323. return 2;
  324. default:
  325. return 0;
  326. }
  327. },
  328. currentTitlePositionIdx() {
  329. switch (this.hotspot.titlePosition) {
  330. case "top":
  331. return 0;
  332. case "bottom":
  333. return 1;
  334. case "left":
  335. return 2;
  336. case "right":
  337. return 3;
  338. case "custom":
  339. return 4;
  340. default:
  341. return 0;
  342. }
  343. },
  344. effectSettingComponent() {
  345. let tmp = this.hotspot.hotspotType;
  346. return () => import(`./hotspotType/${tmp}.vue`);
  347. },
  348. canSubmit() {
  349. // 热点类型相关设置项
  350. switch (this.hotspot.hotspotType) {
  351. case "scene":
  352. if (!this.hotspot.secne) {
  353. return false;
  354. }
  355. break;
  356. case "image":
  357. if (!this.hotspot.image || this.hotspot.image.length === 0) {
  358. return false;
  359. }
  360. break;
  361. case "video":
  362. if (!this.hotspot.video) {
  363. return false;
  364. }
  365. break;
  366. case "audio":
  367. if (!this.hotspot.audio) {
  368. return false;
  369. }
  370. break;
  371. case "link":
  372. if (!this.hotspot.hyperlink) {
  373. return false;
  374. }
  375. break;
  376. case "textarea":
  377. if (!this.hotspot.textarea) {
  378. return false;
  379. }
  380. break;
  381. case "tag":
  382. break;
  383. case "imageText":
  384. if (
  385. this.hotspot.imageTextInfo.imageList.length === 0 &&
  386. !this.hotspot.imageTextInfo.text
  387. ) {
  388. return false;
  389. }
  390. break;
  391. case "article":
  392. if (!this.hotspot.articleInfo.html) {
  393. return false;
  394. }
  395. break;
  396. case "pdf":
  397. if (!this.hotspot.pdfInfo.name || !this.hotspot.pdfInfo.url) {
  398. return false;
  399. }
  400. break;
  401. case "phone":
  402. if (
  403. !isValidPhoneNumber(this.hotspot.phoneInfo.phone) &&
  404. !isValidPhoneNumber("+86" + this.hotspot.phoneInfo.phone)
  405. ) {
  406. return false;
  407. }
  408. break;
  409. default:
  410. break;
  411. }
  412. // 热点图标类型相关设置项
  413. switch (this.hotspot.hotspotIconType) {
  414. case "system_icon":
  415. break;
  416. case "custom_image":
  417. if (!this.hotspot.customIconInfo.img) {
  418. return false;
  419. }
  420. break;
  421. case "serial_frame":
  422. if (
  423. !this.hotspot.serialFrameInfo.url ||
  424. this.hotspot.serialFrameInfo.frameNumber <= 0 ||
  425. this.hotspot.serialFrameInfo <= 0
  426. ) {
  427. return false;
  428. }
  429. break;
  430. case "personalized_tag":
  431. if (
  432. this.hotspot.personalizedTagInfo.isTextWrap &&
  433. this.hotspot.personalizedTagInfo.textNumPerLine <= 0
  434. ) {
  435. return false;
  436. }
  437. break;
  438. default:
  439. break;
  440. }
  441. // 其他设置项
  442. if (!this.hotspot.hotspotTitle) {
  443. return false;
  444. }
  445. return true;
  446. },
  447. currentHotspotTypeConfigData() {
  448. return hotspotTypeList.find((item) => {
  449. return item.id === this.hotspot.hotspotType;
  450. });
  451. },
  452. },
  453. mounted() {
  454. this.$bus.on("resethotspotTitle", this.listerFnReset);
  455. this.$bus.on("delhotspot", () => {
  456. this.cancel();
  457. });
  458. setTimeout(() => {
  459. if (
  460. this.editTitle != "编辑" &&
  461. this.editTitle != this.$i18n.t("hotspot.edit")
  462. ) {
  463. this.rang.value = window.g_hotspotCurrentScale;
  464. this.onRangeChange({ value: window.g_hotspotCurrentScale });
  465. }
  466. }, 300);
  467. },
  468. methods: {
  469. handleSceneSelect(data) {
  470. this.hotspot.secne = {
  471. ...data,
  472. someData: {},
  473. };
  474. },
  475. onHotSpotTypeChange(data) {
  476. this.hotspot.hotspotType = data.id;
  477. },
  478. onHotspotIconTypeChange(data) {
  479. this.hotspot.hotspotIconType = data.id;
  480. },
  481. onRangeChange(data) {
  482. console.log(data);
  483. this.rang = { ...this.rang, value: data.value };
  484. this.hotspot.size = data.value;
  485. switch (data.value) {
  486. case 0.5:
  487. case 0.6:
  488. case 0.7:
  489. this.hotspot.fontSize = 12;
  490. break;
  491. case 0.8:
  492. case 0.9:
  493. case 1.0:
  494. case 1.1:
  495. case 1.2:
  496. this.hotspot.fontSize = 14;
  497. break;
  498. case 1.3:
  499. case 1.4:
  500. case 1.5:
  501. case 1.6:
  502. case 1.7:
  503. this.hotspot.fontSize = 17;
  504. break;
  505. case 1.8:
  506. case 1.9:
  507. case 2:
  508. this.hotspot.fontSize = 20;
  509. break;
  510. default:
  511. break;
  512. }
  513. },
  514. onSelectTitleDisplayMode(idx) {
  515. switch (idx) {
  516. case 0:
  517. this.hotspot.titleDisplayMode = "hover";
  518. break;
  519. case 1:
  520. this.hotspot.titleDisplayMode = "always";
  521. break;
  522. case 2:
  523. this.hotspot.titleDisplayMode = "never";
  524. break;
  525. default:
  526. break;
  527. }
  528. },
  529. onSelectTitlePosition(idx) {
  530. switch (idx) {
  531. case 0:
  532. this.hotspot.titlePosition = "top";
  533. break;
  534. case 1:
  535. this.hotspot.titlePosition = "bottom";
  536. break;
  537. case 2:
  538. this.hotspot.titlePosition = "left";
  539. break;
  540. case 3:
  541. this.hotspot.titlePosition = "right";
  542. break;
  543. case 4:
  544. this.hotspot.titlePosition = "custom";
  545. break;
  546. default:
  547. break;
  548. }
  549. },
  550. listerFnReset() {
  551. if (
  552. this.hotspot.hotspotTitle == "单击确定热点位置" ||
  553. this.hotspot.hotspotTitle == this.$i18n.t("hotspot.click_to_comfirm")
  554. ) {
  555. this.hotspot.hotspotTitle = "";
  556. }
  557. },
  558. cancel() {
  559. this.$store.commit("SetHotspot", this.backupHotSpot);
  560. this.$emit("close", {
  561. type: this.editTitle == this.$i18n.t("hotspot.edit") ? "edit" : "add",
  562. data: this.backupHotSpot,
  563. });
  564. },
  565. reset(data) {
  566. this.$bus.emit("edithotspotTitle", data);
  567. this.$bus.emit("edithotspotTitleisShow", data);
  568. this.$getKrpano().set(`hotspot[${data.name}].url`, data.img);
  569. },
  570. save() {
  571. this.$store.commit("SetHotspot", this.hotspot);
  572. this.$emit("close");
  573. this.$emit("save", this.hotspot);
  574. },
  575. },
  576. };
  577. </script>
  578. <style lang="less" scoped>
  579. .hots-panel {
  580. background: #252526;
  581. z-index: 10;
  582. display: flex;
  583. flex-direction: column;
  584. .header {
  585. padding: 20px;
  586. display: flex;
  587. font-size: 18px;
  588. color: #fff;
  589. flex: 0 0 auto;
  590. .icon_close {
  591. color: rgba(255, 255, 255, 0.6);
  592. cursor: pointer;
  593. }
  594. }
  595. .content {
  596. padding: 0 20px 14px 20px;
  597. flex: 1 0 1px;
  598. overflow: auto;
  599. .type-setting {
  600. .remark {
  601. font-size: 14px;
  602. color: #ababab;
  603. }
  604. .combox {
  605. margin-top: 16px;
  606. }
  607. }
  608. .icon-setting {
  609. .icon-setting-title {
  610. font-size: 18px;
  611. color: #ffffff;
  612. }
  613. .remark {
  614. margin-top: 16px;
  615. font-size: 14px;
  616. color: #ababab;
  617. }
  618. .combox {
  619. margin-top: 16px;
  620. }
  621. .icon-setting-component {
  622. margin-top: 16px;
  623. }
  624. .bars {
  625. margin-top: 16px;
  626. }
  627. }
  628. .title-setting {
  629. .remark-highlight {
  630. margin-top: 16px;
  631. font-size: 18px;
  632. color: #ffffff;
  633. }
  634. > .title-input-wrapper {
  635. position: relative;
  636. border: 1px solid rgba(151, 151, 151, 0.2);
  637. padding: 0 16px;
  638. background: #1a1b1d;
  639. border-radius: 2px;
  640. height: 36px;
  641. width: 100%;
  642. margin-top: 18px;
  643. &:focus-within {
  644. border-color: #0076f6;
  645. }
  646. > input {
  647. border: none;
  648. background: transparent;
  649. outline: none;
  650. height: 100%;
  651. width: calc(100% - 50px);
  652. padding: 0;
  653. color: #fff;
  654. letter-spacing: 1px;
  655. font-size: 14px;
  656. }
  657. > .count {
  658. position: absolute;
  659. top: 50%;
  660. transform: translateY(-50%);
  661. right: 16px;
  662. font-size: 14px;
  663. color: rgba(255, 255, 255, 0.2);
  664. }
  665. }
  666. .remark {
  667. margin-top: 18px;
  668. color: rgba(255, 255, 255, 0.6);
  669. font-size: 14px;
  670. }
  671. .display-mode-selector {
  672. margin-top: 18px;
  673. }
  674. }
  675. .effect-setting {
  676. margin-top: 16px;
  677. > .title-line {
  678. margin-top: 16px;
  679. display: flex;
  680. justify-content: space-between;
  681. align-items: center;
  682. > .remark-highlight {
  683. font-size: 18px;
  684. color: #ffffff;
  685. }
  686. > .tip {
  687. font-size: 14px;
  688. color: #ffffff;
  689. opacity: 0.6;
  690. }
  691. }
  692. .combox {
  693. margin-top: 16px;
  694. }
  695. .effect-setting-component {
  696. margin-top: 16px;
  697. }
  698. }
  699. }
  700. .footer {
  701. flex: 0 0 auto;
  702. padding: 15px;
  703. background: #252526;
  704. .deepcancel {
  705. margin-right: 10px;
  706. }
  707. .ui-button {
  708. width: 112px;
  709. }
  710. }
  711. }
  712. </style>