forgotPwd.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <div class="forgot-container">
  3. <h2 class="title-big">找回密码</h2>
  4. <el-form label-position="top" label-width="80px" ref="loginCodeForm" :model="loginCodeForm" class="form" :hide-required-asterisk="true" :rules="rulesCode" v-if="stepIndex===0">
  5. <el-form-item label="手机号" prop="phone">
  6. <el-input v-model="loginCodeForm.phone" autocomplete="off" placeholder="请输入完整手机号" @blur="handleTrim('loginCodeForm','phone')" maxlength="20">
  7. <template slot="prepend">+86</template>
  8. </el-input>
  9. </el-form-item>
  10. <el-form-item label="验证码" prop="code" class="code-box">
  11. <el-input v-model="loginCodeForm.code" autocomplete="off" placeholder="请输入验证码" class="code-input" @blur="handleTrim('loginCodeForm','code')" @input="handeleInput" maxlength="20">
  12. </el-input>
  13. <el-button type="primary" @click="sendCode('time','phone','verificationCodeShow')" size="small" class="sendCode" @input="handeleInput">
  14. {{ verificationCodeShow ? time+'s' : '发送验证码' }}
  15. </el-button>
  16. </el-form-item>
  17. <el-form-item class="btn-box">
  18. <el-button type="primary" @click="onSubmitPassword('loginCodeForm')" size="small" :disabled="submitDis" :loading="loading">下一步</el-button>
  19. <el-button @click="onCancel('loginCodeForm')" size="small">取消</el-button>
  20. </el-form-item>
  21. </el-form>
  22. <div v-else class="result-box">
  23. <img src="../assets/mail-check-line.png" />
  24. <p>密码已通过短信发送至您的手机中,请注意查收。</p>
  25. <div class="btn-box">
  26. <el-button type="primary" @click="onCancel('loginCodeForm')" size="small">确定</el-button>
  27. </div>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import { getLogin } from "@/api/ajax";
  33. import { setToken } from "@/utils/auth";
  34. export default {
  35. name: "forgotPwd",
  36. props: [],
  37. data() {
  38. const validatePhone = (rule, value, callback) => {
  39. if (value === '') {
  40. callback(new Error('请输入手机号'));
  41. } else {
  42. let reg = /^1[3-9]\d{9}$/;
  43. let result = reg.test(value);
  44. if (result) {
  45. callback();
  46. } else {
  47. callback(new Error('请输入正确的手机号'));
  48. }
  49. }
  50. };
  51. return {
  52. loginCodeForm:{
  53. phone:'',
  54. code:''
  55. },
  56. rulesCode:{
  57. phone:[
  58. { required: true, validator: validatePhone, trigger: 'blur' }
  59. ],
  60. code:[
  61. { required: true, message: '请输入验证码', trigger: 'blur' }
  62. ]
  63. },
  64. time: 60, //获取验证码的时间
  65. verificationCodeShow: false, //是否已经获取了验证码
  66. loading: false,
  67. timer: null,
  68. submitDis: true,
  69. stepIndex: 0
  70. };
  71. },
  72. watch: {
  73. },
  74. methods: {
  75. // 密码登录提交表单
  76. onSubmitPassword(formName){
  77. this.$refs[formName].validate((valid) => {
  78. if (valid) {
  79. this.loading = true
  80. let MethodName = "/OrgServer/LoginControl/Login";
  81. let data = null
  82. if(this.tabsIndex===0){
  83. data = {
  84. user_type:this.loginPwdForm.type,
  85. user_name:this.loginPwdForm.userName,
  86. password:this.loginPwdForm.password
  87. }
  88. }else{
  89. data = {
  90. user_type:this.loginCodeForm.type,
  91. user_name:this.loginCodeForm.phone,
  92. password:this.loginCodeForm.code,
  93. is_dynamic_verification_code_login:"true",
  94. dynamic_verification_send_type:"SMS"
  95. }
  96. }
  97. getLogin(MethodName, data)
  98. .then((res) => {
  99. this.loading = false
  100. this.stepIndex++
  101. })
  102. .catch(() => {
  103. this.loading = false
  104. this.verificationCodeShow = false;
  105. clearInterval(this.timer);
  106. this.time = 60;
  107. });
  108. } else {
  109. return false;
  110. }
  111. });
  112. },
  113. // 取消 恢复到修改前状态
  114. onCancel(formName){
  115. this.$emit('cancelFot')
  116. },
  117. // 发送验证码
  118. sendCode(time,phone,flag,obj){
  119. let this_ = this;
  120. if(this_[time] != 60){
  121. return
  122. }
  123. this_.timer = null;
  124. if (this_.loginCodeForm[phone]) {
  125. let reg = /^1[3-9]\d{9}$/;
  126. let result = reg.test(this_.loginCodeForm[phone]);
  127. if (!result) {
  128. this_.$message.warning('请输入正确的手机号');
  129. return
  130. }
  131. this_[flag] = true;
  132. this_.timer = setInterval(() => {
  133. this_[time]--;
  134. if (this_[time] == 0) {
  135. this_[flag] = false;
  136. clearInterval(this_.timer);
  137. this_.timer = null;
  138. this_[time] = 60;
  139. }
  140. }, 1000);
  141. let MethodName = "/OrgServer/LoginControl/SendVerificationCode";
  142. let data = {
  143. send_type: 'SMS',
  144. phone_or_email: this_.loginCodeForm.phone,
  145. };
  146. getLogin(MethodName, data).then((res) => {
  147. }).catch(()=>{
  148. this_[flag] = false;
  149. clearInterval(this_.timer);
  150. this_.timer = null;
  151. this_[time] = 60;
  152. });
  153. } else {
  154. this_.$message.warning('请先输入手机号');
  155. }
  156. },
  157. // 去掉前后空格
  158. handleTrim(form,fild){
  159. this[form][fild] = this[form][fild].trim()
  160. },
  161. handeleInput(){
  162. if(this.loginCodeForm.phone&&this.loginCodeForm.code){
  163. this.submitDis = false
  164. }else{
  165. this.submitDis = true
  166. }
  167. }
  168. },
  169. mounted() {
  170. },
  171. };
  172. </script>
  173. <style lang="scss" scoped>
  174. .forgot-container{
  175. background: #FFFFFF;
  176. padding: 64px 72px;
  177. .title-big{
  178. font-weight: 400;
  179. font-size: 32px;
  180. line-height: 40px;
  181. margin: 0;
  182. color: #1D2129;
  183. }
  184. .title-name{
  185. font-size: 14px;
  186. line-height: 22px;
  187. color: #86909C;
  188. margin: 0 0 40px 0;
  189. }
  190. .tabs-box{
  191. display: flex;
  192. a{
  193. font-size: 14px;
  194. line-height: 22px;
  195. color: #4E5969;
  196. border-radius: 100px;
  197. padding: 5px 16px;
  198. margin-right: 16px;
  199. &:hover{
  200. background: #F2F3F5;
  201. }
  202. &.active{
  203. background: #F2F3F5;
  204. font-weight: 500;
  205. color: #165DFF;
  206. }
  207. }
  208. }
  209. .form{
  210. margin-top: 40px;
  211. .show-icon{
  212. cursor: pointer;
  213. color: #4E5969;
  214. }
  215. .forgotPwd{
  216. font-size: 14px;
  217. line-height: 22px;
  218. color: #165DFF;
  219. }
  220. }
  221. }
  222. .result-box{
  223. text-align: center;
  224. padding-top: 46px;
  225. img{
  226. width: 64px;
  227. }
  228. p{
  229. width: 260px;
  230. color: #000;
  231. font-size: 16px;
  232. font-weight: 400;
  233. line-height: 24px;
  234. margin: 16px auto 62px auto;
  235. }
  236. .el-button{
  237. width: 100%;
  238. }
  239. }
  240. </style>
  241. <style lang="scss">
  242. .forgot-container{
  243. .form{
  244. .el-form-item__label{
  245. font-weight: 400;
  246. font-size: 14px;
  247. line-height: 22px;
  248. color: #4E5969;
  249. padding-bottom: 8px;
  250. }
  251. .userAgree-box{
  252. .el-form-item__content{
  253. display: flex;
  254. justify-content: space-between;
  255. line-height: 22px;
  256. }
  257. .el-checkbox-group{
  258. flex: 1;
  259. .el-checkbox{
  260. color: rgba(0, 0, 0, 0.88);
  261. font-weight: 400;
  262. }
  263. }
  264. }
  265. .btn-box{
  266. .el-button{
  267. width: 100%;
  268. }
  269. .el-button+.el-button{
  270. margin-left: 0;
  271. margin-top: 8px;
  272. }
  273. }
  274. .el-button--primary{
  275. background: #165DFF;
  276. border-color: #165DFF;
  277. border-radius: 2px;
  278. &:hover{
  279. background: #4080FF;
  280. border-color: #4080FF;
  281. }
  282. &:focus{
  283. background: #0E42D2;
  284. border-color: #0E42D2;
  285. }
  286. }
  287. .el-button--default{
  288. background: #F2F3F5;
  289. border-radius: 2px;
  290. border: none;
  291. color: #4E5969;
  292. &:hover{
  293. background: #E5E6EB;
  294. }
  295. &:focus{
  296. background: #C9CDD4;
  297. }
  298. }
  299. .code-box{
  300. .el-form-item__content{
  301. display: flex;
  302. }
  303. }
  304. .code-input{
  305. height: 32px;
  306. .el-input__inner{
  307. border-radius: 4px 0 0 4px;
  308. }
  309. }
  310. .sendCode{
  311. border-radius: 0 4px 4px 0;
  312. margin-top: 1px;
  313. width: 92px;
  314. flex-shrink: 0;
  315. }
  316. .el-form-item__content,.el-input__icon{
  317. line-height: 32px;
  318. color: #4E5969 !important;
  319. }
  320. .el-input__inner{
  321. height: 32px;
  322. color: #1D2129;
  323. background: #F2F3F5;
  324. border: none;
  325. }
  326. .el-textarea__inner,.el-input-group__prepend{
  327. color: #1D2129;
  328. }
  329. .el-checkbox__input.is-checked+.el-checkbox__label{
  330. color: #165DFF;
  331. }
  332. .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner{
  333. background: #165DFF;
  334. border-color: #165DFF;
  335. }
  336. .el-input-group__prepend{
  337. width: 54px;
  338. height: 32px;
  339. border: none;
  340. background: #F2F3F5;
  341. border-radius: 2px 0px 0px 2px;
  342. line-height: 32px;
  343. text-align: center;
  344. padding: 0;
  345. }
  346. .el-input-group--prepend{
  347. display: flex;
  348. .el-input__inner{
  349. margin-left: 8px;
  350. flex: 1;
  351. }
  352. }
  353. }
  354. .el-button--primary.is-disabled, .el-button--primary.is-disabled:active, .el-button--primary.is-disabled:focus, .el-button--primary.is-disabled:hover{
  355. background-color: #a0cfff;
  356. border-color: #a0cfff;
  357. }
  358. }
  359. </style>