en-nav.vue 4.5 KB

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