index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <!-- 底部导航 -->
  3. <view class="page-footer">
  4. <view class="foot-item" :class="item.pagePath == activeRouter?'active':''"
  5. v-for="(item,index) in footerList" :key="index" @click="goRouter(item, index)">
  6. <block v-if="item.pagePath == activeRouter">
  7. <image :src="item.selectedIconPath"></image>
  8. <view class="txt">{{item.text}}</view>
  9. </block>
  10. <block v-else>
  11. <image :src="item.iconPath"></image>
  12. <view class="txt">{{item.text}}</view>
  13. </block>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name: 'FooterPage',
  20. props: {},
  21. created() {
  22. let routes = getCurrentPages(); //获取当前打开过的页面路由数组
  23. let curRoute = routes[routes.length - 1].route //获取当前页面路由
  24. this.activeRouter = '/' + curRoute
  25. },
  26. mounted() {},
  27. data() {
  28. return {
  29. activeRouter:'',
  30. footerList:[
  31. {
  32. pagePath: "/pages/admin/manage/index",
  33. iconPath: require("../../static/footer1-1.png"),
  34. selectedIconPath: require("../../static/footer1-2.png"),
  35. text: "工作台"
  36. },
  37. {
  38. pagePath: "/pages/admin/goods/index",
  39. iconPath: require("../../static/footer2-1.png"),
  40. selectedIconPath: require("../../static/footer2-2.png"),
  41. text: "商品"
  42. },
  43. {
  44. pagePath: "/pages/admin/orderList/index",
  45. iconPath: require("../../static/footer3-1.png"),
  46. selectedIconPath: require("../../static/footer3-2.png"),
  47. text: "订单"
  48. },
  49. {
  50. pagePath: "/pages/admin/user/list",
  51. iconPath: require("../../static/footer4-1.png"),
  52. selectedIconPath: require("../../static/footer4-2.png"),
  53. text: "用户"
  54. }
  55. ]
  56. }
  57. },
  58. methods: {
  59. goRouter(item) {
  60. var pages = getCurrentPages();
  61. var page = (pages[pages.length - 1]).$page.fullPath;
  62. if (item.pagePath == page) return
  63. uni.redirectTo({
  64. url: item.pagePath,
  65. animationType: 'none' // 关闭默认的滑动效果
  66. });
  67. }
  68. }
  69. }
  70. </script>
  71. <style scoped lang="scss">
  72. .page-footer {
  73. position: fixed;
  74. bottom: 0;
  75. left:0;
  76. z-index: 20;
  77. display: flex;
  78. align-items: center;
  79. justify-content: space-around;
  80. width: 100%;
  81. height: calc(100rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  82. height: calc(100rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  83. box-sizing: border-box;
  84. border-top: solid 1rpx #F3F3F3;
  85. background-color: #fff;
  86. // box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
  87. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  88. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  89. .foot-item {
  90. display: flex;
  91. width: max-content;
  92. align-items: center;
  93. justify-content: center;
  94. flex-direction: column;
  95. position: relative;
  96. padding: 0 20rpx;
  97. &.active {
  98. color: $primary-admin
  99. }
  100. }
  101. .foot-item image {
  102. height: 40rpx;
  103. width: 40rpx;
  104. text-align: center;
  105. margin: 0 auto;
  106. }
  107. .foot-item .txt {
  108. font-size: 20rpx;
  109. margin-top: 6rpx;
  110. }
  111. }
  112. </style>