leftMenu.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="leftMenuRoot df fdr" v-show="isShow">
  3. <!-- 左边导航栏 -->
  4. <view class="leftBox">
  5. <view class="leftMenu-topIcon df aic" @click="hide">
  6. <img src="../assets/leftMenu/icon_leftUp.png"></img>
  7. </view>
  8. <view class="df fdc" v-for="(menu1,i) in btnList" :key="i" @click="onLeftBtn1Click(i)">
  9. <view class="leftMenu-btn1 df fdr aic">
  10. <view class="leftMenu-btn1-icon df ">
  11. <img :src="checkedIndex1==i?menu1.icon_btn1_checked:menu1.icon_btn1_unchecked"></img>
  12. </view>
  13. <view class="leftMenu-btn1-text" :style="{color:checkedIndex1==i?color_checked:color_unchecked}">{{menu1.text}}</view>
  14. </view>
  15. <view class="leftMenu-line"></view>
  16. <view class="leftMenu-btn2-box1 df fdc" v-show="checkedIndex1==i" v-for="(menu2,m) in menu1.list" :key="m" @click="onLeftBtn2Click(m)">
  17. <view class="leftMenu-btn2-box2 df fdr aic">
  18. <view class="leftMenu-btn2-icon df">
  19. <img :src="checkedIndex2==m?icon_btn2_checked:icon_btn2_unchecked"></img>
  20. </view>
  21. <view class="leftMenu-btn2-text" :style="{color:checkedIndex2==m?color_checked:color_unchecked}">{{menu2}}</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 右边半透明 -->
  27. <view class="rightBox" @click="hide"></view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. isShow: false,
  35. checkedIndex1: 3,
  36. checkedIndex2: 0,
  37. // ------以下为静态
  38. btnList: [
  39. {
  40. "text": '后台',
  41. "icon_btn1_checked": require('../assets/leftMenu/icon_ksxx_02.png'),
  42. "icon_btn1_unchecked": require('../assets/leftMenu/icon_ksxx_01.png'),
  43. "list": []
  44. }
  45. ],
  46. icon_btn2_checked: require('../assets/leftMenu/icon_btn2_02.png'),
  47. icon_btn2_unchecked: require('../assets/leftMenu/icon_btn2_01.png'),
  48. color_checked: '#EA252C',
  49. color_unchecked: '#020202'
  50. }
  51. },
  52. methods: {
  53. initData() {
  54. this.checkedIndex1 = -1;
  55. this.checkedIndex2 = -1;
  56. },
  57. hide() {
  58. this.isShow = false;
  59. },
  60. show(indexArr) {
  61. this.isShow = true;
  62. console.log("左侧导航展示",indexArr);
  63. this.checkedIndex1 = indexArr[0];
  64. this.checkedIndex2 = indexArr[1];
  65. },
  66. onLeftBtn1Click(index) {
  67. this.checkedIndex2 = -1;
  68. if (this.btnList[index].list.length > 0) {
  69. // 收起
  70. if (index == this.checkedIndex1) {
  71. this.checkedIndex1 = -1;
  72. }
  73. // 展开
  74. else {
  75. this.checkedIndex1 = index;
  76. }
  77. } else {
  78. this.hide();
  79. this.$emit("onLeftMenuClick", [index,-1])
  80. }
  81. },
  82. onLeftBtn2Click(index) {
  83. this.checkedIndex2 = index;
  84. this.hide();
  85. this.$emit("onLeftMenuClick", [this.checkedIndex1,index])
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss">
  91. .leftMenuRoot {
  92. position: fixed;
  93. width: 100%;
  94. height: 100%;
  95. }
  96. .leftBox {
  97. width: px2vw(226);
  98. background: #FFFFFF;
  99. }
  100. .rightBox {
  101. flex: 1;
  102. background: #000000;
  103. opacity: 0.24;
  104. }
  105. .leftMenu-topIcon {
  106. background: #EA252C;
  107. height: 6.2vw;
  108. }
  109. .leftMenu-topIcon img {
  110. margin-left: px2vw(41);
  111. }
  112. .leftMenu-btn1-icon {
  113. margin-left: px2vw(21);
  114. margin-top: px2vw(32);
  115. margin-bottom: px2vw(32);
  116. }
  117. .leftMenu-btn1-text {
  118. margin-left: px2vw(14);
  119. font-size: px2vw(22);
  120. }
  121. .leftMenu-line {
  122. height: 2px;
  123. background: #F2F2F2;
  124. }
  125. .leftMenu-btn2-box1 {
  126. background: #F2F2F2;
  127. }
  128. .leftMenu-btn2-box2 {
  129. margin-left: px2vw(48);
  130. margin-right: px2vw(45);
  131. margin-top: px2vw(25);
  132. margin-bottom: px2vw(25);
  133. }
  134. .leftMenu-btn2-text {
  135. margin-left: px2vw(14);
  136. font-size: px2vw(20);
  137. }
  138. </style>