headtitle.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view :style="{background:bgColor}">
  3. <!-- 状态栏占位 -->
  4. <view class="status_bar"></view>
  5. <view class="title">
  6. <zui-svg-icon icon="back" v-if="isback" :style="{color:color}" class="icon" @click="leftClick()" />
  7. <view class="content" :style="{color: fontColor}">
  8. <slot></slot>
  9. </view>
  10. <view class="right">
  11. <slot name="right"></slot>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script setup>
  17. import {
  18. onMounted,
  19. ref
  20. } from 'vue';
  21. import {
  22. useColortore
  23. } from '@/store/index.js';
  24. import {
  25. navTo,
  26. navBack,
  27. navTabbar
  28. } from '@/utils/navigate';
  29. const props = defineProps({
  30. theme: String,
  31. isback: String,
  32. bgColor: String,
  33. fontColor: String,
  34. toWallet: Boolean
  35. });
  36. const color = ref('' || '#000000');
  37. const isback = ref(true)
  38. const bgColor = ref('' || '#EC0000');
  39. const fontColor = ref('' || '#FFFFFF');
  40. onMounted(() => {
  41. const colorStore = useColortore()
  42. bgColor.value = colorStore.mainRed
  43. if (props.theme === 'white') {
  44. color.value = '#ffffff'
  45. }
  46. if (props.isback == "false") {
  47. isback.value = false
  48. }
  49. if (props.bgColor != "") {
  50. bgColor.value = props.bgColor
  51. }
  52. if (props.fontColor != "") {
  53. fontColor.value = props.fontColor
  54. }
  55. })
  56. const leftClick = () => {
  57. console.log('leftClick:')
  58. console.log(props.leftFunc)
  59. if (props.toWallet == true) {
  60. navTabbar('/pages/project/index')
  61. } else {
  62. navBack()
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. .title {
  68. display: flex;
  69. justify-content: center;
  70. align-items: center;
  71. position: relative;
  72. padding-bottom: 30rpx;
  73. z-index: 998;
  74. font-size: 36rpx;
  75. .icon {
  76. position: absolute;
  77. left: 30rpx;
  78. width: 20rpx;
  79. height: 34rpx;
  80. }
  81. .right {
  82. position: absolute;
  83. right: 50rpx;
  84. }
  85. }
  86. </style>