StepOne.vue 5.8 KB

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