floatButton.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <up-float-button
  3. :isMenu="isMenu"
  4. :list="list"
  5. :top="top"
  6. :buttom="buttom"
  7. :right="right"
  8. :backgroundColor="backgroundColor"
  9. :color="color"
  10. :width="width"
  11. :height="height"
  12. :borderColor="borderColor"
  13. @click="btnClick"
  14. @item-click="itemClick"
  15. style="z-index: 997"
  16. >
  17. <view class="buttom">
  18. <view class="carts">
  19. <image :src="image" class="img"></image>
  20. <view class="cartNum" v-if="unclaimedNum || cartNum">{{
  21. unclaimedNum || cartNum
  22. }}</view>
  23. </view>
  24. </view>
  25. </up-float-button>
  26. </template>
  27. <script setup>
  28. import { computed } from "vue";
  29. import { useShopStore, useTabbarStore } from "@/store";
  30. const useShop = useShopStore();
  31. const useTabbar = useTabbarStore();
  32. const props = defineProps({
  33. isMenu: Boolean,
  34. list: {
  35. type: Array,
  36. default: () => [],
  37. },
  38. backgroundColor: {
  39. type: String,
  40. default: "#e1e5ed",
  41. },
  42. top: String,
  43. buttom: String,
  44. right: {
  45. type: String,
  46. default: "30px",
  47. },
  48. color: {
  49. type: String,
  50. default: "#fff",
  51. },
  52. width: {
  53. type: String,
  54. default: "100rpx",
  55. },
  56. height: {
  57. type: String,
  58. default: "100rpx",
  59. },
  60. borderColor: {
  61. type: String,
  62. default: "",
  63. },
  64. image: {
  65. type: String,
  66. default: "/static/shop/cart.png",
  67. },
  68. unclaimedNum: {
  69. type: Number,
  70. default: 0,
  71. },
  72. });
  73. const emit = defineEmits(["onConfirm", "itemClick"]);
  74. const cartNum = computed(() => useShop.getCartNum);
  75. const btnClick = () => {
  76. emit("onConfirm");
  77. };
  78. const itemClick = (e) => {
  79. emit("itemClick", e);
  80. };
  81. </script>
  82. <style lang="less" scoped>
  83. @import url("@/style.less");
  84. /deep/ .u-float-button__main {
  85. .flex();
  86. }
  87. .buttom {
  88. background-color: #1e1e1e;
  89. width: 84rpx;
  90. height: 84rpx;
  91. border-radius: 50%;
  92. .carts {
  93. width: 100%;
  94. height: 100%;
  95. .flex_center();
  96. position: relative;
  97. .img {
  98. width: 40rpx;
  99. height: 40rpx;
  100. }
  101. .cartNum {
  102. position: absolute;
  103. top: 5px;
  104. right: 5px;
  105. width: 32rpx;
  106. height: 32rpx;
  107. border-radius: 50%;
  108. border: 1px solid var(--light);
  109. .flex_center();
  110. color: var(--light);
  111. background-color: #f56c6c;
  112. .size(20rpx);
  113. }
  114. }
  115. }
  116. </style>