DetailHeader.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!-- DetailHeader.vue -->
  2. <template>
  3. <view class="ui-detail-header-wrapper">
  4. <title-header />
  5. <view class="div ui-detail-header">
  6. <text class="span iconfont" @click="goBack()">&#xe6ee;</text>
  7. <view class="div navbar-wrapper">
  8. <view class="div"
  9. v-for="(item, key) in data"
  10. :key="key"
  11. v-bind:class="{ navbar_active: key == index }"
  12. v-on:click="changeEvent(key)"
  13. >
  14. {{ item.name }}
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import TitleHeader from '../../TitleHeader'
  22. import { urlencode } from '@/util/common'
  23. import { header } from './static'
  24. import { mapState, mapMutations } from 'vuex'
  25. export default {
  26. data () {
  27. return {
  28. navHeight: 0,
  29. data: header
  30. }
  31. },
  32. components: {
  33. TitleHeader
  34. },
  35. mounted () {
  36. // #ifdef MP-WEIXIN
  37. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  38. // #endif
  39. },
  40. computed: {
  41. ...mapState({
  42. index: state => state.pointsgoods.index
  43. })
  44. },
  45. created () {},
  46. methods: {
  47. ...mapMutations({
  48. changeIndex: 'changeIndex'
  49. }),
  50. changeEvent (index) {
  51. this.changeIndex(index)
  52. },
  53. goBack () {
  54. uni.navigateBack({delta:1})
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss">
  60. .ui-detail-header-wrapper{
  61. position: fixed;
  62. top: var(--status-bar-height);
  63. left: 0;
  64. right: 0;
  65. z-index: 10;
  66. }
  67. .ui-detail-header {
  68. padding: 0 0.45rem;
  69. background: rgba(255, 255, 255, 1);
  70. color: #55595f;
  71. font-size:$h2;
  72. width: auto;
  73. display: flex;
  74. justify-content: center;
  75. align-content: center;
  76. align-items: center;
  77. flex-basis: auto;
  78. .iconfont {
  79. width: 1.2rem;
  80. font-size:$h2;
  81. height: $headerHeight;
  82. line-height:$headerHeight;
  83. cursor: pointer;
  84. position: absolute;
  85. left: 0.45rem;
  86. bottom: 0;
  87. }
  88. .div.navbar-wrapper {
  89. line-height: $headerHeight;
  90. height: $headerHeight;
  91. .div {
  92. // line-height: 2.1rem;
  93. border-bottom: 0;
  94. display: inline-block;
  95. margin-right:2.4rem;
  96. color: #55595f;
  97. background-color: #fff;
  98. position: relative;
  99. &.navbar_active {
  100. color: $primaryColor;
  101. &::after{content:'';display: block;height: .1rem;width: 1rem;position: absolute;bottom:0;left:50%;margin-left:-.5rem;background: $primaryColor}
  102. }
  103. &:last-child {
  104. margin-right: 0;
  105. }
  106. &:focus {
  107. outline: none;
  108. }
  109. }
  110. }
  111. }
  112. </style>