CartItem.vue 4.7 KB

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