forget.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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 ref="loginForm" :model="loginForm" :rules="LoginRules" class="login-form">
  12. <el-form-item prop="mobile">
  13. <el-input v-model="loginForm.mobile" type="text" auto-complete="off" placeholder="请输入手机号">
  14. </el-input>
  15. </el-form-item>
  16. <el-form-item prop="mobileCode">
  17. <el-input v-model="loginForm.mobileCode" type="text" auto-complete="off" placeholder="短信验证码"
  18. class="sms-login-mobile-code-prefix"
  19. @keyup.enter.native="handleLogin">
  20. <template>
  21. </template>
  22. <template slot="append">
  23. <span v-if="mobileCodeTimer <= 0" class="getMobileCode" @click="getSmsCode" style="cursor: pointer;">获取验证码</span>
  24. <span v-if="mobileCodeTimer > 0" class="getMobileCode">{{ mobileCodeTimer }}秒后可重新获取</span>
  25. </template>
  26. </el-input>
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button :loading="loading" size="medium" type="primary" style="width:100%;"
  30. @click.native.prevent="submitForm('loginForm')">
  31. <span v-if="!loading">重置密码</span>
  32. <span v-else>操 作 中...</span>
  33. </el-button>
  34. <el-button style="margin-left: 0;margin-top: 10px;width: 100%;" type="text" @click="backLogin()">返回登录</el-button>
  35. </el-form-item>
  36. </el-form>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import { sendSmsCode } from "@/api/login";
  45. export default {
  46. data() {
  47. return {
  48. mobileCodeTimer: 0,
  49. loginForm: {
  50. mobile: "",
  51. mobileCode: "",
  52. },
  53. LoginRules: {
  54. mobile: [
  55. {required: true, trigger: "blur", message: "手机号不能为空"},
  56. {
  57. validator: function (rule, value, callback) {
  58. if (/^(?:(?:\+|00)86)?1(?:3[\d]|4[5-79]|5[0-35-9]|6[5-7]|7[0-8]|8[\d]|9[189])\d{8}$/.test(value) === false) {
  59. callback(new Error("手机号格式错误"));
  60. } else {
  61. callback();
  62. }
  63. }, trigger: "blur"
  64. }
  65. ]
  66. },
  67. scene: 4,
  68. loading: false,
  69. };
  70. },
  71. methods: {
  72. backLogin(){
  73. this.$router.push({path: '/login'})
  74. },
  75. /** ========== 以下为升级短信登录 ========== */
  76. getSmsCode() {
  77. if (this.mobileCodeTimer > 0) return;
  78. this.$refs.loginForm.validate(valid => {
  79. if (!valid) return;
  80. sendSmsCode(this.loginForm.mobile, this.scene ).then(res => {
  81. this.$modal.msgSuccess("获取验证码成功")
  82. this.mobileCodeTimer = 60;
  83. let msgTimer = setInterval(() => {
  84. this.mobileCodeTimer = this.mobileCodeTimer - 1;
  85. if (this.mobileCodeTimer <= 0) {
  86. clearInterval(msgTimer);
  87. }
  88. }, 1000);
  89. });
  90. });
  91. },
  92. submitForm(formName) {
  93. this.$refs[formName].validate((valid) => {
  94. if (valid) {
  95. this.loading = true;
  96. // 发起登陆
  97. // console.log("发起登录", this.loginForm);
  98. this.$store.dispatch("SmsResetPassword", this.loginForm).then(() => {
  99. this.$router.push({ path: "/password/reset" }).catch(() => {
  100. });
  101. }).catch(() => {
  102. this.loading = false;
  103. });
  104. }
  105. });
  106. },
  107. }
  108. };
  109. </script>
  110. <style lang="scss" scoped>
  111. .fx-account-layout {
  112. background: #f5f6f8;
  113. bottom: 0;
  114. left: 0;
  115. min-height: 500px;
  116. position: absolute;
  117. right: 0;
  118. top: 0;
  119. }
  120. .fx-account-layout .account-logo {
  121. left: 60px;
  122. position: absolute;
  123. top: 40px;
  124. }
  125. a {
  126. outline: none;
  127. text-decoration: none;
  128. }
  129. .fx-account-layout .account-logo>img.official-logo {
  130. height: 24px;
  131. }
  132. .fx-account-layout .account-logo>img {
  133. display: block;
  134. max-height: 200px;
  135. max-width: 200px;
  136. }
  137. img {
  138. border: 0;
  139. outline: none;
  140. }
  141. .fx-account-layout .account-pane-container {
  142. height: 100%;
  143. width: 100%;
  144. }
  145. .fx-account-layout .account-pane, .fx-account-layout .signin-container-banner {
  146. -webkit-box-align: center;
  147. -webkit-box-pack: center;
  148. align-items: center;
  149. display: flex;
  150. height: 100%;
  151. justify-content: center;
  152. }
  153. .fx-account-layout .account-pane {
  154. -ms-flex-align: center;
  155. -ms-flex-pack: center;
  156. width: 100%;
  157. }
  158. .fx-account-layout .account-pane-container.hide-banner .account-container {
  159. -webkit-box-flex: 0;
  160. display: block;
  161. -ms-flex: none;
  162. flex: none;
  163. }
  164. .jdy-page-password-forget .password-forget-container {
  165. padding: 0;
  166. width: 320px;
  167. }
  168. .fx-account-layout .account-container {
  169. align-items: center;
  170. background: #fff;
  171. display: flex;
  172. -ms-flex: 0.42;
  173. flex: 0.42;
  174. justify-content: center;
  175. position: relative;
  176. }
  177. .jdy-page-password-forget .password-forget-container .account-header {
  178. border-bottom: 1px solid #ebecee;
  179. color: #141e31;
  180. font-size: 16px;
  181. font-weight: 500;
  182. height: 60px;
  183. line-height: 60px;
  184. text-align: center;
  185. }
  186. .jdy-page-password-forget .password-forget-container .account-content {
  187. padding: 15px 40px 20px;
  188. }
  189. </style>