gracePage.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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"
  8. :style="{height:statusBarHeight+'px', background:statusBarBG}"></view>
  9. <!-- 头部核心 -->
  10. <view class="grace-page-header-nav" id="gracePageHeader">
  11. <view class="grace-header-main">
  12. <slot name="gHeader"></slot>
  13. </view>
  14. <view :style="{width:BoundingWidth, flexShrink:'0'}" v-if="bounding"></view>
  15. </view>
  16. </view>
  17. <!-- 占位 view -->
  18. <view :style="{width:'100%', height:(headerHeight+statusBarHeight) + 'px'}"></view>
  19. </view>
  20. <!-- 页面主体 -->
  21. <view class="grace-page-body">
  22. <slot name="gBody"></slot>
  23. </view>
  24. <!-- #ifndef APP-PLUS -->
  25. <view v-if="!isSwitchPage" :style="{width:'100%', height:iphoneXButtomHeight+'px'}"></view>
  26. <!-- #endif -->
  27. <!-- 页面底部 -->
  28. <view class="grace-page-footer" :style="{'z-index':footerIndex, background:footerBg, bottom:footerBottom}">
  29. <slot name="gFooter"></slot>
  30. <!-- iphoneX 占位 view -->
  31. <!-- #ifndef APP-PLUS -->
  32. <view v-if="!isSwitchPage" :style="{width:'100%', height:iphoneXButtomHeight+'px'}"></view>
  33. <!-- #endif -->
  34. </view>
  35. <!-- 右下角悬浮按钮 -->
  36. <view class="gui-page-rb-area"
  37. :style="{right:rbRight+'rpx', bottom:rbBottom+'rpx', width:rbWidth+'rpx', zIndex:rbIndex}">
  38. <slot name="gRTArea"></slot>
  39. </view>
  40. <!-- 全屏 loading -->
  41. <view class="grace-page-loading" @tap.stop="" @touchmove.stop.prevent="" :style="{background:loadingBG}" v-if="isLoading">
  42. <view class="grace-page-loading-point">
  43. <view class="grace-page-loading-points animate1" :style="{background:loadingPointBg}"></view>
  44. <view class="grace-page-loading-points animate2" :style="{background:loadingPointBg}"></view>
  45. <view class="grace-page-loading-points animate3" :style="{background:loadingPointBg}"></view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default{
  52. props:{
  53. customHeader : { type : Boolean, default : true },
  54. headerHeight : { type : Number, default : 44 },
  55. headerIndex : { type : Number, default : 98 },
  56. headerBG : { type : String, default : 'none' },
  57. statusBarBG : { type : String, default : 'none' },
  58. footerIndex : { type : Number, default : 98 },
  59. footerBottom : { type : String, default : '0rpx' },
  60. footerBg : { type : String, default : ''},
  61. isSwitchPage : { type : Boolean, default : false },
  62. rbWidth : { type : Number, default : 100},
  63. rbBottom : { type : Number, default : 100 },
  64. rbRight : { type : Number, default : 20 },
  65. rbIndex : { type : Number, default : 1 },
  66. borderWidth : { type : String, default : '0' },
  67. borderColor : { type : String, default : '#D1D1D1'},
  68. loadingBG : { type : String, default : 'rgba(255,255,255, 0.1)'},
  69. isLoading : { type : Boolean, default : false },
  70. loadingPointBg : {type : String, default : '#3688FF'},
  71. bounding : { type : Boolean, default : true }
  72. },
  73. data() {
  74. return {
  75. statusBarHeight : 44,
  76. iphoneXButtomHeight:0,
  77. BoundingWidth : '0px'
  78. }
  79. },
  80. created:function(){
  81. try {
  82. var system = uni.getSystemInfoSync();
  83. system.model = system.model.replace(' ', '');
  84. system.model = system.model.toLowerCase();
  85. if(system.model.indexOf('iphonex') != -1 || system.model.indexOf('iphone11') != -1){this.iphoneXButtomHeight = uni.upx2px(50);}
  86. if(!this.customHeader){return ;}
  87. this.statusBarHeight = system.statusBarHeight;
  88. // #ifdef MP-ALIPAY
  89. this.statusBarHeight = 0;
  90. // #endif
  91. // #ifndef MP-ALIPAY
  92. // #ifdef MP-WEIXIN
  93. // 小程序胶囊按钮
  94. var bounding = uni.getMenuButtonBoundingClientRect();
  95. this.BoundingWidth = (bounding.width + system.windowWidth - bounding.right + 10) + 'px';
  96. // #endif
  97. // #endif
  98. } catch (e){return null;}
  99. },
  100. methods:{
  101. getHeaderHeight:function(){
  102. return this.headerHeight + this.statusBarHeight;
  103. }
  104. }
  105. }
  106. </script>
  107. <style>
  108. /* #ifndef MP */
  109. page{width:100%; min-height:100%; display:flex; flex-direction:column; flex:1;}
  110. /* #endif */
  111. .grace-sbody{display:flex; flex-direction:column; width:100%; min-height:100%; flex:1;}
  112. /* #ifdef MP */
  113. .grace-sbody{min-height:100vh;}
  114. /* #endif */
  115. .grace-page-header{width:100%; position:fixed; left:0; top:0; z-index:99; border-bottom:0px solid #FFFFFF;}
  116. .grace-page-status-bar{width:100%; height:0;}
  117. .grace-page-header-nav{width:100%; display:flex; flex-direction:row; flex-wrap:nowrap; align-items:center;}
  118. .grace-header-main{width:300rpx; flex:auto; overflow:hidden; min-height:44px;}
  119. .grace-page-body{width:100%; flex:1; display:flex; flex-direction:column;}
  120. .grace-page-footer{width:100%; position:fixed; left:0; bottom:0; z-index:99;}
  121. .gui-page-rb-area{width:100rpx; position:fixed; right:20rpx; bottom:100rpx; z-index:1;}
  122. .grace-page-loading{width:100%; height:100%; background:rgba(255,255,255,0.1); position:fixed; z-index:9999; left:0; top:0; bottom:0; display:flex; flex-direction:column; justify-content:center; align-items:center;}
  123. .grace-page-loading-point{display:flex; flex-direction:row; flex-wrap:nowrap; justify-content:center;}
  124. .grace-page-loading-points{width:20rpx; height:20rpx; background-color:#3688FF; border-radius:50rpx; margin:10rpx; opacity:0.5;}
  125. @keyframes pageLoading1{0% {opacity:0.5; transform:scale(1);} 40% {opacity:1; transform:scale(1.5);} 60%{opacity:0.5; transform:scale(1);}}
  126. @keyframes pageLoading2{20% {opacity:0.5; transform:scale(1);} 60% {opacity:1; transform:scale(1.5);} 80% {opacity:0.5; transform:scale(1);}}
  127. @keyframes pageLoading3{40% {opacity:0.5; transform:scale(1);} 80% {opacity:1; transform:scale(1.5);} 100% {opacity:0.5; transform:scale(1);}}
  128. .animate1{animation:pageLoading1 1.2s infinite linear;}
  129. .animate2{animation:pageLoading2 1.2s infinite linear;}
  130. .animate3{animation:pageLoading3 1.2s infinite linear;}
  131. </style>