index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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)">
  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/rider_index/work/index",
  38. iconPath: require("../../static/gzth.png"),
  39. selectedIconPath: require("../../static/gztl.png"),
  40. text: "工作台",
  41. role: '0'
  42. },
  43. {
  44. // pagePath: "/pages/rider_index/order/index?type=all&orderType=-1",
  45. pagePath: "/pages/rider_index/order/index",
  46. iconPath: require("../../static/ddh.png"),
  47. selectedIconPath: require("../../static/ddl.png"),
  48. text: "跑腿记录",
  49. role: '1'
  50. },
  51. {
  52. pagePath: "/pages/rider_index/cashwithdrawal/index",
  53. iconPath: require("../../static/shh.png"),
  54. selectedIconPath: require("../../static/shl.png"),
  55. text: "提现",
  56. role: '2',
  57. }
  58. // {
  59. // pagePath: "/pages/rider_index/cashwithdrawal/index",
  60. // iconPath: require("../../static/sph.png"),
  61. // selectedIconPath: require("../../static/spl.png"),
  62. // text: "商品",
  63. // role: '2'
  64. // }
  65. ]
  66. }
  67. },
  68. methods: {
  69. goRouter(item) {
  70. var pages = getCurrentPages();
  71. var page = (pages[pages.length - 1]).$page.fullPath;
  72. if (item.pagePath == page) return
  73. console.log(item.pagePath+"----------------")
  74. uni.redirectTo({
  75. url: item.pagePath,
  76. animationType: 'none' // 关闭默认的滑动效果
  77. });
  78. }
  79. }
  80. }
  81. </script>
  82. <style scoped lang="scss">
  83. .page-footer {
  84. position: fixed;
  85. bottom: 0;
  86. left: 0;
  87. z-index: 20;
  88. display: flex;
  89. align-items: center;
  90. justify-content: space-around;
  91. width: 100%;
  92. height: calc(100rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  93. height: calc(100rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  94. box-sizing: border-box;
  95. border-top: solid 1rpx #F3F3F3;
  96. background-color: #fff;
  97. // box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
  98. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  99. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  100. .foot-item {
  101. display: flex;
  102. width: max-content;
  103. align-items: center;
  104. justify-content: center;
  105. flex-direction: column;
  106. position: relative;
  107. padding: 0 20rpx;
  108. &.active {
  109. color: #2A7EFB
  110. }
  111. }
  112. .foot-item image {
  113. height: 40rpx;
  114. width: 40rpx;
  115. text-align: center;
  116. margin: 0 auto;
  117. }
  118. .foot-item .txt {
  119. font-size: 20rpx;
  120. margin-top: 6rpx;
  121. }
  122. }
  123. </style>