|
@@ -0,0 +1,163 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="components MainPageContainer flex-v">
|
|
3
|
+
|
|
4
|
+ <!-- 头部 -->
|
|
5
|
+ <div class="MainHeaderPadding"></div>
|
|
6
|
+ <div class="MainHeader flex-h">
|
|
7
|
+ <a class="MainBack iconfont iconjiantouleft" @click="$router.back(-1)"></a>
|
|
8
|
+ <span class="MainTitle">
|
|
9
|
+ <span>找回密码</span>
|
|
10
|
+ </span>
|
|
11
|
+ </div>
|
|
12
|
+
|
|
13
|
+ <!-- 内容 -->
|
|
14
|
+ <div class="MainBody flex-item">
|
|
15
|
+ <div>
|
|
16
|
+ <div class="Form">
|
|
17
|
+ <div class="flex-h">
|
|
18
|
+ <span>手机号</span>
|
|
19
|
+ <div class="flex-item">
|
|
20
|
+ <input type="text" v-model="Phone" placeholder="请输入绑定手机号">
|
|
21
|
+ </div>
|
|
22
|
+ </div>
|
|
23
|
+ <div class="flex-h">
|
|
24
|
+ <span>验证码</span>
|
|
25
|
+ <div class="flex-item">
|
|
26
|
+ <input type="number" v-model="Code" placeholder="请输入手机验证码">
|
|
27
|
+ </div>
|
|
28
|
+ <a :class="{'active': Sec === 60}" @click="ToGetCode">{{Sec === 60 ? '获取验证码' : `${Sec > 9 ? Sec : `0${Sec}`}s后再次获取`}}</a>
|
|
29
|
+ </div>
|
|
30
|
+ <div class="flex-h">
|
|
31
|
+ <span>新密码</span>
|
|
32
|
+ <div class="flex-item">
|
|
33
|
+ <input type="password" v-model="Password" placeholder="请输入新密码">
|
|
34
|
+ </div>
|
|
35
|
+ </div>
|
|
36
|
+ <div class="flex-h">
|
|
37
|
+ <span>确认新密码</span>
|
|
38
|
+ <div class="flex-item">
|
|
39
|
+ <input type="password" v-model="PasswordAgain" placeholder="请再次输入新密码">
|
|
40
|
+ </div>
|
|
41
|
+ </div>
|
|
42
|
+ <div class="Btn">
|
|
43
|
+ <a @click="ToResetPassword">确认</a>
|
|
44
|
+ </div>
|
|
45
|
+ </div>
|
|
46
|
+ </div>
|
|
47
|
+ </div>
|
|
48
|
+
|
|
49
|
+ </div>
|
|
50
|
+</template>
|
|
51
|
+
|
|
52
|
+<script>
|
|
53
|
+import { createNamespacedHelpers } from 'vuex'
|
|
54
|
+const { mapActions: mapUserActions } = createNamespacedHelpers('user')
|
|
55
|
+export default {
|
|
56
|
+ name: '',
|
|
57
|
+ data () {
|
|
58
|
+ return {
|
|
59
|
+ Phone: '',
|
|
60
|
+ Code: '',
|
|
61
|
+ Password: '',
|
|
62
|
+ PasswordAgain: '',
|
|
63
|
+ DataLock: false,
|
|
64
|
+ Timer: null,
|
|
65
|
+ Sec: 60
|
|
66
|
+ }
|
|
67
|
+ },
|
|
68
|
+ computed: {
|
|
69
|
+ },
|
|
70
|
+ components: {
|
|
71
|
+ },
|
|
72
|
+ created () {
|
|
73
|
+ },
|
|
74
|
+ mounted () {
|
|
75
|
+ this.$nextTick(() => {
|
|
76
|
+ })
|
|
77
|
+ },
|
|
78
|
+ methods: {
|
|
79
|
+ ...mapUserActions([
|
|
80
|
+ 'GetRegPhoneCode',
|
|
81
|
+ 'CheckRegPhoneCode',
|
|
82
|
+ 'ResetPassword'
|
|
83
|
+ ]),
|
|
84
|
+ Init () {
|
|
85
|
+ },
|
|
86
|
+ ToResetPassword () {
|
|
87
|
+ if (!this.IsPhone(this.Phone)) {
|
|
88
|
+ this.Toast('手机号格式错误')
|
|
89
|
+ return false
|
|
90
|
+ }
|
|
91
|
+ if (!this.IsPhone(this.Code === '')) {
|
|
92
|
+ this.Toast('请输入验证码')
|
|
93
|
+ return false
|
|
94
|
+ }
|
|
95
|
+ if (!this.IsPhone(this.Password === '')) {
|
|
96
|
+ this.Toast('请输入新密码')
|
|
97
|
+ return false
|
|
98
|
+ }
|
|
99
|
+ if (!this.IsPhone(this.PasswordAgain === '')) {
|
|
100
|
+ this.Toast('请确认新密码')
|
|
101
|
+ return false
|
|
102
|
+ }
|
|
103
|
+ if (!this.IsPhone(this.Password !== this.PasswordAgain)) {
|
|
104
|
+ this.Toast('两次密码输入不一致')
|
|
105
|
+ return false
|
|
106
|
+ }
|
|
107
|
+ if (this.DataLock) return
|
|
108
|
+ this.DataLock = true
|
|
109
|
+ this.ResetPassword({
|
|
110
|
+ data: {
|
|
111
|
+ captcha: this.Code,
|
|
112
|
+ password: this.Password,
|
|
113
|
+ phone: this.Phone
|
|
114
|
+ }
|
|
115
|
+ }).then(() => {
|
|
116
|
+ this.Toast('密码重置成功')
|
|
117
|
+ this.DataLock = false
|
|
118
|
+ window.setTimeout(() => {
|
|
119
|
+ this.$router.go(-1)
|
|
120
|
+ }, 1000)
|
|
121
|
+ }).catch((res) => {
|
|
122
|
+ this.Toast(res.data.message)
|
|
123
|
+ this.DataLock = false
|
|
124
|
+ })
|
|
125
|
+ },
|
|
126
|
+ IsPhone (str) { // 校验手机号
|
|
127
|
+ let myreg = /^[1][3,4,5,7,8][0-9]{9}$/
|
|
128
|
+ return !!myreg.test(str)
|
|
129
|
+ },
|
|
130
|
+ ToGetCode () {
|
|
131
|
+ if (!this.IsPhone(this.Phone)) {
|
|
132
|
+ this.Toast('手机号格式错误')
|
|
133
|
+ return false
|
|
134
|
+ }
|
|
135
|
+ if (this.Sec === 60 && !this.DataLock) {
|
|
136
|
+ this.DataLock = true
|
|
137
|
+ this.GetRegPhoneCode({ urlData: { phone: this.Phone } }).then(() => {
|
|
138
|
+ this.Toast('验证码已发送')
|
|
139
|
+ this.DataLock = false
|
|
140
|
+ window.clearInterval(this.Timer)
|
|
141
|
+ this.Sec -= 1
|
|
142
|
+ this.Timer = window.setInterval(() => {
|
|
143
|
+ if (this.Sec) {
|
|
144
|
+ this.Sec -= 1
|
|
145
|
+ } else {
|
|
146
|
+ this.Sec = 60
|
|
147
|
+ window.clearInterval(this.Timer)
|
|
148
|
+ }
|
|
149
|
+ }, 1000)
|
|
150
|
+ }).catch((res) => {
|
|
151
|
+ this.Toast(res.data.message)
|
|
152
|
+ this.DataLock = false
|
|
153
|
+ })
|
|
154
|
+ }
|
|
155
|
+ }
|
|
156
|
+ }
|
|
157
|
+}
|
|
158
|
+</script>
|
|
159
|
+
|
|
160
|
+<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
161
|
+<style lang="scss" scoped>
|
|
162
|
+@import "page.scss";
|
|
163
|
+</style>
|