footer-bar.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="footer-bar safe-area-inset-bottom">
  3. <view class="icons-area">
  4. <view class="icon-item" @click="onHome">
  5. <image src="/pages-sell/static/goods/icon-home.png" class="bar-icon" mode="widthFix"
  6. style="width: 36rpx;"></image>
  7. <text>首页</text>
  8. </view>
  9. <view class="icon-item" @click="onCollect">
  10. <image v-if="isCollect" src="/pages-sell/static/goods/icon-star-active.png" class="bar-icon" mode="aspectFit"></image>
  11. <image v-else src="/pages-sell/static/goods/icon-star.png" class="bar-icon" mode="aspectFit"></image>
  12. <text :style="{ color: isCollect ? '#FFC107' : '#666' }">{{ isCollect ? '已收藏' : '收藏' }}</text>
  13. </view>
  14. <view class="icon-item" @click="onCart">
  15. <image src="/pages-sell/static/goods/icon-car.png" class="bar-icon" mode="aspectFit"></image>
  16. <text>购物车</text>
  17. </view>
  18. </view>
  19. <view class="action-btn-area">
  20. <view v-if="hasStock" class="action-btn in-stock" @click="onAddCart">
  21. <text>加入购物车</text>
  22. </view>
  23. <view v-else class="action-btn no-stock" @click="onNotify">
  24. <text>到货通知</text>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. name: 'FooterBar',
  32. props: {
  33. hasStock: {
  34. type: Boolean,
  35. default: true
  36. },
  37. isCollect: {
  38. type: Boolean,
  39. default: false
  40. }
  41. },
  42. methods: {
  43. onHome() {
  44. uni.switchTab({
  45. url: '/pages/home/index'
  46. })
  47. },
  48. onCart() {
  49. uni.switchTab({
  50. url: '/pages-car/pages/index'
  51. })
  52. },
  53. onCollect() {
  54. this.$emit('collect');
  55. },
  56. onAddCart() {
  57. this.$emit('addCart', 3);
  58. },
  59. onNotify() {
  60. this.$emit('notify');
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .footer-bar {
  67. position: fixed;
  68. bottom: 0;
  69. left: 0;
  70. width: 100%;
  71. height: 200rpx;
  72. background: #fff;
  73. display: flex;
  74. align-items: center;
  75. justify-content: space-between;
  76. padding: 0 20rpx;
  77. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);
  78. z-index: 3;
  79. padding-bottom: env(safe-area-inset-bottom);
  80. .icons-area {
  81. display: flex;
  82. margin-right: 20rpx;
  83. .icon-item {
  84. display: flex;
  85. flex-direction: column;
  86. align-items: center;
  87. justify-content: center;
  88. width: 80rpx;
  89. margin-right: 10rpx;
  90. .bar-icon {
  91. width: 40rpx;
  92. height: 40rpx;
  93. margin-bottom: 6rpx;
  94. }
  95. .bar-icon-2 {
  96. width: 50rpx;
  97. height: 50rpx;
  98. }
  99. text {
  100. font-size: 20rpx;
  101. color: #666;
  102. text-align: center;
  103. }
  104. }
  105. }
  106. .action-btn-area {
  107. flex: 1;
  108. display: flex;
  109. height: 80rpx;
  110. max-width: 360rpx;
  111. .action-btn {
  112. flex: 1;
  113. display: flex;
  114. align-items: center;
  115. justify-content: center;
  116. border-radius: 40rpx;
  117. font-size: 30rpx;
  118. color: #fff;
  119. font-weight: bold;
  120. background: linear-gradient(0deg, #38C248 0%, #5FEA6F 100%);
  121. }
  122. }
  123. }
  124. </style>