StepThree.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <h3 class="ptc-title">Confirm appointment</h3>
  3. <div class="ptc-block">
  4. <div class="ptc-inner">
  5. <div class="shop-name">{{ state.shop.name }}</div>
  6. <div class="shop-address">
  7. {{ state.shop.centre_name }},{{ state.shop.address }}
  8. </div>
  9. <div v-if="!submitted" class="shop-action">
  10. <span class="modify" @click="state.step = 0">Modify ></span>
  11. </div>
  12. </div>
  13. </div>
  14. <div class="ptc-block">
  15. <div class="ptc-inner">
  16. <p class="t2">Appointed time</p>
  17. <div class="flex-ac space-between">
  18. <strong class="p1">{{ state.uiDate }}</strong>
  19. <strong class="p2">{{ state.uiPeriod }}</strong>
  20. <span :class="['modify', { hidden: submitted }]" @click="state.step--"
  21. >Modify ></span
  22. >
  23. </div>
  24. </div>
  25. </div>
  26. <div class="ptc-block">
  27. <div class="ptc-inner">
  28. <p class="t1">
  29. Please provide a mobile number so that the customer service can confirm
  30. the details with you。
  31. </p>
  32. <p class="t2">Phone number</p>
  33. <input
  34. v-model="state.phoneNumber"
  35. type="text"
  36. class="ptc-input"
  37. placeholder="Please enter"
  38. />
  39. </div>
  40. </div>
  41. <div class="ptc-wrapper">
  42. <div class="ptc-block">
  43. <div class="ptc-inner">
  44. <p class="t1">
  45. Is there anything to pay attention to, nothing to skip。
  46. </p>
  47. <textarea
  48. v-model="state.remark"
  49. placeholder="Please enter, up to 1000 characters"
  50. ></textarea>
  51. </div>
  52. </div>
  53. <div class="ptc-button-group">
  54. <div class="ptc-inner">
  55. <button class="ptc-button" :loading="loading" @click="onSubmit">
  56. SUBMIT
  57. </button>
  58. </div>
  59. </div>
  60. </div>
  61. </template>
  62. <script setup lang="ts">
  63. import { ref } from 'vue'
  64. import { state } from '../store'
  65. import * as api from '@/service/repair'
  66. import Toast from '@/components/toast'
  67. import NProgress from 'nprogress'
  68. const submitted = ref(false)
  69. const loading = ref(false)
  70. function onSubmit() {
  71. submit().then(next)
  72. }
  73. async function submit() {
  74. if (submitted.value) return
  75. if (!state.phoneNumber) {
  76. Toast('Please enter your phone number')
  77. return Promise.reject()
  78. }
  79. const commonParams = {
  80. igeektek_id: state.shop.igeektek_id,
  81. pickup_time: state.date + ' ' + state.period,
  82. phone_number: state.phoneNumber,
  83. remark: state.remark || '',
  84. }
  85. const request = state.repairId
  86. ? api.rescheduleRepair({ id: state.repairId, ...commonParams })
  87. : api.applyRepair({ right_id: state.rightId, ...commonParams })
  88. loading.value = true
  89. request.finally(() => (loading.value = false))
  90. const { results } = await request
  91. state.repairId = results
  92. submitted.value = true
  93. }
  94. async function next() {
  95. if (NProgress.status) return
  96. try {
  97. NProgress.start()
  98. state.detail = (await api.getRepairInfo(+state.repairId)).results
  99. state.step++
  100. NProgress.done()
  101. } catch {
  102. NProgress.status = null
  103. NProgress.remove()
  104. }
  105. }
  106. </script>