刘磊
2025-04-19 2f18780a16a68f7fc67dd3bca61b8d0aed7c8e1a
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
<template>
    <view class="uni-section" nvue>
        <view v-if="type" class="uni-section__head">
            <view :class="type" class="uni-section__head-tag" />
        </view>
        <view class="uni-section__content">
            <text :class="{'distraction':!subTitle}" class="uni-section__content-title">{{ title }}</text>
            <text v-if="subTitle" class="uni-section__content-sub">{{ subTitle }}</text>
        </view>
        <slot />
    </view>
</template>
 
<script>
    /**
     * Section 标题栏
     * @description 标题栏
     * @property {String} type = [line|circle] 标题装饰类型
     *     @value line 竖线
     *     @value circle 圆形
     * @property {String} title 主标题
     * @property {String} subTitle 副标题
     */
 
    export default {
        name: 'UniTitle',
        props: {
            type: {
                type: String,
                default: ''
            },
            title: {
                type: String,
                default: ''
            },
            subTitle: {
                type: String,
                default: ''
            }
        },
        data() {
            return {}
        },
        watch: {
            title(newVal) {
                if (uni.report && newVal !== '') {
                    uni.report('title', newVal)
                }
            }
        },
        methods: {
            onClick() {
                this.$emit('click')
            }
        }
    }
</script>
<style scoped>
    .uni-section {
        position: relative;
        /* #ifndef APP-NVUE */
        display: flex;
        /* #endif */
        margin-top: 10px;
        flex-direction: row;
        align-items: center;
        padding: 0 10px;
        height: 50px;
        background-color: #f8f8f8;
        /* #ifdef APP-NVUE */
        border-bottom-color: #e5e5e5;
        border-bottom-style: solid;
        border-bottom-width: 0.5px;
        /* #endif */
        font-weight: normal;
    }
 
    /* #ifndef APP-NVUE */
    .uni-section:after {
        position: absolute;
        bottom: 0;
        right: 0;
        left: 0;
        height: 1px;
        content: '';
        -webkit-transform: scaleY(.5);
        transform: scaleY(.5);
        background-color: #e5e5e5;
    }
 
    /* #endif */
 
    .uni-section__head {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        margin-right: 10px;
    }
 
    .line {
        height: 15px;
        background-color: #c0c0c0;
        border-radius: 5px;
        width: 3px;
    }
 
    .circle {
        width: 8px;
        height: 8px;
        border-top-right-radius: 50px;
        border-top-left-radius: 50px;
        border-bottom-left-radius: 50px;
        border-bottom-right-radius: 50px;
        background-color: #c0c0c0;
    }
 
    .uni-section__content {
        flex-direction: column;
        flex: 1;
        color: #333;
    }
 
    .uni-section__content-title {
        font-size: 14px;
        color: #333;
    }
 
    .distraction {
        flex-direction: row;
        align-items: center;
    }
 
    .uni-section__content-sub {
        font-size: 12px;
        color: #999;
    }
</style>