liaoxujun@qq.com
2024-02-28 9f8e542b9b74fe18a6a4e0a00fef4b50e3e62581
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
<template>
    <view class="">
        <view class="coreshop-tabbar coreshop-margin-bottom-10" ref="tabBar">
            <scroll-view scroll-x='true' class="tabbar-list">
                <view class="tabbar-item" v-for="(item, index) in coreshopdata.parameters.list" :key="index" @click="showSliderInfo(item.linkType, item.linkValue)">
                    {{item.text}}
                    <view class="active-tabbar"></view>
                </view>
            </scroll-view>
        </view>
    </view>
</template>
 
<script>
    export default {
        name: "coreshopTabbar",
        props: {
            coreshopdata: {
                // type: Object,
                required: true,
            }
        },
        data() {
            return {
                searchTop: 0,
                scrollTop: 0,
                tabbarFixed: false
            };
        },
        created() {
            this.searchStyle()
        },
        mounted() {
        },
        methods: {
            searchStyle() {
                this.$store.commit('searchStyle', this.coreshopdata.parameters.style)
            },
            handleScroll() {
                this.scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
                this.scrollTop >= this.searchTop ? this.tabbarFixed = true : this.tabbarFixed = false;
            },
            goClassify() {
                this.$u.route({ type: 'switchTab', url: '/pages/category/index/index' });
            },
        },
        onPageScroll() {
            var _this = this;
            // #ifdef MP-WEIXIN || APP-PLUS || APP-PLUS-NVUE
            const query = uni.createSelectorQuery().in(this)
            query.select('.search').boundingClientRect(function (res) {
                if (res.top < 0) {
                    _this.tabbarFixed = true;
                } else {
                    _this.tabbarFixed = false;
                }
            }).exec()
            // #endif
        }
    }
</script>
 
<style lang="scss" scoped>
    .tabbar-list { padding: 5px 0; background-color: #fff; white-space: nowrap; width: 100%;
        .tabbar-item { display: inline-block; padding: 5px 10px;
            .active-tabbar { display: none; }
        }
    }
    .tabbar-item:first-of-type { color: #FF7159;
        .active-tabbar { display: block; width: 100%; height: 2px; margin: 5px auto 0; background-color: #FF7159; }
    }
    .tabbar-fixed { position: fixed; top: 52px; transition: all .5s; z-index: 999; background-color: #fff; width: 100%; }
</style>