CartItem.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template lang="pug">
  2. li.cart-item
  3. h3.item-name {{ item.name || 'Sin Nombre' }}
  4. input.item-quantity(type='number' min='1' :value='item.quantity')
  5. span.item-x x
  6. span.item-price {{ (item.price || 1) | currency(...options) }}
  7. span.item-equals =
  8. span.item-subtotal {{ ((item.price || 1) * (item.quantity || 1)) | currency(...options) }}
  9. .cart-item-options-wrapper
  10. .cart-item-options
  11. .cart-item-option(class='fa fa-plus' @click='onClickIncrement')
  12. .cart-item-option(class='fa fa-minus' @click='onClickDecrement')
  13. .cart-item-option(class='fa fa-trash' @click='onClickDelete')
  14. </template>
  15. <script>
  16. export default {
  17. props: {
  18. index: {
  19. type: Number,
  20. default: -1,
  21. required: true
  22. },
  23. item: {
  24. type: Object,
  25. default: null
  26. },
  27. options: {
  28. type: Object,
  29. default: {
  30. symbol: '$',
  31. position: 'before',
  32. thousandsSeparator: '.',
  33. decimalPlaces: 2,
  34. decimalSeparator: ','
  35. }
  36. }
  37. },
  38. watch: {
  39. item: {
  40. handler(value) {
  41. this.onChange(value)
  42. },
  43. deep: true,
  44. immediate: true
  45. }
  46. },
  47. methods: {
  48. onChange(item) {
  49. this.$emit('onChange', item)
  50. },
  51. onClickIncrement() {
  52. this.$emit('onClickIncrement', this.item)
  53. },
  54. onClickDecrement() {
  55. this.$emit('onClickDecrement', this.item)
  56. },
  57. onClickDelete() {
  58. this.$emit('onClickDelete', this.item)
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="sass">
  64. @import '../../assets/variables'
  65. .cart-item
  66. width: 100%
  67. height: 90px
  68. list-style: none outside none
  69. border-bottom: 1px solid $app-border-color
  70. box-sizing: border-box
  71. position: relative
  72. &:nth-child(1)
  73. border-top: 1px solid $app-border-color
  74. &:hover
  75. transition-duration: 1000ms
  76. border-bottom: 2px solid $app-main-color
  77. .item-name
  78. width: 100%
  79. height: 20px
  80. margin: 10px 0 5px 0
  81. float: left
  82. font-size: 8pt
  83. display: inline-block
  84. .item-quantity
  85. width: 50px
  86. height: 28px
  87. margin-top: 6px
  88. text-align: right
  89. float: left
  90. display: inline-block
  91. .item-x
  92. width: 20px
  93. height: 20px
  94. margin-top: 12px
  95. text-align: right
  96. float: left
  97. display: inline-block
  98. .item-price
  99. width: 80px
  100. height: 20px
  101. margin-top: 12px
  102. text-align: right
  103. float: left
  104. display: inline-block
  105. .item-equals
  106. width: 20px
  107. height: 20px
  108. margin-top: 12px
  109. text-align: center
  110. float: left
  111. display: inline-block
  112. .item-subtotal
  113. width: 100px
  114. height: 20px
  115. margin-top: 12px
  116. text-align: right
  117. font-weight: bold
  118. display: inline-block
  119. .cart-item-options-wrapper
  120. width: 100%
  121. height: 20px
  122. position: absolute
  123. bottom: 0
  124. display: flex
  125. justify-content: center
  126. .cart-item-options
  127. width: 90px
  128. height: 20px
  129. border: 1px solid #d3d3d3
  130. border-bottom: none
  131. display: flex
  132. justify-content: center
  133. .cart-item-option
  134. width: 18px
  135. height: 18px
  136. margin: 0 5px
  137. color: #666
  138. &:hover
  139. cursor: pointer
  140. &.fa
  141. padding-left: 2px
  142. line-height: 20px
  143. &.fa-plus:hover
  144. color: #2196f3
  145. &.fa-minus:hover
  146. color: #ffc107
  147. &.fa-trash:hover
  148. color: #f44336
  149. </style>