StepOne.vue 6.2 KB

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