zhangwei
2025-01-16 e3f6581c48b1dfb65c55e8a1a6ce1761a7dc26b4
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<template>
    <!--本文件由FirstUI授权予四川政采招投标咨询有限公司(会员ID: 1 63,营业执照号:    9  15  101313 3  2  006  193  K)专用,请尊重知识产权,勿私下传播,违者追究法律责任。-->
    <view class="fui-footer" :class="[isFixed?'fui-footer__fixed-bottom':'']"
        :style="{background:background,bottom:bottom+'rpx'}">
        <view class="fui-footer__link" v-if="navigate.length>0">
            <navigator v-for="(item,index) in navigate" :key="index" class="fui-link__item" hover-class="fui-link-hover"
                hover-stop-propagation :open-type="item.openType || 'navigate'" :url="item.url" :delta="item.delta">
                <text class="fui-link__text"
                    :class="{'fui-link__color':!item.color,'fui-link__text-border':index===navigate.length-1}"
                    :style="{color:item.color || linkColor,fontSize:(item.size || 28)+'rpx',borderColor:borderColor,lineHeight:(item.size || 28)+'rpx'}">{{item.text}}</text>
            </navigator>
        </view>
        <view class="fui-footer__text"
            :class="{'fui-as__safe-weex':iphoneX && safeArea,'fui-footer__safearea':safeArea}">
            <text :style="{color:color,fontSize:size+'rpx'}">{{text}}</text>
        </view>
    </view>
</template>
 
<script>
    export default {
        name: "fui-footer",
        props: {
            //url,openType,delta ,text,color,size
            //链接设置  object数据格式对应上面注释的属性值
            navigate: {
                type: Array,
                default: function() {
                    return []
                }
            },
            //底部文本
            text: {
                type: String,
                default: ''
            },
            //文本字体颜色
            color: {
                type: String,
                default: "#B2B2B2"
            },
            //文本字体大小
            size: {
                type: [Number, String],
                default: 24
            },
            //footer背景颜色
            background: {
                type: String,
                default: "transparent"
            },
            //分隔线颜色,仅nvue生效
            borderColor: {
                type: String,
                default: '#B2B2B2'
            },
            //是否固定在底部
            isFixed: {
                type: Boolean,
                default: false
            },
            bottom: {
                type: [Number, String],
                default: 0
            },
            //是否适配底部安全区
            safeArea: {
                type: Boolean,
                default: true
            }
        },
        computed: {
            linkColor() {
                const app = uni && uni.$fui && uni.$fui.color;
                return (app && app.link) || '#465CFF';
            }
        },
        data() {
            return {
                iphoneX: false
            }
        },
        created() {
            // #ifdef APP-NVUE || MP-TOUTIAO
            this.iphoneX = this.isPhoneX();
            // #endif
        },
        methods: {
            // #ifdef APP-NVUE || MP-TOUTIAO
            isPhoneX() {
                if (!this.safeArea) return false;
                //34px
                const res = uni.getSystemInfoSync();
                let iphonex = false;
                let models = ['iphonex', 'iphonexr', 'iphonexsmax']
                for (let i = 11; i < 20; i++) {
                    models.push(`iphone${i}`)
                    models.push(`iphone${i}mini`)
                    models.push(`iphone${i}pro`)
                    models.push(`iphone${i}promax`)
                }
                const model = res.model.replace(/\s/g, "").toLowerCase()
                const newModel = model.split('<')[0]
                if (models.includes(model) || models.includes(newModel) || (res.safeAreaInsets && res.safeAreaInsets
                        .bottom > 0)) {
                    iphonex = true;
                }
                return iphonex;
            }
            // #endif
        }
    }
</script>
 
<style scoped>
    .fui-footer {
        flex: 1;
        /* #ifndef APP-NVUE */
        width: 100%;
        box-sizing: border-box;
        word-break: break-all;
        /* #endif */
        overflow: hidden;
        padding-top: 32rpx;
        padding-bottom: 32rpx;
        padding-left: 32rpx;
        padding-right: 32rpx;
    }
 
    .fui-footer__fixed-bottom {
        position: fixed;
        z-index: 99;
        left: 0;
        right: 0;
        /* #ifndef APP-NVUE */
        left: constant(safe-area-inset-left);
        left: env(safe-area-inset-left);
        right: constant(safe-area-inset-right);
        right: env(safe-area-inset-right)
            /* #endif */
    }
 
    .fui-footer__link {
        /* #ifndef APP-NVUE */
        display: flex;
        /* #endif */
        flex-direction: row;
        align-items: center;
        justify-content: center;
        font-size: 28rpx;
    }
 
    /* #ifndef APP-NVUE */
    .fui-link__color {
        color: var(--fui-color-link, #465CFF) !important;
    }
 
    /* #endif */
 
    .fui-link__item {
        position: relative;
        line-height: 1;
    }
 
 
    .fui-link__text {
        padding: 0 18rpx;
        /* #ifdef APP-NVUE */
        border-right-width: 0.5px;
        border-right-style: solid;
        /* #endif */
        font-weight: 400;
    }
 
    .fui-link__text-border {
        border-right-width: 0;
    }
 
 
    /* #ifndef APP-NVUE */
    .fui-link__item::before {
        content: " ";
        position: absolute;
        right: 0;
        top: 4rpx;
        width: 1px;
        bottom: 4rpx;
        border-right: 1px solid var(--fui-color-label, #B2B2B2);
        -webkit-transform-origin: 100% 0;
        transform-origin: 100% 0;
        -webkit-transform: scaleX(0.5);
        transform: scaleX(0.5);
    }
 
    .fui-link__item:last-child::before {
        border-right: 0 !important
    }
 
    /* #endif */
 
    .fui-link-hover {
        opacity: 0.5
    }
 
    .fui-footer__text {
        flex: 1;
        /* #ifdef APP-NVUE */
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
        /* #endif */
        line-height: 1;
        text-align: center;
        padding-top: 8rpx;
        font-weight: 400;
    }
 
    /* #ifndef APP-NVUE || MP-TOUTIAO */
    .fui-footer__safearea {
        padding-bottom: constant(safe-area-inset-bottom);
        padding-bottom: env(safe-area-inset-bottom);
    }
 
    /* #endif */
 
    /* #ifdef APP-NVUE || MP-TOUTIAO */
    .fui-as__safe-weex {
        padding-bottom: 34px;
    }
 
    /* #endif */
</style>