en-nav.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. toBack: {
  96. type: Boolean,
  97. default: true
  98. },
  99. is_fixed: {
  100. type: Boolean,
  101. default: false
  102. },
  103. is_filter: {
  104. type: Boolean,
  105. default: false
  106. },
  107. is_icons: {
  108. type: Boolean,
  109. default: false
  110. },
  111. fixedHeight: {
  112. type: Number,
  113. default: 0
  114. },
  115. bgHeight: {
  116. type: Number,
  117. default: 0
  118. },
  119. navsHeight: {
  120. type: Number,
  121. default: 0
  122. },
  123. },
  124. created() {
  125. const navTop = uni.getMenuButtonBoundingClientRect()
  126. this.height = navTop.height + 'px'
  127. this.paddingTop = navTop.top + 'px'
  128. this.navHeight = `${navTop.height+navTop.top}px`
  129. },
  130. watch: {
  131. opacity(newValue, oldValue) {
  132. this.navOpacity = newValue;
  133. }
  134. },
  135. methods: {
  136. // 左侧返回按钮调用
  137. onBack() {
  138. console.log('toBack:',this.toBack)
  139. if(this.toBack){
  140. uni.navigateBack()
  141. }
  142. this.$emit('onBack')
  143. },
  144. getTopBg(type) {
  145. switch (type) {
  146. case 0:
  147. return 'nav-bg1'
  148. case 0:
  149. return 'nav-bg1'
  150. case 0:
  151. return 'nav-bg1'
  152. default:
  153. break;
  154. }
  155. }
  156. }
  157. }
  158. </script>
  159. <style lang="scss" scoped>
  160. .header {
  161. position: fixed;
  162. width: 100%;
  163. display: flex;
  164. align-items: center;
  165. font-size: 26rpx;
  166. z-index: 1;
  167. // padding-bottom: 10rpx;
  168. top: 0;
  169. .left {
  170. float: left;
  171. position: absolute;
  172. width: 100rpx;
  173. height: 42rpx;
  174. top: 12rpx;
  175. bottom: 0;
  176. left: 30rpx;
  177. color: #fff;
  178. margin: auto;
  179. .back {
  180. width: 25rpx;
  181. height: 32rpx;
  182. }
  183. }
  184. .title {
  185. font-size: 32rpx;
  186. font-weight: bold;
  187. font-family: Source Han Sans CN;
  188. }
  189. }
  190. .top-nav-bg {
  191. background-repeat: no-repeat;
  192. background-size: 100% auto;
  193. z-index: 999999;
  194. }
  195. .nav-bg2 {
  196. background-image: url("https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/index/index-bg.png?imageMogr2/quality/20");
  197. }
  198. </style>