stepOne.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <!-- @format -->
  2. <script lang="ts" setup>
  3. import type { FormInstance, FormRules } from 'element-plus'
  4. import DragVerify from '~/components/common/drag-verify/index.vue'
  5. import { useRegister } from '~/pages/register/useRegister'
  6. import { getDictListApi } from '~/api/model/common'
  7. import { passwordRegular } from '~/enums/regEnum'
  8. const { params, register, backStep } = useRegister()
  9. const mobileAreaCodeList = ref()
  10. const ruleFormRef = ref<FormInstance>()
  11. const rules = ref<FormRules>({
  12. firstName: [
  13. {
  14. required: true,
  15. message: 'FirstName must be filled in',
  16. trigger: 'blur',
  17. },
  18. ],
  19. lastName: [
  20. {
  21. required: true,
  22. message: 'LastName must be filled in',
  23. trigger: 'blur',
  24. },
  25. ],
  26. email: [
  27. { required: true, message: 'Email must be filled in', trigger: 'blur' },
  28. {
  29. pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
  30. message: 'please fill in correct email',
  31. },
  32. ],
  33. mobile: [
  34. {
  35. required: true,
  36. message: 'Mobile must be filled in',
  37. trigger: 'blur',
  38. },
  39. ],
  40. password: [
  41. {
  42. required: true,
  43. trigger: 'change',
  44. validator: (rule, value, callback) => {
  45. if (value) {
  46. if (passwordRegular.test(value))
  47. callback()
  48. else
  49. callback(new Error('Please enter password that matches the rules'))
  50. }
  51. else { callback(new Error('Password must be filled in')) }
  52. },
  53. },
  54. ],
  55. checked: [
  56. {
  57. required: true,
  58. validator: (rule, value, callback) => {
  59. if (value)
  60. callback()
  61. else callback(new Error('Please check the agreement'))
  62. },
  63. },
  64. ],
  65. isUnlock: [
  66. {
  67. required: true,
  68. validator: (rule, value, callback) => {
  69. if (value)
  70. callback()
  71. else callback(new Error('Please slide to verity'))
  72. },
  73. },
  74. ],
  75. })
  76. async function getMobileAreaCodeList() {
  77. const list = await getDictListApi('A064')
  78. mobileAreaCodeList.value = list
  79. }
  80. async function submitForm(formEl: FormInstance | undefined) {
  81. if (!formEl)
  82. return
  83. await formEl.validate((valid, fields) => {
  84. if (valid)
  85. register()
  86. else
  87. console.log('error submit!', fields)
  88. })
  89. }
  90. getMobileAreaCodeList()
  91. </script>
  92. <template>
  93. <div>
  94. <div class="fw-500 mb-24px text-40px text-#000">
  95. Personal
  96. </div>
  97. <el-form
  98. ref="ruleFormRef"
  99. :model="params"
  100. :rules="rules"
  101. label-width="auto"
  102. size="default"
  103. status-icon
  104. >
  105. <div class="flex">
  106. <el-form-item
  107. class="custom-form-item custom-form-item-hidden-label mr-12px"
  108. label="Full Name"
  109. prop="firstName"
  110. >
  111. <el-input v-model="params.firstName" placeholder="Full Name" class="h-50px" />
  112. </el-form-item>
  113. <el-form-item
  114. class="custom-form-item custom-form-item-hidden-label mr-12px"
  115. label="Last Name"
  116. prop="lastName"
  117. >
  118. <el-input v-model="params.lastName" placeholder="Last Name" class="h-50px" />
  119. </el-form-item>
  120. </div>
  121. <el-form-item
  122. label="Email"
  123. class="custom-form-item "
  124. prop="email"
  125. >
  126. <el-input v-model="params.email" placeholder="Email" class="h-50px" />
  127. </el-form-item>
  128. <el-form-item
  129. label="Mobile Number"
  130. class="custom-form-item"
  131. prop="mobile"
  132. >
  133. <el-input v-model="params.mobile" placeholder="Mobile Number" class="h-50px">
  134. <template #prepend>
  135. <el-select v-model="params.mobileAreaCode" class="!h-50px" placeholder="Select" style="width: 120px">
  136. <el-option
  137. v-for="(item, index) in mobileAreaCodeList"
  138. :key="index"
  139. :value="item.value"
  140. :label="`${item.value} ${item.label}`"
  141. >
  142. {{ item.value }} {{ item.label }}
  143. </el-option>
  144. </el-select>
  145. </template>
  146. </el-input>
  147. </el-form-item>
  148. <el-form-item
  149. label="Create Password"
  150. class="custom-form-item"
  151. prop="password"
  152. >
  153. <el-popover
  154. placement="right"
  155. :width="270"
  156. class="!text-#5B463E !text-16px"
  157. trigger="hover"
  158. content="6-20 characters, contain letters numbers or symbols only"
  159. >
  160. <template #reference>
  161. <el-input v-model="params.password" :show-password="true" placeholder="Password" class="h-50px" />
  162. </template>
  163. </el-popover>
  164. </el-form-item>
  165. <el-form-item label="Verity" class="custom-form-item !mb-12px" prop="isUnlock">
  166. <DragVerify
  167. v-model:value="params.isUnlock"
  168. start-text="please slide to verify"
  169. />
  170. </el-form-item>
  171. <el-form-item label="" class="custom-form-item" prop="checked">
  172. <el-checkbox v-model="params.checked">
  173. I agree to the
  174. </el-checkbox>
  175. <span class="text-16px text-#CC9879 cursor-pointer">《Terms & Conditions》
  176. </span>
  177. <a href="/policy"> <span class="text-16px text-#CC9879 cursor-pointer"> Privacy Policy
  178. </span></a>.
  179. </el-form-item>
  180. <el-form-item class="custom-form-item">
  181. <el-button
  182. class="!bg-#fff !text-#5B463E !w-48% !h-50px !text-18px !fw-500 !b-rd-6px b-#5B463E"
  183. @click="backStep"
  184. >
  185. Back
  186. </el-button>
  187. <el-button
  188. class="!bg-#C58C64 !text-#fff !ml-0 !w-48% !h-50px !text-18px !fw-500 !b-rd-6px"
  189. @click="submitForm(ruleFormRef)"
  190. >
  191. Next
  192. </el-button>
  193. </el-form-item>
  194. </el-form>
  195. </div>
  196. </template>
  197. <style lang="less" scoped>
  198. :deep(.custom-form-item) {
  199. margin-bottom: 22px;
  200. display: block !important;
  201. .el-form-item__content{
  202. justify-content: space-between;
  203. .el-input{
  204. .el-select{
  205. .el-select__wrapper{
  206. height: 50px!important;
  207. background-color: #fff!important;
  208. }
  209. }
  210. }
  211. }
  212. .el-form-item__label-wrap {
  213. margin-left: unset!important;
  214. .el-form-item__label {
  215. margin-bottom: 5px;
  216. font-size: 16px !important;
  217. color: #5b463e !important;
  218. }
  219. }
  220. &.custom-form-item-hidden-label {
  221. width: 270px;
  222. &:last-child {
  223. .el-form-item__label-wrap {
  224. opacity: 0;
  225. }
  226. }
  227. }
  228. }
  229. </style>