uni-cart-fix.vue 870 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. this.$bindClick(function(){
  22. uni.navigateTo({
  23. url:"/pages/cart/cart"
  24. })
  25. })
  26. }
  27. },
  28. }
  29. </script>
  30. <style lang="scss">
  31. .cart-fix{
  32. position: fixed;
  33. z-index: 100000;
  34. background: rgba($color: #ffffff, $alpha: 0.7);
  35. padding: 10upx;
  36. border-radius: 100%;
  37. bottom: 40%;
  38. right: 2%;
  39. box-shadow: 3upx 3upx 8upx #ccc;
  40. }
  41. </style>