mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-28 01:53:53 +08:00
@@ -43,9 +43,9 @@ export default {
|
|||||||
})
|
})
|
||||||
.fail(() => {
|
.fail(() => {
|
||||||
RequestService.reAjaxFun(() => {
|
RequestService.reAjaxFun(() => {
|
||||||
this.unbindDevice(device_id, callback);
|
this.unbindDevice(device_id, callback);
|
||||||
});
|
});
|
||||||
}).send()
|
}).send()
|
||||||
},
|
},
|
||||||
// 绑定设备
|
// 绑定设备
|
||||||
bindDevice(deviceCode, callback) {
|
bindDevice(deviceCode, callback) {
|
||||||
@@ -71,9 +71,9 @@ export default {
|
|||||||
.method('GET')
|
.method('GET')
|
||||||
.type('blob')
|
.type('blob')
|
||||||
.header({
|
.header({
|
||||||
'Content-Type': 'image/gif',
|
'Content-Type': 'image/gif',
|
||||||
'Pragma': 'No-cache',
|
'Pragma': 'No-cache',
|
||||||
'Cache-Control': 'no-cache'
|
'Cache-Control': 'no-cache'
|
||||||
})
|
})
|
||||||
.success((res) => {
|
.success((res) => {
|
||||||
RequestService.clearRequestTime();
|
RequestService.clearRequestTime();
|
||||||
@@ -157,7 +157,7 @@ export default {
|
|||||||
this.getAgentList(callback);
|
this.getAgentList(callback);
|
||||||
});
|
});
|
||||||
}).send();
|
}).send();
|
||||||
},
|
},
|
||||||
|
|
||||||
getUserInfo(callback) {
|
getUserInfo(callback) {
|
||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
@@ -179,7 +179,7 @@ export default {
|
|||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
.url(`${getServiceUrl()}/api/v1/user/agent`)
|
.url(`${getServiceUrl()}/api/v1/user/agent`)
|
||||||
.method('POST')
|
.method('POST')
|
||||||
.data({ name: agentName })
|
.data({name: agentName})
|
||||||
.success((res) => {
|
.success((res) => {
|
||||||
RequestService.clearRequestTime();
|
RequestService.clearRequestTime();
|
||||||
callback(res);
|
callback(res);
|
||||||
@@ -205,6 +205,26 @@ export default {
|
|||||||
});
|
});
|
||||||
}).send();
|
}).send();
|
||||||
},
|
},
|
||||||
|
// API接口代码修改
|
||||||
|
changePassword(oldPassword, newPassword, successCallback, errorCallback) {
|
||||||
|
RequestService.sendRequest()
|
||||||
|
.url(`${getServiceUrl()}/api/v1/user/change-password`) // 修改URL
|
||||||
|
.method('PUT') // 修改方法为PUT
|
||||||
|
.data({
|
||||||
|
old_password: oldPassword, // 修改参数名
|
||||||
|
new_password: newPassword // 修改参数名
|
||||||
|
})
|
||||||
|
.success((res) => {
|
||||||
|
RequestService.clearRequestTime();
|
||||||
|
successCallback(res);
|
||||||
|
})
|
||||||
|
.fail((error) => {
|
||||||
|
RequestService.reAjaxFun(() => {
|
||||||
|
this.changePassword(oldPassword, newPassword, successCallback, errorCallback);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.send();
|
||||||
|
},
|
||||||
// 获取智能体配置
|
// 获取智能体配置
|
||||||
getDeviceConfig(deviceId, callback) {
|
getDeviceConfig(deviceId, callback) {
|
||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
@@ -237,5 +257,4 @@ export default {
|
|||||||
});
|
});
|
||||||
}).send();
|
}).send();
|
||||||
},
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog :visible.sync="visible" width="400px" center>
|
||||||
|
<div
|
||||||
|
style="margin: 0 10px 10px;display: flex;align-items: center;gap: 10px;font-weight: 700;font-size: 20px;text-align: left;color: #3d4566;">
|
||||||
|
<div
|
||||||
|
style="width: 40px;height: 40px;border-radius: 50%;background: #5778ff;display: flex;align-items: center;justify-content: center;">
|
||||||
|
<img src="@/assets/login/shield.png" alt="" style="width: 19px;height: 23px; filter: brightness(0) invert(1);" />
|
||||||
|
</div>
|
||||||
|
修改密码
|
||||||
|
</div>
|
||||||
|
<div style="height: 1px;background: #e8f0ff;"/>
|
||||||
|
<div style="margin: 22px 15px;">
|
||||||
|
<div style="font-weight: 400;font-size: 14px;text-align: left;color: #3d4566;">
|
||||||
|
<div style="color: red;display: inline-block;">*</div>
|
||||||
|
旧密码:
|
||||||
|
</div>
|
||||||
|
<div class="input-46" style="margin-top: 12px;">
|
||||||
|
<el-input placeholder="请输入旧密码" v-model="oldPassword" type="password" show-password/>
|
||||||
|
</div>
|
||||||
|
<div style="font-weight: 400;font-size: 14px;text-align: left;color: #3d4566;margin-top: 12px;">
|
||||||
|
<div style="color: red;display: inline-block;">*</div>
|
||||||
|
新密码:
|
||||||
|
</div>
|
||||||
|
<div class="input-46" style="margin-top: 12px;">
|
||||||
|
<el-input placeholder="请输入新密码" v-model="newPassword" type="password" show-password/>
|
||||||
|
</div>
|
||||||
|
<div style="font-weight: 400;font-size: 14px;text-align: left;color: #3d4566;margin-top: 12px;">
|
||||||
|
<div style="color: red;display: inline-block;">*</div>
|
||||||
|
确认新密码:
|
||||||
|
</div>
|
||||||
|
<div class="input-46" style="margin-top: 12px;">
|
||||||
|
<el-input placeholder="请再次输入新密码" v-model="confirmNewPassword" type="password" show-password/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="display: flex;margin: 15px 15px;gap: 7px;">
|
||||||
|
<div class="dialog-btn" @click="confirm">
|
||||||
|
确定
|
||||||
|
</div>
|
||||||
|
<div class="dialog-btn"
|
||||||
|
style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;"
|
||||||
|
@click="cancel">
|
||||||
|
取消
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import userApi from '@/apis/module/user';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'ChangePasswordDialog',
|
||||||
|
props: {
|
||||||
|
visible: {type: Boolean, required: true}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
oldPassword: "",
|
||||||
|
newPassword: "",
|
||||||
|
confirmNewPassword: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
confirm() {
|
||||||
|
if (!this.oldPassword.trim() || !this.newPassword.trim() || !this.confirmNewPassword.trim()) {
|
||||||
|
this.$message.error('请填写所有字段');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.newPassword !== this.confirmNewPassword) {
|
||||||
|
this.$message.error('两次输入的新密码不一致');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.newPassword === this.oldPassword) {
|
||||||
|
this.$message.error('新密码不能与旧密码相同');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 直接调用修改密码接口
|
||||||
|
userApi.changePassword(this.oldPassword, this.newPassword, (res) => {
|
||||||
|
if (res.code === 0) {
|
||||||
|
this.$message.error(res.msg || '密码修改失败');
|
||||||
|
} else {
|
||||||
|
this.$message.success('密码修改成功');
|
||||||
|
this.$emit('confirm', res);
|
||||||
|
this.$emit('update:visible', false);
|
||||||
|
this.resetForm();
|
||||||
|
}
|
||||||
|
}, (err) => {
|
||||||
|
this.$message.error(err.msg || '密码修改失败');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
cancel() {
|
||||||
|
this.$emit('update:visible', false);
|
||||||
|
this.resetForm();
|
||||||
|
},
|
||||||
|
resetForm() {
|
||||||
|
this.oldPassword = "";
|
||||||
|
this.newPassword = "";
|
||||||
|
this.confirmNewPassword = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.input-46 {
|
||||||
|
border: 1px solid #e4e6ef;
|
||||||
|
background: #f6f8fb;
|
||||||
|
border-radius: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-btn {
|
||||||
|
cursor: pointer;
|
||||||
|
flex: 1;
|
||||||
|
border-radius: 23px;
|
||||||
|
background: #5778ff;
|
||||||
|
height: 40px;
|
||||||
|
font-weight: 500;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #fff;
|
||||||
|
line-height: 40px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .el-dialog {
|
||||||
|
border-radius: 15px;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .el-dialog__headerbtn {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .el-dialog__body {
|
||||||
|
padding: 4px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep .el-dialog__header {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -25,25 +25,31 @@
|
|||||||
<img alt="" src="@/assets/home/avatar.png" style="width: 21px;height: 21px;"/>
|
<img alt="" src="@/assets/home/avatar.png" style="width: 21px;height: 21px;"/>
|
||||||
<el-dropdown trigger="click">
|
<el-dropdown trigger="click">
|
||||||
<span class="el-dropdown-link">
|
<span class="el-dropdown-link">
|
||||||
{{ userInfo.username }}<i class="el-icon-arrow-down el-icon--right"></i>
|
{{ userInfo.username || '加载中...' }}<i class="el-icon-arrow-down el-icon--right"></i>
|
||||||
</span>
|
</span>
|
||||||
<el-dropdown-menu slot="dropdown">
|
<el-dropdown-menu slot="dropdown">
|
||||||
<el-dropdown-item icon="el-icon-plus" @click.native="">个人中心</el-dropdown-item>
|
<el-dropdown-item icon="el-icon-plus" @click.native="">个人中心</el-dropdown-item>
|
||||||
<el-dropdown-item icon="el-icon-circle-plus" @click.native="">修改密码</el-dropdown-item>
|
<el-dropdown-item icon="el-icon-circle-plus" @click.native="showChangePasswordDialog">修改密码</el-dropdown-item>
|
||||||
<el-dropdown-item icon="el-icon-circle-plus-outline" @click.native="">退出登录</el-dropdown-item>
|
<el-dropdown-item icon="el-icon-circle-plus-outline" @click.native="">退出登录</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- 修改密码弹窗 -->
|
||||||
|
<ChangePasswordDialog :visible.sync="isChangePasswordDialogVisible" />
|
||||||
</el-header>
|
</el-header>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import userApi from '@/apis/module/user'
|
import userApi from '@/apis/module/user';
|
||||||
|
import ChangePasswordDialog from './ChangePasswordDialog.vue'; // 引入修改密码弹窗组件
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'HeaderBar',
|
name: 'HeaderBar',
|
||||||
|
components: {
|
||||||
|
ChangePasswordDialog
|
||||||
|
},
|
||||||
props: ['devices'], // 接收父组件设备列表
|
props: ['devices'], // 接收父组件设备列表
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -51,7 +57,8 @@ export default {
|
|||||||
userInfo: {
|
userInfo: {
|
||||||
username: '',
|
username: '',
|
||||||
mobile: ''
|
mobile: ''
|
||||||
}
|
},
|
||||||
|
isChangePasswordDialogVisible: false // 控制修改密码弹窗的显示
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -71,10 +78,7 @@ export default {
|
|||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
fetchUserInfo() {
|
fetchUserInfo() {
|
||||||
userApi.getUserInfo(({data}) => {
|
userApi.getUserInfo(({data}) => {
|
||||||
this.userInfo = {
|
this.userInfo = data.data
|
||||||
username: data.data.mobile, // 暂时先使用手机号作为用户名
|
|
||||||
mobile: data.data.mobile
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -96,10 +100,13 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('search-result', filteredDevices);
|
this.$emit('search-result', filteredDevices);
|
||||||
|
},
|
||||||
|
|
||||||
|
// 显示修改密码弹窗
|
||||||
|
showChangePasswordDialog() {
|
||||||
|
this.isChangePasswordDialogVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user