mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
优化了user.js文件
This commit is contained in:
parent
be3e67b2c1
commit
a43acca375
1 changed files with 17 additions and 62 deletions
|
|
@ -18,51 +18,6 @@ export default {
|
||||||
})
|
})
|
||||||
}).send()
|
}).send()
|
||||||
},
|
},
|
||||||
// 获取设备信息
|
|
||||||
getHomeList(callback) {
|
|
||||||
RequestService.sendRequest().url(`${getServiceUrl()}/api/v1/user/device/bind`)
|
|
||||||
.method('GET')
|
|
||||||
.success((res) => {
|
|
||||||
RequestService.clearRequestTime()
|
|
||||||
callback(res)
|
|
||||||
})
|
|
||||||
.fail(() => {
|
|
||||||
RequestService.reAjaxFun(() => {
|
|
||||||
this.getUserInfo()
|
|
||||||
})
|
|
||||||
}).send()
|
|
||||||
},
|
|
||||||
// 解绑设备
|
|
||||||
unbindDevice(device_id, callback) {
|
|
||||||
RequestService.sendRequest()
|
|
||||||
.url(`${getServiceUrl()}/api/v1/user/device/unbind/${device_id}`)
|
|
||||||
.method('PUT')
|
|
||||||
.success((res) => {
|
|
||||||
RequestService.clearRequestTime();
|
|
||||||
callback(res);
|
|
||||||
})
|
|
||||||
.fail(() => {
|
|
||||||
RequestService.reAjaxFun(() => {
|
|
||||||
this.unbindDevice(device_id, callback);
|
|
||||||
});
|
|
||||||
}).send()
|
|
||||||
},
|
|
||||||
// 绑定设备
|
|
||||||
bindDevice(deviceCode, callback) {
|
|
||||||
RequestService.sendRequest()
|
|
||||||
.url(`${getServiceUrl()}/api/v1/user/device/bind/${deviceCode}`)
|
|
||||||
.method('POST')
|
|
||||||
.success((res) => {
|
|
||||||
RequestService.clearRequestTime();
|
|
||||||
callback(res);
|
|
||||||
})
|
|
||||||
.fail((err) => {
|
|
||||||
console.error('绑定设备失败:', err);
|
|
||||||
RequestService.reAjaxFun(() => {
|
|
||||||
this.bindDevice(deviceCode, callback);
|
|
||||||
});
|
|
||||||
}).send();
|
|
||||||
},
|
|
||||||
// 获取验证码
|
// 获取验证码
|
||||||
getCaptcha(uuid, callback) {
|
getCaptcha(uuid, callback) {
|
||||||
|
|
||||||
|
|
@ -158,7 +113,7 @@ export default {
|
||||||
});
|
});
|
||||||
}).send();
|
}).send();
|
||||||
},
|
},
|
||||||
|
// 用户信息获取
|
||||||
getUserInfo(callback) {
|
getUserInfo(callback) {
|
||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
.url(`${getServiceUrl()}/api/v1/user/info`)
|
.url(`${getServiceUrl()}/api/v1/user/info`)
|
||||||
|
|
@ -257,20 +212,20 @@ export default {
|
||||||
});
|
});
|
||||||
}).send();
|
}).send();
|
||||||
},
|
},
|
||||||
// 获取已绑设备
|
// 已绑设备
|
||||||
getAgentBindDevices(agentId, callback) {
|
getAgentBindDevices(agentId, callback) {
|
||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
.url(`${getServiceUrl()}/api/v1/user/agent/device/bind/${agentId}`)
|
.url(`${getServiceUrl()}/api/v1/user/agent/device/bind/${agentId}`)
|
||||||
.method('GET')
|
.method('GET')
|
||||||
.success((res) => {
|
.success((res) => {
|
||||||
RequestService.clearRequestTime();
|
RequestService.clearRequestTime();
|
||||||
callback(res);
|
callback(res);
|
||||||
})
|
})
|
||||||
.fail((err) => {
|
.fail((err) => {
|
||||||
console.error('获取设备列表失败:', err);
|
console.error('获取设备列表失败:', err);
|
||||||
RequestService.reAjaxFun(() => {
|
RequestService.reAjaxFun(() => {
|
||||||
this.getAgentBindDevices(agentId, callback);
|
this.getAgentBindDevices(agentId, callback);
|
||||||
});
|
});
|
||||||
}).send();
|
}).send();
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue