Browse Source

登录的问题解决了

zhangyang 6 years ago
parent
commit
ebfebd3f37

File diff suppressed because it is too large
+ 6 - 4
bin/Win32/Debug/zhipuzi_pos_windows/skin/GameRes/login.xml


BIN
bin/Win32/Debug/zhipuzi_pos_windows/zhipuzi_pos_windows.exe


+ 10 - 1
lewaimai_dispatch/CLoginWnd.cpp

@@ -24,7 +24,8 @@ void CLoginFrameWnd::HandleLogin()
 
 	CZhipuziHttpClient::Init(s_account, s_password);
 
-	bool res = CZhipuziHttpClient::Login();
+	std::string errmsg;
+	bool res = CZhipuziHttpClient::Login(errmsg);
 
 	if (res)
 	{
@@ -42,6 +43,14 @@ void CLoginFrameWnd::HandleLogin()
 
 		Close();
 	}
+	else
+	{
+		//µÇ¼ʧ°ÜÁË
+		CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
+
+		pLoginResultLabel->SetText(std::wstring(_T("µÇ¼ʧ°Ü£º") + CLewaimaiString::string2wstring(errmsg)).c_str());
+		pLoginResultLabel->SetVisible(true);
+	}
 }
 
 

+ 4 - 4
lewaimai_dispatch/helper/CLewaimaiString.h

@@ -21,11 +21,11 @@ public:
 		wstring result;
 
 		//获取缓冲区大小,并申请空间,缓冲区大小按字符计算  
-		int len = MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.size(), NULL, 0);
+		int len = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.size(), NULL, 0);
 		TCHAR* buffer = new TCHAR[len + 1];
 
 		//多字节编码转换成宽字节编码  
-		MultiByteToWideChar(CP_ACP, 0, str.c_str(), str.size(), buffer, len);
+		MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.size(), buffer, len);
 
 		//添加字符串结尾  
 		buffer[len] = '\0';
@@ -42,11 +42,11 @@ public:
 	{
 		string result;
 		//获取缓冲区大小,并申请空间,缓冲区大小事按字节计算的  
-		int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wstr.size(), NULL, 0, NULL, NULL);
+		int len = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wstr.size(), NULL, 0, NULL, NULL);
 		char* buffer = new char[len + 1];
 
 		//宽字节编码转换成多字节编码  
-		WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wstr.size(), buffer, len, NULL, NULL);
+		WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wstr.size(), buffer, len, NULL, NULL);
 		buffer[len] = '\0';
 
 		//删除缓冲区并返回值  

+ 4 - 1
lewaimai_dispatch/network/CZhipuziHttpClient.cpp

@@ -27,7 +27,7 @@ void CZhipuziHttpClient::Init(std::string username, std::string password)
 	m_client.m_password = password;
 }
 
-bool CZhipuziHttpClient::Login()
+bool CZhipuziHttpClient::Login(std::string& errmsg)
 {
 	std::map<string, string> params;
 
@@ -38,6 +38,7 @@ bool CZhipuziHttpClient::Login()
 	{
 		//网络请求出错
 		LOG_INFO("network failed!");
+		errmsg = "network failed!";
 		return false;
 	}
 
@@ -48,6 +49,7 @@ bool CZhipuziHttpClient::Login()
 	if (!document.IsObject())
 	{
 		LOG_INFO("message 非法!");
+		errmsg = "message 非法!";
 		return false;
 	}
 
@@ -56,6 +58,7 @@ bool CZhipuziHttpClient::Login()
 	if (errcode > 0)
 	{
 		LOG_INFO("login failed! message:" << document["errmsg"].GetString());
+		errmsg = std::string(document["errmsg"].GetString());
 		return false;
 	}
 

+ 1 - 1
lewaimai_dispatch/network/CZhipuziHttpClient.h

@@ -11,7 +11,7 @@ public:
 public:
 	static void Init(std::string username, std::string password);
 
-	static bool Login();
+	static bool Login(std::string& errmsg);
 
 	bool Request(std::string url, std::map<string, string> params, std::string& response);