StepOne.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="step-1 ptc-wrapper">
  3. <div class="ptc-block">
  4. <div class="ptc-inner">
  5. <p class="ptc-label">Choose a version</p>
  6. <PtcRadioGroup v-model="state.form.product_id" style="display: flex">
  7. <PtcRadio
  8. v-for="product of state.productList"
  9. :key="product.id"
  10. class="version"
  11. :value="product.id"
  12. >
  13. <i
  14. class="version-icon"
  15. :style="{ backgroundImage: `url(${product.image})` }"
  16. ></i>
  17. <span class="mt18">{{ product.name }}</span>
  18. </PtcRadio>
  19. </PtcRadioGroup>
  20. <div
  21. class="version-desc"
  22. :class="{
  23. second:
  24. state.productList[1] &&
  25. state.form.product_id === state.productList[1].id,
  26. }"
  27. >
  28. {{ getters.selectedProduct.remark }}
  29. </div>
  30. </div>
  31. </div>
  32. <div class="ptc-block">
  33. <div class="ptc-inner">
  34. <p class="ptc-label">Choose a subscription method</p>
  35. <PtcRadioGroup v-model="state.form.subscribe_type">
  36. <PtcRadio class="method" value="year">
  37. <span class="cost">${{ getters.selectedProduct.amount_year }}</span>
  38. <span class="name">Annual</span>
  39. <span class="ptc-tag"
  40. >-{{ getters.selectedProduct.better_than_monthly }}% OFF</span
  41. >
  42. </PtcRadio>
  43. <PtcRadio class="method" value="month">
  44. <span class="cost"
  45. >${{ getters.selectedProduct.amount_month }}</span
  46. >
  47. <span class="name">
  48. Monthly<template v-if="+getters.selectedProduct.amount_month_open"
  49. >&nbsp; Activation fee ${{
  50. getters.selectedProduct.amount_month_open
  51. }}</template
  52. ></span
  53. >
  54. </PtcRadio>
  55. </PtcRadioGroup>
  56. </div>
  57. </div>
  58. <div class="ptc-block">
  59. <div class="ptc-inner">
  60. <p class="ptc-label">Do you have a discount code?</p>
  61. <div v-if="!state.discount" class="input-wrap pr">
  62. <input
  63. v-model="state.form.discount_code"
  64. class="ptc-input"
  65. placeholder="Enter promotional code"
  66. />
  67. <button class="input-btn" @click="checkDiscount">sbumit</button>
  68. </div>
  69. <div v-else class="coupon-wrap">
  70. <div class="coupon">
  71. <p class="p1">PTC CARE PLUS</p>
  72. <p class="p2">{{ state.discount.name }}</p>
  73. <p class="p3">- ${{ state.discount.discount_amount }}</p>
  74. </div>
  75. <div class="action">
  76. <span class="code">{{ state.form.discount_code }}</span>
  77. <span class="primary" @click="reviseDiscount">Revise</span>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="total">
  83. <div v-if="getters.cost" class="ptc-inner">
  84. <p>
  85. total<strong>${{ getters.cost }}</strong>
  86. </p>
  87. <p v-if="state.discount" class="highlight">
  88. (${{ state.discount.discount_amount }} discounted)
  89. </p>
  90. </div>
  91. </div>
  92. <div class="ptc-button-group">
  93. <div class="ptc-inner">
  94. <button class="ptc-button" @click="next">NEXT</button>
  95. </div>
  96. </div>
  97. </div>
  98. </template>
  99. <script setup lang="ts">
  100. import { PtcRadioGroup, PtcRadio } from '@/components/radio'
  101. import { state, getters, getBrandList } from './store'
  102. import * as api from '@/service/order'
  103. import Toast from '@/components/toast'
  104. const emit = defineEmits<{
  105. (e: 'go', delta?: number): void
  106. }>()
  107. async function checkDiscount() {
  108. if (!state.form.discount_code) return Toast('Please enter promotional code')
  109. try {
  110. const { results, message } = await api.checkDiscount(
  111. state.form.discount_code
  112. )
  113. Toast(message)
  114. state.discount = results
  115. } catch {
  116. state.form.discount_code = ''
  117. }
  118. }
  119. function reviseDiscount() {
  120. state.discount = null
  121. state.form.discount_code = ''
  122. }
  123. async function next() {
  124. if (!state.form.subscribe_type)
  125. return Toast('Please choose a subscription method')
  126. if (!state.brandList.length) await getBrandList()
  127. emit('go')
  128. if (!state.discount) state.form.discount_code = ''
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. .version {
  133. display: flex;
  134. flex-direction: column;
  135. justify-content: center;
  136. align-items: center;
  137. margin-right: 64px;
  138. width: 212px;
  139. height: 212px;
  140. font-size: 56px;
  141. font-weight: bold;
  142. &-icon {
  143. width: 36px;
  144. height: 36px;
  145. background-size: contain;
  146. }
  147. .mt18 {
  148. margin-top: 18px;
  149. }
  150. &-desc {
  151. position: relative;
  152. margin-top: 32px;
  153. padding: 28px 24px;
  154. line-height: 40px;
  155. font-size: 28px;
  156. color: #193059;
  157. background: #f2f5fb;
  158. &::before {
  159. content: '';
  160. position: absolute;
  161. left: 88px;
  162. top: 0;
  163. transform: translateY(-100%);
  164. border-style: solid;
  165. border-width: 0 12px 14px;
  166. border-color: #f2f5fb transparent;
  167. }
  168. &.second::before {
  169. left: 88px + 276px;
  170. }
  171. }
  172. }
  173. .method {
  174. display: flex;
  175. align-items: center;
  176. padding: 0 38px;
  177. height: 130px;
  178. + .method {
  179. margin-top: 48px;
  180. }
  181. .cost {
  182. font-size: 56px;
  183. font-weight: bold;
  184. }
  185. .name {
  186. margin-left: 20px;
  187. font-size: 32px;
  188. }
  189. }
  190. .ptc-input {
  191. padding-right: 154px;
  192. }
  193. .input-btn {
  194. position: absolute;
  195. top: 0;
  196. right: 0;
  197. height: 100%;
  198. width: 154px;
  199. background: #1a3059;
  200. border-radius: 0px 8px 8px 0px;
  201. color: #fff;
  202. font-size: 32px;
  203. &:active {
  204. background: $primary-color-lighten;
  205. }
  206. }
  207. .total {
  208. padding-left: 36px;
  209. font-size: 32px;
  210. color: #333;
  211. strong {
  212. margin-left: 8px;
  213. font-size: 40px;
  214. }
  215. }
  216. .coupon {
  217. @include icon('@img/coupon-s.png', 488px, 224px);
  218. margin-bottom: 48px;
  219. padding-top: 22px;
  220. text-align: center;
  221. font-size: 28px;
  222. font-weight: bold;
  223. .p1 {
  224. color: #9aa8c5;
  225. }
  226. .p2 {
  227. margin: 16px 0 34px;
  228. color: $primary-color;
  229. }
  230. .p3 {
  231. font-size: 56px;
  232. color: $primary-color;
  233. }
  234. }
  235. .action {
  236. font-size: 32px;
  237. color: #666;
  238. .code {
  239. margin-right: 64px;
  240. }
  241. }
  242. .highlight {
  243. margin-top: 4px;
  244. color: $danger-color;
  245. }
  246. </style>