layout-header.vue
2.22 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
<template>
<div class="layout-header" :class="{[`theme-${theme}`]: theme}">
<div class="back flex hover-opacity" @click="onBack">
<slot name="back" v-if="back">
<i class="iconfont icon-left"></i>
</slot>
</div>
<div class="title flex" :style="{opacity}">
<slot>
{{title}}
</slot>
</div>
<div class="opts flex" :style="{opacity}">
<slot name="opts"></slot>
</div>
</div>
</template>
<script>
import {mapState} from 'vuex';
export default {
name: 'LayoutHeader',
props: {
title: String,
theme: String,
fixed: Boolean,
back: {
type: Boolean,
default: true
},
transparentSeek: Number,
opacity: {
type: Number,
default: 1
}
},
computed: {
...mapState(['yoho'])
},
watch: {
transparentSeek(value) {
this.animeEl && this.animeEl.seek(this.animeEl.duration * value);
}
},
mounted() {
if (this.transparentSeek >= 0) {
import('animejs').then(({default: anime}) => {
this.animeEl = anime({
targets: this.$el,
backgroundColor: '#222',
easing: 'easeInOutQuad',
autoplay: false
});
});
}
},
methods: {
onBack() {
if (this.yoho.homePage) {
this.$yoho.finishPage({});
} else {
this.$router.go(-1);
}
}
}
};
</script>
<style lang="scss" scoped>
.layout-header {
width: 100%;
height: 44PX;
background-color: #444;
color: #fff;
overflow: hidden;
display: flex;
&.theme-white {
background-color: #fff;
color: #222;
border-bottom: solid 1px #e0e0e0;
}
&.theme-transparent {
background-color: initial;
color: #fff;
}
.flex {
display: flex;
align-items: center;
}
.iconfont {
height: 100%;
font-size: 20PX;
display: flex;
align-items: center;
justify-content: center;
padding-left: 10PX;
padding-right: 10PX;
}
.back {
width: 160px;
padding-left: 5px;
}
.title {
flex: 1;
justify-content: center;
font-size: 18PX;
letter-spacing: 0.09PX;
}
.opts {
width: 160px;
justify-content: flex-end;
padding-right: 5px;
.iconfont {
font-size: 23PX;
}
}
}
</style>