main.vue 3.7 KB

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