panoImagePreviewer.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <popup v-if="ifShow">
  3. <div class="preview-wrapper" ref="preview-wrapper">
  4. <div class="title">{{imageTitleList[currentIndex]}}</div>
  5. <img class="close-btn" :src="require('@/assets/images/icons/material_preview_close@2x.png')" @click=onClickClose />
  6. <iframe
  7. ref="iframe"
  8. class="iframe"
  9. allowfullscreen="true"
  10. :src="'./vr.html?hideScale=true&vr='+ sceneCodeList[currentIndex]"
  11. frameborder="0"
  12. :style="{width: imageWidth, height: imageHeight}"
  13. />
  14. <div class="toolbar">
  15. <i
  16. class="iconfont icon-material_preview_previous hover-tips" :class="{disabled: currentIndex === 0}" @click="onClickPrevious()">
  17. <div>
  18. <div class="remark">上一张</div>
  19. </div>
  20. </i>
  21. <i class="iconfont icon-material_preview_next1 hover-tips append-splitter" :class="{disabled: currentIndex === sceneCodeList.length - 1}" @click="onClickNext()">
  22. <div>
  23. <div class="remark">下一张</div>
  24. </div>
  25. </i>
  26. <i class="iconfont icon-material_preview_next hover-tips-warn" @click="onClickDelete()">
  27. <div>
  28. <div class="remark">删除</div>
  29. </div>
  30. </i>
  31. <i v-if="!isFullscreen" class="iconfont icon-material_preview_full_screen hover-tips" @click="onClickFullScreen()">
  32. <div>
  33. <div class="remark">全屏</div>
  34. </div>
  35. </i>
  36. <i v-if="isFullscreen" class="iconfont icon-material_preview_drop_out hover-tips" @click="onClickCancelFullScreen()">
  37. <div>
  38. <div class="remark">取消全屏</div>
  39. </div>
  40. </i>
  41. </div>
  42. </div>
  43. </popup>
  44. </template>
  45. <script>
  46. import Popup from "@/components/shared/popup";
  47. export default {
  48. props: {
  49. imageTitleList: {
  50. type: Array,
  51. default: () => {
  52. return [
  53. // 'aaa',
  54. // 'bbb'
  55. ]
  56. }
  57. },
  58. sceneCodeList: {
  59. type: Array,
  60. default: () => {
  61. return [
  62. // 'fd720_jWlTO6FIr',
  63. // 'fd720_egHPArS4K',
  64. ]
  65. }
  66. },
  67. canFullScreen: {
  68. type: Boolean,
  69. default: true
  70. },
  71. },
  72. components:{
  73. Popup
  74. },
  75. data(){
  76. return {
  77. ifShow: false,
  78. currentIndex: 0,
  79. isFullscreen: false,
  80. }
  81. },
  82. computed: {
  83. imageWidth() {
  84. return this.isFullscreen ? '100%' : '960px'
  85. },
  86. imageHeight() {
  87. return this.isFullscreen ? '100%': '540px'
  88. }
  89. },
  90. watch: {
  91. sceneCodeList: {
  92. handler: function (newList) {
  93. if (newList.length - 1 < this.currentIndex) {
  94. this.currentIndex = newList.length - 1
  95. }
  96. }
  97. }
  98. },
  99. methods:{
  100. show(index) {
  101. Number.isSafeInteger(index) && (this.currentIndex = index)
  102. this.ifShow = true
  103. },
  104. onClickPrevious() {
  105. if (this.currentIndex > 0) {
  106. this.currentIndex--
  107. }
  108. },
  109. onClickNext() {
  110. if (this.currentIndex < this.sceneCodeList.length - 1) {
  111. this.currentIndex++
  112. }
  113. },
  114. onClickDelete() {
  115. this.$emit('click-delete', this.currentIndex)
  116. },
  117. onClickFullScreen() {
  118. const element = this.$refs['preview-wrapper']
  119. if (element.requestFullscreen) {
  120. element.requestFullscreen();
  121. } else if (element.webkitRequestFullScreen) {
  122. element.webkitRequestFullScreen();
  123. } else if (element.mozRequestFullScreen) {
  124. element.mozRequestFullScreen();
  125. } else if (element.msRequestFullscreen) {
  126. element.msRequestFullscreen();
  127. }
  128. this.isFullscreen = true
  129. },
  130. onClickCancelFullScreen() {
  131. if (document.exitFullscreen) {
  132. document.exitFullscreen();
  133. } else if (document.webkitCancelFullScreen) {
  134. document.webkitCancelFullScreen();
  135. } else if (document.mozCancelFullScreen) {
  136. document.mozCancelFullScreen();
  137. } else if (document.msExitFullscreen) {
  138. document.msExitFullscreen();
  139. }
  140. this.isFullscreen = false
  141. },
  142. onClickClose() {
  143. this.ifShow = false
  144. }
  145. }
  146. }
  147. </script>
  148. <style scoped lang="less">
  149. .preview-wrapper {
  150. position: fixed;
  151. top: 0;
  152. left: 0;
  153. right: 0;
  154. bottom: 0;
  155. .title {
  156. position: absolute;
  157. top: 16px;
  158. left: 30px;
  159. z-index: 2;
  160. height: 36px;
  161. font-size: 14px;
  162. color: #FFFFFF;
  163. background: rgba(0, 0, 0, 0.6);
  164. border-radius: 18px;
  165. display: flex;
  166. justify-content: center;
  167. align-items: center;
  168. padding-left: 16px;
  169. padding-right: 16px;
  170. }
  171. .close-btn {
  172. position: absolute;
  173. top: 16px;
  174. right: 30px;
  175. width: 36px;
  176. height: 36px;
  177. z-index: 2;
  178. cursor: pointer;
  179. }
  180. .toolbar {
  181. position: absolute;
  182. bottom: 110px;
  183. left: 50%;
  184. transform: translateX(-50%);
  185. height: 60px;
  186. display: flex;
  187. justify-content: center;
  188. align-items: center;
  189. padding: 0 43px;
  190. background: rgba(0, 0, 0, 0.6);
  191. border-radius: 8px;
  192. z-index: 2;
  193. .iconfont {
  194. cursor: pointer;
  195. color: white;
  196. margin-right: 36px;
  197. font-size: 22px;
  198. &.disabled {
  199. opacity: 0.5;
  200. pointer-events: none;
  201. }
  202. &:last-child {
  203. margin-right: 0;
  204. }
  205. }
  206. .append-splitter {
  207. &::after {
  208. pointer-events: none;
  209. content: "|";
  210. position: absolute;
  211. right: -18px;
  212. top: -4px;
  213. font-size: 20px;
  214. color: rgba(255, 255, 255, 0.5);
  215. }
  216. }
  217. }
  218. .iframe {
  219. position: absolute;
  220. left: 50%;
  221. top: 50%;
  222. transform: translate(-50%, -50%);
  223. z-index: 1;
  224. }
  225. }
  226. .hover-tips, .hover-tips-warn {
  227. position: relative;
  228. font-size: 18px;
  229. &:hover {
  230. > div {
  231. display: block;
  232. }
  233. }
  234. // tip的方框
  235. > div {
  236. background: rgba(0, 0, 0, 0.6);
  237. border: none;
  238. cursor: default;
  239. display: none;
  240. z-index: 10000;
  241. position: absolute;
  242. left: 50%;
  243. transform: translateX(-50%);
  244. top: -60px;
  245. color: #fff;
  246. pointer-events: none;
  247. text-align: center;
  248. word-break: keep-all;
  249. padding: 0 8px;
  250. font-size: 12px;
  251. border-radius: 3px;
  252. // tip的箭头
  253. &::before {
  254. border: 7px solid transparent;
  255. border-top: 7px solid rgba(0, 0, 0, 0.6);
  256. width: 0;
  257. height: 0px;
  258. content: "";
  259. display: inline-block;
  260. position: absolute;
  261. bottom: -14px;
  262. left: 50%;
  263. transform: translateX(-50%);
  264. }
  265. // tip的文字
  266. .remark {
  267. line-height: 2.5;
  268. color: #fff;
  269. }
  270. }
  271. }
  272. </style>