Skip to content

Commit

Permalink
feat: 新增修改手机号、修改邮箱、修改密码、修改基本信息
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Apr 27, 2024
1 parent 136f07c commit 99498a3
Show file tree
Hide file tree
Showing 14 changed files with 393 additions and 187 deletions.
1 change: 1 addition & 0 deletions src/apis/auth/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface UserInfo {
email: string
phone: string
avatar: string
pwdResetTime: string
registrationDate: string
deptName: string
roles: string[]
Expand Down
4 changes: 2 additions & 2 deletions src/apis/system/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ export * from './user'
export * from './role'
export * from './menu'
export * from './dept'
export * from '../monitor/log'
export * from './announcement'
export * from './dict'
export * from './file'
export * from './storage'
export * from './option'
export * from './announcement'
export * from './user-center'
39 changes: 39 additions & 0 deletions src/apis/system/user-center.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import http from '@/utils/http'
import type * as System from '@/apis/system/type'

const BASE_URL = '/system/user'

/** @desc 修改用户基本信息 */
export function updateUserBaseInfo(data: { nickname: string; gender: number }) {
return http.patch(`${BASE_URL}/basic/info`, data)
}

/** @desc 修改密码 */
export function updateUserPassword(data: { oldPassword: string; newPassword: string }) {
return http.patch(`${BASE_URL}/password`, data)
}

/** @desc 修改手机号 */
export function updateUserPhone(data: { newPhone: string; captcha: string; currentPassword: string }) {
return http.patch(`${BASE_URL}/phone`, data)
}

/** @desc 修改邮箱 */
export function updateUserEmail(data: { newEmail: string; captcha: string; currentPassword: string }) {
return http.patch(`${BASE_URL}/email`, data)
}

/** @desc 获取绑定的三方账号 */
export function listUserSocial() {
return http.get<System.BindSocialAccountRes[]>(`${BASE_URL}/social`)
}

/** @desc 绑定三方账号 */
export function bindSocialAccount(source: string, data: any) {
return http.post(`${BASE_URL}/social/${source}`, data)
}

/** @desc 解绑三方账号 */
export function unbindSocialAccount(source: string) {
return http.del(`${BASE_URL}/social/${source}`)
}
22 changes: 0 additions & 22 deletions src/apis/system/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,3 @@ export function exportUser(query: System.UserQuery) {
export function resetUserPwd(data: any, id: string) {
return http.patch(`${BASE_URL}/${id}/password`, data)
}

/** @desc 修改用户基础信息 */
export function updateUserBaseInfo(data: { nickname?: string; gender?: number }) {
return http.patch(`${BASE_URL}/basic/info`, data)
}

/** @desc 修改邮箱 */
export function updateUserEmail(data: { newEmail: string; captcha: string; currentPassword: string }) {
return http.patch(`${BASE_URL}/email`, data)
}
/**@desc 绑定三方账号 */
export function bindSocialAccount(source: string, data: any) {
return http.post(`${BASE_URL}/social/${source}`, data)
}
/**@desc 获取绑定的三方账号 */
export function getSocialAccount() {
return http.get<System.BindSocialAccountRes[]>(`${BASE_URL}/social`)
}
/**@desc 解绑三方账号 */
export function unbindSocialAccount(source: string) {
return http.del(`${BASE_URL}/social/${source}`)
}
1 change: 1 addition & 0 deletions src/stores/modules/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const storeSetup = () => {
email: '',
phone: '',
avatar: '',
pwdResetTime: '',
registrationDate: '',
deptName: '',
roles: [],
Expand Down
6 changes: 6 additions & 0 deletions src/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@
.btn {
height: 28px;
width: 56px;
&:hover {
-webkit-box-shadow: 0 2px 3px rgba(0, 0, 0, .15);
box-shadow: 0 2px 3px rgba(0, 0, 0, .15);
border-color: rgb(var(--primary-5));
color: var(--color-text-2);
}
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/views/login/components/email/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ const handleLogin = async () => {
}
}
const captchaTime = ref(60)
const captchaTimer = ref()
const captchaTime = ref(60)
const captchaBtnName = ref('获取验证码')
const captchaDisable = ref(false)
// 重置验证码
const resetCaptcha = () => {
window.clearInterval(captchaTimer.value)
Expand All @@ -84,15 +86,13 @@ const resetCaptcha = () => {
captchaDisable.value = false
}
const captchaBtnName = ref('获取验证码')
const captchaLoading = ref(false)
const captchaDisable = ref(false)
// 获取验证码
const onCaptcha = async () => {
if (captchaLoading.value) return
const isInvalid = await formRef.value?.validateField('email')
if (isInvalid) return
try {
if (captchaLoading.value) return
const isInvalid = await formRef.value?.validateField('email')
if (isInvalid) return
captchaLoading.value = true
captchaBtnName.value = '发送中...'
// await getEmailCaptcha({
Expand Down
12 changes: 6 additions & 6 deletions src/views/login/components/phone/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ const handleLogin = async () => {
}
}
const captchaTime = ref(60)
const captchaTimer = ref()
const captchaTime = ref(60)
const captchaBtnName = ref('获取验证码')
const captchaDisable = ref(false)
// 重置验证码
const resetCaptcha = () => {
window.clearInterval(captchaTimer.value)
Expand All @@ -87,15 +89,13 @@ const resetCaptcha = () => {
captchaDisable.value = false
}
const captchaBtnName = ref('获取验证码')
const captchaLoading = ref(false)
const captchaDisable = ref(false)
// 获取验证码
const onCaptcha = async () => {
if (captchaLoading.value) return
const isInvalid = await formRef.value?.validateField('phone')
if (isInvalid) return
try {
if (captchaLoading.value) return
const isInvalid = await formRef.value?.validateField('phone')
if (isInvalid) return
captchaLoading.value = true
captchaBtnName.value = '发送中...'
// await getSmsCaptcha({
Expand Down
43 changes: 0 additions & 43 deletions src/views/setting/components/Card.vue

This file was deleted.

Loading

0 comments on commit 99498a3

Please sign in to comment.