hookehuyr

荣誉展示自适应调整

1 <!-- 1 <!--
2 * @Date: 2024-10-17 11:13:44 2 * @Date: 2024-10-17 11:13:44
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-10-18 16:26:32 4 + * @LastEditTime: 2024-10-22 13:45:54
5 * @FilePath: /hager/src/views/about/honors.vue 5 * @FilePath: /hager/src/views/about/honors.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -15,17 +15,28 @@ ...@@ -15,17 +15,28 @@
15 </el-breadcrumb> 15 </el-breadcrumb>
16 </div> 16 </div>
17 </hager-box> 17 </hager-box>
18 - <hager-box> 18 + <div :class="['top-img', is_xs ? 'xs' : '']"></div>
19 - <div :class="['top-img', is_xs ? 'xs' : '']"></div> 19 + <hager-box v-if="!is_xs">
20 - </hager-box>
21 - <hager-box>
22 <div class="select-btn-box"> 20 <div class="select-btn-box">
23 <div @click="onClickBtn(0)" :class="['btn', active_idx === 0 ? 'active' : 'normal']">行业荣誉</div> 21 <div @click="onClickBtn(0)" :class="['btn', active_idx === 0 ? 'active' : 'normal']">行业荣誉</div>
24 <div @click="onClickBtn(1)":class="['btn', active_idx === 1 ? 'active' : 'normal']">美学设计</div> 22 <div @click="onClickBtn(1)":class="['btn', active_idx === 1 ? 'active' : 'normal']">美学设计</div>
25 <div @click="onClickBtn(2)":class="['btn', active_idx === 2 ? 'active' : 'normal']">卓越发展</div> 23 <div @click="onClickBtn(2)":class="['btn', active_idx === 2 ? 'active' : 'normal']">卓越发展</div>
26 </div> 24 </div>
27 </hager-box> 25 </hager-box>
28 - <hager-box v-for="(item, index) in years_list" :key="index"> 26 + <div v-else class="select-btn-box" style="padding: 1rem;">
27 + <el-row :gutter="10">
28 + <el-col :span="8">
29 + <div @click="onClickBtn(0)" :class="['btn xs', active_idx === 0 ? 'active' : 'normal']">行业荣誉</div>
30 + </el-col>
31 + <el-col :span="8">
32 + <div @click="onClickBtn(1)" :class="['btn xs', active_idx === 1 ? 'active' : 'normal']">美学设计</div>
33 + </el-col>
34 + <el-col :span="8">
35 + <div @click="onClickBtn(2)" :class="['btn xs', active_idx === 2 ? 'active' : 'normal']">卓越发展</div>
36 + </el-col>
37 + </el-row>
38 + </div>
39 + <hager-box v-if="!is_xs" v-for="(item, index) in years_list" :key="index">
29 <p class="list-title">{{ item.year }}年</p> 40 <p class="list-title">{{ item.year }}年</p>
30 <div class="list-wrapper"> 41 <div class="list-wrapper">
31 <div class="card" v-for="(x, idx) in item.list" :key="idx"> 42 <div class="card" v-for="(x, idx) in item.list" :key="idx">
...@@ -39,6 +50,34 @@ ...@@ -39,6 +50,34 @@
39 </div> 50 </div>
40 </div> 51 </div>
41 </hager-box> 52 </hager-box>
53 + <div v-if="is_xs" v-for="(item, index) in years_list" :key="index" style="padding: 1rem;">
54 + <p class="list-title">{{ item.year }}年</p>
55 + <swiper class="swiper"
56 + :ref="'mySwiper' + item.id"
57 + :options="swiperOption"
58 + @slideChange="onSlideChange(item)"
59 + >
60 + <swiper-slide v-for="(x, idx) in item.list" :key="idx">
61 + <div class="list-wrapper-mini">
62 + <div class="card">
63 + <div class="card-image-box">
64 + <div class="card-image" :style="{ backgroundImage: `url(${x.img})` }"></div>
65 + </div>
66 + <div class="card-content">
67 + <h3>{{ x.title }}</h3>
68 + <p>{{ x.content }}</p>
69 + </div>
70 + </div>
71 + </div>
72 + </swiper-slide>
73 + </swiper>
74 + <div v-if="item.list.length > item.slidesPerView || is_xs" class="xs-control">
75 + <div>
76 + <i :class="['el-icon-arrow-left', item.activeIndex === 0 ? 'disabled' : '']" @click="prevBtn(item)"></i>
77 + <i :class="['el-icon-arrow-right', item.reach_end ? 'disabled' : '']" @click="nextBtn(item)"></i>
78 + </div>
79 + </div>
80 + </div>
42 <hager-box> 81 <hager-box>
43 <hager-load-more></hager-load-more> 82 <hager-load-more></hager-load-more>
44 </hager-box> 83 </hager-box>
...@@ -57,6 +96,7 @@ export default { ...@@ -57,6 +96,7 @@ export default {
57 return { 96 return {
58 active_idx: 0, 97 active_idx: 0,
59 years_list: [{ 98 years_list: [{
99 + id: '1',
60 year: '2022', 100 year: '2022',
61 list: [{ 101 list: [{
62 img: 'https://cdn.ipadbiz.cn/hager/img/WX20241018-161943@2x.png', 102 img: 'https://cdn.ipadbiz.cn/hager/img/WX20241018-161943@2x.png',
...@@ -66,8 +106,20 @@ export default { ...@@ -66,8 +106,20 @@ export default {
66 img: 'https://cdn.ipadbiz.cn/hager/img/WX20241018-161943@2x.png', 106 img: 'https://cdn.ipadbiz.cn/hager/img/WX20241018-161943@2x.png',
67 title: '中国建筑学会建筑电气分会', 107 title: '中国建筑学会建筑电气分会',
68 content: '海格电气凭借在建筑电气行业的应用成果与专业地位,荣获由中国建筑学会建筑电气分会颁发的“铂金合作单位' 108 content: '海格电气凭借在建筑电气行业的应用成果与专业地位,荣获由中国建筑学会建筑电气分会颁发的“铂金合作单位'
69 - }] 109 + }, {
110 + img: 'https://cdn.ipadbiz.cn/hager/img/WX20241018-161943@2x.png',
111 + title: '金牌合作单位',
112 + content: '由浙江省土木建筑学会建筑电气学术委员会等单位主办的2022年浙江省建筑电气学术年会,在浙江杭州成功举办。海格电气受邀参加年会,并荣获“金牌合作单位”荣誉称号。'
113 + }, {
114 + img: 'https://cdn.ipadbiz.cn/hager/img/WX20241018-161943@2x.png',
115 + title: '中国建筑学会建筑电气分会',
116 + content: '海格电气凭借在建筑电气行业的应用成果与专业地位,荣获由中国建筑学会建筑电气分会颁发的“铂金合作单位'
117 + }],
118 + activeIndex: 0,
119 + reach_end: false,
120 + slidesPerView: 2,
70 }, { 121 }, {
122 + id: '2',
71 year: '2023', 123 year: '2023',
72 list: [{ 124 list: [{
73 img: 'https://cdn.ipadbiz.cn/hager/img/WX20241018-161943@2x.png', 125 img: 'https://cdn.ipadbiz.cn/hager/img/WX20241018-161943@2x.png',
...@@ -77,17 +129,89 @@ export default { ...@@ -77,17 +129,89 @@ export default {
77 img: 'https://cdn.ipadbiz.cn/hager/img/WX20241018-161943@2x.png', 129 img: 'https://cdn.ipadbiz.cn/hager/img/WX20241018-161943@2x.png',
78 title: '中国建筑学会建筑电气分会', 130 title: '中国建筑学会建筑电气分会',
79 content: '海格电气凭借在建筑电气行业的应用成果与专业地位,荣获由中国建筑学会建筑电气分会颁发的“铂金合作单位' 131 content: '海格电气凭借在建筑电气行业的应用成果与专业地位,荣获由中国建筑学会建筑电气分会颁发的“铂金合作单位'
80 - }] 132 + }],
81 - }] 133 + activeIndex: 0,
134 + reach_end: false,
135 + slidesPerView: 2,
136 + }],
137 + swiperOption: {
138 + slidesPerView: 2,
139 + spaceBetween: 20,
140 + preventClicks : true,
141 + slideToClickedSlide: false,
142 + touchRatio: 0,
143 + breakpoints: {
144 + 1480: {
145 + slidesPerView: 5,
146 + spaceBetween: 30
147 + },
148 + 1024: {
149 + slidesPerView: 5,
150 + spaceBetween: 30
151 + },
152 + 768: {
153 + slidesPerView: 3,
154 + spaceBetween: 20
155 + },
156 + 640: {
157 + slidesPerView: 2,
158 + spaceBetween: 10
159 + },
160 + 320: {
161 + slidesPerView: 1,
162 + spaceBetween: 10
163 + },
164 + 160: {
165 + slidesPerView: 1,
166 + spaceBetween: 0
167 + }
168 + }
169 + },
82 } 170 }
83 }, 171 },
84 mounted () { 172 mounted () {
85 - 173 + this.years_list.forEach((item) => {
174 + this.$nextTick(() => {
175 + const swiperRef = this.$refs[`mySwiper${item.id}`];
176 + if (swiperRef && swiperRef[0].$swiper) {
177 + swiperRef[0].$swiper.on('breakpoint', (swiper) => {
178 + // breakpoint时 显示的条数
179 + item.slidesPerView = swiper.slidesPerView;
180 + });
181 + }
182 + });
183 + });
86 }, 184 },
87 methods: { 185 methods: {
88 onClickBtn (idx) { 186 onClickBtn (idx) {
89 this.active_idx = idx; 187 this.active_idx = idx;
90 - } 188 + },
189 + prevBtn (item) {
190 + this.$nextTick(() => {
191 + const swiperRef = this.$refs[`mySwiper${item.id}`];
192 + if (swiperRef && swiperRef[0].$swiper) {
193 + swiperRef[0].$swiper.slidePrev();
194 + }
195 + });
196 + },
197 + nextBtn (item) {
198 + this.$nextTick(() => {
199 + const swiperRef = this.$refs[`mySwiper${item.id}`];
200 + if (swiperRef && swiperRef[0].$swiper) {
201 + swiperRef[0].$swiper.slideNext();
202 + }
203 + });
204 + },
205 + onSlideChange (item) {
206 + item.activeIndex = this.$refs[`mySwiper${item.id}`][0].$swiper.activeIndex;
207 + const isEnd = this.$refs[`mySwiper${item.id}`][0].$swiper.isEnd;
208 +
209 + if (isEnd) {
210 + item.reach_end = true;
211 + } else {
212 + item.reach_end = false;
213 + }
214 + },
91 } 215 }
92 } 216 }
93 </script> 217 </script>
...@@ -102,13 +226,15 @@ export default { ...@@ -102,13 +226,15 @@ export default {
102 background-repeat: no-repeat; 226 background-repeat: no-repeat;
103 margin: 2rem 0; 227 margin: 2rem 0;
104 &.xs { 228 &.xs {
105 - // background-size: contain; 229 + height: 12rem;
106 - height: 8rem;
107 } 230 }
108 } 231 }
109 232
110 .select-btn-box { 233 .select-btn-box {
111 margin-bottom: 2rem; 234 margin-bottom: 2rem;
235 + &.xs {
236 + margin-bottom: 0;
237 + }
112 .btn { 238 .btn {
113 width: 8rem; 239 width: 8rem;
114 height: 2rem; 240 height: 2rem;
...@@ -117,6 +243,9 @@ export default { ...@@ -117,6 +243,9 @@ export default {
117 display: inline-block; 243 display: inline-block;
118 padding: 0.5rem 0; 244 padding: 0.5rem 0;
119 margin-right: 1rem; 245 margin-right: 1rem;
246 + &.xs {
247 + width: 100%;
248 + }
120 &.active { 249 &.active {
121 background-color: @primary-color; 250 background-color: @primary-color;
122 color: #fff; 251 color: #fff;
...@@ -206,5 +335,52 @@ export default { ...@@ -206,5 +335,52 @@ export default {
206 margin-right: 0; 335 margin-right: 0;
207 } 336 }
208 } 337 }
338 +
339 + .list-wrapper-mini {
340 + margin-bottom: 1rem;
341 + .card-image-box {
342 + padding: 1rem;
343 + background-color: #E3F1F7;
344 + }
345 + .card-image {
346 + // width: 100%;
347 + height: 17rem;
348 + background-size: cover;
349 + background-position: center;
350 + background-repeat: no-repeat;
351 + }
352 + .card-content {
353 + background-color: #F7F7F7;
354 + padding: 2rem 1.5rem;
355 + height: 12rem;
356 + overflow: scroll;
357 + h3 {
358 + color: @secondary-color;
359 + font-size: 1rem;
360 + margin: 0;
361 + margin-bottom: 0.5rem;
362 + }
363 + p {
364 + font-size: 0.95rem;
365 + line-height: 1.8;
366 + }
367 + }
368 + }
369 +
370 + .xs-control {
371 + display: flex;
372 + justify-content: flex-end;
373 + margin-top: 1rem;
374 + i {
375 + font-size: 1.35rem;
376 + color: #EE6D10;
377 + &:hover {
378 + cursor: pointer;
379 + }
380 + &.disabled {
381 + color: #ccc;
382 + }
383 + }
384 + }
209 } 385 }
210 </style> 386 </style>
......