index.vue 2.1 KB

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