Skip to content

Commit 1e0e076

Browse files
author
piexlmax
committed
增加用户自行修改手机号邮箱功能
1 parent 64ca2a4 commit 1e0e076

File tree

3 files changed

+131
-7
lines changed

3 files changed

+131
-7
lines changed

server/source/system/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ func (a *api) Initialize() error {
2222
{ApiGroup: "jwt", Method: "POST", Path: "/jwt/jsonInBlacklist", Description: "jwt加入黑名单(退出,必选)"},
2323

2424
{ApiGroup: "系统用户", Method: "DELETE", Path: "/user/deleteUser", Description: "删除用户"},
25-
{ApiGroup: "系统用户", Method: "POST", Path: "/user/register", Description: "用户注册(必选)"},
25+
{ApiGroup: "系统用户", Method: "POST", Path: "/user/register", Description: "用户注册"},
2626
{ApiGroup: "系统用户", Method: "POST", Path: "/user/getUserList", Description: "获取用户列表"},
2727
{ApiGroup: "系统用户", Method: "PUT", Path: "/user/setUserInfo", Description: "设置用户信息"},
2828
{ApiGroup: "系统用户", Method: "PUT", Path: "/user/setSelfInfo", Description: "设置自身信息(必选)"},
2929
{ApiGroup: "系统用户", Method: "GET", Path: "/user/getUserInfo", Description: "获取自身信息(必选)"},
3030
{ApiGroup: "系统用户", Method: "POST", Path: "/user/setUserAuthorities", Description: "设置权限组"},
31-
{ApiGroup: "系统用户", Method: "POST", Path: "/user/changePassword", Description: "修改密码(建(选择)"},
31+
{ApiGroup: "系统用户", Method: "POST", Path: "/user/changePassword", Description: "修改密码(建议选择)"},
3232
{ApiGroup: "系统用户", Method: "POST", Path: "/user/setUserAuthority", Description: "修改用户角色(必选)"},
3333
{ApiGroup: "系统用户", Method: "POST", Path: "/user/resetPassword", Description: "重置用户密码"},
3434

web/src/style/element_visiable.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@
154154
.el-button--small {
155155
min-height: 32px;
156156
font-size: 12px !important;
157-
line-height: 32px;
158157
}
159158

160159
.el-checkbox{

web/src/view/person/person.vue

Lines changed: 129 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@
9494
<li>
9595
<p class="title">密保手机</p>
9696
<p class="desc">
97-
已绑定手机:1245678910
98-
<a href="javascript:void(0)">立即修改</a>
97+
已绑定手机:{{ userStore.userInfo.phone }}
98+
<a href="javascript:void(0)" @click="changePhoneFlag = true">立即修改</a>
9999
</p>
100100
</li>
101101
<li>
102102
<p class="title">密保邮箱</p>
103103
<p class="desc">
104-
已绑定邮箱:gin-vue-admin@google.com.cn
105-
<a href="javascript:void(0)">立即修改</a>
104+
已绑定邮箱:{{ userStore.userInfo.email }}
105+
<a href="javascript:void(0)" @click="changeEmailFlag = true">立即修改</a>
106106
</p>
107107
</li>
108108
<li>
@@ -167,6 +167,60 @@
167167
</div>
168168
</template>
169169
</el-dialog>
170+
171+
<el-dialog v-model="changePhoneFlag" title="绑定手机" width="600px">
172+
<el-form :model="phoneForm">
173+
<el-form-item label="手机号" label-width="120px">
174+
<el-input v-model="phoneForm.phone" placeholder="请输入手机号" autocomplete="off" />
175+
</el-form-item>
176+
<el-form-item label="验证码" label-width="120px">
177+
<div class="code-box">
178+
<el-input v-model="phoneForm.code" autocomplete="off" placeholder="请自行设计短信服务,此处为模拟随便写" style="width:300px" />
179+
<el-button size="small" type="primary" :disabled="time>0" @click="getCode">{{ time>0?`(${time}s)后重新获取`:'获取验证码' }}</el-button>
180+
</div>
181+
</el-form-item>
182+
</el-form>
183+
<template #footer>
184+
<span class="dialog-footer">
185+
<el-button
186+
size="small"
187+
@click="closeChangePhone"
188+
>取消</el-button>
189+
<el-button
190+
type="primary"
191+
size="small"
192+
@click="changePhone"
193+
>更改</el-button>
194+
</span>
195+
</template>
196+
</el-dialog>
197+
198+
<el-dialog v-model="changeEmailFlag" title="绑定邮箱" width="600px">
199+
<el-form :model="emailForm">
200+
<el-form-item label="邮箱" label-width="120px">
201+
<el-input v-model="emailForm.email" placeholder="请输入邮箱" autocomplete="off" />
202+
</el-form-item>
203+
<el-form-item label="验证码" label-width="120px">
204+
<div class="code-box">
205+
<el-input v-model="emailForm.code" placeholder="请自行设计邮件服务,此处为模拟随便写" autocomplete="off" style="width:300px" />
206+
<el-button size="small" type="primary" :disabled="emailTime>0" @click="getEmailCode">{{ emailTime>0?`(${emailTime}s)后重新获取`:'获取验证码' }}</el-button>
207+
</div>
208+
</el-form-item>
209+
</el-form>
210+
<template #footer>
211+
<span class="dialog-footer">
212+
<el-button
213+
size="small"
214+
@click="closeChangeEmail"
215+
>取消</el-button>
216+
<el-button
217+
type="primary"
218+
size="small"
219+
@click="changeEmail"
220+
>更改</el-button>
221+
</span>
222+
</template>
223+
</el-dialog>
170224
</div>
171225
</template>
172226

@@ -288,6 +342,73 @@ const enterEdit = async() => {
288342
const handleClick = (tab, event) => {
289343
console.log(tab, event)
290344
}
345+
346+
const changePhoneFlag = ref(false)
347+
const time = ref(0)
348+
const phoneForm = reactive({
349+
phone: '',
350+
code: ''
351+
})
352+
353+
const getCode = async() => {
354+
time.value = 60
355+
let timer = setInterval(() => {
356+
time.value--
357+
if (time.value <= 0) {
358+
clearInterval(timer)
359+
timer = null
360+
}
361+
}, 1000)
362+
}
363+
364+
const closeChangePhone = () => {
365+
changePhoneFlag.value = false
366+
phoneForm.phone = ''
367+
phoneForm.code = ''
368+
}
369+
370+
const changePhone = async() => {
371+
const res = await setSelfInfo({ phone: phoneForm.phone })
372+
if (res.code === 0) {
373+
ElMessage.success('修改成功')
374+
userStore.ResetUserInfo({ phone: phoneForm.phone })
375+
closeChangePhone()
376+
}
377+
}
378+
379+
const changeEmailFlag = ref(false)
380+
const emailTime = ref(0)
381+
const emailForm = reactive({
382+
email: '',
383+
code: ''
384+
})
385+
386+
const getEmailCode = async() => {
387+
emailTime.value = 60
388+
let timer = setInterval(() => {
389+
emailTime.value--
390+
if (emailTime.value <= 0) {
391+
clearInterval(timer)
392+
timer = null
393+
}
394+
}, 1000)
395+
}
396+
397+
const closeChangeEmail = () => {
398+
changeEmailFlag.value = false
399+
emailForm.email = ''
400+
emailForm.code = ''
401+
}
402+
403+
const changeEmail = async() => {
404+
const res = await setSelfInfo({ email: emailForm.email })
405+
if (res.code === 0) {
406+
ElMessage.success('修改成功')
407+
userStore.ResetUserInfo({ email: emailForm.email })
408+
closeChangeEmail()
409+
}
410+
}
411+
291412
</script>
292413
293414
<style lang="scss">
@@ -425,4 +546,8 @@ const handleClick = (tab, event) => {
425546
.pointer {
426547
cursor: pointer;
427548
}
549+
.code-box{
550+
display: flex;
551+
justify-content: space-between;
552+
}
428553
</style>

0 commit comments

Comments
 (0)