indexNav.vue
2.46 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
<template>
<view class="index-nav" :class="[`is-${position}`]">
<view class="nav-logo" :class="{ 'is-active': active === 'home' }" @tap="() => on_select('home')">
<image class="nav-icon" :src="icons?.home" mode="aspectFit" />
<text class="nav-text">首页</text>
</view>
<view
class="nav-logo"
:class="[{ 'is-active': active === 'code' }, { 'is-center-raised': center_variant === 'raised' }]"
@tap="() => on_select('code')"
>
<image
class="nav-icon"
:class="{ 'nav-icon--raised': center_variant === 'raised' }"
:src="icons?.code"
mode="aspectFit"
/>
<view v-if="center_variant === 'raised'" class="nav-icon-placeholder"></view>
<text class="nav-text">预约码</text>
</view>
<view class="nav-logo" :class="{ 'is-active': active === 'me' }" @tap="() => on_select('me')">
<image class="nav-icon" :src="icons?.me" mode="aspectFit" />
<text class="nav-text">我的</text>
</view>
</view>
</template>
<script setup>
const props = defineProps({
icons: {
type: Object,
default: () => ({})
},
active: {
type: String,
default: ''
},
position: {
type: String,
default: 'fixed'
},
center_variant: {
type: String,
default: 'normal'
},
allow_active_tap: {
type: Boolean,
default: false
}
})
const emit = defineEmits(['select'])
const on_select = (key) => {
if (!props.allow_active_tap && props.active && key === props.active) return
emit('select', key)
}
</script>
<style lang="less">
.index-nav {
left: 0;
bottom: 0;
width: 750rpx;
height: 134rpx;
background: #FFFFFF;
box-shadow: 0 -10rpx 8rpx 0 rgba(0, 0, 0, 0.12);
display: flex;
align-items: center;
justify-content: space-around;
color: #A67939;
z-index: 99;
&.is-fixed {
position: fixed;
}
&.is-absolute {
position: absolute;
}
.nav-logo {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
}
.nav-icon {
width: 48rpx;
height: 48rpx;
display: block;
&.nav-icon--raised {
width: 130rpx;
height: 130rpx;
position: absolute;
top: -100rpx;
left: 50%;
transform: translateX(-50%);
}
}
.nav-icon-placeholder {
width: 48rpx;
height: 48rpx;
}
.nav-text {
font-size: 24rpx;
margin-top: 12rpx;
line-height: 1;
}
.nav-logo.is-center-raised {
.nav-text {
margin-top: -10rpx;
}
}
}
</style>