张延森 3 år sedan
förälder
incheckning
c180232dea

+ 1
- 1
package.json Visa fil

@@ -13,12 +13,12 @@
13 13
   "dependencies": {
14 14
     "animate.css": "^4.1.1",
15 15
     "core-js": "^3.6.4",
16
-    "dialog-polyfill": "^0.5.6",
17 16
     "lib-flexible": "^0.3.2",
18 17
     "lodash": "^4.17.15",
19 18
     "regenerator-runtime": "^0.13.5",
20 19
     "swiper": "6.8.4",
21 20
     "vue": "^2.6.11",
21
+    "vue-js-modal": "^2.0.1",
22 22
     "vue-router": "^3.2.0"
23 23
   },
24 24
   "devDependencies": {

Binär
src/assets/images/apartment/backSign-2.png Visa fil


Binär
src/assets/images/apartment/backSign.png Visa fil


+ 27
- 32
src/components/Modal/index.vue Visa fil

@@ -1,41 +1,36 @@
1 1
 <template>
2
-  <dialog>
2
+  <modal :name="name" :clickToClose="false" :width="width" :height="height">
3 3
     <slot></slot>
4
-  </dialog>
4
+  </modal>
5 5
 </template>
6 6
 
7 7
 <script>
8
-import dialogPolyfill from 'dialog-polyfill'
9
-
10 8
 export default {
11
-  name: 'Modal',
12
-  // props: {
13
-  //   visible: Boolean
14
-  // },
15
-  // watch: {
16
-  //   visible(val) {
17
-  //     if (this.$el) {
18
-  //       if (val) {
19
-  //         this.$el.showModal()
20
-  //       } else {
21
-  //         this.$el.close()
22
-  //       }
23
-  //     }
24
-  //   }
25
-  // },
26
-  mounted() {
27
-    this.$nextTick(() => {
28
-      dialogPolyfill.registerDialog(this.$el)
29
-      this.$el.showModal()
30
-    })
9
+  name: 'YZModal',
10
+  props: {
11
+    visible: Boolean,
12
+    width: {
13
+      type: String,
14
+      default: '100%'
15
+    },
16
+    height: {
17
+      type: String,
18
+      default: '100%'
19
+    }
20
+  },
21
+  watch: {
22
+    visible(val) {
23
+      if (val) {
24
+        this.$modal.show(this.name)
25
+      } else {
26
+        this.$modal.hide(this.name)
27
+      }
28
+    }
29
+  },
30
+  data() {
31
+    return {
32
+      name: `modal-${Math.random().toString(36).substring(2)}`
33
+    }
31 34
   }
32 35
 }
33 36
 </script>
34
-
35
-<style lang="scss">
36
-dialog {
37
-  margin: 0;
38
-  padding: 0;
39
-  border: none;
40
-}
41
-</style>

+ 3
- 1
src/main.js Visa fil

@@ -4,6 +4,7 @@ import 'core-js/stable'
4 4
 import 'regenerator-runtime/runtime'
5 5
 
6 6
 import Vue from 'vue'
7
+import VModal from 'vue-js-modal'
7 8
 import Modal from '@/components/Modal'
8 9
 import Swiper from '@/components/Swiper'
9 10
 import SwiperSlide from '@/components/SwiperSlide'
@@ -25,7 +26,8 @@ import 'lib-flexible/flexible.js'
25 26
 import './filters'
26 27
 Vue.config.productionTip = false
27 28
 
28
-Vue.component('modal', Modal)
29
+Vue.use(VModal)
30
+Vue.component('yz-modal', Modal)
29 31
 Vue.component('swiper', Swiper)
30 32
 Vue.component('swiper-slide', SwiperSlide)
31 33
 

+ 23
- 13
src/views/apartment.vue Visa fil

@@ -4,24 +4,27 @@
4 4
     <pure-image :bg-image="require('@/assets/images/apartment/1.jpg')"></pure-image>
5 5
     <apartment-navi class="apartment-navi" @goto="handleGoto" />
6 6
     <div v-for="(item, index) in list" :key="item.image">
7
-      <modal v-if="visible[index]" class="apartment-modal">
7
+      <yz-modal :visible="visible[index]" class="apartment-modal">
8 8
         <pure-image :bg-image="item.image"></pure-image>
9 9
         <div class="back-sign" @click="cancelShow(index)">
10
-          <img :src="require('@/assets/images/apartment/backSign.png')" alt="">
10
+          <img :src="item.backSign" alt="">
11 11
         </div>
12
-      </modal>
12
+      </yz-modal>
13 13
     </div>
14
-    <modal v-if="visible[5]" class="apartment-modal">
14
+    <yz-modal :visible="visible[5]" class="apartment-modal">
15 15
       <swiper-image :list="houseList"></swiper-image>
16 16
       <div class="back-sign" @click="cancelShow(5)">
17
-        <img :src="require('@/assets/images/apartment/backSign.png')" alt="">
17
+        <img :src="backSignImg" alt="">
18 18
       </div>
19
-    </modal>
19
+    </yz-modal>
20 20
   </div>
21 21
 </template>
22 22
 
23 23
 <script>
24 24
 
25
+const backSignImg = require('@/assets/images/apartment/backSign.png')
26
+const backSignImg2 = require('@/assets/images/apartment/backSign-2.png')
27
+
25 28
 export default {
26 29
   components: {
27 30
     PureImage: () => import('./components/PureImage.vue'),
@@ -30,27 +33,34 @@ export default {
30 33
   },
31 34
   data() {
32 35
     return {
36
+      backSignImg,
37
+      backSignImg2,
33 38
       visible: Array(6).fill(false),
34 39
       list: [
35 40
         {
36 41
           image: require('@/assets/images/apartment/2-2.jpg'),
37
-          color: '#f0f0f0'
42
+          color: '#f0f0f0',
43
+          backSign: backSignImg
38 44
         },
39 45
         {
40 46
           image: require('@/assets/images/apartment/3-1.jpg'),
41
-          color: '#f0f0f0'
47
+          color: '#f0f0f0',
48
+          backSign: backSignImg2
42 49
         },
43 50
         {
44 51
           image: require('@/assets/images/apartment/4-1.jpg'),
45
-          color: '#f0f0f0'
52
+          color: '#f0f0f0',
53
+          backSign: backSignImg
46 54
         },
47 55
         {
48 56
           image: require('@/assets/images/apartment/6-1.jpg'),
49
-          color: '#f0f0f0'
57
+          color: '#f0f0f0',
58
+          backSign: backSignImg
50 59
         },
51 60
         {
52 61
           image: require('@/assets/images/apartment/5-1.jpg'),
53
-          color: '#f0f0f0'
62
+          color: '#f0f0f0',
63
+          backSign: backSignImg
54 64
         }
55 65
       ],
56 66
       houseList: [
@@ -109,8 +119,8 @@ export default {
109 119
 
110 120
   .apartment-modal {
111 121
     position: absolute;
112
-    width: 100%;
113
-    height: 100%;
122
+    width: 100vw;
123
+    height: 100vh;
114 124
     bottom: 0;
115 125
     left: 0;
116 126
   }

+ 13
- 7
src/views/components/ApartmentNavi.vue Visa fil

@@ -2,29 +2,29 @@
2 2
   <div>
3 3
     <div class="flex-box">
4 4
       <div class="flex-box-item">
5
-        <img :src="require('@/assets/images/apartment/1-2.png')" style="height: 64px; display: block; margin: 0 auto" alt="">
5
+        <img :src="require('@/assets/images/apartment/1-2.png')" style="height: 64px;" alt="">
6 6
       </div>
7 7
     </div>
8 8
     <div class="flex-box" style="margin-top: 10px">
9 9
       <div class="flex-box-item">
10
-        <img :src="require('@/assets/images/apartment/2-1.png')" style="height: 78px" alt="" @click="handleClick(1)">
10
+        <img :src="require('@/assets/images/apartment/2-1.png')" alt="" @click="handleClick(1)">
11 11
       </div>
12 12
       <div class="flex-box-item">
13
-        <img :src="require('@/assets/images/apartment/3.png')" style="height: 78px" alt="" @click="handleClick(2)">
13
+        <img :src="require('@/assets/images/apartment/3.png')" alt="" @click="handleClick(2)">
14 14
       </div>
15 15
       <div class="flex-box-item">
16
-        <img :src="require('@/assets/images/apartment/4.png')" style="height: 78px" alt="" @click="handleClick(3)">
16
+        <img :src="require('@/assets/images/apartment/4.png')" alt="" @click="handleClick(3)">
17 17
       </div>
18 18
     </div>
19 19
     <div class="flex-box" style="margin-top: 20px">
20 20
       <div class="flex-box-item">
21
-        <img :src="require('@/assets/images/apartment/5.png')" style="height: 78px" alt="" @click="handleClick(4)">
21
+        <img :src="require('@/assets/images/apartment/5.png')" alt="" @click="handleClick(4)">
22 22
       </div>
23 23
       <div class="flex-box-item">
24
-        <img :src="require('@/assets/images/apartment/6.png')" style="height: 78px" alt="" @click="handleClick(5)">
24
+        <img :src="require('@/assets/images/apartment/6.png')" alt="" @click="handleClick(5)">
25 25
       </div>
26 26
       <div class="flex-box-item">
27
-        <img :src="require('@/assets/images/apartment/7.png')" style="height: 78px" alt="" @click="handleClick(6)">
27
+        <img :src="require('@/assets/images/apartment/7.png')" alt="" @click="handleClick(6)">
28 28
       </div>
29 29
     </div>
30 30
   </div>
@@ -51,6 +51,12 @@ export default {
51 51
 
52 52
   &-item {
53 53
     flex: 1;
54
+
55
+    img {
56
+      display: block;
57
+      height: 78px;
58
+      margin: 0 auto;
59
+    }
54 60
   }
55 61
 }
56 62
 </style>

+ 1
- 0
src/views/components/IndexImage.vue Visa fil

@@ -61,6 +61,7 @@ export default {
61 61
   height: 100%;
62 62
   display: flex;
63 63
   align-items: center;
64
+  overflow: hidden;
64 65
 
65 66
   .bg-image {
66 67
     width: 100%;

+ 2
- 2
src/views/components/PureImage.vue Visa fil

@@ -27,8 +27,8 @@ export default {
27 27
 
28 28
 <style lang="scss" scoped>
29 29
 .pure-image {
30
-  background-position: center;
31
-  background-size: 100%;
30
+  background-position: center center;
31
+  background-size: cover;
32 32
   background-repeat: no-repeat;
33 33
   width: 100%;
34 34
   height: 100%;