en-nav.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <view class="top-nav-bg" :style="{'background-image':`url(${bgList[genre].bg_path})`}">
  3. <view class="header" style="z-index: 3;" :style="[{color},{height},{paddingTop},{justifyContent:justify}]">
  4. <view class="left" :style="[{color},{paddingTop}]" v-if="back" @click="onBack">
  5. <image class="back" src="/static/img/tabBar/nav-back.png"></image>
  6. </view>
  7. <view class="title row center" :style="[{marginLeft:justify == 'left'?'30rpx':0},{fontSize}]">
  8. <image class="wh-36 m-r20" src="/static/img/statistics/stat-calendar.png" mode="aspectFill"
  9. v-if="is_icons">
  10. </image>
  11. <text>{{title}}</text>
  12. </view>
  13. </view>
  14. <view :style="[{height:is_fixed? `${$tools.topHeight()+bgHeight}px`:`${$tools.topHeight()+fixedHeight}px`}]">
  15. </view>
  16. <!-- 带背景插槽 start-->
  17. <slot></slot>
  18. <!-- 带背景插槽 end-->
  19. <view class="sys-list-background-color header" style="z-index: 2;" :style="{opacity:is_fixed?navOpacity:1}">
  20. <image class="" style="width: 100%;"
  21. :style="[{height:is_fixed?`${$tools.topHeight()+navsHeight}px` :`${$tools.topHeight()+fixedHeight}px`}]"
  22. :src="bgList[genre].nav_path" mode="">
  23. </image>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. // 获取系统状态栏的高度
  29. let systemInfo = uni.getSystemInfoSync();
  30. let menuButtonInfo = {};
  31. // #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
  32. menuButtonInfo = uni.getMenuButtonBoundingClientRect();
  33. // #endif
  34. export default {
  35. data() {
  36. return {
  37. height: 0,
  38. paddingTop: 0,
  39. navOpacity: 0,
  40. navHeight: 0,
  41. bgList: [{
  42. bg_path: 'https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/index/index-bg.png?imageMogr2/quality/20',
  43. nav_path: '/static/img/index/top-nav.png'
  44. }, {
  45. bg_path: '',
  46. nav_path: 'https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/task/task-nav-bg.png'
  47. }, {
  48. bg_path: '',
  49. nav_path: 'https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/task/task-nav-bg.png'
  50. }, {
  51. bg_path: '',
  52. nav_path: 'https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/statistics/statistics-bg2.png'
  53. }, {
  54. bg_path: '',
  55. nav_path: 'https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/task/task-nav-bg.png'
  56. }],
  57. }
  58. },
  59. props: {
  60. genre: {
  61. type: Number,
  62. default: 0
  63. },
  64. type: {
  65. type: Number,
  66. default: 0
  67. },
  68. fontSize: {
  69. type: String,
  70. default: '32rpx'
  71. },
  72. title: {
  73. type: String,
  74. default: ''
  75. },
  76. justify: {
  77. type: String,
  78. default: 'center'
  79. },
  80. color: {
  81. type: String,
  82. default: '#333'
  83. },
  84. opacity: {
  85. type: Number,
  86. default: 0
  87. },
  88. back: {
  89. type: Boolean,
  90. default: true
  91. },
  92. is_fixed: {
  93. type: Boolean,
  94. default: false
  95. },
  96. is_filter: {
  97. type: Boolean,
  98. default: false
  99. },
  100. is_icons: {
  101. type: Boolean,
  102. default: false
  103. },
  104. fixedHeight: {
  105. type: Number,
  106. default: 0
  107. },
  108. bgHeight: {
  109. type: Number,
  110. default: 0
  111. },
  112. navsHeight: {
  113. type: Number,
  114. default: 0
  115. },
  116. },
  117. created() {
  118. const navTop = uni.getMenuButtonBoundingClientRect()
  119. this.height = navTop.height + 'px'
  120. this.paddingTop = navTop.top + 'px'
  121. this.navHeight = `${navTop.height+navTop.top}px`
  122. },
  123. watch: {
  124. opacity(newValue, oldValue) {
  125. this.navOpacity = newValue;
  126. }
  127. },
  128. methods: {
  129. // 左侧返回按钮调用
  130. onBack() {
  131. uni.navigateBack()
  132. this.$emit('onBack')
  133. },
  134. getTopBg(type) {
  135. switch (type) {
  136. case 0:
  137. return 'nav-bg1'
  138. case 0:
  139. return 'nav-bg1'
  140. case 0:
  141. return 'nav-bg1'
  142. default:
  143. break;
  144. }
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .header {
  151. position: fixed;
  152. width: 100%;
  153. display: flex;
  154. align-items: center;
  155. font-size: 26rpx;
  156. z-index: 1;
  157. // padding-bottom: 10rpx;
  158. top: 0;
  159. .left {
  160. float: left;
  161. position: absolute;
  162. width: 100rpx;
  163. height: 42rpx;
  164. top: 0;
  165. bottom: 0;
  166. left: 30rpx;
  167. color: #fff;
  168. margin: auto;
  169. .back {
  170. width: 25rpx;
  171. height: 35rpx;
  172. }
  173. }
  174. .title {
  175. font-size: 32rpx;
  176. font-weight: bold;
  177. font-family: Source Han Sans CN;
  178. }
  179. }
  180. .top-nav-bg {
  181. background-repeat: no-repeat;
  182. background-size: 100% auto;
  183. z-index: 999999;
  184. }
  185. .nav-bg2 {
  186. background-image: url("https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/index/index-bg.png?imageMogr2/quality/20");
  187. }
  188. </style>