shuishen
2021-09-07 70b392ddda24207abd902f992d1e5d6680d185b4
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
<template>
    <view class="index-header">
        <view class="cu-custom" :style="[{height:CustomBar + 'px'}]">
            <view class="cu-bar fixed" :style="style" :class="bgColor">
                
                <view class="action" @tap="SwitchTab(1)">
                    <text class="cuIcon-playfill"></text>
                </view>
                
                <view class="content-1" :style="[{top:StatusBar + 'px'}]">
                    <view class="action">
                        <view class="item" 
                        :class="SwitchCur == 1 ? 'selected' : null "
                        @tap.stop="SwitchTab(1)">关注</view>
                        <view class="item"
                         :class="SwitchCur == 2 ? 'selected' : null "
                         @tap.stop="SwitchTab(2)">
                            <text>推荐</text>
                         </view>
                    </view>
                </view>
                
                <view class="right" @tap="SwitchTab(2)">
                    <text class="cuIcon-search"></text>
                </view>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                StatusBar: this.StatusBar,
                CustomBar: this.CustomBar,
                SwitchCur: 2
            };
        },
        name: 'index-header',
        computed: {
            style() {
                var StatusBar= this.StatusBar;
                var CustomBar= this.CustomBar;
                var bgImage = this.bgImage;
                var style = `height:${CustomBar}px;padding-top:${StatusBar}px;`;
                if (this.bgImage) {
                    style = `${style}background-image:url(${bgImage});`;
                }
                return style
            }
        },
        props: {
            bgColor: {
                type: String,
                default: ''
            },
            isBack: {
                type: [Boolean, String],
                default: false
            }
        },
        methods: {
            SwitchTab(val) {
                this.SwitchCur = val;
                // console.log( this.SwitchCur );
                this.$emit('headerSwitch',val);
            }
        }
    }
</script>
 
<style lang="less">
.cu-custom{
    .bg-index-header{
        background-color: rgba(255,255,255,0);
    }
    .action{
        .cuIcon-playfill{
            background-color: rgba(255,255,255,0.5);
            border-radius: 50upx;
            padding: 18upx;
            color: #FFFFFF;
        }
    }
    
    .right{
        padding-right: 30upx;
        .cuIcon-search{
            background-color: rgba(255,255,255,0.5);
            border-radius: 50upx;
            padding: 18upx;
            color: #FFFFFF;
        }
    }
    .content-1{
        .action{
            border-radius: 80upx;
            background-color: rgba(255,255,255,0.2);
            .item{
                border-radius: 80upx;
                padding: 12upx 30upx;
                margin: 0 5upx;
                color: #FFFFFF;
            }
            .selected{
                background-color: rgba(255,255,255,0.5);
            }
        }
    }
}
 
</style>