liyaozhi
2025-10-28 9ad5fcb425da23ecc8f88a11604015d13c536bb7
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
<template>
    <view>
        <!--图标入口-->
        <view class="diy-navbar" :style="{background:itemData.style.background}">
            <view class="item" v-for="(item, index) in itemData.data" :key="index" :style="'border-left:1rpx solid '+item.color+';width:'+item_width+';'" @click="gotoDetail(item)" v-if="index<itemData.style.rowsNum">
                <text class="gray3" :style="{color:item.color}">{{item.text}}</text>
            </view>
        </view>
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                //单个宽度
                item_width: '25%'
            }
        },
        props: ['itemData'],
        created() {
            this.item_width = 100 / Math.abs(this.itemData.style.rowsNum) + '%';
        },
        methods: {
 
            /*跳转页面*/
            gotoDetail(e) {
                if(e.type && e.type == "小程序"){
                    wx.navigateToMiniProgram({
                      appId: e.inputname,
                      path: e.linkUrl,
                      extarData: {
                        open: 'happy'
                      },
                      envVersion: 'release',
                      success(res) {
                        // 打开成功
                        console.log("成功")
                      }
                    })
                    
                }else{
                    this.gotoPage(e.linkUrl);
                }
            }
        }
    }
</script>
 
<style>
    .diy-navbar {
        margin: 20rpx;
        padding: 20rpx 0;
        border-radius: 6rpx;
        background: #FFFFFF;
        display: flex;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
 
    .diy-navbar .item {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 120rpx;
        box-sizing: border-box;
    }
    .diy-navbar .item:first-child {
        border: 0 !important;
    }
 
    .diy-navbar .item image {
        width: 70rpx;
        height: 70rpx;
    }
 
    .diy-navbar .item text {
        display: block;
        text-overflow: ellipsis;
        white-space: nowrap;
        width: 100%;
        overflow: hidden;
        line-height: 66rpx;
        font-size: 26rpx;
        text-align: center;
    }
</style>