You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
4.3 KiB

2 years ago
  1. <template>
  2. <div v-show="show" :class="[
  3. 'optionItem',
  4. index <= 2
  5. ? 'tw-pb-[10px] tw-mb-[10px] tw-border-0 tw-border-b tw-border-solid tw-border-neutrals-100'
  6. : '',
  7. seeMore
  8. ? 'tw-pb-[10px] tw-mb-[10px] tw-border-0 tw-border-b tw-border-solid tw-border-neutrals-100'
  9. : '',
  10. ]">
  11. <div :class="['tw-flex tw-justify-between tw-items-center']">
  12. <div>
  13. <h4 class="t12 tw-mb-[4px] tw-text-neutrals-900 md:t16 md:tw-font-normal">
  14. {{ $t(item.name) }}
  15. </h4>
  16. <!-- <div
  17. class="t12 tw-mb-[4px] tw-text-neutrals-500 md:t16 md:tw-font-normal"
  18. >
  19. {{ $t("Notes : Inclusive Of oooooooooo") }}
  20. </div> -->
  21. <div class="t12 tw-mb-[4px] tw-text-neutrals-900 md:tw-hidden">
  22. ${{ price.toLocaleString() }} {{ currency }}
  23. </div>
  24. </div>
  25. <div class="tw-flex tw-justify-between tw-items-center">
  26. <div class="t12 tw-mr-[35px] tw-text-neutrals-900 tw-hidden md:tw-block md:t16 md:tw-font-normal">
  27. ${{ price.toLocaleString() }} {{ currency }}
  28. </div>
  29. <button :class="[
  30. 'custom-button button-reduce tw-text-transparent tw-p-[6px] tw-rounded-[8px] tw-max-w-[24px] tw-max-h-[24px] tw-mr-[16px] md:tw-max-w-[30px] md:tw-max-h-[30px] md:tw-mr-[42px]',
  31. value == 0 ? 'tw-bg-neutrals-200' : 'tw-bg-primary-default',
  32. ]" @click="reduce()">
  33. reduce
  34. </button>
  35. <div class="tw-min-w-[24px] tw-text-center md:t18 md:tw-font-normal">
  36. {{ value }}
  37. </div>
  38. <button :class="[
  39. 'custom-button button-add tw-text-transparent tw-p-[6px] tw-rounded-[8px] tw-max-w-[24px] tw-max-h-[24px] tw-ml-[16px] md:tw-max-w-[30px] md:tw-max-h-[30px] md:tw-text-medium md:tw-ml-[42px]',
  40. ]" @click="add()">
  41. add
  42. </button>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. export default {
  49. props: {
  50. index: {
  51. type: Number,
  52. },
  53. item: {
  54. type: Object,
  55. },
  56. hasValue: {
  57. type: Number,
  58. },
  59. seeMore: {
  60. type: Boolean,
  61. },
  62. },
  63. data() {
  64. return {
  65. value: 0,
  66. langQuery: this.$i18n.localeProperties["langQuery"],
  67. currentPirce: "US",
  68. };
  69. },
  70. computed: {
  71. currency() {
  72. return this.$store.getters.getCurrency;
  73. },
  74. show() {
  75. if (this.index <= 3) {
  76. return true;
  77. } else {
  78. if (this.seeMore == true) {
  79. return true;
  80. } else {
  81. return false;
  82. }
  83. }
  84. },
  85. price() {
  86. return Number(this.item.price);
  87. },
  88. totalPrice() {
  89. return Math.round(this.price * this.value * 100) / 100;
  90. },
  91. },
  92. watch: {
  93. hasValue: {
  94. handler: function () {
  95. if (this.hasValue == null) {
  96. this.value = 0;
  97. }
  98. },
  99. },
  100. item: {
  101. handler: function () {
  102. let vm = this;
  103. vm.$nextTick(function () {
  104. vm.$emit("selected", {
  105. addon_service_id: vm.item.addon_service_id,
  106. addon_service_name: vm.item.name,
  107. number: vm.value,
  108. total: vm.totalPrice,
  109. });
  110. })
  111. },
  112. }
  113. },
  114. methods: {
  115. add() {
  116. this.value += 1;
  117. if (this.value !== 0) {
  118. this.$emit("disabled", this.index);
  119. }
  120. this.$emit("selected", {
  121. addon_service_id: this.item.addon_service_id,
  122. addon_service_name: this.item.name,
  123. number: this.value,
  124. total: this.totalPrice,
  125. });
  126. },
  127. reduce() {
  128. if (this.value !== 0) {
  129. this.value -= 1;
  130. this.$emit("selected", {
  131. addon_service_id: this.item.addon_service_id,
  132. addon_service_name: this.item.name,
  133. number: this.value,
  134. total: this.totalPrice,
  135. });
  136. }
  137. },
  138. },
  139. };
  140. </script>
  141. <style lang="scss" scoped>
  142. .custom-button {
  143. background-position: center;
  144. background-repeat: no-repeat;
  145. background-size: 12px;
  146. }
  147. .button {
  148. &-reduce {
  149. background-image: url("~/assets/svg/reduce.svg");
  150. background-color: #e5e5e5;
  151. }
  152. &-add {
  153. background-image: url("~/assets/svg/add.svg");
  154. background-color: #f48800;
  155. }
  156. }
  157. .bounce-enter-active {
  158. animation: bounce-in 0.3s ease-out;
  159. }
  160. .bounce-leave-active {
  161. animation: bounce-in 0.3s reverse;
  162. }
  163. @keyframes bounce-in {
  164. 0% {
  165. opacity: 0;
  166. }
  167. 50% {
  168. opacity: 0.5;
  169. }
  170. 100% {
  171. opacity: 1;
  172. }
  173. }
  174. </style>