layout.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <!-- @notes: 页面于2024-11-17 由判断是否为app [isShowApp] 进行背景颜色判断的需求取消,统一换成白色背景. html上直接写 布尔值的均由 [isShowApp] 替换-->
  2. <template>
  3. <!-- <div :class="isShowApp?'layout':'layout layout-white'"> -->
  4. <div class="layout" :class="{'layout-white': !false}">
  5. <div style="height: 12.2666666667vw" v-if="isShowNavBar">
  6. <van-nav-bar :title="title" left-arrow fixed @click-left="goBackFun" />
  7. </div>
  8. <div class="layout-container" :style="containerStyle">
  9. <slot></slot>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'layout',
  16. props: {
  17. // 是否显示头部
  18. title: {
  19. type: String,
  20. default: '推荐云手机',
  21. },
  22. // 是否强制像是头部
  23. forceShowNavBar: {
  24. type: Boolean,
  25. default: false
  26. },
  27. padding: {
  28. type: String,
  29. default: ''
  30. },
  31. isRouterBack: {
  32. type: Boolean,
  33. default: false
  34. }
  35. },
  36. data() {
  37. return {};
  38. },
  39. mounted() { },
  40. computed: {
  41. containerStyle() {
  42. // if (this.isShowApp) {
  43. // return { backgroundColor: '#1C1C1E', padding: this.padding ? this.padding : '16px' };
  44. // }
  45. return { backgroundColor: '#F2F4F7', padding: this.padding ? this.padding : '16px' };
  46. },
  47. isShowApp() {
  48. // 是否是APP
  49. const isApp = this.$userAgent.isSzx || this.$userAgent.isSzxBrowser;
  50. const isAndroid = this.$userAgent.isAndroid;
  51. const isIos = this.$userAgent.isIos;
  52. const isWx = this.$userAgent.isWx;
  53. console.log('isApp:' + isApp)
  54. console.log('isAndroid:' + isAndroid)
  55. console.log('isIos:' + isIos)
  56. console.log('isWx:' + isWx)
  57. // 如果是App并且是安卓,就不显示头部, ios显示
  58. // 如果微信小程序环境的,也不显示头部
  59. // 如果是h5 就显示头部
  60. let bool = false;
  61. bool = isApp && (isAndroid || isIos) ? true : false;
  62. return bool;
  63. },
  64. isShowNavBar() {
  65. // 是否是APP
  66. const isApp = this.$userAgent.isSzx || this.$userAgent.isSzxBrowser;
  67. const isAndroid = this.$userAgent.isAndroid;
  68. const isIos = this.$userAgent.isIos;
  69. const isWx = this.$userAgent.isWx;
  70. // 如果是App并且是安卓,就不显示头部, ios显示
  71. // 如果微信小程序环境的,也不显示头部
  72. // 如果是h5 就显示头部
  73. let bool = false;
  74. // bool = isApp ? (isAndroid ? !isAndroid : isIos) : (isWx ? !isWx : !isWx);
  75. bool = (isApp && (isAndroid || isIos)) || isWx ? false : true;
  76. // console.log()
  77. return bool || this.forceShowNavBar;
  78. },
  79. },
  80. methods: {
  81. goBackFun() {
  82. if (this.$listeners.goBack) {
  83. this.$emit('goBack');
  84. return;
  85. }
  86. this.$router.go(-1);
  87. },// 退出相关逻辑
  88. },
  89. };
  90. </script>
  91. <style lang="less" scoped>
  92. .layout {
  93. height: 100%;
  94. display: flex;
  95. flex-direction: column;
  96. .layout-container {
  97. flex: 1;
  98. overflow-y: auto;
  99. }
  100. ::v-deep .van-nav-bar__arrow {
  101. color: #000000;
  102. font-size: 24px;
  103. }
  104. ::v-deep .van-nav-bar__title {
  105. font-weight: bold !important;
  106. font-size: 17px !important;
  107. color: #0a132b !important;
  108. line-height: 24px !important;
  109. }
  110. .van-nav-bar {
  111. z-index: 0;
  112. }
  113. .floating-back {
  114. position: fixed; /* 设定定位为固定 */
  115. left: 26px; /* 距离右侧10像素 */
  116. bottom: 98px; /* 距离底部10像素 */
  117. background-color: transparent; /* 背景颜色 */
  118. z-index: 1000; /* 确保悬浮在其他内容之上 */
  119. }
  120. }
  121. .layout-white {
  122. .van-nav-bar {
  123. background-color: #f2f4f7;
  124. }
  125. ::v-deep [class*='van-hairline']::after {
  126. border: 0px;
  127. }
  128. }
  129. </style>