SkillSelect.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <script setup lang="ts">
  2. import { storeToRefs } from 'pinia'
  3. import { useI18n } from 'vue-i18n'
  4. import type { PlaymateInfoVO } from '~/types/api'
  5. import { useFirstOrderDiscountStore } from '~/stores/firstOrderDiscount'
  6. import { useAuthStore } from '~/stores/auth'
  7. const props = withDefaults(
  8. defineProps<{
  9. show: boolean
  10. skills: PlaymateInfoVO['skills']
  11. activeSkillId: string
  12. quantity: number
  13. formattedTotalPrice: string | number
  14. /** When provided, display price uses first-order discount (exclude own products). */
  15. ownerUserNo?: string
  16. }>(),
  17. { ownerUserNo: undefined },
  18. )
  19. const emit = defineEmits<{
  20. 'update:show': [value: boolean]
  21. 'update:quantity': [value: number]
  22. 'select-skill': [skillId: string]
  23. 'order': []
  24. }>()
  25. const { t } = useI18n()
  26. const firstOrderDiscountStore = useFirstOrderDiscountStore()
  27. const { userProfile } = storeToRefs(useAuthStore())
  28. const displayPrice = (price: number) =>
  29. firstOrderDiscountStore.getDisplayPrice(price, props.ownerUserNo, userProfile.value?.userNo)
  30. const showDiscount = (price: number) =>
  31. firstOrderDiscountStore.isDiscountEligible(price, props.ownerUserNo, userProfile.value?.userNo)
  32. </script>
  33. <template>
  34. <van-popup
  35. :show="props.show"
  36. round
  37. position="bottom"
  38. class="pay-popup"
  39. @update:show="value => emit('update:show', value)"
  40. >
  41. <div class="pay-popup__container">
  42. <div class="pay-popup__skills">
  43. <article
  44. v-for="skill in props.skills"
  45. :key="skill.id"
  46. class="pay-popup-skill"
  47. :class="{ 'pay-popup-skill--active': skill.id === props.activeSkillId }"
  48. @click="emit('select-skill', skill.id)"
  49. >
  50. <div class="pay-popup-skill__info">
  51. <img
  52. v-if="skill.icon"
  53. class="pay-popup-skill__logo"
  54. :src="skill.icon"
  55. :alt="skill.name"
  56. >
  57. <div class="pay-popup-skill__texts">
  58. <p class="pay-popup-skill__name">
  59. {{ skill.name }}
  60. </p>
  61. </div>
  62. </div>
  63. <div class="pay-popup-skill__price">
  64. <span
  65. class="pay-popup-skill__amount"
  66. :class="{ 'text-[#FF6F32]': showDiscount(skill.price) }"
  67. >
  68. {{ displayPrice(skill.price) }}
  69. </span>
  70. <span class="pay-popup-skill__unit">
  71. /{{ skill.unit }}
  72. </span>
  73. <div
  74. v-if="showDiscount(skill.price)"
  75. class="discount-tip"
  76. >
  77. <span>{{ firstOrderDiscountStore.discountRatePercent }} OFF</span>
  78. </div>
  79. </div>
  80. </article>
  81. </div>
  82. <div class="pay-popup__quantity">
  83. <span class="pay-popup__quantity-label">
  84. {{ t('order.detail.quantity') }}
  85. </span>
  86. <CommonStepper
  87. :model-value="props.quantity"
  88. @update:model-value="(value: number) => emit('update:quantity', value)"
  89. />
  90. </div>
  91. <div class="pay-popup__footer">
  92. <CommonOrderBtn
  93. :price="props.formattedTotalPrice"
  94. @click="emit('order')"
  95. />
  96. </div>
  97. </div>
  98. </van-popup>
  99. </template>
  100. <style lang="scss" scoped>
  101. .pay-popup {
  102. &__container {
  103. height: 100%;
  104. display: flex;
  105. flex-direction: column;
  106. padding: 16px 16px 0;
  107. gap: 20px;
  108. }
  109. }
  110. .pay-popup__skills {
  111. max-height: 250px;
  112. overflow-y: auto;
  113. display: flex;
  114. flex-direction: column;
  115. gap: 8px;
  116. }
  117. .pay-popup-skill {
  118. height: 52px;
  119. display: flex;
  120. align-items: center;
  121. justify-content: space-between;
  122. padding: 10px 14px;
  123. border-radius: 12px;
  124. border: 1px solid #c9cdd4;
  125. background-color: #fff;
  126. cursor: pointer;
  127. transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  128. &--active {
  129. border-color: #1789ff;
  130. background-color: #e6fffa;
  131. box-shadow: 0 0 0 1px rgba(23, 137, 255, 0.16);
  132. }
  133. &__info {
  134. display: flex;
  135. align-items: center;
  136. gap: 10px;
  137. }
  138. &__logo {
  139. @include size(32px);
  140. flex-shrink: 0;
  141. }
  142. &__texts {
  143. display: flex;
  144. flex-direction: column;
  145. gap: 2px;
  146. }
  147. &__name {
  148. font-family: var(--font-title);
  149. font-size: 14px;
  150. font-weight: 600;
  151. color: #1d2129;
  152. }
  153. &__price {
  154. display: flex;
  155. align-items: center;
  156. gap: 2px;
  157. font-size: 14px;
  158. font-weight: 600;
  159. color: #1d2129;
  160. position: relative;
  161. .discount-tip {
  162. display: flex;
  163. height: 20px;
  164. padding: 0 6px;
  165. border-radius: 4px;
  166. background: #FF6F32;
  167. justify-content: center;
  168. align-items: center;
  169. position: absolute;
  170. left: -65px;
  171. span {
  172. color: #FFF;
  173. font-size: 11px;
  174. font-weight: 400;
  175. line-height: 14px;
  176. }
  177. }
  178. }
  179. &__unit {
  180. font-size: 12px;
  181. font-weight: 400;
  182. color: var(--color-text-secondary);
  183. }
  184. }
  185. .pay-popup__quantity {
  186. display: flex;
  187. align-items: center;
  188. justify-content: space-between;
  189. padding: 0 4px;
  190. }
  191. .pay-popup__quantity-label {
  192. font-size: 16px;
  193. font-weight: 600;
  194. color: #1d2129;
  195. }
  196. .pay-popup__footer {
  197. margin-top: auto;
  198. }
  199. </style>