hagerHeader.vue
17.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
<!--
* @Date: 2024-09-26 13:42:11
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-10-15 16:53:54
* @FilePath: /hager/src/components/common/hagerHeader.vue
* @Description: 文件描述
-->
<template>
<div class="hager-header">
<el-row class="hidden-xs-only" style="background-color: #fff;">
<el-col :sm="1" :md="1" :lg="3" :xl="4"> </el-col>
<el-col :sm="22" :md="22" :lg="18" :xl="16" style="position: relative;height: 5rem;">
<el-row>
<el-col :sm="6" :md="6" :lg="6" :xl="6">
<div class="nav-logo">
<div>图标</div>
</div>
</el-col>
<el-col :sm="10" :md="10" :lg="10" :xl="10">
<el-row class="nav-right">
<el-col :span="24">
<div class="search">
<i class="el-icon-search" style="color: #00477E;"></i>
<input placeholder="搜索" />
</div>
</el-col>
</el-row>
</el-col>
<el-col :sm="8" :md="8" :lg="8" :xl="8">
<div class="nav-right" style="float: right;">
<div @click="goToWeb" class="tooltip">
<el-tooltip class="item" effect="dark" content="国际站" placement="bottom">
<i class=el-icon-orange style="font-size: 1.25rem;"></i>
</el-tooltip>
</div>
<div @click="goToLogin" class="tooltip">
<el-tooltip class="item" effect="dark" content="用户登录" placement="bottom">
<i class=el-icon-user style="font-size: 1.25rem;"></i>
</el-tooltip>
</div>
</div>
</el-col>
</el-row>
</el-col>
<el-col :sm="1" :md="1" :lg="3" :xl="4"> </el-col>
</el-row>
<el-row class="hidden-xs-only" style="background-color: #fff; border-top: 1px solid rgba(218, 218, 218, 0.4);">
<el-col :sm="1" :md="1" :lg="3" :xl="4"> </el-col>
<el-col :sm="22" :md="22" :lg="18" :xl="16" style="position: relative;height: 5rem;">
<el-row>
<el-col :sm="16" :md="16" :lg="16" :xl="16">
<div class="nav-wrapper">
<div :class="[is_active === 'product' ? 'active' : '', 'item']" @click="onClickProduct" @mouseenter="onClickProduct">
<i class="el-icon-s-operation"></i>
产品中心
</div>
<div :class="[is_active === 'solution' ? 'active' : '', 'item']" @click="goTo('/solution/index')">解决方案</div>
<div :class="[is_active === '新闻中心' ? 'active' : '', 'item']">新闻中心</div>
<div :class="[is_active === '招聘信息' ? 'active' : '', 'item']">招聘信息</div>
<div :class="[is_active === '关于海格' ? 'active' : '', 'item']">关于海格</div>
<div :class="[is_active === '联系我们' ? 'active' : '', 'item']">联系我们</div>
<div :class="[is_active === 'index' ? 'active' : '', 'item']" @click="goTo('/')">首页</div>
</div>
</el-col>
</el-row>
<el-collapse-transition>
<div v-show="show" class="product-center" v-click-outside="closeMenu">
<div style="display: flex; width: 100%;">
<div class="product-left-wrapper">
<div :class="['product-left-item', p_index === index ? 'active' : '']" v-for="(item, index) in product_menu" :key="index" @click="onClick(item, index)">
<div style="display: flex; align-items: center;">
<el-image style="width: 2rem; height: 2rem" src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" fit="fit"></el-image>
{{ item.name }}
</div>
<div>
<i class="el-icon-right"></i>
</div>
</div>
</div>
<div class="product-right-wrapper">
<div class="product-right-title">
<div class="text">{{ product_info.name }}</div>
<div @click="closeMenu"><i class="el-icon-close" style="font-size: 1.25rem;"></i></div>
</div>
<div class="product-right-desc">{{ product_info.desc }}</div>
<div class="product-right-center">
<div v-for="(item, index) in product_info.product" :key="index" class="product-right-center-item">
<div @click="goToC(item)" class="header-text">{{ item.name }} </div>
<div>
<div class="item-text" @click="goToP(item)" v-for="(p, idx) in item.list" :key="idx">{{ p.name }}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</el-collapse-transition>
</el-col>
<el-col :sm="1" :md="1" :lg="3" :xl="4"> </el-col>
</el-row>
<div v-if="is_xs" style="background-color: #fff; padding: 0.5rem 1rem;">
<div style="display: flex; align-items: center;justify-content: space-between;">
<div @click="openMenu"><i class="el-icon-menu"></i></div>
<div>
<el-image style="height: 2rem;" src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" fit="cover"></el-image>
</div>
<div>
<i class=el-icon-orange style="font-size: 1.25rem;"></i>
<i class=el-icon-user style="font-size: 1.25rem;"></i>
</div>
</div>
<div style="display: flex; align-items: center; border-radius: 1rem; border: 1px solid #f5f5f5; background-color: #e3f1f7; padding: 0.5rem 1rem; margin-top: 1rem;">
<i class=el-icon-search></i>
<input style="border: 0;background-color: #e3f1f7;" placeholder="搜索" />
</div>
<el-collapse-transition>
<div v-show="show_menu" class="menu-mini">
<hager-menu @close="closeMiniMenu"></hager-menu>
</div>
</el-collapse-transition>
</div>
</div>
</template>
<script>
import mixin from 'common/mixin';
import { parseQueryString } from '@/utils/tools';
import $ from 'jquery';
import hagerMenu from '../hagerMenu.vue';
export default {
components: { hagerMenu },
mixins: [mixin.init],
data () {
return {
show: false,
test1: true,
product_menu: [{
name: '配电产品',
info: {
name: '配电产品',
desc: '探索配电新境界,我们的产品引领行业潮流,提供高效、安全的配电解决方案,助您事业更上一层楼!',
product: [
{
name: '空气断路器',
list: [{
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW+系列空气断路器'
}]
},
{
name: '空气断路器',
list: [{
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW+系列空气断路器'
}]
},
{
name: '空气断路器',
list: [{
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW+系列空气断路器'
}]
},
{
name: '空气断路器',
list: [{
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW+系列空气断路器'
}, {
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW+系列空气断路器'
}, {
id: '',
name: 'HW系列空气断路器'
}]
},
{
name: '空气断路器',
list: [{
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW+系列空气断路器'
}]
},
{
name: '空气断路器',
list: [{
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW+系列空气断路器'
}]
},
{
name: '空气断路器',
list: [{
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW+系列空气断路器'
}, {
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW+系列空气断路器'
}, {
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW+系列空气断路器'
}, {
id: '',
name: 'HW系列空气断路器'
}, {
id: '',
name: 'HW+系列空气断路器'
}, {
id: '',
name: 'HW系列空气断路器'
}]
},
]
}
}, {
name: '成套产品',
info: {
name: '成套产品',
desc: '探索配电新境界,我们的产品引领行业潮流,提供高效、安全的配电解决方案,助您事业更上一层楼!',
product: []
}
}, {
name: '开关面板',
info: {
name: '开关面板',
desc: '探索配电新境界,我们的产品引领行业潮流,提供高效、安全的配电解决方案,助您事业更上一层楼!',
product: []
}
}, {
name: '智能控制',
info: {
name: '智能控制',
desc: '探索配电新境界,我们的产品引领行业潮流,提供高效、安全的配电解决方案,助您事业更上一层楼!',
product: []
}
}],
product_info: {},
is_active: '',
p_index: 0,
show_menu: false,
margin_top: 0,
// choose_country: false, // 主动选择了国家地区
}
},
mounted () {
//
// let margin_top = 5; // 默认高度
// let once_header_height = 5; // 选择国家地区高度
// // let hidden_header_height = 2; // 可隐藏高度s
// if (this.choose_country) { // 没有点击国家地区
// margin_top += once_header_height;
// }
// this.$nextTick(() => {
// $('.wrapper').css('marginTop', margin_top + 'rem');
// })
// 监听屏幕滚动
// $('.wrapper').css('marginTop', margin_top + hidden_header_height + 'rem');
// window.addEventListener('scroll', (evt) => {
// if ($(window).scrollTop()) {
// $('.header-top').css('height', 0);
// $('.wrapper').css('marginTop', margin_top - hidden_header_height + 'rem');
// } else {
// $('.header-top').css('height', '2rem');
// $('.wrapper').css('marginTop', margin_top + hidden_header_height + 'rem');
// }
// });
//
this.product_info = this.product_menu[0]['info'];
// 修改数据结构显示
this.product_info.product = this.splitProductList(this.product_info.product);
},
watch: {
'$route' (to, from) {
this.is_active = to.meta.tag;
this.show = false;
}
},
methods: {
splitProductList (products) {
const maxLength = 5; // 超过5个需要拆分
let result = [];
products.forEach(product => {
// 如果 list 长度不超过 5,则直接加入 result
if (product.list.length <= maxLength) {
result.push(product);
} else {
// 如果 list 长度超过 5,则拆分
let listChunks = [];
for (let i = 0; i < product.list.length; i += maxLength) {
listChunks.push(product.list.slice(i, i + maxLength));
}
// 第一个块保留原有的 name,后续块 name 设为空
listChunks.forEach((chunk, index) => {
if (index === 0) {
result.push({
name: product.name,
list: chunk
});
} else {
result.push({
name: '',
list: chunk
});
}
});
}
});
return result;
},
onClickProduct() {
// 当鼠标悬停时
this.show = true;
},
onClick (item, index) {
this.product_info = item.info;
this.p_index = index
},
closeMenu () {
this.show = false;
},
goTo (path) { // 跳转页面
if (this.$route.path !== path) { // 不能重复点击当前页面
this.$router.push({
path,
});
}
},
goToC (item) { // 跳转产品二级
this.$router.push({
path: '/product/index',
query: {
// id: id
}
});
this.closeMenu();
},
goToP (item) { // 跳转产品详情
this.$router.push({
path: '/product/detail',
query: {
// id: id
}
});
this.closeMenu();
},
goToWeb () {
console.warn('暂无跳转');
},
goToLogin () {
this.$router.push({
path: '/login'
});
},
openMenu () {
this.show_menu = !this.show_menu;
if (this.show_menu) {
$('body').css('overflow', 'hidden');
} else {
$('body').css('overflow', 'auto');
}
},
closeMiniMenu () {
this.show_menu = false;
$('body').css('overflow', 'auto');
},
}
}
</script>
<style lang="less" scoped>
.hager-header {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 9;
.location-banner {
display: flex;
background: linear-gradient(0deg, rgba(0, 0, 0, .2), rgba(0, 0, 0, .2)), #00477e;
width: 100%;
height: 5rem;
color: white;
}
.header-top {
display: flex;
background-color: #00477e;
height: 2rem;
transition: all .4s ease-in-out;
}
.product-center {
position: absolute;
top: 5rem;
left: 0;
width: 100%;
height: auto;
background-color: #fff;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
.product-left-wrapper {
flex-basis: 33.33%;
padding: 1rem;
&:hover {
cursor: pointer;
}
.product-left-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem;
&.active {
background-color: @background-color;
border-radius: 5px;
}
i {
color: @primary-color;
}
}
}
.product-right-wrapper {
flex-basis: 66.67%;
background-color: @background-color;
padding: 1.75rem 1.5rem;
.product-right-title {
display: flex;
justify-content: space-between;
margin-bottom: 0.25rem;
.text {
font-size: 1.25rem;
color: @text-color;
font-weight: bold;
}
i {
&:hover {
cursor: pointer;
}
}
}
.product-right-desc {
margin-bottom: 1.5rem;
color: @secondary-text-color;
}
.product-right-center {
display: flex;
flex-wrap: wrap;
// justify-content: space-between;
.product-right-center-item {
flex-basis: calc(33.33%);
margin-bottom: 10px;
.header-text {
margin-bottom: 0.25rem;
color: @text-color;
&:hover {
cursor: pointer;
text-decoration: underline;
}
}
.item-text {
line-height: 1.75;
color: @secondary-text-color;
&:hover {
cursor: pointer;
text-decoration: underline;
}
}
}
}
}
}
.nav-logo {
display: flex;
height: 5rem;
align-items: center;
}
.nav-wrapper {
display: flex;
height: 5rem;
// align-items: center;
// justify-content: space-around;
margin-top: 1.25rem;
.item {
color: @secondary-color;
margin-right: 1.5rem;
font-size: 0.95rem;
&:hover {
cursor: pointer;
}
}
.active {
color: @primary-color;
}
}
.nav-right {
display: flex;
height: 5rem;
align-items: center;
justify-content: right;
.search {
display: flex;
align-items: center;
border-radius: 1rem;
border: 1px solid #f5f5f5;
background-color: #e3f1f7;
padding: 0.5rem 1rem;
overflow: hidden;
width: 100%;
input {
border: 0;
background-color: #E3F1F7;
margin-left: 0.5rem;
width: calc(100% - 0.5rem);
&::placeholder {
color: #00477E;
}
}
}
.tooltip {
margin: 0 1rem;
&:hover {
cursor: pointer;
}
}
}
.menu-mini {
position: absolute;
top: 6.7rem;
right: 0;
left: 0;
width: 100vw;
height: calc(100vh - 6.7rem);
background-color: #F7F7F7;
}
}
</style>