StepTwo.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div class="step-2">
  3. <div class="ptc-block">
  4. <div class="ptc-inner">
  5. <p class="ptc-label">Version & Price</p>
  6. <div class="detail">
  7. <strong class="s1 ellipsis" :title="getters.selectedProduct.name">{{
  8. getters.selectedProduct.name
  9. }}</strong>
  10. <span class="fls0" style="font-size: 0"
  11. ><strong class="s2">${{ getters.cost }}</strong
  12. ><span class="s3">{{
  13. state.form.subscribe_type === 'year' ? 'Annual' : 'Monthly'
  14. }}</span></span
  15. >
  16. <strong class="s4 fls0" @click="$emit('go', -1)">Modify ></strong>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="ptc-block">
  21. <div class="ptc-inner">
  22. <p class="ptc-label">Choose a mobile phone brand</p>
  23. <PtcRadioGroup
  24. v-model="state.form.brand_id"
  25. class="device-list"
  26. @change="onSelectBrand"
  27. >
  28. <PtcRadio
  29. v-for="brand of state.brandList"
  30. :key="brand.id"
  31. class="device-item"
  32. :value="brand.id"
  33. :disabled="!!state.form.renewal"
  34. >
  35. <i
  36. :class="[
  37. 'device-img',
  38. [, 'd-iphone', 'd-ipad', 'd-samsung'][brand.id] || 'd-other',
  39. ]"
  40. />
  41. <p class="device-name">{{ brand.name }}</p>
  42. </PtcRadio>
  43. </PtcRadioGroup>
  44. </div>
  45. </div>
  46. <div v-if="state.modelList.length" class="ptc-wrapper">
  47. <div class="ptc-block">
  48. <div class="ptc-inner">
  49. <p class="ptc-label">Choose phone model</p>
  50. <PtcRadioGroup v-model="state.form.phone_id" class="device-list">
  51. <PtcRadio
  52. v-for="model of state.modelList"
  53. :key="model.id"
  54. class="device-item"
  55. :value="model.id"
  56. :disabled="!!state.form.renewal"
  57. :style="{
  58. fontSize: $util.calcFZ({
  59. text: model.name,
  60. baseLength: 12,
  61. baseSize: 40,
  62. }),
  63. }"
  64. >
  65. <img class="device-img" :src="model.image" />
  66. <p class="device-name">{{ model.name }}</p>
  67. </PtcRadio>
  68. </PtcRadioGroup>
  69. </div>
  70. </div>
  71. <div class="ptc-button-group">
  72. <div class="ptc-inner">
  73. <button
  74. class="ptc-button"
  75. :class="{ disabled: !state.form.phone_id }"
  76. @click="$emit('go')"
  77. >
  78. NEXT
  79. </button>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </template>
  85. <script setup lang="ts">
  86. import { PtcRadioGroup, PtcRadio } from '@/components/radio'
  87. import { state, getters, getModelList } from './store'
  88. const emit = defineEmits<{
  89. (e: 'go', delta?: number): void
  90. }>()
  91. // const showNextBtn = state.form.brand_id && state.form.phone_id
  92. function onSelectBrand() {
  93. state.form.phone_id = ''
  94. getModelList()
  95. }
  96. function onSelectModel() {
  97. setTimeout(() => emit('go'), 200)
  98. }
  99. </script>
  100. <style lang="scss">
  101. .device {
  102. &-list {
  103. display: flex;
  104. flex-wrap: wrap;
  105. width: 680px;
  106. margin: auto;
  107. }
  108. &-item {
  109. padding-top: 24px;
  110. width: 322px;
  111. height: 322px;
  112. text-align: center;
  113. font-size: 40px;
  114. font-weight: bold;
  115. &:nth-child(2n + 1) {
  116. margin-right: 34px;
  117. }
  118. &:nth-child(n + 3) {
  119. margin-top: 36px;
  120. }
  121. }
  122. &-img {
  123. display: inline-block;
  124. vertical-align: top;
  125. margin-bottom: 18px;
  126. width: 200px;
  127. height: 200px;
  128. background-color: #eee;
  129. background-size: contain;
  130. &.d-iphone {
  131. background-image: url(@img/d-iphone.png);
  132. }
  133. &.d-ipad {
  134. background-image: url(@img/d-ipad.png);
  135. }
  136. &.d-samsung {
  137. background-image: url(@img/d-samsung.png);
  138. }
  139. &.d-other {
  140. background-image: url(@img/d-other.png);
  141. }
  142. }
  143. &-name {
  144. padding: 0 24px;
  145. }
  146. }
  147. </style>