index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view>
  3. <view :style="{height:footHeight+'px'}"></view>
  4. <view>
  5. <view class="page-footer" id="target" :style="{'background-color':configData.bgColor.color[0].item}">
  6. <view class="foot-item" v-for="(item,index) in configData.menuList" :key="index" @click="goRouter(item)">
  7. <block v-if="item.link == activeRouter">
  8. <image :src="item.imgList[0]"></image>
  9. <view class="txt" :style="{color:configData.activeTxtColor.color[0].item}">{{item.name}}</view>
  10. </block>
  11. <block v-else>
  12. <image :src="item.imgList[1]"></image>
  13. <view class="txt" :style="{color:configData.txtColor.color[0].item}">{{item.name}}</view>
  14. </block>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import {mapState} from "vuex"
  22. import { getNavigation } from '@/api/public.js'
  23. export default{
  24. name:'pageFooter',
  25. props:{
  26. curTitle:{
  27. type:String | Number
  28. }
  29. },
  30. computed:{
  31. ...mapState({
  32. configData: state => state.app.pageFooter
  33. })
  34. },
  35. watch:{
  36. configData:{
  37. handler (nVal, oVal) {
  38. const query = uni.createSelectorQuery().in(this);
  39. this.newData = nVal
  40. this.$nextTick(()=>{
  41. query.select('#target').boundingClientRect(data => {
  42. this.footHeight = data.height+20
  43. }).exec();
  44. })
  45. },
  46. deep: true
  47. }
  48. },
  49. created(){
  50. getNavigation().then(res=>{
  51. uni.setStorageSync('pageFoot',res.data)
  52. this.$store.commit('FOOT_UPLOAD',res.data)
  53. })
  54. },
  55. mounted() {
  56. let that = this
  57. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  58. let curRoute = routes[routes.length - 1].route //获取当前页面路由
  59. this.activeRouter = '/'+curRoute
  60. this.newData = this.$store.state.app.pageFooter
  61. },
  62. data(){
  63. return {
  64. newData:{},
  65. activeRouter:'/',
  66. footHeight:0
  67. }
  68. },
  69. methods:{
  70. goRouter(item){
  71. if(item.name == this.curTitle){
  72. return
  73. }
  74. uni.reLaunch({
  75. url:item.link
  76. })
  77. }
  78. }
  79. }
  80. </script>
  81. <style lang="scss" scoped>
  82. .page-footer{
  83. position: fixed;
  84. bottom: 0;
  85. z-index: 30;
  86. display: flex;
  87. align-items: center;
  88. width: 100%;
  89. height: calc(98rpx+ constant(safe-area-inset-bottom));///兼容 IOS<11.2/
  90. height: calc(98rpx + env(safe-area-inset-bottom));///兼容 IOS>11.2/
  91. box-sizing: border-box;
  92. border-top: solid 1rpx #F3F3F3;
  93. background-color: #fff;
  94. box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
  95. padding-bottom: constant(safe-area-inset-bottom);///兼容 IOS<11.2/
  96. padding-bottom: env(safe-area-inset-bottom);///兼容 IOS>11.2/
  97. .foot-item {
  98. flex: 1;
  99. display: flex;
  100. align-items: center;
  101. justify-content: center;
  102. flex-direction: column;
  103. }
  104. .foot-item image {
  105. height: 50rpx;
  106. width: 50rpx;
  107. text-align: center;
  108. margin: 0 auto;
  109. }
  110. .foot-item .txt {
  111. font-size: 24rpx;
  112. &.active {
  113. }
  114. }
  115. }
  116. </style>