浏览代码

自适应兼容处理

zweizhao 7 年之前
父节点
当前提交
dba2c18c90
共有 4 个文件被更改,包括 50 次插入4 次删除
  1. 19 3
      pages/index.vue
  2. 15 0
      pages/index/type/pay.vue
  3. 0 1
      pages/index/type/vip.vue
  4. 16 0
      store/index.js

+ 19 - 3
pages/index.vue

@@ -1,20 +1,36 @@
 <template>
 <template>
   <section id="proginn-container">
   <section id="proginn-container">
-    <proginn-header/>
-    <router-view id="main"/>
-    <proginn-footer/>
+    <proginn-header v-if="isPC != -1 && isPC"/>
+    <router-view v-if="isPC != -1" id="main"/>
+    <proginn-footer v-if="isPC != -1 && isPC"/>
   </section>
   </section>
 </template>
 </template>
 
 
 <script>
 <script>
 import ProginnHeader from '@/components/header'
 import ProginnHeader from '@/components/header'
 import ProginnFooter from '@/components/footer'
 import ProginnFooter from '@/components/footer'
+import { mapState, mapMutations } from 'vuex'
 
 
 export default {
 export default {
   components: {
   components: {
     ProginnHeader,
     ProginnHeader,
     ProginnFooter
     ProginnFooter
   },
   },
+  computed: {
+    ...mapState(['isPC']),
+  },
+  mounted() {
+    this.checkInnerWidth()
+    window.addEventListener('resize', this.checkInnerWidth)
+  },
+  methods: {
+    ...mapMutations(['updateIsPC']),
+    checkInnerWidth() {
+      this.updateIsPC({
+        isPC: window.innerWidth > 960,
+      })
+    }
+  }
 }
 }
 </script>
 </script>
 
 

+ 15 - 0
pages/index/type/pay.vue

@@ -0,0 +1,15 @@
+<template>
+  <section class="pay">
+    pay
+  </section>
+</template>
+
+<script>
+export default {
+
+}
+</script>
+
+<style>
+
+</style>

+ 0 - 1
pages/index/type/vip.vue

@@ -95,7 +95,6 @@ export default {
       return this.vipList[1];
       return this.vipList[1];
     }
     }
   },
   },
-  mounted() {},
   methods: {
   methods: {
     /**
     /**
      * 点击支付
      * 点击支付

+ 16 - 0
store/index.js

@@ -0,0 +1,16 @@
+import Vue from 'vue'
+import Vuex from 'vuex'
+Vue.use(Vuex)
+
+const store = () => new Vuex.Store({
+  state: {
+    isPC: -1,
+  },
+  mutations: {
+    updateIsPC(state, payload) {
+      state.isPC = payload.isPC
+    }
+  }
+})
+
+export default store