image.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <div class="hotspot" v-if="!isMobile">
  3. <img class="aa" v-if="hotspot.images.length > 1" :src="require('@/assets/images/proj2022/pc/left_1.png')" alt="" @click="handlePage('prev')" />
  4. <div class="vhotspotcon">
  5. <div class="vtitle" v-if="hotspot.title" v-html="hotspot.title"></div>
  6. <div class="hotspotcon" :class="{hotconfull:!hotspot.title&&!(hotspot.title||hotspot.imagesDesc[active])}">
  7. <div class="img-con" :class="{ bigImg: !(hotspot.imagesDesc[active]|| hotspot.contents[active]) }">
  8. <div class="imgmain">
  9. <img id="map" :src="g_fixUrl(hotspot.images[active])" alt="" />
  10. </div>
  11. <div class="pagna" v-if="hotspot.images.length > 1">
  12. <span>{{ active + 1 }}</span>
  13. /
  14. <span>{{ hotspot.images.length }}</span>
  15. </div>
  16. </div>
  17. <div class="desc" v-html="handleContent(hotspot.imagesDesc[active] || hotspot.contents[active])"></div>
  18. </div>
  19. </div>
  20. <img class="aa" v-if="hotspot.images.length > 1" :src="require('@/assets/images/proj2022/pc/right_1.png')" alt="" @click="handlePage('next')" />
  21. </div>
  22. <div v-else class="mbhotspot">
  23. <div class="mbhcon" :class="{ fullcon: !hotspot.content || !hotspot.contents[active] }">
  24. <div class="img-con">
  25. <img class="aa" :class="{hengaa:g_isLandscape}" v-if="hotspot.images.length > 1" :src="require('@/assets/images/proj2022/mobile/prev.png')" alt="" @click="handlePage('prev')" />
  26. <div class="imgmain" >
  27. <img id="map" :src="g_fixUrl(hotspot.images[active])" alt="" />
  28. </div>
  29. <img class="aa" :class="{hengaa:g_isLandscape}" v-if="hotspot.images.length > 1" :src="require('@/assets/images/proj2022/mobile/next.png')" alt="" @click="handlePage('next')" />
  30. </div>
  31. <div class="desc" v-if="hotspot.imagesDesc[active] || hotspot.contents[active]">
  32. <div class="title" v-html="hotspot.title"></div>
  33. <div v-html="handleContent(hotspot.imagesDesc[active] || hotspot.contents[active], 14)"></div>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import Panzoom from "@panzoom/panzoom";
  40. export default {
  41. props: ["hotspot", "type"],
  42. data() {
  43. return {
  44. panzoom: "",
  45. active: 0,
  46. to: null,
  47. };
  48. },
  49. watch: {
  50. active() {
  51. setTimeout(() => {
  52. this.$showLoading();
  53. });
  54. if (this.to) {
  55. clearTimeout(this.to);
  56. this.to = null;
  57. }
  58. this.to = setTimeout(() => {
  59. this.$hideLoading();
  60. }, 1000);
  61. },
  62. },
  63. methods: {
  64. handlePage(type) {
  65. if (type === "next") {
  66. if (this.active >= this.hotspot.images.length - 1) {
  67. this.active = 0;
  68. return;
  69. }
  70. this.active += 1;
  71. } else {
  72. if (this.active == 0) {
  73. this.active = this.hotspot.images.length - 1;
  74. return;
  75. }
  76. this.active -= 1;
  77. }
  78. },
  79. reset() {
  80. this.panzoom.pan(0, 0);
  81. // this.panzoom.zoom(this.isMobile ? 1 : !this.hotspot.content ? 0.8 : 1);
  82. this.panzoom.zoom(1);
  83. this.$hideLoading();
  84. },
  85. },
  86. computed: {
  87. },
  88. mounted() {
  89. const elem = document.getElementById("map");
  90. this.panzoom = Panzoom(elem, {
  91. maxScale: 10,
  92. startScale: 1
  93. });
  94. const parent = elem.parentElement
  95. // No function bind needed
  96. parent.addEventListener("wheel", this.panzoom.zoomWithWheel);
  97. parent.addEventListener("load", () => {
  98. this.reset();
  99. });
  100. parent.addEventListener("abort", () => {
  101. this.reset();
  102. });
  103. parent.addEventListener("error", () => {
  104. this.reset();
  105. });
  106. },
  107. };
  108. </script>
  109. <style lang="less" scoped>
  110. .noshow {
  111. opacity: 0 !important;
  112. pointer-events: none !important;
  113. }
  114. @w: 75%;
  115. @fixw: 8px;
  116. .hotspot {
  117. .vhotspotcon{
  118. width: 100%;
  119. }
  120. }
  121. .mbhotspot {
  122. width: 100%;
  123. height: 100%;
  124. position: fixed;
  125. left: 0;
  126. top: 0;
  127. z-index: 9999;
  128. .close {
  129. position: absolute;
  130. top: 26px;
  131. right: 16px;
  132. width: 20px;
  133. z-index: 1000;
  134. }
  135. .mbhcon {
  136. position: absolute;
  137. top: 50%;
  138. width: 100%;
  139. left: 50%;
  140. transform: translate(-50%, -50%);
  141. height: 100%;
  142. .img-con {
  143. display: flex;
  144. height: 100%;
  145. align-items: center;
  146. justify-content: space-between;
  147. position: relative;
  148. overflow: hidden;
  149. .imgmain {
  150. width: 100%;
  151. height: auto;
  152. min-height: 100%;
  153. display: flex;
  154. align-items: center;
  155. justify-content: center;
  156. text-align: center;
  157. img {
  158. cursor: pointer;
  159. max-width: 100%;
  160. }
  161. }
  162. @pos: 10px;
  163. @posh: 50px;
  164. .aa {
  165. position: absolute;
  166. width: 30px;
  167. height: auto;
  168. cursor: pointer;
  169. top: 50%;
  170. transform: translateY(-50%);
  171. left: @pos;
  172. z-index: 999;
  173. &:last-of-type {
  174. right: @pos;
  175. left: unset;
  176. }
  177. }
  178. .hengaa{
  179. position: absolute;
  180. width: 30px;
  181. height: auto;
  182. cursor: pointer;
  183. top: 50%;
  184. transform: translateY(-50%);
  185. left: @posh;
  186. z-index: 999;
  187. &:last-of-type {
  188. right: @posh;
  189. left: unset;
  190. }
  191. }
  192. }
  193. .desc {
  194. overflow-y: auto;
  195. position: absolute;
  196. z-index: 99999;
  197. bottom: 0;
  198. left: 50%;
  199. width: 100%;
  200. padding: 2% 5%;
  201. transform: translateX(-50%);
  202. margin: 0;
  203. min-height: 10vh;
  204. max-height: 34vh;
  205. background: rgba(0, 0, 0, 0.5);
  206. text-align: left;
  207. word-break: break-all;
  208. .title {
  209. width: 100%;
  210. display: inline-block;
  211. font-size: 16px;
  212. margin-bottom: 10px;
  213. }
  214. }
  215. }
  216. .fullcon {
  217. width: 100%;
  218. height: 100%;
  219. .img-con {
  220. height: 100%;
  221. .imgmain {
  222. width: 100%;
  223. height: auto;
  224. min-height: 100%;
  225. display: flex;
  226. align-items: center;
  227. text-align: center;
  228. }
  229. }
  230. }
  231. }
  232. </style>