uni-cart-fix.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. props:{
  10. closeCurPage:{
  11. type: Boolean,
  12. default: false
  13. }
  14. },
  15. computed: {
  16. count() {
  17. let arr = this.$store.state.vuex_cartList || []
  18. let count = 0
  19. arr.map(item=>{
  20. count = count + item.shoppingCartGoodsList.length
  21. })
  22. return count
  23. },
  24. },
  25. methods: {
  26. toCart() {
  27. let _this = this
  28. this.$bindClick(function(){
  29. if(_this.closeCurPage){
  30. uni.redirectTo({
  31. url:"/pages/cart/cart"
  32. })
  33. }else{
  34. uni.navigateTo({
  35. url:"/pages/cart/cart"
  36. })
  37. }
  38. })
  39. }
  40. },
  41. }
  42. </script>
  43. <style lang="scss">
  44. .cart-fix{
  45. position: fixed;
  46. z-index: 100000;
  47. background: rgba($color: #ffffff, $alpha: 0.7);
  48. padding: 10upx;
  49. border-radius: 100%;
  50. bottom: 40%;
  51. right: 2%;
  52. box-shadow: 3upx 3upx 8upx #ccc;
  53. }
  54. </style>