You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.9 KiB
72 lines
1.9 KiB
<!--本文件由FirstUI授权予内蒙古晟誉网络科技有限责任公司(手机号:15 1 482 2810 8,身份证尾号:1R6T39)专用,请尊重知识产权,勿私下传播,违者追究法律责任。-->
|
|
<template>
|
|
<view class="fui-safe__area-wrap" :class="{'fui-safe__area-weex':iphonex}" :style="{background:background}"></view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: "fui-safe-area",
|
|
props: {
|
|
//背景颜色
|
|
background: {
|
|
type: String,
|
|
default: '#FFFFFF'
|
|
}
|
|
},
|
|
created() {
|
|
// #ifdef APP-NVUE || MP-TOUTIAO
|
|
this.iphonex = this.isPhoneX();
|
|
// #endif
|
|
},
|
|
data() {
|
|
return {
|
|
iphonex: false
|
|
};
|
|
},
|
|
methods: {
|
|
// #ifdef APP-NVUE || MP-TOUTIAO
|
|
isPhoneX() {
|
|
//34px
|
|
const res = uni.getSystemInfoSync();
|
|
let iphonex = false;
|
|
let models = ['iphonex', 'iphonexr', 'iphonexsmax', 'iphone11', 'iphone11pro', 'iphone11promax',
|
|
'iphone12', 'iphone12mini', 'iphone12pro', 'iphone12promax', 'iphone13', 'iphone13mini',
|
|
'iphone13pro', 'iphone13promax', 'iphone14', 'iphone14mini',
|
|
'iphone14pro', 'iphone14promax', 'iphone15', 'iphone15mini',
|
|
'iphone15pro', 'iphone15promax'
|
|
]
|
|
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-safe__area-wrap {
|
|
/* #ifndef APP-NVUE */
|
|
width: 100%;
|
|
display: flex;
|
|
/* #endif */
|
|
|
|
/* #ifndef APP-NVUE || MP-TOUTIAO */
|
|
padding-bottom: constant(safe-area-inset-bottom);
|
|
padding-bottom: env(safe-area-inset-bottom);
|
|
/* #endif */
|
|
flex: 1;
|
|
flex-direction: row;
|
|
}
|
|
|
|
/* #ifdef APP-NVUE || MP-TOUTIAO */
|
|
.fui-safe__area-weex {
|
|
padding-bottom: 34px;
|
|
}
|
|
|
|
/* #endif */
|
|
</style>
|