123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <template>
- <div :style="{minHeight:scene.length>0?'none':'95vh'}">
- <div class="case-con" :style="{paddingLeft:(split-260)+ 'px'}">
- <div class="case-header">
- <img src="@/assets/images/3dcase_img_tit.png" alt="">
- <div class="case-nav">
- <div class="nav-con">
- <vcenter>
- <div class="list-nav" :style="{width:language==='en'?'800px':'605px'}">
- <div class="list-txt b-title">{{caseType}}</div>
- <router-link class="sub-list b-title" :to="item.to" v-for="(item,i) in navs" :key="i">{{langCases.typeName[item.name]}}</router-link>
- </div>
- <div class="lists">
- <ul class="list-navs">
- <li :class="{active:sortActive===item.id}" v-for="(item,index) in langCases.sort.items" :key="index" @click="sortActive = item.id">
- <span class="b-label">{{item.name}}</span>
- </li>
- </ul>
- <div class="select" ref="mbMenu">
- <span @click="selectActive=!selectActive" :class="{active:selectActive}">{{langCases.sceneSelected[selected]}}</span>
- <ul :style="{maxHeight:selectActive?'200px':'0',padding:selectActive?'15px 0':'0'}">
- <li @click="selected= item.id" v-for="(item,i) in langCases.selectType" :key="i">{{item.name}}</li>
- </ul>
- </div>
- </div>
- </vcenter>
- </div>
- </div>
- </div>
- </div>
- <div class="case-body" :style="{marginLeft:(split-(isWide?380:329))+ 'px'}">
- <div class="card" :class="{card_active:scene.length>0}" :style="{animationDelay:`${0.1*(i)}s`}" v-for="(item,i) in scene" :key="i">
- <card :data="item" :style="{marginRight:(i+1)%(isWide?4:3)===0?'0':'50px'}"></card>
- </div>
- </div>
- <div class="paging" v-if="total">
- <vcenter>
- <Paging @clickHandle="pageChange" :current="currentPage" :total="total" :equable="pageSize" />
- </vcenter>
- </div>
- </div>
- </template>
- <script>
- // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
- // 例如:import 《组件名称》 from '《组件路径》';
- import {mapState} from 'vuex'
- import vcenter from '@/components/vcenter'
- import card from '@/components/card'
- import Paging from '@/components/Paging'
- let typeArr = {
- '房地产': 2,
- '博物馆': 1,
- '家居': 5,
- '餐饮': 4,
- '其他': 0
- }
- let sceneSTYpe = {
- '全部': null,
- '四维看看 Lite': 1,
- '四维看看 Pro': 4
- }
- let nav = [
- {
- name: '其他',
- to: {name: 'cases', params: {id: '其他'}}
- },
- {
- name: '餐饮',
- to: {name: 'cases', params: {id: '餐饮'}}
- },
- {
- name: '家居',
- to: {name: 'cases', params: {id: '家居'}}
- },
- {
- name: '博物馆',
- to: {name: 'cases', params: {id: '博物馆'}}
- },
- {
- name: '房地产',
- to: {name: 'cases', params: {id: '房地产'}}
- }
- ]
- export default {
- // import引入的组件需要注入到对象中才能使用
- components: {
- vcenter,
- card,
- Paging
- },
- data () {
- // 这里存放数据
- return {
- selectActive: false,
- total: 0,
- pageSize: 12,
- currentPage: 1,
- sortActive: 1,
- scene: [],
- isWide: Math.round(devicePixelRatio * 100) === 100 ? window.innerWidth > 1697 : !(Math.round(devicePixelRatio * 100) >= 120),
- selected: '筛选设备',
- caseType: null
- }
- },
- // 监听属性 类似于data概念
- computed: {
- ...mapState({
- langCases: state => state.language.home.cases,
- language: state => state.language.current,
- split: state => state.ui.navDivision
- }),
- navs () {
- let temp = []
- nav.map(item => {
- if (item.name !== this.$route.params.id) {
- temp.push(item)
- }
- })
- return temp
- }
- },
- // 监控data中的数据变化
- watch: {
- currentPage () {
- this.getData()
- },
- selected () {
- this.selectActive = false
- this.getData()
- },
- sortActive () {
- this.currentPage = 1
- this.selectActive = false
- this.getData()
- },
- langCases (newVal) {
- this.caseType = newVal.typeName[this.$route.params.id]
- },
- '$route.params.id': {
- deep: true,
- immediate: true,
- handler (newVal) {
- this.currentPage = 1
- this.caseType = this.langCases.typeName[newVal]
- this.selectActive = false
- this.getData()
- }
- }
- },
- // 方法集合
- methods: {
- pageChange (data) {
- this.currentPage = data
- },
- async getData () {
- window.scrollTo(0, 0)
- let params = {
- pageSize: this.pageSize,
- sceneType: typeArr[this.caseType],
- sceneInterest: this.sortActive,
- pageNum: this.currentPage,
- sceneScheme: sceneSTYpe[this.selected]
- }
- let result = await this.$http({
- method: 'post',
- data: params,
- url: '/scene/loadScene'
- })
- let data = result.data.data
- this.scene = []
- setTimeout(() => {
- this.scene = data.list
- }, 0)
- this.total = data.total
- }
- },
- // 生命周期 - 创建完成(可以访问当前this实例)
- created () {
- },
- // 生命周期 - 挂载完成(可以访问DOM元素)
- mounted () {
- document.addEventListener('click', (e) => {
- if (this.$refs.mbMenu) {
- if (!this.$refs.mbMenu.contains(e.target)) {
- this.selectActive = false
- }
- }
- })
- window.addEventListener('resize', () => {
- let DPR = Math.round(devicePixelRatio * 100)
- let grt120 = DPR >= 120
- this.isWide = DPR === 100 ? window.innerWidth > 1697 : !grt120
- })
- }
- }
- </script>
- <style lang="scss" scoped>
- @import './style.scss';
- </style>
|