index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div :style="{minHeight:scene.length>0?'none':'95vh'}">
  3. <div class="case-con" :style="{paddingLeft:(split-260)+ 'px'}">
  4. <div class="case-header">
  5. <img src="@/assets/images/3dcase_img_tit.png" alt="">
  6. <div class="case-nav">
  7. <div class="nav-con">
  8. <vcenter>
  9. <div class="list-nav" :style="{width:language==='en'?'800px':'605px'}">
  10. <div class="list-txt b-title">{{caseType}}</div>
  11. <router-link class="sub-list b-title" :to="item.to" v-for="(item,i) in navs" :key="i">{{langCases.typeName[item.name]}}</router-link>
  12. </div>
  13. <div class="lists">
  14. <ul class="list-navs">
  15. <li :class="{active:sortActive===item.id}" v-for="(item,index) in langCases.sort.items" :key="index" @click="sortActive = item.id">
  16. <span class="b-label">{{item.name}}</span>
  17. </li>
  18. </ul>
  19. <div class="select" ref="mbMenu">
  20. <span @click="selectActive=!selectActive" :class="{active:selectActive}">{{langCases.sceneSelected[selected]}}</span>
  21. <ul :style="{maxHeight:selectActive?'200px':'0',padding:selectActive?'15px 0':'0'}">
  22. <li @click="selected= item.id" v-for="(item,i) in langCases.selectType" :key="i">{{item.name}}</li>
  23. </ul>
  24. </div>
  25. </div>
  26. </vcenter>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="case-body" :style="{marginLeft:(split-(isWide?380:329))+ 'px'}">
  32. <div class="card" :class="{card_active:scene.length>0}" :style="{animationDelay:`${0.1*(i)}s`}" v-for="(item,i) in scene" :key="i">
  33. <card :data="item" :style="{marginRight:(i+1)%(isWide?4:3)===0?'0':'50px'}"></card>
  34. </div>
  35. </div>
  36. <div class="paging" v-if="total">
  37. <vcenter>
  38. <Paging @clickHandle="pageChange" :current="currentPage" :total="total" :equable="pageSize" />
  39. </vcenter>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  45. // 例如:import 《组件名称》 from '《组件路径》';
  46. import {mapState} from 'vuex'
  47. import vcenter from '@/components/vcenter'
  48. import card from '@/components/card'
  49. import Paging from '@/components/Paging'
  50. let typeArr = {
  51. '房地产': 2,
  52. '博物馆': 1,
  53. '家居': 5,
  54. '餐饮': 4,
  55. '其他': 0
  56. }
  57. let sceneSTYpe = {
  58. '全部': null,
  59. '四维看看 Lite': 1,
  60. '四维看看 Pro': 4
  61. }
  62. let nav = [
  63. {
  64. name: '其他',
  65. to: {name: 'cases', params: {id: '其他'}}
  66. },
  67. {
  68. name: '餐饮',
  69. to: {name: 'cases', params: {id: '餐饮'}}
  70. },
  71. {
  72. name: '家居',
  73. to: {name: 'cases', params: {id: '家居'}}
  74. },
  75. {
  76. name: '博物馆',
  77. to: {name: 'cases', params: {id: '博物馆'}}
  78. },
  79. {
  80. name: '房地产',
  81. to: {name: 'cases', params: {id: '房地产'}}
  82. }
  83. ]
  84. export default {
  85. // import引入的组件需要注入到对象中才能使用
  86. components: {
  87. vcenter,
  88. card,
  89. Paging
  90. },
  91. data () {
  92. // 这里存放数据
  93. return {
  94. selectActive: false,
  95. total: 0,
  96. pageSize: 12,
  97. currentPage: 1,
  98. sortActive: 1,
  99. scene: [],
  100. isWide: Math.round(devicePixelRatio * 100) === 100 ? window.innerWidth > 1697 : !(Math.round(devicePixelRatio * 100) >= 120),
  101. selected: '筛选设备',
  102. caseType: null
  103. }
  104. },
  105. // 监听属性 类似于data概念
  106. computed: {
  107. ...mapState({
  108. langCases: state => state.language.home.cases,
  109. language: state => state.language.current,
  110. split: state => state.ui.navDivision
  111. }),
  112. navs () {
  113. let temp = []
  114. nav.map(item => {
  115. if (item.name !== this.$route.params.id) {
  116. temp.push(item)
  117. }
  118. })
  119. return temp
  120. }
  121. },
  122. // 监控data中的数据变化
  123. watch: {
  124. currentPage () {
  125. this.getData()
  126. },
  127. selected () {
  128. this.selectActive = false
  129. this.getData()
  130. },
  131. sortActive () {
  132. this.currentPage = 1
  133. this.selectActive = false
  134. this.getData()
  135. },
  136. langCases (newVal) {
  137. this.caseType = newVal.typeName[this.$route.params.id]
  138. },
  139. '$route.params.id': {
  140. deep: true,
  141. immediate: true,
  142. handler (newVal) {
  143. this.currentPage = 1
  144. this.caseType = this.langCases.typeName[newVal]
  145. this.selectActive = false
  146. this.getData()
  147. }
  148. }
  149. },
  150. // 方法集合
  151. methods: {
  152. pageChange (data) {
  153. this.currentPage = data
  154. },
  155. async getData () {
  156. window.scrollTo(0, 0)
  157. let params = {
  158. pageSize: this.pageSize,
  159. sceneType: typeArr[this.caseType],
  160. sceneInterest: this.sortActive,
  161. pageNum: this.currentPage,
  162. sceneScheme: sceneSTYpe[this.selected]
  163. }
  164. let result = await this.$http({
  165. method: 'post',
  166. data: params,
  167. url: '/scene/loadScene'
  168. })
  169. let data = result.data.data
  170. this.scene = []
  171. setTimeout(() => {
  172. this.scene = data.list
  173. }, 0)
  174. this.total = data.total
  175. }
  176. },
  177. // 生命周期 - 创建完成(可以访问当前this实例)
  178. created () {
  179. },
  180. // 生命周期 - 挂载完成(可以访问DOM元素)
  181. mounted () {
  182. document.addEventListener('click', (e) => {
  183. if (this.$refs.mbMenu) {
  184. if (!this.$refs.mbMenu.contains(e.target)) {
  185. this.selectActive = false
  186. }
  187. }
  188. })
  189. window.addEventListener('resize', () => {
  190. let DPR = Math.round(devicePixelRatio * 100)
  191. let grt120 = DPR >= 120
  192. this.isWide = DPR === 100 ? window.innerWidth > 1697 : !grt120
  193. })
  194. }
  195. }
  196. </script>
  197. <style lang="scss" scoped>
  198. @import './style.scss';
  199. </style>