Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

137 satır
3.1 KiB

  1. <template>
  2. <form>
  3. <div>
  4. <label>Given name</label>
  5. <input required type="text" name="gname" v-model="user.firstName"/>
  6. </div>
  7. <div>
  8. <label>Surname</label>
  9. <input required type="text" name="sname" v-model="user.lastName"/>
  10. </div>
  11. <div>
  12. <label>Email</label>
  13. <input type="email" name="email" v-model="user.email"/>
  14. </div>
  15. <div>
  16. <label>Title</label>
  17. <select name="country" v-model="user.title">
  18. <option value="Loan Officer">Loan Officer</option>
  19. <option value="Mortgage Broker">Mortgage Broker</option>
  20. <option value="Executive">Executive</option>
  21. <option value="Other">Other</option>
  22. </select>
  23. </div>
  24. <div>
  25. <label>Password</label>
  26. <input requried type="password" name="pass" v-model="user.password"/>
  27. </div>
  28. <div>
  29. <label>Country</label>
  30. <select name="country" v-model="user.country">
  31. <option value="USA">USA</option>
  32. <option value="Canada">Canada</option>
  33. </select>
  34. </div>
  35. <div class="address-entry">
  36. <label for="">Address</label>
  37. <input
  38. type="text" @input="searchLocation" v-model="address.full">
  39. <dropdown v-if="addresses && addresses.length"
  40. :entries="addresses.map(a => ({text: a.full_address, value: a}))"
  41. @select="setAddress"
  42. >
  43. </dropdown>
  44. </div>
  45. <div><label>NMLS ID</label><input type="text" name="nmls"/></div>
  46. <div><span class="error">{{err}}</span></div>
  47. <div>
  48. <button class="btn" @click="submit" type="button">Continue</button>
  49. </div>
  50. </form>
  51. </template>
  52. <script setup>
  53. import { ref } from "vue"
  54. import Dropdown from "./dropdown.vue"
  55. const addresses = ref([])
  56. const user = ref({country: "USA", title: "Loan Officer"})
  57. const address = ref({})
  58. const locationsId = ref(null)
  59. const props = defineProps(['err'])
  60. const emit = defineEmits(['submit'])
  61. function searchLocation(e) {
  62. address.value.full = e.target.value
  63. clearTimeout(locationsId.value)
  64. locationsId.value = setTimeout(getLocations, 1000, e)
  65. }
  66. function getLocations(e) {
  67. let prefix = "https://api.mapbox.com/search/searchbox/v1/suggest?"
  68. let search = e.target.value
  69. let key = encodeURIComponent(process.env.MAPBOX_API_KEY)
  70. if (!search) return
  71. fetch(`${prefix}q=${search}&proximity=ip&access_token=${key}&session_token=1`
  72. ).then(resp => resp.json()).then(entries => {
  73. if (!entries?.suggestions) {
  74. addresses.value = null
  75. return
  76. }
  77. addresses.value = entries.suggestions.filter(e => e.full_address)
  78. })
  79. }
  80. function setAddress(a) {
  81. address.value = {
  82. id: address.value.id,
  83. full: a.full_address,
  84. street: a.address,
  85. city: a.context?.place.name ?? '',
  86. region: a.context?.region?.name ?? '',
  87. country: a.context?.country?.name ?? '',
  88. zip: a.context?.postcode?.name ?? '',
  89. }
  90. addresses.value = null
  91. }
  92. function submit() {
  93. user.value.address = address.value
  94. emit('submit', user.value)
  95. }
  96. </script>
  97. <style scoped>
  98. form > div {
  99. display: flex;
  100. justify-content: space-between;
  101. margin: 10px;
  102. position: relative;
  103. }
  104. button {
  105. margin: auto;
  106. min-width: 90px;
  107. display: block;
  108. }
  109. span.error {
  110. margin: 10px auto;
  111. color: darkred;
  112. }
  113. </style>