password.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <div class="page">
  3. <div class="page-content">
  4. <el-form :model="formData" :rules="rules" label-position="top">
  5. <el-form-item label="手机号" prop="mobile">
  6. <el-input
  7. placeholder="请输入手机号"
  8. maxlength="11"
  9. v-model="formData.mobile"
  10. ></el-input>
  11. </el-form-item>
  12. <el-form-item label="验证码" prop="verifyCode">
  13. <div class="verify-code">
  14. <el-input
  15. placeholder="请输入验证码"
  16. maxlength="6"
  17. v-model="formData.verifyCode"
  18. ></el-input>
  19. <div class="send">获取验证码</div>
  20. </div>
  21. </el-form-item>
  22. <el-form-item label="新密码" prop="password">
  23. <el-input
  24. type="password"
  25. placeholder="请输入新密码"
  26. v-model="formData.password"
  27. ></el-input>
  28. </el-form-item>
  29. <el-form-item label="确认密码" prop="confirmPwd">
  30. <el-input
  31. type="password"
  32. placeholder="请输入确认密码"
  33. v-model="formData.confirmPwd"
  34. ></el-input>
  35. </el-form-item>
  36. </el-form>
  37. <div class="submit-button">
  38. <div class="back btn">返回</div>
  39. <div class="submit btn">提交</div>
  40. </div>
  41. </div>
  42. </div>
  43. </template>
  44. <script>
  45. import { validPassword } from '~/utils/validator'
  46. export default {
  47. layout: 'app-ross',
  48. data() {
  49. const passwordValidate = (rule, value, callback) => {
  50. console.log(value)
  51. if (validPassword(value)) {
  52. callback()
  53. } else {
  54. callback(new Error('密码只能包含英文大小写和数字'))
  55. }
  56. }
  57. const confirmPwdValide = (rule, value, callback) => {
  58. if (this.formData.password !== value) {
  59. callback(new Error('两次输入的密码不一致'))
  60. } else {
  61. callback()
  62. }
  63. }
  64. return {
  65. formData: {
  66. mobile: '',
  67. verifyCode: '',
  68. password: '',
  69. confirmPwd: '',
  70. },
  71. rules: {
  72. mobile: [
  73. { required: true, message: '请输入手机号', trigger: ['blur'] },
  74. ],
  75. verifyCode: [
  76. { required: true, message: '请输入验证码', trigger: ['blur'] },
  77. ],
  78. password: [
  79. { required: true, message: '请输入新密码', trigger: ['blur'] },
  80. { min: 6, message: '密码长度不能小于6位', trigger: ['blur'] },
  81. { validator: passwordValidate, trigger: ['blur'] },
  82. ],
  83. confirmPwd: [
  84. { required: true, message: '请输入确认密码', trigger: ['blur'] },
  85. { validator: confirmPwdValide, trigger: ['blur'] },
  86. ],
  87. },
  88. }
  89. },
  90. }
  91. </script>
  92. <style lang="scss" scoped>
  93. @media screen and (min-width: 768px) {
  94. .page {
  95. position: relative;
  96. min-height: calc(100vh - 80px - 80px);
  97. background-color: #fff;
  98. overflow: hidden;
  99. }
  100. .page-content {
  101. width: 518px;
  102. margin: 0 auto;
  103. margin-top: 100px;
  104. .verify-code {
  105. width: 100%;
  106. display: flex;
  107. align-items: center;
  108. .send {
  109. flex-shrink: 0;
  110. margin-left: 16px;
  111. height: 40px;
  112. text-align: center;
  113. line-height: 40px;
  114. width: 118px;
  115. background: #f3920d;
  116. border-radius: 4px;
  117. font-size: 16px;
  118. color: #fff;
  119. cursor: pointer;
  120. }
  121. }
  122. .submit-button {
  123. display: flex;
  124. align-items: center;
  125. justify-content: center;
  126. margin-top: 32px;
  127. .btn {
  128. text-align: center;
  129. width: 118px;
  130. height: 40px;
  131. border-radius: 4px;
  132. font-size: 16px;
  133. cursor: pointer;
  134. box-sizing: border-box;
  135. margin: 0 16px;
  136. &.back {
  137. border: 1px solid #f3920d;
  138. color: #f3920d;
  139. line-height: 38px;
  140. }
  141. &.submit {
  142. background: #f3920d;
  143. color: #fff;
  144. line-height: 40px;
  145. }
  146. }
  147. }
  148. }
  149. }
  150. @media screen and (max-width: 768px) {
  151. .page-content {
  152. padding: 10vw 4vw 0;
  153. .verify-code {
  154. width: 100%;
  155. display: flex;
  156. align-items: center;
  157. .send {
  158. flex-shrink: 0;
  159. margin-left: 2.4vw;
  160. height: 40px;
  161. text-align: center;
  162. line-height: 40px;
  163. width: 24.2vw;
  164. background: #f3920d;
  165. border-radius: 0.4vw;
  166. font-size: 3.4vw;
  167. color: #fff;
  168. cursor: pointer;
  169. }
  170. }
  171. .submit-button {
  172. margin-top: 20vw;
  173. .btn {
  174. text-align: center;
  175. height: 40px;
  176. border-radius: 0.4vw;
  177. font-size: 3.4vw;
  178. cursor: pointer;
  179. box-sizing: border-box;
  180. margin-bottom: 3.2vw;
  181. &.back {
  182. border: 1px solid #f3920d;
  183. color: #f3920d;
  184. line-height: 38px;
  185. }
  186. &.submit {
  187. background: #f3920d;
  188. color: #fff;
  189. line-height: 40px;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. </style>