layout-header.vue
1.77 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
<template>
<div class="header">
<div class="back-wrapper flex" @touchend="onBack">
<div class="back" v-if="showBack"></div>
</div>
<div class="title flex" :style="{opacity}">
<slot>
<span class="title-inner">{{title}}</span>
</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,
opacity: {
type: Number,
default: 1
},
showBack: {
type: Boolean,
default: true
}
},
title(setTitle) {
if (!setTitle) {
return this.title;
}
if (this.title) {
setTitle(this.title);
}
this.setTitle = setTitle;
},
computed: {
...mapState(['yoho'])
},
methods: {
onBack() {
this.$router.go(-1);
}
}
};
</script>
<style lang="scss" scoped>
.header {
width: 100%;
height: 45PX;
padding-left: 20PX;
padding-right: 20PX;
background-color: #fff;
display: flex;
align-items: stretch;
box-sizing: border-box;
.flex {
display: flex;
align-items: center;
}
.back-wrapper {
height: 100%;
width: 60PX;
}
.back {
width: 24PX;
height: 24PX;
background: url(~statics/image/order/back@3x.png) no-repeat;
background-size: cover;
}
.title {
flex: 1;
justify-content: center;
font-size: 18PX;
letter-spacing: 0.09PX;
overflow: hidden;
z-index: 1;
.title-inner {
max-width: 90%;
line-height: 1.4;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: inline-block;
}
}
.opts {
width: 60PX;
height: inherit;
justify-content: flex-end;
}
}
</style>