k94314517
2025-06-25 f6722e13ba28cd292c162df9292bb3418ba12bec
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
<template>
    <view class="tabBar">
        <view class="tabBar_list">
            <view v-for="(item,index) in tabBar" :key="item.url" class="tabbar_item" :class="{'active':item.url == currentPage}" @click="navTo(item)">
                <template v-if="item.url">
                    <image v-if="item.url == currentPage" :src="item.imgClick" mode="widthFix"></image>
                    <image v-else :src="item.imgNormal" mode="widthFix"></image>
                    <view class="text">{{item.text}}</view>
                </template>
                <view class="tabbar_quan" v-else></view>
            </view>
        </view>
        <view class="tabBar_zw"></view>
    </view>
</template>
 
<script>
    export default {
        props: {
            currentPage: {
                type: String,
                default: 'index'
            }
        },
        data() {
            return {
                value: 1,
                tabBar: [
                    {
                        url: '/pages/myPolicy/myPolicy',
                        text: '保单',
                        imgNormal: '../../static/icon/nav_home@2x.png',
                        imgClick: '../../static/icon/nav_home_sel@2x.png'
                    },
                    {
                        url: '/pages/online_reporting/online_reporting',
                        text: '理赔',
                        imgNormal: '../../static/icon/nav_lipei@2x.png',
                        imgClick: '../../static/icon/nav_lipei_sel@2x.png'
                    },
                    {
                        url: '',
                        text: ''
                    },
                    {
                        url: '/pages/changeRecord/changeRecord',
                        text: '变更记录',
                        imgNormal: '../../static/icon/nav_biangeng@2x.png',
                        imgClick: '../../static/icon/nav_biangeng_sel@2x.png'
                    },
                    {
                        url: '/pages/mine/mine',
                        text: '我的',
                        imgNormal: '../../static/icon/nav_wode@2x.png',
                        imgClick: '../../static/icon/nav_wode_sel@2x.png'
                    }
                ]
            };
        },
        methods: {
            navTo(item) {
                if (item.url !== this.currentPage) {
                    var isUrl = item.url
                    const that = this
                    uni.switchTab({
                        url: isUrl
                    })
                }
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    //导航栏设置
    $isRadius: 20upx; //左上右上圆角
    $isWidth: 100vw; //导航栏宽度
    $isBorder: 0px solid white; //边框 不需要则设为0px
    $isBg: white; //背景
 
    // 选中设置
    $chooseTextColor: #222222; //选中时字体颜色
    $chooseBgColor: transparent; //选中时背景颜色 transparent为透明
 
    //未选中设置
    $normalTextColor: #312F32; //未选中颜色
 
    .tabBar {
        width: 100vw;
        // height: 110upx;
        // padding-bottom: env(safe-area-inset-bottom);
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 988;
        background-color: $isBg;
        color: $normalTextColor;
        display: flex;
        flex-direction: column;
        
        .tabBar_zw {
            width: 100vw;
            height: env(safe-area-inset-bottom);
        }
        
        .tabBar_list {
            width: 100vw;
            height: 110upx;
            background-color: $isBg;
            color: $normalTextColor;
            display: flex;
            justify-content: space-around;
            box-sizing: border-box;
            overflow: hidden;
            
            .tabbar_item {
                flex: 1;
                font-size: 12px;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                position: relative;
                
                .tabbar_quan {
                    width: 40px;
                    height: 40px;
                    background: #437CB3;
                    border-radius: 20px;
                    border: 3px solid rgba(67,124,179,0.14);
                }
                
                .tabbar_item_hot {
                    position: absolute;
                    left: 50%;
                    top: 25upx;
                    transform: translate(0, -50%);
                    width: 30rpx;
                    height: 30rpx;
                    line-height: 30rpx;
                    text-align: center;
                    background-color: red;
                    border-radius: 50%;
                    color: #ffffff;
                    font-size: 18rpx;
                    z-index: 9;
                }
            
                &.active {
                    border-left: $isBorder;
                    border-top: $isBorder;
                    background: $chooseBgColor;
                    color: $chooseTextColor;
                }
            }
            
            image {
                width: 48upx;
                height: 48upx;
            }
        }
    }
</style>