aaa
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
import ShoppingDrawer from '@/views/shopping-drawer.vue'
|
||||
const globalStore = useGlobalStore()
|
||||
const loading = computed(() => globalStore.state.loading)
|
||||
globalStore.setLoading(false)
|
||||
const viewRef = ref()
|
||||
const viewStyle = ref({
|
||||
'--app-view-width': '',
|
||||
|
||||
@@ -60,3 +60,40 @@ export const AccountSendVerifyCode = (data) => {
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 忘记密码:重置密码
|
||||
* @param data - 包含邮箱的参数
|
||||
* @param data.email - 邮箱
|
||||
* @param data.password - 密码
|
||||
* @param data.emailVerifyCode - 验证码
|
||||
*/
|
||||
export const AccountResetPassword = (data) => {
|
||||
return request({
|
||||
url: '/buyer/account/resetPassword',
|
||||
method: 'post',
|
||||
data,
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 通用验证码校验
|
||||
* @param data - 包含邮箱的参数
|
||||
* @param data.email - 邮箱
|
||||
* @param data.emailVerifyCode - 验证码
|
||||
* @param data.operationType - 操作类型:FORGET_PWD, BIND_MAILBOX
|
||||
*/
|
||||
export const AccountVerifyCode = (data) => {
|
||||
return request({
|
||||
url: '/buyer/account/verifyCode',
|
||||
method: 'post',
|
||||
data,
|
||||
loading: true
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更邮箱:发送新邮箱验证码
|
||||
* @param data - 包含邮箱的参数
|
||||
* @param data.email - 邮箱
|
||||
* @param data.operationType - 操作类型:BIND_MAILBOX
|
||||
*/
|
||||
|
||||
@@ -76,8 +76,9 @@ service.interceptors.response.use(
|
||||
// 处理异常的情况
|
||||
// console.log(res)
|
||||
if (res.errCode != 0) {
|
||||
ElMessage.error(res.message)
|
||||
return Promise.reject(new Error(res.errMsg || res.message || 'error'))
|
||||
let msg = res.errMsg || res.message || 'error'
|
||||
ElMessage.error(msg)
|
||||
return Promise.reject(new Error(msg))
|
||||
} else {
|
||||
// 默认只返回data,不返回状态码和message
|
||||
// 通过 meta 中的 responseAll 配置来取决后台是否返回所有数据(包括状态码,message和data)
|
||||
@@ -109,8 +110,7 @@ service.interceptors.response.use(
|
||||
message: 'Please log in and try again.',
|
||||
duration: 5000
|
||||
})
|
||||
router.push('/login')
|
||||
useUserInfoStore().logOut(false)
|
||||
useUserInfoStore().logout()
|
||||
return Promise.reject(false)
|
||||
}
|
||||
error.config && removePending(error.config)
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { AccountSendVerifyCode, AccountVerifyCode, AccountResetPassword } from '@/api/account'
|
||||
import md5 from 'md5'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import { validateEmail, validatePass } from './tools'
|
||||
@@ -103,22 +104,12 @@
|
||||
const onSubmit1 = () => {
|
||||
form1Ref.value?.validate?.((valid) => {
|
||||
if (valid) {
|
||||
index.value = 1
|
||||
} else {
|
||||
console.warn('error submit!')
|
||||
}
|
||||
})
|
||||
}
|
||||
const onSubmit2 = () => {
|
||||
form2Ref.value?.validate?.((valid) => {
|
||||
if (valid) {
|
||||
const data = {
|
||||
AccountSendVerifyCode({
|
||||
email: formData.email,
|
||||
code: formData.code,
|
||||
password: md5(formData.password)
|
||||
}
|
||||
console.log(data)
|
||||
emit('back')
|
||||
operationType: 'FORGOT_PWD'
|
||||
}).then(() => {
|
||||
index.value = 1
|
||||
})
|
||||
} else {
|
||||
console.warn('error submit!')
|
||||
}
|
||||
@@ -126,8 +117,30 @@
|
||||
}
|
||||
const onVerifyCode = (code: string) => {
|
||||
if (!code) return
|
||||
formData.code = code
|
||||
index.value = 2
|
||||
AccountVerifyCode({
|
||||
email: formData.email,
|
||||
emailVerifyCode: code,
|
||||
operationType: 'FORGOT_PWD'
|
||||
}).then(() => {
|
||||
formData.code = code
|
||||
index.value = 2
|
||||
})
|
||||
}
|
||||
const onSubmit2 = () => {
|
||||
form2Ref.value?.validate?.((valid) => {
|
||||
if (valid) {
|
||||
const data = {
|
||||
email: formData.email,
|
||||
password: md5(formData.password),
|
||||
emailVerifyCode: formData.code
|
||||
}
|
||||
AccountResetPassword(data).then(() => {
|
||||
emit('back')
|
||||
})
|
||||
} else {
|
||||
console.warn('error submit!')
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import img from '@/assets/images/brand-null.png'
|
||||
let data = reactive({
|
||||
})
|
||||
const router = useRouter()
|
||||
const isShoppingShow = ref(true)
|
||||
const isShoppingShow = ref(false)
|
||||
const shoppingClose = () => {
|
||||
isShoppingShow.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user