reset.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <div class="fx-account-layout jdy-page-password-forget">
  3. <!-- <a class="account-logo" href="/">
  4. <img class="official-logo" src="https://g.jdycdn.com/shared/images/logo/logo_text.png" alt="">
  5. </a> -->
  6. <div class="account-pane-container hide-banner">
  7. <div class="account-pane">
  8. <div class="account-container password-forget-container">
  9. <div class="account-header">重置密码</div>
  10. <div class="account-content">
  11. <el-form v-if="!resetStatus" ref="ruleForm" :model="ruleForm" :rules="rules" class="login-form">
  12. <el-form-item prop="pass">
  13. <el-input type="password" show-password v-model="ruleForm.pass" placeholder="密码">
  14. </el-input>
  15. </el-form-item>
  16. <el-form-item prop="checkPass" style="margin-top: 35px;">
  17. <el-input type="password" show-password v-model="ruleForm.checkPass" placeholder="确认密码">
  18. </el-input>
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button size="medium" type="primary" style="width:100%;"
  22. @click="submitForm('ruleForm')">
  23. 确定
  24. </el-button>
  25. <!-- <el-button style="margin-left: 0;margin-top: 10px;width: 100%;" type="text" @click="backLogin()">返回登录</el-button> -->
  26. </el-form-item>
  27. </el-form>
  28. <div class="success-box" v-else>
  29. <div class="success-box-content">
  30. <svg-icon class="success-icon" icon-class="success" />
  31. <div class="success-box-content-text">
  32. <span class="success-text">密码重置成功</span>
  33. <el-button class="success-btn" type="text" @click="backLogin()">立即登录</el-button>
  34. </div>
  35. </div>
  36. <div class="success-box-footer">
  37. {{ numberTimer }}秒后自动跳转登录页
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. import { updatePassword } from "@/api/login";
  48. export default {
  49. data() {
  50. var validatePass = (rule, value, callback) => {
  51. //必须包含大小写字母、数字、特殊字符长度再9-16位之间
  52. var regex = new RegExp("(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{9,30}");
  53. if (value === "") {
  54. callback(new Error("请输入密码"));
  55. } else if (value.length < 9 || value.length > 30) {
  56. callback(new Error("请输入9~30位密码"));
  57. } else if (!regex.test(value)) {
  58. callback(new Error("密码必须同时包含字母、数字和特殊字符其中三项且至少9位"));
  59. } else {
  60. if (this.ruleForm.checkPass !== '') {
  61. this.$refs.ruleForm.validateField('checkPass');
  62. }
  63. callback();
  64. }
  65. };
  66. var validatePass2 = (rule, value, callback) => {
  67. if (value === '') {
  68. callback(new Error('请再次输入密码'));
  69. } else if (value !== this.ruleForm.pass) {
  70. callback(new Error('两次输入密码不一致!'));
  71. } else {
  72. callback();
  73. }
  74. };
  75. return {
  76. resetStatus: false,
  77. numberTimer: 3,
  78. countdown: 3,
  79. ruleForm: {
  80. pass: '',
  81. checkPass: '',
  82. },
  83. rules: {
  84. pass: [
  85. { validator: validatePass, trigger: 'blur' }
  86. ],
  87. checkPass: [
  88. { validator: validatePass2, trigger: 'blur' }
  89. ],
  90. },
  91. };
  92. },
  93. methods: {
  94. myTimer() {
  95. let msgTimer = setInterval(() => {
  96. this.numberTimer = this.numberTimer - 1;
  97. if (this.numberTimer <= 0) {
  98. clearInterval(msgTimer);
  99. this.$router.push({ path: '/login' })
  100. }
  101. }, 1000);
  102. },
  103. backLogin() {
  104. this.$router.push({ path: '/login' })
  105. },
  106. submitForm(formName) {
  107. this.$refs[formName].validate((valid) => {
  108. if (valid) {
  109. updatePassword(this.ruleForm.pass, this.ruleForm.checkPass ).then(res => {
  110. this.resetStatus = true;
  111. this.myTimer();
  112. });
  113. } else {
  114. console.log('error submit!!');
  115. return false;
  116. }
  117. });
  118. },
  119. }
  120. };
  121. </script>
  122. <style lang="scss" scoped>
  123. .success-box {
  124. .success-box-content {
  125. display: flex;
  126. flex-direction: column;
  127. justify-content: center;
  128. align-items: center;
  129. .success-icon {
  130. font-size: 80px;
  131. color: #67C23A;
  132. }
  133. .success-box-content-text {
  134. display: flex;
  135. flex-direction: column;
  136. justify-content: center;
  137. align-items: center;
  138. .success-text {
  139. font-size: 24px;
  140. color: #303133;
  141. margin: 20px 0;
  142. }
  143. .success-btn {
  144. font-size: 16px;
  145. color: #409EFF
  146. }
  147. }
  148. }
  149. .success-box-footer {
  150. text-align: center;
  151. font-size: 16px;
  152. color: gray;
  153. }
  154. }
  155. .fx-account-layout {
  156. background: #f5f6f8;
  157. bottom: 0;
  158. left: 0;
  159. min-height: 500px;
  160. position: absolute;
  161. right: 0;
  162. top: 0;
  163. }
  164. .fx-account-layout .account-logo {
  165. left: 60px;
  166. position: absolute;
  167. top: 40px;
  168. }
  169. a {
  170. outline: none;
  171. text-decoration: none;
  172. }
  173. .fx-account-layout .account-logo>img.official-logo {
  174. height: 24px;
  175. }
  176. .fx-account-layout .account-logo>img {
  177. display: block;
  178. max-height: 200px;
  179. max-width: 200px;
  180. }
  181. img {
  182. border: 0;
  183. outline: none;
  184. }
  185. .fx-account-layout .account-pane-container {
  186. height: 100%;
  187. width: 100%;
  188. }
  189. .fx-account-layout .account-pane,
  190. .fx-account-layout .signin-container-banner {
  191. -webkit-box-align: center;
  192. -webkit-box-pack: center;
  193. align-items: center;
  194. display: flex;
  195. height: 100%;
  196. justify-content: center;
  197. }
  198. .fx-account-layout .account-pane {
  199. -ms-flex-align: center;
  200. -ms-flex-pack: center;
  201. width: 100%;
  202. }
  203. .fx-account-layout .account-pane-container.hide-banner .account-container {
  204. -webkit-box-flex: 0;
  205. display: block;
  206. -ms-flex: none;
  207. flex: none;
  208. }
  209. .jdy-page-password-forget .password-forget-container {
  210. padding: 0;
  211. width: 320px;
  212. }
  213. .fx-account-layout .account-container {
  214. align-items: center;
  215. background: #fff;
  216. display: flex;
  217. -ms-flex: 0.42;
  218. flex: 0.42;
  219. justify-content: center;
  220. position: relative;
  221. }
  222. .jdy-page-password-forget .password-forget-container .account-header {
  223. border-bottom: 1px solid #ebecee;
  224. color: #141e31;
  225. font-size: 16px;
  226. font-weight: 500;
  227. height: 60px;
  228. line-height: 60px;
  229. text-align: center;
  230. }
  231. .jdy-page-password-forget .password-forget-container .account-content {
  232. padding: 15px 40px 20px;
  233. }
  234. </style>