main.vue 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="header_screen relative flex">
  3. <!-- 头部组件 -->
  4. <view
  5. :style="{
  6. 'padding-top': statusBarHeight+'px',
  7. 'height': (statusBarHeight + headerHeight)+'px',
  8. 'background-color': headerBackgroundColor
  9. }"
  10. class="header_header flex-shrink-0"
  11. :class="[immersion ? 'absolute immersion-header':'relative',border?'header-border':'']"
  12. >
  13. <view class="absolute header-watch-scroll" :style="{background:transitionBackgroundColor,opacity: watchOpacity}" v-if="watchScroll"></view>
  14. <!-- 内容包裹 -->
  15. <view class="relative flex-1 flex row" >
  16. <!-- 左侧 -->
  17. <view class="relative header-left flex row">
  18. <block v-if="control">
  19. <view v-if="headerIcon[mode]" @click="goBack" class="header-back flex jCenter" :style="{height:headerHeight+'px'}">
  20. <image class="header-back-image" :src="headerIcon[mode][headerStyle]"></image>
  21. </view>
  22. </block>
  23. <slot name="header-left"></slot>
  24. </view>
  25. <view v-if="!alignCenter" @click="goBack" class="header-title flex center" :style="{color:headerStyle==='black'?'#000':'#fff'}">
  26. <view v-if="state===1" class="header-load flat-load-animate" :style="{'border-color':headerStyle==='black'?'#000':'#fff'}"></view>
  27. <text v-else-if="state===3" @click="reload" class="header-fail relative" :class="['header-fail-'+headerStyle]">网络繁忙,点击重试</text>
  28. <text v-else>{{title}}</text>
  29. </view>
  30. <!--标题文字-->
  31. <view v-if="alignCenter" class="header-title-model absolute flex center">
  32. <view class="header-title flex center" :style="{color:headerStyle==='black'?'#000':'#fff'}">
  33. <view v-if="state===1" class="header-load flat-load-animate" :style="{'border-color':headerStyle==='black'?'#000':'#fff'}"></view>
  34. <text v-else-if="state===3" @click="reload" :class="['header-fail-'+headerStyle]" class="header-fail relative">网络繁忙,点击重试</text>
  35. <text v-else>{{title}}</text>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <slot name="background"></slot>
  41. <!-- 其他位置 -->
  42. <view class="flex-1 flex relative" >
  43. <slot name="header-background"></slot>
  44. <view class="flex-all-1 overflow" :style="{'background-color':backgroundColor}">
  45. <view v-if="scroll"
  46. class="header-title-model absolute flex"
  47. :style="{'padding-top': (immersion&&immersionFixed?(statusBarHeight + headerHeight):0)+'px'}"
  48. >
  49. <scroll-view v-if="watchScroll" @scroll="watchScrollEvent" scroll-y class="header_screen">
  50. <slot></slot>
  51. </scroll-view>
  52. <scroll-view wx:else scroll-y class="header_screen">
  53. <slot></slot>
  54. </scroll-view>
  55. </view>
  56. <view v-else
  57. :style="{'padding-top': (immersion&&immersionFixed?(statusBarHeight + headerHeight):0)+'px'}"
  58. class="header-title-model absolute flex">
  59. <slot></slot>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 其他内容 -->
  64. <slot name="modal"></slot>
  65. <!-- 间距 -->
  66. <view v-if="phoneX&&mode==='back'" :style="{height:(footerHeight + vFooterHeight)+'px','background-color':backgroundColor}"></view>
  67. </view>
  68. </template>
  69. <script>
  70. import mixins from './mixins';
  71. import props from './props';
  72. export default {
  73. name: "v-header",
  74. mixins,
  75. props
  76. }
  77. </script>
  78. <style scoped lang="scss" src="./style.scss"></style>