|
@@ -122,7 +122,7 @@ import email from '/images/email.png'
|
|
|
import dui from '/images/dui.png'
|
|
|
import quan from '/images/quan.png'
|
|
|
|
|
|
-import { cloneDeep } from 'lodash-es'
|
|
|
+import { cloneDeep, get } from 'lodash-es'
|
|
|
import { UserStore } from '@/store/user'
|
|
|
const userStore = UserStore()
|
|
|
const user = computed(() => userStore.user)
|
|
@@ -178,22 +178,39 @@ const toNext = async (formEl, item) => {
|
|
|
console.log(formEl, item)
|
|
|
if (item == 0) current.value = item + 1
|
|
|
else if (item == 1) {
|
|
|
+ // 验证 验证码
|
|
|
if (!formEl) return
|
|
|
await formEl.validate(async (valid, fields) => {
|
|
|
if (valid) {
|
|
|
const data = cloneDeep(form.value)
|
|
|
- console.log(data)
|
|
|
- current.value = item + 1
|
|
|
- toClear()
|
|
|
+ data.type = select.value === '1' ? 'phone' : 'email'
|
|
|
+ data.to = data[data.type]
|
|
|
+ delete data.phone, data.email
|
|
|
+ const result = await store.pwdCheck(data)
|
|
|
+ if ($checkRes(result, null, result.errmsg)) {
|
|
|
+ current.value = item + 1
|
|
|
+ toClear()
|
|
|
+ // 将id放在form中,为后面重置密码用
|
|
|
+ const id = get(result, 'data')
|
|
|
+ console.log(id)
|
|
|
+ form.value.id = id
|
|
|
+ console.log(form)
|
|
|
+ }
|
|
|
} else {
|
|
|
console.log('error submit!', fields)
|
|
|
}
|
|
|
})
|
|
|
} else if (item == 2) {
|
|
|
+ // 重置密码
|
|
|
if (!formEl) return
|
|
|
await formEl.validate(async (valid, fields) => {
|
|
|
if (valid) {
|
|
|
const data = cloneDeep(form.value)
|
|
|
+ const result = await store.pwdReset(data)
|
|
|
+ if ($checkRes(result, '密码重置成功,请重新登录', result.errmsg)) {
|
|
|
+ current.value = item + 1
|
|
|
+ toClear()
|
|
|
+ }
|
|
|
// const res = await store.rp({
|
|
|
// type: 'User',
|
|
|
// id: user.value.id,
|
|
@@ -203,9 +220,6 @@ const toNext = async (formEl, item) => {
|
|
|
// current.value = item + 1
|
|
|
// toClear()
|
|
|
// }
|
|
|
- console.log(data)
|
|
|
- current.value = item + 1
|
|
|
- toClear()
|
|
|
} else {
|
|
|
console.log('error submit!', fields)
|
|
|
}
|
|
@@ -226,20 +240,26 @@ const verify = reactive({
|
|
|
const disabledVerify = computed(() => {
|
|
|
return !form.value.phone || verify.count <= 10
|
|
|
})
|
|
|
-const getVerifyCode = () => {
|
|
|
- ElMessage.success('验证码发送成功,请查看')
|
|
|
- verify.count--
|
|
|
- verify.buttonText = verify.count + ' 秒后重新获取验证码'
|
|
|
- timer = window.setInterval(() => {
|
|
|
- if (verify.count <= 1) {
|
|
|
- resetCount()
|
|
|
- verify.buttonText = '重新发送验证码'
|
|
|
- verify.count = 60
|
|
|
- return
|
|
|
- }
|
|
|
+const getVerifyCode = async () => {
|
|
|
+ const data = cloneDeep(form.value)
|
|
|
+ data.type = select.value === '1' ? 'phone' : 'email'
|
|
|
+ data.to = data[data.type]
|
|
|
+ delete data.phone, data.email
|
|
|
+ const result = await store.pwdCode(data)
|
|
|
+ if ($checkRes(result, '验证码发送成功,请查看', result.errmsg)) {
|
|
|
verify.count--
|
|
|
verify.buttonText = verify.count + ' 秒后重新获取验证码'
|
|
|
- }, 1000)
|
|
|
+ timer = window.setInterval(() => {
|
|
|
+ if (verify.count <= 1) {
|
|
|
+ resetCount()
|
|
|
+ verify.buttonText = '重新发送验证码'
|
|
|
+ verify.count = 60
|
|
|
+ return
|
|
|
+ }
|
|
|
+ verify.count--
|
|
|
+ verify.buttonText = verify.count + ' 秒后重新获取验证码'
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
}
|
|
|
// 清空form
|
|
|
const toClear = () => {
|