second-class.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. this.switchBool = false;
  46. this.$emit('setNav',{
  47. it, key
  48. });
  49. }
  50. }
  51. }
  52. </script>
  53. <style scoped lang="scss">
  54. .second-class {
  55. position: relative;
  56. height: #{106upx};
  57. width: #{528upx};
  58. background-color: #ffffff;
  59. }
  60. .left {
  61. width: #{448upx};
  62. white-space: nowrap;
  63. vertical-align: center;
  64. background-color: #ffffff;
  65. line-height: #{106upx};
  66. }
  67. .right {
  68. width: #{80upx};
  69. height: #{106upx};
  70. position: relative;
  71. box-shadow: #{-1upx 0 5upx -5upx} rgba(0, 0, 0, .2);
  72. }
  73. .item {
  74. display: inline-block;
  75. font-size: #{24upx};
  76. height: #{54upx};
  77. line-height: #{54upx};
  78. padding: #{0 20upx};
  79. border: #{1upx} solid #cccccc;
  80. border-radius: #{34upx};
  81. margin-right: #{16upx};
  82. }
  83. .icon {
  84. position: absolute;
  85. top: 50%;
  86. left: 50%;
  87. transform: translate(-50%, -50%);
  88. width: #{56upx};
  89. height: #{56upx};
  90. }
  91. .ollapse {
  92. height: #{106upx};
  93. width: #{528upx};
  94. position: relative;
  95. }
  96. .ollapse-icon {
  97. position: absolute;
  98. top: 50%;
  99. right: #{12upx};
  100. width: #{56upx};
  101. height: #{56upx};
  102. transform: translateY(-50%);
  103. }
  104. .ollapse-view > text {
  105. margin-bottom: #{20upx};
  106. }
  107. .spring-board {
  108. position: absolute;
  109. top: 0;
  110. left: 0;
  111. width: #{528upx};
  112. z-index: 1000;
  113. background-color: #ffffff;
  114. }
  115. .active {
  116. border: #{1rpx} solid;
  117. }
  118. </style>