index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <template>
  2. <div class="iframe-layout" :class="{mobile: ismobile}">
  3. <template v-if="ismobile">
  4. <div class="top-layer">
  5. <a @click="clickHandle" class="rad"><i class="iconfont icon-left"></i>返回</a>
  6. <template v-if="$route.params.id">
  7. <a @click="exitHandle" class="xiangce" v-if="key" :class="{active: big}">{{isHangpai?'航拍':'大场景'}}</a>
  8. <!-- <a @click="xiangceHandle" class="xiangce" v-if="key&&imgs" :class="{active: !big}">相册</a> -->
  9. <div @click="showQuestion = true" class="dati">开始答题</div>
  10. </template>
  11. </div>
  12. </template>
  13. <template v-else>
  14. <a @click="clickHandle" class="rad"><i class="iconfont icon-left"></i>返回</a>
  15. <!-- <a @click="xiangceHandle" class="xiangce" v-if="key">相册</a> -->
  16. <select @change="changeHandle" class="ncxihiasj" v-model="asdasd" v-if="key">
  17. <option value="big">{{isHangpai?'航拍':'大场景'}}</option>
  18. <option v-if="imgs" value="xiangce">相册</option>
  19. </select>
  20. <div v-if="introduce" class="r-aside" :class="{'show':show}" @click.stop>
  21. <div class="image-title">{{name}}</div>
  22. <div class="image-detail">
  23. <p v-for="(item,i) in introduce" :key="i">{{item}}</p>
  24. </div>
  25. <div class="switch" @click="show = !show" @touchmove.prevent>
  26. <i class="iconfont" :class="show ? 'icon-left' : 'icon-right'"></i>
  27. </div>
  28. </div>
  29. <div @click="showQuestion = true" class="dati">开始答题</div>
  30. </template>
  31. <template v-if="ismobile">
  32. <iframe :src="url" frameborder="0" v-if="big"></iframe>
  33. <div class="asjdfioasfhuioasfh" v-else >
  34. <img class="cls" :src="require('@/assets/images/close.png')" @click="handleExit" alt="">
  35. <div class="image-layout">
  36. <Slide :screens="screensa" :current="0">
  37. <i class="iconfont icon-left" slot="up"></i>
  38. <div slot="item" slot-scope="{data}" class="image-item" :style="{background:`url(${data.img}) no-repeat center center`,backgroundSize:`${data.size}`}" @click.stop></div>
  39. <!-- <img slot="item" slot-scope="{data}" :src="data" class="image-item"> -->
  40. <i class="iconfont icon-right" slot="next"></i>
  41. </Slide>
  42. <div class="image-introduce" v-if="introduce">
  43. <div class="intro-title">{{name}}</div>
  44. <div class="intro-detail">
  45. <p v-for="(item,i) in introduce" :key="i">{{item}}</p>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <template v-else>
  52. <iframe :src="url" frameborder="0"></iframe>
  53. <imageQuery :show="show" :screens="screens" @exitHandle="exitHandle" />
  54. </template>
  55. <question v-if="showQuestion" @close="showQuestion=false" :show="showQuestion"></question>
  56. </div>
  57. </template>
  58. <script>
  59. import Vue from 'vue'
  60. import data from '@/data.js'
  61. import imageQuery from '@/pages/imageQuery'
  62. import browser from '@/util/browser'
  63. import Slide from '@/components/Slide'
  64. import question from '@/components/question'
  65. export default {
  66. components: { imageQuery, Slide, question },
  67. data () {
  68. let key = Object.keys(data.data).find(id => this.$route.params.id === id)
  69. if (!key) {
  70. key = null
  71. }
  72. return {
  73. showQuestion: false,
  74. asdasd: 'big',
  75. urls: [],
  76. key,
  77. big: true,
  78. show: false,
  79. ismobile: browser.mobile,
  80. screens: null,
  81. screensa: []
  82. }
  83. },
  84. computed: {
  85. url () {
  86. return this.$route.params.url
  87. },
  88. isHangpai () {
  89. let id = this.key
  90. let isTrue = id && data.data[id].showType.find((item) => {
  91. return item === 'leixing_hangpai'
  92. })
  93. return isTrue
  94. },
  95. imgs () {
  96. let id = this.key
  97. return id ? data.data[id].data : null
  98. },
  99. name () {
  100. let id = this.key
  101. return id ? data.data[id].name : null
  102. },
  103. introduce () {
  104. let id = this.key
  105. return id ? data.data[id].introduce : null
  106. }
  107. },
  108. watch: {
  109. screens (newVal) {
  110. let arr = newVal && newVal.map((info, i) => {
  111. let item = {}
  112. var img = new Image()
  113. var handle = () => {
  114. if (img.width > img.height) {
  115. item.size = '100% auto'
  116. } else {
  117. item.size = 'auto 100%'
  118. }
  119. this.screensa && Vue.set(this.screensa, i, item)
  120. }
  121. item.img = info
  122. img.src = info
  123. if (img.complete) {
  124. handle()
  125. } else {
  126. img.onload = handle
  127. }
  128. return item
  129. })
  130. this.screensa = arr
  131. }
  132. },
  133. methods: {
  134. changeHandle () {
  135. if (this.asdasd === 'xiangce') {
  136. if (data.data[this.key]) {
  137. this.screens = data.data[this.key].data
  138. this.big = false
  139. }
  140. }
  141. },
  142. xiangceHandle () {
  143. if (data.data[this.key]) {
  144. this.screens = data.data[this.key].data
  145. this.big = false
  146. }
  147. },
  148. handleExit () {
  149. if (!this.$route.params.id) {
  150. this.exitHandle()
  151. }
  152. },
  153. exitHandle () {
  154. this.screens = null
  155. this.big = true
  156. this.asdasd = 'big'
  157. if (!this.$route.params.id) {
  158. this.key = null
  159. }
  160. },
  161. clickHandle () {
  162. if (this.$route.query.show) {
  163. let {show, title, type} = this.$route.query
  164. this.$router.push({
  165. name: 'item',
  166. params: {
  167. show, title, type
  168. }
  169. })
  170. } else {
  171. this.$router.back()
  172. }
  173. // while (global.paths.length !== 0) {
  174. // let path = global.paths.pop()
  175. // if (path.name !== 'external' && path.name) {
  176. // return this.$router.push({path: path.path})
  177. // }
  178. // }
  179. // this.$router.push({name: 'home'})
  180. }
  181. },
  182. mounted () {
  183. window.addEventListener('message', res => {
  184. if (res.data.event === 'openHotspot') {
  185. let tmp = Object.keys(data.data).find(key => {
  186. return data.data[key].name === res.data.data
  187. })
  188. let m = data.data[tmp]
  189. this.key = tmp
  190. this.screens = m.data
  191. this.big = false
  192. // this.show = true
  193. }
  194. })
  195. }
  196. }
  197. </script>
  198. <style scoped>
  199. .top-layer {
  200. padding-top: 4px;
  201. height: 42px;
  202. }
  203. .iframe-layout {
  204. position: relative;
  205. width: 100%;
  206. height: 100%;
  207. }
  208. .iframe-layout iframe {
  209. position: absolute;
  210. left: 0;
  211. right: 0;
  212. width: 100%;
  213. height: 100%;
  214. }
  215. .iframe-layout a {
  216. position: absolute;
  217. color: #fff;
  218. background-color: #fa3800;
  219. left: 10px;
  220. top: 10px;
  221. padding: 8px 20px 10px 16px;
  222. cursor: pointer;
  223. z-index: 999;
  224. }
  225. .iframe-layout a.xiangce {
  226. left: 100px;
  227. }
  228. .mobile a {
  229. margin-right: 20px;
  230. padding: 4px 10px;
  231. }
  232. .mobile .top-layer{
  233. height: 15px;
  234. padding: 10px;
  235. background-color: #f1f2f3;
  236. position: relative;
  237. }
  238. .mobile .dati {
  239. height: 29px;
  240. padding: 0 10px;
  241. line-height: 29px;
  242. position: absolute;
  243. top:50%;
  244. transform: translateY(-50%);
  245. }
  246. .asjdfioasfhuioasfh {
  247. height: 100%;
  248. background-color: rgba(0, 0, 0, 0.8)
  249. }
  250. .iframe-layout a i {
  251. font-size: 0.8em;
  252. vertical-align: middle;
  253. }
  254. .top-layer a{
  255. position: relative;
  256. }
  257. .top-layer a.xiangce {
  258. background: none;
  259. color: #000;
  260. padding-left: 3px;
  261. padding-right: 3px;
  262. margin-left: 5px;
  263. margin-right: 5px
  264. }
  265. .top-layer a.xiangce.active {
  266. color: #fa3800;
  267. }
  268. .mobile a {
  269. left: inherit !important;
  270. top: inherit !important;
  271. }
  272. .mobile iframe {
  273. height: calc(100% - 35px);
  274. }
  275. .ncxihiasj {
  276. position: absolute;
  277. left: 112px;
  278. border: 1px solid #fff;
  279. z-index: 999;
  280. font-size: 1em;
  281. /* background: url('~@/assets/images/xiala.png') center right 6px no-repeat; */
  282. background: none;
  283. background-size: 20%;
  284. color: #fff;
  285. top: 10px;
  286. width: 90px;
  287. border-radius: 3px;
  288. height: 34px;
  289. line-height: 34px;
  290. text-align: center;
  291. padding: 0 10px;
  292. cursor: pointer;
  293. }
  294. .ncxihiasj option{
  295. color: black;
  296. background: #fff;
  297. line-height: 20px;
  298. }
  299. .dati{
  300. position: absolute;
  301. color: #fff;
  302. background-color: #fa3800;
  303. left: 220px;
  304. top: 10px;
  305. padding: 8px 20px 10px 16px;
  306. border-radius: 4px;
  307. cursor: pointer;
  308. z-index: 999;
  309. }
  310. </style>
  311. <style scoped>
  312. @media screen and (max-width: 1024px) {
  313. .dati{
  314. left:180px;
  315. top:0px;
  316. }
  317. }
  318. </style>
  319. <style scoped>
  320. .image-dialog {
  321. position: fixed;
  322. z-index: 9999;
  323. left: 0;
  324. top: 0;
  325. right: 0;
  326. bottom: 0;
  327. background-color: rgba(0,0,0,0.8);
  328. }
  329. .image-dialog a {
  330. position: absolute;
  331. color: #fff;
  332. background-color: #fa3800;
  333. left: 10px;
  334. top: 10px;
  335. padding: 8px 15px;
  336. cursor: pointer;
  337. border-radius: 3px;
  338. }
  339. .image-layout {
  340. width: 100%;
  341. padding-left: 20px;
  342. padding-right: 20px;
  343. position: absolute;
  344. top: calc(50% + 15px);
  345. left: 50%;
  346. transform: translateY(-50%) translateX(-50%);
  347. }
  348. .asjdfioasfhuioasfh .cls{
  349. position: fixed;
  350. right: 10px;
  351. top: 10px;
  352. z-index: 999;
  353. }
  354. .image-item {
  355. width: 100%;
  356. height: 100%;
  357. }
  358. .r-aside{
  359. box-sizing: border-box;
  360. position: absolute;
  361. right: 0;
  362. top: 0;
  363. bottom: 0;
  364. width: 350px;
  365. height: 100%;
  366. background-color: #fffbf8;
  367. display: flex;
  368. flex-direction: column;
  369. padding: 20px 0;
  370. border-left: 1px solid #f1c4a3;
  371. z-index: 999999;
  372. transform: translateX(0);
  373. transition: transform .3s ease;
  374. }
  375. .r-aside.show{
  376. transform: translateX(350px);
  377. transition: transform .3s ease;
  378. }
  379. .r-aside .image-title{
  380. font-weight: bold;
  381. font-size: 18px;
  382. padding-bottom: 15px;
  383. border-bottom: 1px solid #f1c4a3;
  384. margin: 0 20px;
  385. }
  386. .r-aside .image-detail{
  387. padding: 15px 0;
  388. height: 100%;
  389. overflow-y: scroll;
  390. margin: 0 10px 0 20px;
  391. }
  392. .r-aside .image-detail p{
  393. text-indent: 32px;
  394. line-height: 1.8;
  395. }
  396. .switch {
  397. position: absolute;
  398. right: 100%;
  399. top: 50%;
  400. transform: translateY(-50%);
  401. background-color: #fa3800;
  402. width: 14px;
  403. height: 80px;
  404. color: #fff;
  405. line-height: 80px;
  406. text-align: center;
  407. cursor: pointer;
  408. z-index: 9999999;
  409. }
  410. .image-introduce{
  411. color:#fff;
  412. padding:20px 10px;
  413. line-height:1.5;
  414. }
  415. .image-introduce .intro-title{
  416. font-size:18px;
  417. font-weight:bold;
  418. margin-bottom:20px;
  419. text-align: center;
  420. }
  421. .image-introduce .intro-detail{
  422. height: 32vh;
  423. overflow-y: auto;
  424. overflow-x: hidden;
  425. -webkit-overflow-scrolling: touch;
  426. }
  427. .image-introduce .intro-detail p{
  428. text-indent:32px;
  429. }
  430. .asjdfioasfhuioasfh >>> .ctrl{
  431. top:25%;
  432. }
  433. </style>