index.vue 3.1 KB

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