uni-cart-fix.vue 820 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <view class="cart-fix" @click="toCart">
  3. <u-image width="70rpx" height="70rpx" src="/static/cart.png"></u-image>
  4. <u-badge absolute :offset="[15,10]" type="error" :count="count"></u-badge>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. computed: {
  10. count() {
  11. let arr = this.$store.state.vuex_cartList
  12. let count = 0
  13. arr.map(item=>{
  14. count = count + item.shoppingCartGoodsList.length
  15. })
  16. return count
  17. },
  18. },
  19. methods: {
  20. toCart() {
  21. uni.navigateTo({
  22. url:"/pages/cart/cart"
  23. })
  24. }
  25. },
  26. }
  27. </script>
  28. <style lang="scss">
  29. .cart-fix{
  30. position: fixed;
  31. z-index: 100000;
  32. background: rgba($color: #ffffff, $alpha: 0.7);
  33. padding: 10upx;
  34. border-radius: 100%;
  35. bottom: 40%;
  36. right: 2%;
  37. box-shadow: 3upx 3upx 8upx #ccc;
  38. }
  39. </style>