gracePage.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="grace-sbody">
  3. <!-- 头部导航 -->
  4. <view v-if="customHeader">
  5. <view class="grace-page-header" :style="{'z-index':headerIndex, background:headerBG, borderBottomWidth:borderWidth, borderBottomColor:borderColor}">
  6. <!-- 沉浸式状态栏 -->
  7. <view class="grace-page-status-bar" :style="{height:statusBarHeight+'px', background:statusBarBG}"></view>
  8. <!-- 头部核心 -->
  9. <view class="grace-page-header-nav" :style="{height:headerHeight+'px'}">
  10. <view class="grace-header-main">
  11. <slot name="gHeader"></slot>
  12. </view>
  13. <view :style="{width:BoundingWidth, height:'10px'}"></view>
  14. </view>
  15. </view>
  16. <!-- 占位 view -->
  17. <view :style="{width:'100%', height:(statusBarHeight + headerHeight) + 'px'}"></view>
  18. </view>
  19. <!-- 页面主体 -->
  20. <view class="grace-page-body">
  21. <slot name="gBody"></slot>
  22. </view>
  23. <!-- #ifndef APP-PLUS -->
  24. <view v-if="!isSwitchPage" :style="{width:'100%', height:iphoneXButtomHeight+'px'}"></view>
  25. <!-- #endif -->
  26. <!-- 页面底部 -->
  27. <view class="grace-page-footer" :style="{'z-index':footerIndex, background:footerBg}">
  28. <slot name="gFooter"></slot>
  29. <!-- iphoneX 占位 view -->
  30. <!-- #ifndef APP-PLUS -->
  31. <view v-if="!isSwitchPage" :style="{width:'100%', height:iphoneXButtomHeight+'px'}"></view>
  32. <!-- #endif -->
  33. </view>
  34. <!-- 右下角悬浮按钮 -->
  35. <view class="gui-page-rb-area" :style="{right:rbRight+'rpx', bottom:rbBottom+'rpx', width:rbWidth+'rpx', zIndex:rbIndex}">
  36. <slot name="gRTArea"></slot>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default{
  42. props:{
  43. customHeader : { type : Boolean, default : true },
  44. headerHeight : { type : Number, default : 44 },
  45. headerIndex : { type : Number, default : 1 },
  46. headerBG : { type : String, default : 'none' },
  47. statusBarBG : { type : String, default : 'none' },
  48. footerIndex : { type : Number, default : 1 },
  49. footerBg : { type : String, default : ''},
  50. isSwitchPage : { type : Boolean, default : false },
  51. rbWidth : { type : Number, default : 100},
  52. rbBottom : { type : Number, default : 100 },
  53. rbRight : { type : Number, default : 20 },
  54. rbIndex : { type : Number, default : 1 },
  55. borderWidth : { type : String, default : '0' },
  56. borderColor : { type : String, default : '#D1D1D1' }
  57. },
  58. data() {
  59. return {
  60. statusBarHeight : 0,
  61. iphoneXButtomHeight:0,
  62. BoundingWidth : '0px'
  63. }
  64. },
  65. created:function(){
  66. try {
  67. var res = uni.getSystemInfoSync();
  68. res.model = res.model.replace(' ', '');
  69. res.model = res.model.toLowerCase();
  70. if(res.model.indexOf('iphonex') != -1 || res.model.indexOf('iphone11') != -1){
  71. this.iphoneXButtomHeight = uni.upx2px(50);
  72. }
  73. } catch (e){return null;}
  74. if(!this.customHeader){return ;}
  75. // #ifndef MP-ALIPAY
  76. this.statusBarHeight = res.statusBarHeight;
  77. // #ifdef MP-WEIXIN
  78. // 小程序胶囊按钮
  79. var res = uni.getMenuButtonBoundingClientRect();
  80. this.BoundingWidth = (res.width + 20) + 'px';
  81. // #endif
  82. // #endif
  83. }
  84. }
  85. </script>
  86. <style>
  87. page{width:100%; min-height:100%; display:flex; flex-direction:column; flex:1;}
  88. .grace-sbody{display:flex; flex-direction:column; width:100%; min-height:100%; flex:1;}
  89. /* #ifdef MP */
  90. .grace-sbody{min-height:100vh;}
  91. /* #endif */
  92. .grace-page-header{width:100%; position:fixed; left:0; top:0; z-index:99; border-bottom:0px solid #FFFFFF;}
  93. .grace-page-status-bar{width:100%; height:0;}
  94. .grace-page-header-nav{width:100%; display:flex; flex-direction:row; flex-wrap:nowrap; height:44px; align-items:center;}
  95. .grace-header-main{width:300rpx; flex:auto; overflow:hidden;}
  96. .grace-page-body{width:100%; flex:1; display:flex; flex-direction:column;}
  97. .grace-page-footer{width:100%; position:fixed; left:0; bottom:0; z-index:99;}
  98. .gui-page-rb-area{width:100rpx; position:fixed; right:20rpx; bottom:100rpx; z-index:1;}
  99. </style>