-
zhangwei
2024-08-21 9efb46fe04b3bb9098e92979ae2c658256446f25
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
<template>
    <!--本文件由FirstUI授权予四川政采招投标咨询有限公司(会员ID:1 6 3,营业执照号:91 510       1 3 1 33200  619 3   K)专用,请尊重知识产权,勿私下传播,违者追究法律责任。-->
    <view :style="getStyle">
        <view :style="{ height: statusBarHeight,zIndex:isFixed?zIndex:1,background:background }" class="fui-status__bar"
            :class="{'fui-status__bar-fixed':isFixed}">
            <slot />
        </view>
    </view>
</template>
 
<script>
    var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px'
    export default {
        name: "fui-status-bar",
        emits: ['init'],
        props: {
            //背景色
            background: {
                type: String,
                default: 'transparent'
            },
            //是否固定在顶部
            isFixed: {
                type: Boolean,
                default: false
            },
            //z-index值,isFixed为true时生效
            zIndex: {
                type: Number,
                default: 99
            },
            //v2.3.0+
            isOccupy: {
                type: Boolean,
                default: false
            }
        },
        data() {
            return {
                statusBarHeight
            };
        },
        computed: {
            getStyle() {
                let style = ''
                if (this.isOccupy) {
                    style += `height:${this.statusBarHeight}px;`
                }
                return style
            }
        },
        created() {
            this.$emit('init', {
                statusBarHeight: statusBarHeight
            })
        }
    }
</script>
 
<style scoped>
    .fui-status__bar {
        /* #ifndef APP-NVUE */
        width: 100%;
        /* #endif */
        height: 20px;
        overflow: hidden;
    }
 
    .fui-status__bar-fixed {
        position: fixed;
        left: 0;
        right: 0;
        top: 0;
    }
</style>