Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

OnboardingView.vue 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template lang="pug">
  2. main.view--onboarding
  3. article(
  4. style='display: flex; flex-direction: column; align-items: center'
  5. v-if='incomplete'
  6. )
  7. .answers(v-for='(value, key) in answered')
  8. span(v-if='key == "name" && value && currentStep == 2') Hi {{ value }}!
  9. span(v-if='key == "email" && value && currentStep == 3') Thanks for the contact info, {{ answered.name }}!
  10. h3(v-if="currentStep == 1") Welcome to Siimee Onboarding! Let's get started!
  11. br
  12. .step(v-for='(step, i) in survey.steps')
  13. component(
  14. :aspect-questions='step.component == "Aspects" ? survey.aspectQuestions : null'
  15. :is='step.component'
  16. :question='step'
  17. @handle-submit='onSubmit'
  18. @update-answers='updateAnswers'
  19. v-if='step && currentStep == i'
  20. )
  21. footer
  22. p(v-if='currentStep != 0') You have completed: {{ currentStep - 1 }} / {{ survey.steps.length -2 }} survey steps
  23. article(v-else)
  24. SurveyCompleteView(:answers='answered' :surveySteps='survey.steps')
  25. </template>
  26. <script>
  27. import { surveyFactory } from '@/utils'
  28. import { allSteps } from '@/utils/lang'
  29. import stepViews from '@/components/onboarding'
  30. import SurveyCompleteView from './SurveyCompleteView.vue'
  31. // import savesurveybyprfileid - call it on submit
  32. // paginate to save every steps answers
  33. export default {
  34. name: 'OnboardingView',
  35. components: {
  36. ...stepViews,
  37. SurveyCompleteView,
  38. },
  39. data: () => ({
  40. answered: {},
  41. aspectQuestions: [],
  42. currentStep: 0,
  43. survey: null,
  44. incomplete: true,
  45. }),
  46. async created() {
  47. this.survey = await surveyFactory.createSurvey(allSteps['usa'])
  48. },
  49. methods: {
  50. onSubmit() {
  51. console.log(JSON.stringify(this.answered))
  52. this.incomplete = null
  53. },
  54. goToStep(num) {
  55. this.currentStep = num
  56. },
  57. updateAnswers(payload) {
  58. // null payload is passed on splash page
  59. if (payload) {
  60. const k = payload.question.survey_stage
  61. this.answered[k] = payload.input
  62. console.log(`Updated answers: ${JSON.stringify(this.answered)}`)
  63. if (k === 'aspects') return
  64. }
  65. if (this.currentStep > this.survey.steps.length) {
  66. this.onSubmit(this.answered)
  67. } else {
  68. this.goToStep(this.currentStep + 1)
  69. }
  70. },
  71. },
  72. }
  73. </script>
  74. <style lang="sass">
  75. .view--onboarding
  76. width: 100%
  77. max-width: 428px
  78. background-color: #fff
  79. color: #1F2024
  80. font-family: Century Gothic,CenturyGothic,AppleGothic,sans-serif
  81. margin: 0 auto
  82. article
  83. height: 100vh
  84. .answers
  85. text-align: center
  86. .w-button
  87. display: flex
  88. width: 315px
  89. height: 60px
  90. border-radius: 6
  91. background-color: #D5D5D5
  92. color: #1F2024
  93. margin: 11px auto
  94. font-weight: bold
  95. font-size: 16px
  96. text-transform: uppercase
  97. &.next-btn
  98. border-radius: 6px
  99. background-color: #5BA626
  100. color: #1F2024
  101. height: 50px
  102. width: 315px
  103. font-size: 18px
  104. padding: 7px
  105. .w-card
  106. background-color: #1F2024
  107. justify-content: center
  108. align-items: center
  109. width: 100%
  110. h3
  111. text-transform: uppercase
  112. text-align: center
  113. font-size: 28px
  114. font-weight: bold
  115. color: white
  116. margin-top: 88px
  117. p
  118. color: white
  119. font-size: 18px
  120. padding: 11px
  121. text-align: center
  122. margin: 22px auto
  123. font-weight: bold
  124. input
  125. display: flex
  126. width: 315px
  127. height: 60px
  128. padding: 11px
  129. border-radius: 6
  130. background-color: #D5D5D5
  131. color: #1F2024
  132. margin: 11px auto
  133. font-weight: bold
  134. font-size: 16px
  135. .w-select
  136. padding: 11px
  137. color: #1F2024
  138. .search-type
  139. color: #1F2024
  140. height: 50px
  141. &.question
  142. p
  143. font-size: 18px
  144. text-align: left
  145. margin: 7px auto
  146. font-weight: normal
  147. section
  148. p
  149. margin: 0
  150. font-weight: bold
  151. text-transform: capitalize
  152. .w-radio__input
  153. &.primary
  154. background-color: #FFFFFF
  155. border: #BCC5D3 1px solid
  156. .w-card__content
  157. .w-button
  158. height: 50px
  159. background-color: #5BA626
  160. </style>