Page.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div :class="`page ${!props.title? 'page-no-title':''} ${styleReset}`">
  3. <van-nav-bar class="header"
  4. v-bind:title="props.title"
  5. v-if="showHeader"
  6. :border="!!props.title"
  7. :style="`height:${usePxToVwView(headerHeight)}`">
  8. <template v-slot:left>
  9. <!-- <van-icon @click="goBack" name="revoke" size="1.29rem" color="#000000" class="font-bold" v-if="routerStore.currentPages?.length>1"/> -->
  10. <img src="/src/assets/image/back.png" @click="goBack" class="headerBack" v-if="routerStore.currentPages?.length>1">
  11. <slot name="headerLeft"></slot>
  12. </template>
  13. <template v-slot:title>
  14. <span v-if="props.title" class="text-size-large">{{ props.title }}</span>
  15. <slot v-else name="title"></slot>
  16. </template>
  17. <template v-slot:right>
  18. <slot name="headerRight"></slot>
  19. </template>
  20. </van-nav-bar>
  21. <slot name="top"></slot>
  22. <div class="body">
  23. <slot name="body"></slot>
  24. </div>
  25. <slot name="footer"></slot>
  26. </div>
  27. </template>
  28. <script setup>
  29. import useRouterStore from "@/store/useRouterStore.js";
  30. import usePxToVwView from "@hooks/usePxTransform.js";
  31. const routerStore = useRouterStore();
  32. /**
  33. * @description 组件参数
  34. * */
  35. const props = defineProps({
  36. /**
  37. * @property showHeader {Boolean} 是否显示header
  38. * @desc header 页面顶部标题
  39. * */
  40. showHeader: {
  41. type: Boolean,
  42. default: true
  43. },
  44. /**
  45. * @property headerHeight {Number || String} 页面顶部标题高度
  46. * */
  47. headerHeight: {
  48. type: [String, Number],
  49. default: 44
  50. },
  51. /**
  52. * @property headerHeight {String} 外盒子样式重置
  53. * */
  54. styleReset: {
  55. type: String,
  56. default: ''
  57. },
  58. /**
  59. * @property title {String} 页面顶部标题
  60. * */
  61. title: String,
  62. });
  63. const goBack = ()=>{
  64. history.back();
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .headerBack {
  69. width: 18px;
  70. height: 18px;
  71. }
  72. .page{
  73. width: 100%;
  74. height: 100%;
  75. display: flex;
  76. flex-direction: column;
  77. overflow: hidden;
  78. box-sizing: border-box;
  79. font-size: 14px;
  80. color: #333333;
  81. background: #F8F8F8;
  82. }
  83. .body {
  84. height: 100%;
  85. flex: 1;
  86. overflow-x: auto;
  87. }
  88. .no-data, .loading {
  89. height: 100%;
  90. display: flex;
  91. align-items: center;
  92. justify-content: center;
  93. }
  94. .data-loading-complete {
  95. padding: 12px 0;
  96. display: flex;
  97. align-items: center;
  98. justify-content: center;
  99. color: #999999;
  100. }
  101. .page-no-title {
  102. .header {
  103. .back {
  104. color: #ffffff;
  105. }
  106. }
  107. }
  108. :deep(.van-nav-bar__content) {
  109. height: 100% !important;
  110. }
  111. .headerClass {
  112. :deep(.van-nav-bar__content) {
  113. background: $themeColor;
  114. }
  115. }
  116. .headerNoBack {
  117. :deep(.van-nav-bar) {
  118. background: none !important;
  119. }
  120. }
  121. </style>