second-class.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="second-class dir-left-nowrap">
  3. <view class="spring-board" v-if="switchBool">
  4. <view class="ollapse main-right" @click="switchBool = false">
  5. <image :src="catsImg.ollapse" class="ollapse-icon"></image>
  6. </view>
  7. <view class="ollapse-view">
  8. <text class="item" v-for="(it, key) in list" :key="key" :class="key == activeIndexTwo ? 'active': ''" :style="{'color': key == activeIndexTwo ? theme.color : ''}" @click="setNav(it, key)">
  9. {{it.name}}
  10. </text>
  11. </view>
  12. </view>
  13. <scroll-view scroll-x
  14. v-if="!switchBool"
  15. class="left dir-left-nowrap"
  16. >
  17. <view>
  18. <text class="item " v-for="(it, key) in list" :key="key" :class="key == activeIndexTwo ? 'active': ''" :style="{'color': key == activeIndexTwo ? theme.color : ''}" @click="setNav(it, key)">
  19. {{it.name}}
  20. </text>
  21. </view>
  22. </scroll-view>
  23. <view class="right" v-if="!switchBool" @click="switchBool = true">
  24. <image :src="catsImg.expand" class="icon"></image>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { mapGetters, mapState } from 'vuex';
  30. export default {
  31. name: "second-class",
  32. props: ['list', `activeIndexTwo`, `theme`],
  33. computed: {
  34. ...mapState({
  35. catsImg: state => state.mallConfig.__wxapp_img.cats,
  36. })
  37. },
  38. data() {
  39. return {
  40. switchBool: false
  41. }
  42. },
  43. methods: {
  44. setNav(it, key) {
  45. console.log('测试....',it,key);
  46. this.switchBool = false;
  47. this.$emit('setNav',{
  48. it, key
  49. });
  50. }
  51. }
  52. }
  53. </script>
  54. <style scoped lang="scss">
  55. .second-class {
  56. position: relative;
  57. height: #{106upx};
  58. width: #{528upx};
  59. background-color: #ffffff;
  60. }
  61. .left {
  62. width: #{448upx};
  63. white-space: nowrap;
  64. vertical-align: center;
  65. background-color: #ffffff;
  66. line-height: #{106upx};
  67. }
  68. .right {
  69. width: #{80upx};
  70. height: #{106upx};
  71. position: relative;
  72. box-shadow: #{-1upx 0 5upx -5upx} rgba(0, 0, 0, .2);
  73. }
  74. .item {
  75. display: inline-block;
  76. font-size: #{24upx};
  77. height: #{54upx};
  78. line-height: #{54upx};
  79. padding: #{0 20upx};
  80. border: #{1upx} solid #cccccc;
  81. border-radius: #{34upx};
  82. margin-right: #{16upx};
  83. }
  84. .icon {
  85. position: absolute;
  86. top: 50%;
  87. left: 50%;
  88. transform: translate(-50%, -50%);
  89. width: #{56upx};
  90. height: #{56upx};
  91. }
  92. .ollapse {
  93. height: #{106upx};
  94. width: #{528upx};
  95. position: relative;
  96. }
  97. .ollapse-icon {
  98. position: absolute;
  99. top: 50%;
  100. right: #{12upx};
  101. width: #{56upx};
  102. height: #{56upx};
  103. transform: translateY(-50%);
  104. }
  105. .ollapse-view > text {
  106. margin-bottom: #{20upx};
  107. }
  108. .spring-board {
  109. position: absolute;
  110. top: 0;
  111. left: 0;
  112. width: #{528upx};
  113. z-index: 1000;
  114. background-color: #ffffff;
  115. }
  116. .active {
  117. border: #{1rpx} solid;
  118. }
  119. </style>