top_bar.vue
2.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
<template>
<view>
<view class="dh_top" :class="bg_img?'cf':''" :style="style+'background-color:'+bg_color">
<image v-if="bg_img" class="nav_bar_img" :src="bg_img" mode="widthFix"></image>
<!-- <text class=""></text>
<text>个人中心</text>
<text class=""></text> -->
<view class="dh_top_box" :style="style1">
<!-- {{bg_img}} -->
<slot></slot>
</view>
</view>
<view v-if="have_top" class="dh_top dh_top1" :style="'height: '+CustomBar+'px;background-color:'+bg_color"></view>
</view>
</template>
<script>
var that
import {
mapState,
mapMutations
} from 'vuex'
export default {
name:"top_bar",
props: {
bg_img:{
type: String,
default: ''
},
bg_color:{
type: String,
default: ''
},
have_top:{
type: Boolean,
default: true
}
},
data() {
return {
StatusBar: this.StatusBar,
CustomBar: this.CustomBar,
};
},
computed: {
...mapState(['hasLogin', 'forcedLogin', 'userName','loginDatas','relation_phone']),
style0() {
var StatusBar = this.StatusBar;
var CustomBar = this.CustomBar;
var padd_top = CustomBar
var style = `padding-top:${padd_top}px;`;
return style
},
style() {
var StatusBar = this.StatusBar;
var CustomBar = this.CustomBar;
var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
return style
},
style1(){
var StatusBar = this.StatusBar;
var style = `top:${StatusBar}px;`;
return style
},
style2(){
var StatusBar = this.StatusBar;
var CustomBar = this.CustomBar;
var style = `padding-top:${CustomBar}px;`;
return style
}
},
methods:{
back(){
uni.navigateBack({
delta:1
})
}
}
}
</script>
<style scoped>
.dh_top{
width: 100vw;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 991;
background-color: #fff;
padding: var(--status-bar-height) 15upx 0;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
overflow: hidden;
box-sizing: border-box;
}
.dh_top1{
opacity: 0;
position: relative;
z-index: 100;
}
.dh_top_box{
position: absolute;
left: 0;
bottom: 0;
right: 0;
margin: auto;
height: 60rpx;
font-size: 32rpx;
/* line-height: 60rpx; */
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 0 15upx;
}
.dh_top>.nav_bar_img{
position: absolute;
top: 0;
left: 0;
right: 0;
width: 100vw;
height: auto;
z-index: 991;
}
.dh_top /deep/ text{
position: relative;
z-index: 992;
color: #333;
}
.cf /deep/ text{
color: #fff;
}
</style>