景徳镇旅游微信小程序
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.

67 lines
1.8 KiB

9 months ago
  1. <template>
  2. <view
  3. class="uv-safe-bottom"
  4. :style="[style]"
  5. :class="[!isNvue && 'uv-safe-area-inset-bottom']"
  6. >
  7. </view>
  8. </template>
  9. <script>
  10. import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'
  11. import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'
  12. /**
  13. * SafeBottom 底部安全区
  14. * @description 这个适配主要是针对IPhone X等一些底部带指示条的机型指示条的操作区域与页面底部存在重合容易导致用户误操作因此我们需要针对这些机型进行底部安全区适配
  15. * @tutorial https://www.uvui.cn/components/safeAreaInset.html
  16. * @property {type} prop_name
  17. * @property {Object} customStyle 定义需要用到的外部样式
  18. *
  19. * @event {Function()}
  20. * @example <uv-status-bar></uv-status-bar>
  21. */
  22. export default {
  23. name: "uv-safe-bottom",
  24. mixins: [mpMixin, mixin],
  25. data() {
  26. return {
  27. safeAreaBottomHeight: 0,
  28. isNvue: false,
  29. };
  30. },
  31. computed: {
  32. style() {
  33. const style = {};
  34. // #ifdef APP-NVUE || MP-TOUTIAO || MP-LARK
  35. // nvue下,高度使用js计算填充
  36. style.height = this.$uv.addUnit(this.$uv.sys()?.safeAreaInsets?.bottom, 'px');
  37. // #endif
  38. return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle));
  39. },
  40. },
  41. mounted() {
  42. // #ifdef APP-NVUE
  43. // 标识为是否nvue
  44. this.isNvue = true;
  45. // #endif
  46. },
  47. };
  48. </script>
  49. <style lang="scss" scoped>
  50. .uv-safe-bottom {
  51. /* #ifndef APP-NVUE */
  52. width: 100%;
  53. /* #endif */
  54. }
  55. /* #ifndef APP-NVUE */
  56. // 历遍生成4个方向的底部安全区
  57. @each $d in top, right, bottom, left {
  58. .uv-safe-area-inset-#{$d} {
  59. padding-#{$d}: 0;
  60. padding-#{$d}: constant(safe-area-inset-#{$d});
  61. padding-#{$d}: env(safe-area-inset-#{$d});
  62. }
  63. }
  64. /* #endif */
  65. </style>