appointment.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <div class="p-repair" :class="{ step0: state.step === 0 }">
  3. <component :is="Component" />
  4. </div>
  5. </template>
  6. <script setup lang="ts">
  7. import { computed, watch, onMounted, onUnmounted } from 'vue'
  8. import { useRouter, useRoute } from 'vue-router'
  9. import StepOne from './steps/StepOne.vue'
  10. import StepTwo from './steps/StepTwo.vue'
  11. import StepThree from './steps/StepThree.vue'
  12. // import StepFour from './steps/StepFour.vue'
  13. import StepFive from './steps/StepFive.vue'
  14. import { state, resetState } from './store'
  15. import { state as rootState } from '@/store'
  16. import { getRepairInfo } from '@/service/repair'
  17. const Component = computed(
  18. () => [StepOne, StepTwo, StepThree, StepFive][state.step]
  19. )
  20. const { id, right_id } = useRoute().query as any
  21. id && (state.repairId = id)
  22. right_id && (state.rightId = right_id)
  23. onMounted(async () => {
  24. if (id) {
  25. const res = (await getRepairInfo(+id)).results
  26. state.phoneNumber = res.phone_number
  27. state.remark = res.remark
  28. }
  29. })
  30. onUnmounted(() => resetState())
  31. watch(
  32. () => state.step,
  33. () => {
  34. window.scrollTo(0, 0)
  35. rootState.bgWhite = state.step === 3
  36. }
  37. )
  38. </script>
  39. <style lang="scss" src="./index.scss"></style>