en-nav.vue 4.6 KB

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