index.vue
4.2 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
<template>
<view>
<!-- #ifdef MP-WEIXIN -->
<view class="CustomReturn-container" :style="{height: titleHeight, paddingTop: paddingTop, backgroundColor: bgColor}">
<view class="CustomReturn">
<view v-if="isShowBreak" class="CustomReturn-r">
<u-icon name="home" v-if="isFirstPage && !isCustomReturn" @click="toBreak()" size="23" :color="color"></u-icon>
<u-icon name="arrow-left" v-else @click="toBreak()" size="20" :color="color"></u-icon>
</view>
<view style="width: 200rpx;" v-else></view>
<view class="CustomReturn-title">
<view class="CustomReturn-title-c">
<u-icon name="search" size="20"></u-icon>
<input class="CustomReturn-title-c-c" v-model="value" placeholder="请输入教师姓名" type="text" confirm-type="search" @confirm="confirm">
<u-icon name="close-circle-fill" size="20" color="#E6E6E6"></u-icon>
</view>
</view>
<view style="width: 200rpx;"></view>
</view>
<view class="other">
<slot></slot>
</view>
</view>
<!-- #endif -->
</view>
</template>
<script>
export default {
name:"CustomReturn",
components: {
},
props: {
color: {
type: String,
default: '#000000'
},
isShowOtherIcon: {
type: Boolean,
default: true
},
bgColor: {
type: String,
default: '#fff'
},
breakUrl: {
type: String,
default: ''
},
isShowBreak: {
type: Boolean,
default: true
},
title: {
type: [String, Number],
default: '标题'
},
isCustomReturn: {
type: Boolean,
default: false
}
},
data() {
return {
value: '',
show: false,
titleHeight: 0,
paddingTop: 0,
otherHeight: 0,
isFirstPage: false,
entityHeight: 0
};
},
mounted() {
this.getHeight()
this.getOther()
this.identifyPages()
},
methods: {
confirm() {
this.$emit('confirm', this.value)
},
toExamination() {
uni.reLaunch({
url: '/pages/examination/examination'
})
},
toPersonalCenter() {
uni.reLaunch({
url: '/pages/personalCenter/personalCenter'
})
},
// 获取除顶部导航栏以外的高度
getOtherHeight() {
return this.otherHeight
},
getOther() {
uni.createSelectorQuery().in(this).select('.other')
.fields({ size: true }, (res) => {
if (res) {
this.otherHeight = res.height
console.log('元素高度', res.height);
this.$emit('init', {otherHeight: this.otherHeight, entityHeight: this.entityHeight})
}
}).exec();
},
// 辨别页面
identifyPages() {
let result = getCurrentPages()
if(result.length === 1) {
this.isFirstPage = true
} else {
this.isFirstPage = false
}
},
getHeight() {
this.titleHeight = 88 + 'rpx';
this.paddingTop = uni.getSystemInfoSync().statusBarHeight + 'px'
// #ifdef MP-WEIXIN
let res = wx.getMenuButtonBoundingClientRect();
// #endif
this.paddingTop = res.top + 'px'
this.titleHeight = res.height + 10 + 'px';
this.entityHeight = res.top + res.height
},
toBreak(){
if(!this.isCustomReturn) {
let result = getCurrentPages()
if(result.length === 1) {
uni.reLaunch({
url: '/pages/examination/examination'
})
} else {
uni.navigateBack({
delta: 1
})
}
} else {
this.$emit('goBack')
}
}
}
}
</script>
<style lang="scss" scoped>
.CustomReturn-container{
position: fixed;
top: 0;
width: 100%;
z-index: 1002;
transition: all .5s;
box-sizing: content-box;
}
.CustomReturn{
display: flex;
align-items: center;
flex-grow: 1;
padding: 0 24rpx;
justify-content: space-between;
position: relative;
z-index: 1002;
height: 100%;
padding-bottom: 10px;
box-sizing: border-box;
.CustomReturn-title{
font-size: 36rpx;
.CustomReturn-title-c{
background-color: #F6F6F6;
border: 1px solid #E6E6E6;
border-radius: 200rpx;
display: flex;
align-items: center;
height: 68rpx;
padding: 0 20rpx;
.CustomReturn-title-c-c{
flex-grow: 1;
margin-left: 10rpx;
font-size: 28rpx;
}
}
}
.CustomReturn-r{
display: flex;
width: 80rpx;
align-items: center;
.CustomReturn-i{
height: 36rpx;
width: 36rpx;
margin-left: 30rpx;
}
}
}
</style>