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