5 changed files with 169 additions and 7 deletions
-
8uappbase/service/gstate_mgr.cpp
-
4uappbase/service/gstate_mgr.hpp
-
4usrc/service/app_core.cpp
-
9usrc/uicontroler/page/login_page.cpp
-
151usrc/uicontroler/page/mupage/muChangePasswd_page.cpp
@ -0,0 +1,151 @@ |
|||
|
|||
#include "db/dao/user_dao.hpp"
|
|||
#include "uappbase/apphal/apphal.hpp"
|
|||
#include "ui/ui.h"
|
|||
#include "uicontroler/base/page_processer.hpp"
|
|||
//
|
|||
#include "db/dao/acid_ch_cfg_dao.hpp"
|
|||
#include "db/dao/device_setting_dao.hpp"
|
|||
//
|
|||
#include "service/pump_ctrl_service.hpp"
|
|||
|
|||
namespace iflytop { |
|||
using namespace std; |
|||
#define TAG "MuChangePasswdPage"
|
|||
|
|||
static char pwd[20] = {0}; |
|||
static char newPwd[20] = {0}; |
|||
static char cfirmPwd[20] = {0}; |
|||
|
|||
class MuChangePasswdPage : public IPageProcesser { |
|||
private: |
|||
public: |
|||
MuChangePasswdPage() : IPageProcesser(TAG, pg_muChangePasswd) {} |
|||
|
|||
virtual void initialize() override { |
|||
IPageProcesser::initialize(); |
|||
setText(ob_muChangePasswd_pwd, ""); |
|||
setText(ob_muChangePasswd_pwdEMsg, ""); |
|||
setText(ob_muChangePasswd_newPwd, ""); |
|||
setText(ob_muChangePasswd_newPwdMsg, ""); |
|||
setText(ob_muChangePasswd_cfirmPwd, ""); |
|||
setText(ob_muChangePasswd_cfirmPwdMsg, ""); |
|||
} |
|||
|
|||
private: |
|||
virtual void onPageLoad(OnPageLoadContext* cxt) override { return; }; |
|||
/**
|
|||
* @brief 返回上一页 |
|||
*/ |
|||
virtual void onBackKey() override { |
|||
setText(ob_muChangePasswd_pwd, ""); |
|||
setText(ob_muChangePasswd_pwdEMsg, ""); |
|||
setText(ob_muChangePasswd_newPwd, ""); |
|||
setText(ob_muChangePasswd_newPwdMsg, ""); |
|||
setText(ob_muChangePasswd_cfirmPwd, ""); |
|||
setText(ob_muChangePasswd_cfirmPwdMsg, ""); |
|||
|
|||
memset(pwd, 0, sizeof(pwd)); |
|||
memset(newPwd, 0, sizeof(newPwd)); |
|||
memset(cfirmPwd, 0, sizeof(cfirmPwd)); |
|||
|
|||
UIControler::ins()->chpage(pg_navi, true); |
|||
}; |
|||
|
|||
virtual void onChangePageEvent() override {}; |
|||
virtual void onInputFieldContentChange(uint8_t bid, uint8_t slecId, const char* text) override { |
|||
if (bid == ob_muChangePasswd_pwd) { |
|||
setText(ob_muChangePasswd_pwd, text); |
|||
strcpy(pwd, text); |
|||
} else if (bid == ob_muChangePasswd_newPwd) { |
|||
setText(ob_muChangePasswd_newPwd, text); |
|||
strcpy(newPwd, text); |
|||
} else if (bid == ob_muChangePasswd_cfirmPwd) { |
|||
setText(ob_muChangePasswd_cfirmPwd, text); |
|||
strcpy(cfirmPwd, text); |
|||
} |
|||
|
|||
if (!GStateMgr::ins()->isLogin()) { |
|||
UIS->popWarningWin("请先登录"); |
|||
return; |
|||
} |
|||
user_t* user = UserDao::getUserById(GStateMgr::ins()->getUserId()); |
|||
if (user == nullptr) { |
|||
ZLOGW(TAG, "can not find user by id:%d", GStateMgr::ins()->getUserId()); |
|||
UIS->popWarningWin("用户不存在"); |
|||
return; |
|||
} |
|||
|
|||
setText(ob_muChangePasswd_pwdEMsg, ""); |
|||
setText(ob_muChangePasswd_newPwdMsg, ""); |
|||
setText(ob_muChangePasswd_cfirmPwdMsg, ""); |
|||
|
|||
if (strcmp(pwd, user->passwd) != 0) { |
|||
setText(ob_muChangePasswd_pwdEMsg, "密码错误"); |
|||
return; |
|||
} |
|||
|
|||
if (strlen(newPwd) != 0 && strlen(newPwd) < 6) { |
|||
setText(ob_muChangePasswd_newPwdMsg, "密码长度不能小于6"); |
|||
return; |
|||
} |
|||
|
|||
if (strlen(cfirmPwd) != 0) { |
|||
if (strcmp(newPwd, cfirmPwd) != 0) { |
|||
setText(ob_muChangePasswd_cfirmPwdMsg, "两次密码不一致"); |
|||
return; |
|||
} |
|||
} |
|||
}; |
|||
|
|||
virtual void onClickRelease(uint8_t bid, uint8_t val, const char* text) override { |
|||
if (bid == ob_muChangePasswd_pwd) { |
|||
popPasswdKeyBoard(ob_muChangePasswd_pwd, 6); |
|||
} else if (bid == ob_muChangePasswd_newPwd) { |
|||
popPasswdKeyBoard(ob_muChangePasswd_newPwd, 6); |
|||
} else if (bid == ob_muChangePasswd_cfirmPwd) { |
|||
popPasswdKeyBoard(ob_muChangePasswd_cfirmPwd, 6); |
|||
} |
|||
if (bid == ob_muChangePasswd_save) { |
|||
updateUser(); |
|||
} |
|||
} |
|||
|
|||
void updateUser() { |
|||
if (!GStateMgr::ins()->isLogin()) { |
|||
UIS->popWarningWin("请先登录"); |
|||
return; |
|||
} |
|||
|
|||
user_t* user = UserDao::getUserById(GStateMgr::ins()->getUserId()); |
|||
if (user == nullptr) { |
|||
ZLOGW(TAG, "can not find user by id:%d", GStateMgr::ins()->getUserId()); |
|||
UIS->popWarningWin("用户不存在"); |
|||
return; |
|||
} |
|||
|
|||
if (strcmp(pwd, user->passwd) != 0) { |
|||
UIS->popWarningWin("密码错误"); |
|||
return; |
|||
} |
|||
|
|||
if (strlen(newPwd) != 6) { |
|||
UIS->popWarningWin("密码长度需要等于6"); |
|||
return; |
|||
} |
|||
|
|||
if (strlen(cfirmPwd) != 0) { |
|||
if (strcmp(newPwd, cfirmPwd) != 0) { |
|||
UIS->popWarningWin("两次密码不一致"); |
|||
return; |
|||
} |
|||
} |
|||
|
|||
UserDao::updateUser(user->id, user->name, newPwd, GStateMgr::ins()->getLoginUsrType()); |
|||
UIS->popInfoWin("修改成功"); |
|||
} |
|||
}; |
|||
|
|||
// 实例化Page, 使其自动注册
|
|||
static MuChangePasswdPage instance; |
|||
} // namespace iflytop
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue