index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div>
  3. <div class="mobile-z" :class="{show: show}" v-if="ismobile" @click="show = false" @touchmove.prevent></div>
  4. <div class="search mobileSearch" v-if="ismobile" @touchmove.prevent>
  5. <a @click="show = true"><i class="iconfont icon-menu"></i></a>
  6. <div @click="$router.push({name: 'search',query:{type:$route.name}})">
  7. <input placeholder="搜索">
  8. </div>
  9. <a><i class="iconfont icon-sousuo"></i></a>
  10. </div>
  11. <div class="right-layout" :class="{show: show, mobile: ismobile}">
  12. <div class="info" @touchmove.prevent @click="mainHandle">
  13. <i class="iconfont icon-guojiagaoxinqu"></i>
  14. <h1>珠海高新区</h1>
  15. <p>不可移动文物一张图</p>
  16. </div>
  17. <div class="search rad" v-if="!ismobile">
  18. <input placeholder="搜索" type="search" v-model="keyword" >
  19. <a><i class="iconfont icon-sousuo"></i></a>
  20. </div>
  21. <div class="list-layout">
  22. <div class="tabs">
  23. <a @click="showTab = 'module'" :class="{active: showTab === 'module'}">区域划分</a>
  24. <a @click="showTab = 'type'" :class="{active: showTab === 'type'}">类型划分</a>
  25. </div>
  26. <div class="content" v-show="showTab === 'module'">
  27. <down
  28. :aaaactive="showTitle === type.title"
  29. :keyword="keyword"
  30. :setting="type"
  31. v-for="(type, key) in modules"
  32. :key="key"
  33. @showcontent="handleChange(type)"
  34. @checkItem="item => checkHandle(type, item)"
  35. :show="showTitle"
  36. />
  37. </div>
  38. <div class="content" v-show="showTab === 'type'">
  39. <down
  40. :aaaactive="showTitle === type.title"
  41. :setting="type"
  42. :keyword="keyword"
  43. v-for="(type, key) in types"
  44. :key="key"
  45. @showcontent="handleChange(type)"
  46. @checkItem="item => checkHandle(type, item)"
  47. :show="showTitle"
  48. />
  49. </div>
  50. </div>
  51. <a class="switch" v-if="!ismobile" @click="show = !show" @touchmove.prevent>
  52. <i class="iconfont" :class="show ? 'icon-right' : 'icon-left'"></i>
  53. </a>
  54. </div>
  55. </div>
  56. </template>
  57. <script>
  58. import browser from '@/util/browser'
  59. import data from '@/data'
  60. import down from './down'
  61. export default {
  62. components: { down },
  63. data () {
  64. return {
  65. show: !browser.mobile,
  66. types: data.types,
  67. modules: data.modules,
  68. showTab: 'module',
  69. keyword: '',
  70. ismobile: browser.mobile,
  71. showTitle: '',
  72. clickItem: false
  73. }
  74. },
  75. methods: {
  76. mainHandle () {
  77. this.$router.push({name: 'home'})
  78. this.ismobile && this.$bus.$emit('showaside', false)
  79. },
  80. handleChange (type) {
  81. let route = this.$route
  82. if (route.name === 'map' || route.name === 'info') {
  83. if (route.params.title !== type.title) {
  84. this.$router.push({name: 'map', params: {title: type.title}})
  85. }
  86. } else {
  87. this.$router.push({
  88. name: 'list',
  89. params: this.showTab === 'type' ? {type: type.title} : {title: type.title}
  90. })
  91. }
  92. },
  93. checkHandle (type, item) {
  94. let route = this.$route
  95. if ((route.name === 'map' || route.name === 'info' || route.name === 'home') && !this.$isLocal) {
  96. this.$router.push({name: 'info',
  97. params: {
  98. title: type.title,
  99. show: item.name
  100. }
  101. })
  102. } else {
  103. this.clickItem = !this.clickItem
  104. this.$bus.$emit('itemclick', this.clickItem)
  105. this.$router.push({
  106. name: 'item',
  107. params: this.showTab === 'type' ? {title: '全部', type: type.title, show: item.name} : {title: type.title, type: '全部', show: item.name}
  108. })
  109. }
  110. }
  111. },
  112. watch: {
  113. '$route': {
  114. deep: true,
  115. immediate: false,
  116. handler (newVal) {
  117. setTimeout(() => {
  118. if (newVal.name === 'map' || newVal.name === 'info' || newVal.name === 'home') {
  119. this.showTitle = newVal.params.title
  120. } else {
  121. this.showTitle = this.showTab === 'type' ? newVal.params.type : newVal.params.title
  122. }
  123. // if (this.types.find(item => item.title === this.showTitle)) {
  124. // this.showTab = 'type'
  125. // } else {
  126. // this.showTab = 'module'
  127. // }
  128. })
  129. }
  130. },
  131. showTab (newVal) {
  132. if (!this.keyword) {
  133. this.$bus.$emit('closeitem', false)
  134. }
  135. this.showTitle = newVal === 'type' ? this.$route.params.type : this.$route.params.title
  136. }
  137. },
  138. mounted () {
  139. this.$bus.$on('showaside', data => {
  140. this.show = data
  141. })
  142. }
  143. }
  144. </script>
  145. <style scoped>
  146. @import url('./style.css');
  147. </style>