en-nav.vue 4.0 KB

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