index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="container body">
  3. <view class="info">
  4. <scroll-view scroll-y="true" class="scroll-view">
  5. <view class="list-scroll-view">
  6. <slot></slot>
  7. </view>
  8. </scroll-view>
  9. </view>
  10. <view class="foot" v-if="frameStyle&&frameStyle.useBar||false">
  11. <view class="list" v-for="(item,index) in barList" :key="index" @tap="toPath(index,item)">
  12. <image class="image" :src="item.normal" mode="" v-if="active!=index"></image>
  13. <image class="image" :src="item.active" mode="" v-else></image>
  14. <view class="name" :style="{color:active==index?frameStyle.barActive||'#FB1438':''}">{{item.name}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. props: {
  22. frameStyle: {
  23. type: Object,
  24. },
  25. },
  26. data() {
  27. return {
  28. active: 0,
  29. barList: [{
  30. name: '首页',
  31. route: 'pages/home/index',
  32. normal: require('@/static/shouye.png'),
  33. active: require('@/static/shouye_1.png')
  34. },
  35. {
  36. name: '微店',
  37. route: 'pages/store/index',
  38. normal: require('@/static/store.png'),
  39. active: require('@/static/store_1.png')
  40. },
  41. {
  42. name: '周边',
  43. route: 'pages/week/index',
  44. normal: require('@/static/week.png'),
  45. active: require('@/static/week_1.png')
  46. },
  47. {
  48. name: '购物车',
  49. route: 'pages/market/index',
  50. normal: require('@/static/market.png'),
  51. active: require('@/static/market_1.png')
  52. },
  53. {
  54. name: '我的',
  55. route: 'pages/my/index',
  56. normal: require('@/static/my.png'),
  57. active: require('@/static/my_1.png')
  58. },
  59. ]
  60. };
  61. },
  62. created: function() {
  63. const that = this;
  64. that.search()
  65. },
  66. onShow: function() {},
  67. methods: {
  68. search() {
  69. const that = this;
  70. let pages = getCurrentPages();
  71. let currentPage = pages[pages.length - 1];
  72. let index = that.barList.findIndex((i) => i.route == currentPage.route);
  73. if (index) that.$set(that, `active`, index);
  74. },
  75. toPath(index, item) {
  76. const that = this;
  77. that.$set(that, `active`, index);
  78. that.$emit('toPath', item)
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. .body {
  85. .info {
  86. position: relative;
  87. flex-grow: 1;
  88. }
  89. .foot {
  90. height: 8vh;
  91. overflow: hidden;
  92. background-color: var(--fffColor);
  93. display: flex;
  94. flex-direction: row;
  95. justify-content: space-around;
  96. border-top: 1px solid var(--f1Color);
  97. .list {
  98. padding: 1vw 0;
  99. text-align: center;
  100. .image {
  101. width: 7vw;
  102. height: 6vw;
  103. }
  104. .name {
  105. font-size: 12px;
  106. }
  107. }
  108. }
  109. }
  110. .scroll-view {
  111. position: absolute;
  112. top: 0;
  113. left: 0;
  114. right: 0;
  115. bottom: 0;
  116. .list-scroll-view {
  117. display: flex;
  118. flex-direction: column;
  119. }
  120. }
  121. </style>