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

OnboardingView.vue 5.3KB

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