index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <!-- 底部导航 -->
  3. <view>
  4. <view v-if="newData.bgColor">
  5. <view class="page-footer" id="target" :style="{'background-color':newData.bgColor.color[0].item}">
  6. <view class="foot-item" v-for="(item,index) in newData.menuList" :key="index" @click="goRouter(item)">
  7. <block v-if="item.link.split('?')[0] == activeRouter">
  8. <image :src="item.imgList[0]"></image>
  9. <view class="txt" :style="{color:newData.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:newData.txtColor.color[0].item}">{{item.name}}</view>
  14. </block>
  15. <!-- <div class="count-num"
  16. v-if="item.link === '/pages/order_addcart/order_addcart' && cartNum>0">
  17. {{cartNum}}
  18. </div> -->
  19. <uni-badge v-if="item.link === '/pages/order_addcart/order_addcart' && cartNum>0" class="uni-badge-left-margin" :text="cartNum" absolute="rightTop">
  20. </uni-badge>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. mapState,
  29. mapGetters
  30. } from "vuex"
  31. import {
  32. getNavigation
  33. } from '@/api/public.js'
  34. import {
  35. getCartCounts,
  36. } from '@/api/order.js';
  37. export default {
  38. name: 'pageFooter',
  39. props: {},
  40. computed: mapGetters(['isLogin', 'cartNum']),
  41. created() {
  42. let routes = getCurrentPages(); //获取当前打开过的页面路由数组
  43. let curRoute = routes[routes.length - 1].route //获取当前页面路由
  44. this.activeRouter = '/' + curRoute
  45. },
  46. mounted() {
  47. this.navigationInfo();
  48. if (this.isLogin) {
  49. this.getCartNum()
  50. }
  51. },
  52. data() {
  53. return {
  54. newData: {},
  55. activeRouter:''
  56. }
  57. },
  58. methods: {
  59. navigationInfo(){
  60. getNavigation().then(res => {
  61. this.newData = res.data
  62. console.log(this.newData.status,'this.newData.status')
  63. this.$emit('newDataStatus', this.newData.status?this.newData.status.status:false)
  64. if (this.newData.status && this.newData.status.status) {
  65. uni.hideTabBar()
  66. } else {
  67. uni.hideTabBar()
  68. }
  69. })
  70. },
  71. goRouter(item) {
  72. var pages = getCurrentPages();
  73. var page = (pages[pages.length - 1]).$page.fullPath;
  74. if (item.link == page) return
  75. if(item.link == '/pages/short_video/appSwiper/index' || item.link == '/pages/short_video/nvueSwiper/index'){
  76. //#ifdef APP
  77. item.link = '/pages/short_video/appSwiper/index'
  78. //#endif
  79. //#ifndef APP
  80. item.link = '/pages/short_video/nvueSwiper/index'
  81. //#endif
  82. }
  83. uni.switchTab({
  84. url: item.link,
  85. fail(err) {
  86. uni.redirectTo({
  87. url: item.link
  88. })
  89. }
  90. })
  91. },
  92. getCartNum: function() {
  93. let id = uni.getStorageSync('user_store_id') || 0;
  94. getCartCounts(0,id).then(res => {
  95. this.$store.commit('indexData/setCartNum', res.data.count + '')
  96. });
  97. }
  98. }
  99. }
  100. </script>
  101. <style scoped lang="scss">
  102. .page-footer {
  103. position: fixed;
  104. bottom: 0;
  105. z-index: 666;
  106. display: flex;
  107. align-items: center;
  108. justify-content: space-around;
  109. width: 100%;
  110. height: calc(98rpx+ constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  111. height: calc(98rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  112. box-sizing: border-box;
  113. border-top: solid 1rpx #F3F3F3;
  114. background-color: #fff;
  115. box-shadow: 0px 0px 17rpx 1rpx rgba(206, 206, 206, 0.32);
  116. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  117. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  118. .foot-item {
  119. display: flex;
  120. width: max-content;
  121. align-items: center;
  122. justify-content: center;
  123. flex-direction: column;
  124. position: relative;
  125. .count-num {
  126. position: absolute;
  127. display: flex;
  128. justify-content: center;
  129. align-items: center;
  130. width: 40rpx;
  131. height: 40rpx;
  132. top: 0rpx;
  133. right: -15rpx;
  134. color: #fff;
  135. font-size: 20rpx;
  136. background-color: #FD502F;
  137. border-radius: 50%;
  138. padding: 4rpx;
  139. }
  140. }
  141. .foot-item image {
  142. height: 50rpx;
  143. width: 50rpx;
  144. text-align: center;
  145. margin: 0 auto;
  146. }
  147. .foot-item .txt {
  148. font-size: 24rpx;
  149. &.active {}
  150. }
  151. }
  152. </style>