|
1 | 1 | <template> |
2 | | - <div class="pass-page"> |
3 | | - <div class="pass-mian"> |
4 | | - <input v-model.trim="mail" placeholder="请输入邮箱" class="pass-input" @change="changeInput($event)"> |
5 | | - <div class="pass-btn" @click="submit">确定</div> |
6 | | - </div> |
| 2 | + <div class="reset-pass"> |
| 3 | + <el-form ref="form" :model="form" size="medium" class="form-container"> |
| 4 | + <el-form-item label="邮箱"> |
| 5 | + <div class="input-container"> |
| 6 | + <el-input v-model="form.mail" placeholder="请输入个人邮箱"></el-input> |
| 7 | + <el-button type="primary" @click="sendEmailCode">发送验证码</el-button> |
| 8 | + </div> |
| 9 | + </el-form-item> |
| 10 | + <el-form-item label="验证码" class="code-item"> |
| 11 | + <el-input v-model="form.code" placeholder="请输入验证码"></el-input> |
| 12 | + </el-form-item> |
| 13 | + <el-form-item class="reset-item"> |
| 14 | + <el-button type="primary" @click="resetPass">重置密码</el-button> |
| 15 | + </el-form-item> |
| 16 | + </el-form> |
7 | 17 | </div> |
8 | 18 | </template> |
9 | 19 |
|
10 | 20 | <script> |
11 | | -import { emailPass } from '@/api/system/user' |
| 21 | +import { emailPass,sendCode } from '@/api/system/user' |
| 22 | +import { Message } from 'element-ui' |
12 | 23 |
|
13 | 24 | export default { |
14 | 25 | name: 'ChangePass', |
15 | 26 | data() { |
16 | 27 | return { |
17 | 28 | // 查询参数 |
18 | | - mail: '' |
| 29 | + form: { |
| 30 | + mail: "", |
| 31 | + code: "" |
| 32 | + } |
19 | 33 | } |
20 | 34 | }, |
21 | 35 | methods: { |
22 | | - // 查询 |
23 | | - changeInput(e) { |
24 | | - this.mail = e.target.value |
25 | | - }, |
26 | | - async submit() { |
27 | | - try { |
28 | | - const { msg, code } = await emailPass({ mail: this.mail }) |
29 | | - if (code === 0) { |
| 36 | + // 判断结果 |
| 37 | + judgeResult(res){ |
| 38 | + if (res.code==0){ |
30 | 39 | Message({ |
31 | 40 | showClose: true, |
32 | | - message: msg, |
| 41 | + message: "操作成功", |
33 | 42 | type: 'success' |
34 | 43 | }) |
35 | | - // 重新登录 |
36 | | - setTimeout(() => { |
37 | | - this.$router.replace({ path: '/login' }) |
38 | | - }, 1500) |
39 | | - } else { |
40 | | - Message({ |
41 | | - showClose: true, |
42 | | - message: msg, |
43 | | - type: 'error' |
44 | | - }) |
45 | | - return false |
46 | 44 | } |
47 | | - } finally {} |
48 | | - } |
| 45 | + }, |
| 46 | +
|
| 47 | + // 发送邮箱验证码 |
| 48 | + async sendEmailCode() { |
| 49 | + console.log('aaaaaaaa',this.form.mail); |
49 | 50 |
|
| 51 | + await sendCode({ mail: this.form.mail }).then(res =>{ |
| 52 | + this.judgeResult(res) |
| 53 | + }) |
| 54 | + }, |
| 55 | + // 重置密码 |
| 56 | + async resetPass() { |
| 57 | + await emailPass(this.form).then(res =>{ |
| 58 | + this.judgeResult(res) |
| 59 | + }) |
| 60 | + // 重新登录 |
| 61 | + setTimeout(() => { |
| 62 | + this.$router.replace({ path: '/login' }) |
| 63 | + }, 1500) |
| 64 | + }, |
50 | 65 | } |
51 | 66 | } |
52 | 67 | </script> |
53 | 68 |
|
54 | 69 | <style scoped lang="scss"> |
55 | | -.pass-page{ |
56 | | - .pass-mian{ |
57 | | - padding-top:25%; |
58 | | - display: flex; |
59 | | - justify-content: center; |
60 | | - align-items: center; |
61 | | - margin:0 20%; |
62 | | - .pass-input{ |
63 | | - flex: 2; |
64 | | - height: 45px; |
65 | | - line-height: 45px; |
66 | | - font-size: 18px; |
67 | | - } |
68 | | - .pass-btn{ |
69 | | - margin-left: 20px; |
70 | | - width: 15%; |
71 | | - height: 48px; |
72 | | - background: #1990FF; |
73 | | - color:#fff; |
74 | | - font-size: 18px; |
75 | | - line-height: 48px; |
76 | | - text-align: center; |
77 | | - border-radius: 20px; |
78 | | - } |
79 | | - } |
80 | | - // .container-card{ |
| 70 | +.reset-pass { |
| 71 | + display: flex; |
| 72 | + justify-content: center; |
| 73 | + align-items: center; |
| 74 | + height: 100vh; |
| 75 | +} |
| 76 | +
|
| 77 | +.form-container { |
| 78 | + width: 400px; |
| 79 | +} |
81 | 80 |
|
82 | | - // padding-top:25%; |
83 | | - // border: 0px solid #fff; |
84 | | - // box-shadow:0 0px 0px; |
85 | | - // border-bottom: 0; |
86 | | - // .demo-form-inline{ |
87 | | - // display: flex; |
88 | | - // .from-items{ |
89 | | - // text-align: center; |
90 | | - // } |
91 | | - // } |
| 81 | +.input-container { |
| 82 | + display: flex; |
| 83 | + align-items: center; |
| 84 | + justify-content: space-between; |
| 85 | +} |
| 86 | +.input-container .el-input { |
| 87 | + flex: 1; |
| 88 | + margin-right: 10px; |
| 89 | +} |
| 90 | +
|
| 91 | +.code-item .el-form-item__label { |
| 92 | + width: 80px; |
| 93 | +} |
| 94 | +.code-item .el-input { |
| 95 | + width: 345px; |
| 96 | +} |
92 | 97 |
|
93 | | - // } |
| 98 | +.reset-item { |
| 99 | + text-align: right; |
94 | 100 | } |
95 | 101 | </style> |
0 commit comments