Kaynağa Gözat

各种优化

zhangyang 6 yıl önce
ebeveyn
işleme
08f2a817a3

+ 2 - 1
bin/Win32/Debug/lewaimai_pos_windows/skin/waimai_order_item.xml

@@ -7,9 +7,10 @@
 			
 			<Label float="true" name="waimai_order_list_name" text="姓名:" pos="10,36,182,66" />
 			<Label float="true" name="waimai_order_list_phone" text="电话:" pos="350,36,600,66" />
-			<Label float="true" name="waimai_order_list_price" text="价格:" pos="10,66,252,96" />
+			<Label float="true" name="waimai_order_list_address" text="地址:" pos="10,66,550,96" />
 			
 			<Label float="true" name="waimai_order_list_init_date" text="下单时间:" pos="10,96,220,126" />
+			<Label float="true" name="waimai_order_list_price" text="价格:" pos="350,96,500,126" />
 			
 			<Label float="true" name="waimai_order_list_type" text="订单类型:" pos="10,126,182,156" />
 			

BIN
bin/Win32/Release/lewaimai_pos_windows/db/pos.db


BIN
bin/Win32/Release/lewaimai_pos_windows/lewaimai_pos_windows.exe


Dosya farkı çok büyük olduğundan ihmal edildi
+ 384 - 0
bin/Win32/Release/lewaimai_pos_windows/log/pos.log


+ 2 - 1
bin/Win32/Release/lewaimai_pos_windows/skin/waimai_order_item.xml

@@ -7,9 +7,10 @@
 			
 			<Label float="true" name="waimai_order_list_name" text="姓名:" pos="10,36,182,66" />
 			<Label float="true" name="waimai_order_list_phone" text="电话:" pos="350,36,600,66" />
-			<Label float="true" name="waimai_order_list_price" text="价格:" pos="10,66,252,96" />
+			<Label float="true" name="waimai_order_list_address" text="地址:" pos="10,66,550,96" />
 			
 			<Label float="true" name="waimai_order_list_init_date" text="下单时间:" pos="10,96,220,126" />
+			<Label float="true" name="waimai_order_list_price" text="价格:" pos="350,96,500,126" />
 			
 			<Label float="true" name="waimai_order_list_type" text="订单类型:" pos="10,126,182,156" />
 			

+ 4 - 1
lewaimai_pos_windows/control/CWaimaiOrderItemUI.cpp

@@ -14,7 +14,7 @@ CWaimaiOrderItemUI::~CWaimaiOrderItemUI()
 void CWaimaiOrderItemUI::SetData(rapidjson::Value& orderinfo)
 {
 	m_name = orderinfo["customer_name"].GetString();
-	//m_address = orderinfo["address"].GetString();
+	m_address = orderinfo["address"].GetString();
 	m_phone = orderinfo["customer_phone"].GetString();
 	m_price = orderinfo["price"].GetString();
 	m_order_no = orderinfo["order_no"].GetString();
@@ -40,6 +40,9 @@ void CWaimaiOrderItemUI::SetData(rapidjson::Value& orderinfo)
 	std::wstring phone_show = L"电话:" + CLewaimaiString::UTF8ToUnicode(m_phone);
 	this->FindSubControl(L"waimai_order_list_phone")->SetText(phone_show.c_str());
 
+	std::wstring address_show = L"地址:" + CLewaimaiString::UTF8ToUnicode(m_address);
+	this->FindSubControl(L"waimai_order_list_address")->SetText(address_show.c_str());
+
 	std::wstring price_show = L"价格:" + CLewaimaiString::UTF8ToUnicode(m_price);
 	this->FindSubControl(L"waimai_order_list_price")->SetText(price_show.c_str());
 

+ 9 - 1
lewaimai_pos_windows/control/OrderListUI.cpp

@@ -118,7 +118,15 @@ void OrderListUI::DoRefresh()
 	rapidjson::Value& data = document["data"];
 
 	rapidjson::Value& v_count = data["count"];
-	string count = v_count.GetString();
+	string count;
+	if (v_count.IsInt())
+	{
+		count = to_string(data["count"].GetInt());
+	}
+	else
+	{
+		count = v_count.GetString();
+	}
 
 	//处理页数
 	int nCount = atoi(count.c_str());

+ 170 - 146
lewaimai_pos_windows/network/CHttpClient.cpp

@@ -4,7 +4,7 @@
 #include <curl/curl.h>
 
 CHttpClient::CHttpClient(void) :
-	m_bDebug(false)
+    m_bDebug(false)
 {
 
 }
@@ -16,96 +16,107 @@ CHttpClient::~CHttpClient(void)
 
 static int OnDebug(CURL *, curl_infotype itype, char * pData, size_t size, void *)
 {
-	if (itype == CURLINFO_TEXT)
-	{
-		//printf("[TEXT]%s\n", pData);
-	}
-	else if (itype == CURLINFO_HEADER_IN)
-	{
-		printf("[HEADER_IN]%s\n", pData);
-	}
-	else if (itype == CURLINFO_HEADER_OUT)
-	{
-		printf("[HEADER_OUT]%s\n", pData);
-	}
-	else if (itype == CURLINFO_DATA_IN)
-	{
-		printf("[DATA_IN]%s\n", pData);
-	}
-	else if (itype == CURLINFO_DATA_OUT)
-	{
-		printf("[DATA_OUT]%s\n", pData);
-	}
-	return 0;
+    if(itype == CURLINFO_TEXT)
+    {
+        //printf("[TEXT]%s\n", pData);
+    }
+    else if(itype == CURLINFO_HEADER_IN)
+    {
+        printf("[HEADER_IN]%s\n", pData);
+    }
+
+    else if(itype == CURLINFO_HEADER_OUT)
+    {
+        printf("[HEADER_OUT]%s\n", pData);
+    }
+
+    else if(itype == CURLINFO_DATA_IN)
+    {
+        printf("[DATA_IN]%s\n", pData);
+    }
+
+    else if(itype == CURLINFO_DATA_OUT)
+    {
+        printf("[DATA_OUT]%s\n", pData);
+    }
+
+    return 0;
 }
 
 static size_t OnWriteData(void* buffer, size_t size, size_t nmemb, void* lpVoid)
 {
-	std::string* str = dynamic_cast<std::string*>((std::string *)lpVoid);
-	if (NULL == str || NULL == buffer)
-	{
-		return -1;
-	}
-
-	char* pData = (char*)buffer;
-	str->append(pData, size * nmemb);
-	return nmemb;
+    std::string* str = dynamic_cast<std::string*>((std::string *)lpVoid);
+
+    if(NULL == str || NULL == buffer)
+    {
+        return -1;
+    }
+
+    char* pData = (char*)buffer;
+    str->append(pData, size * nmemb);
+    return nmemb;
 }
 
 int CHttpClient::Post(const std::string & strUrl, const std::string & strPost, std::string & strResponse)
 {
-	CURLcode res;
-	CURL* curl = curl_easy_init();
-	if (NULL == curl)
-	{
-		return CURLE_FAILED_INIT;
-	}
-	if (m_bDebug)
-	{
-		curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
-		curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
-	}
-	curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
-	curl_easy_setopt(curl, CURLOPT_POST, 1);
-	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strPost.c_str());
-	curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
-	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
-	curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
-	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
-	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
-	res = curl_easy_perform(curl);
-	curl_easy_cleanup(curl);
-	return res;
+    CURLcode res;
+    CURL* curl = curl_easy_init();
+
+    if(NULL == curl)
+    {
+        return CURLE_FAILED_INIT;
+    }
+
+    if(m_bDebug)
+    {
+        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+        curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
+    }
+
+    curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
+    curl_easy_setopt(curl, CURLOPT_POST, 1);
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strPost.c_str());
+    curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
+    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
+    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
+    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
+    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+    return res;
 }
 
 int CHttpClient::Get(const std::string & strUrl, std::string & strResponse)
 {
-	CURLcode res;
-	CURL* curl = curl_easy_init();
-	if (NULL == curl)
-	{
-		return CURLE_FAILED_INIT;
-	}
-	if (m_bDebug)
-	{
-		curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
-		curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
-	}
-	curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
-	curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
-	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
-	curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
-	/**
-	* 当多个线程都使用超时处理的时候,同时主线程中有sleep或是wait等操作。
-	* 如果不设置这个选项,libcurl将会发信号打断这个wait从而导致程序退出。
-	*/
-	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
-	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
-	res = curl_easy_perform(curl);
-	curl_easy_cleanup(curl);
-	return res;
+    CURLcode res;
+    CURL* curl = curl_easy_init();
+
+    if(NULL == curl)
+    {
+        return CURLE_FAILED_INIT;
+    }
+
+    if(m_bDebug)
+    {
+        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+        curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
+    }
+
+    curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
+    curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
+    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
+    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
+    /**
+    * 当多个线程都使用超时处理的时候,同时主线程中有sleep或是wait等操作。
+    * 如果不设置这个选项,libcurl将会发信号打断这个wait从而导致程序退出。
+    */
+    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
+    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+    return res;
 }
 
 /*
@@ -113,81 +124,94 @@ int CHttpClient::Get(const std::string & strUrl, std::string & strResponse)
  **/
 int CHttpClient::Posts(const std::string & strUrl, const std::string & strPost, std::string & strResponse, const char * pCaPath)
 {
-	CURLcode res;
-	CURL* curl = curl_easy_init();
-	if (NULL == curl)
-	{
-		return CURLE_FAILED_INIT;
-	}
-	if (m_bDebug)
-	{
-		curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
-		curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
-	}
-	curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
-	curl_easy_setopt(curl, CURLOPT_POST, 1);
-	curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strPost.c_str());
-	curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
-	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
-	curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
-	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-	if (NULL == pCaPath)
-	{
-		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
-		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
-	}
-	else
-	{
-		//缺省情况就是PEM,所以无需设置,另外支持DER
-		//curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");
-		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
-		curl_easy_setopt(curl, CURLOPT_CAINFO, pCaPath);
-	}
-	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
-	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
-	res = curl_easy_perform(curl);
-	curl_easy_cleanup(curl);
-	return res;
+    CURLcode res;
+    CURL* curl = curl_easy_init();
+
+    if(NULL == curl)
+    {
+        return CURLE_FAILED_INIT;
+    }
+
+    if(m_bDebug)
+    {
+        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+        curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
+    }
+
+    curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
+    curl_easy_setopt(curl, CURLOPT_POST, 1);
+    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strPost.c_str());
+    curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
+    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
+    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
+    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+    curl_easy_setopt(curl, CURLOPT_COOKIE, "lwm_gray_tag=rc");;
+
+    if(NULL == pCaPath)
+    {
+        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
+        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
+    }
+
+    else
+    {
+        //缺省情况就是PEM,所以无需设置,另外支持DER
+        //curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");
+        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
+        curl_easy_setopt(curl, CURLOPT_CAINFO, pCaPath);
+    }
+
+    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
+    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+    return res;
 }
 
 int CHttpClient::Gets(const std::string & strUrl, std::string & strResponse, const char * pCaPath)
 {
-	CURLcode res;
-	CURL* curl = curl_easy_init();
-	if (NULL == curl)
-	{
-		return CURLE_FAILED_INIT;
-	}
-	if (m_bDebug)
-	{
-		curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
-		curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
-	}
-	curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
-	curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
-	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
-	curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
-	curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
-	if (NULL == pCaPath)
-	{
-		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
-		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
-	}
-	else
-	{
-		curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
-		curl_easy_setopt(curl, CURLOPT_CAINFO, pCaPath);
-	}
-	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
-	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
-	res = curl_easy_perform(curl);
-	curl_easy_cleanup(curl);
-	return res;
+    CURLcode res;
+    CURL* curl = curl_easy_init();
+
+    if(NULL == curl)
+    {
+        return CURLE_FAILED_INIT;
+    }
+
+    if(m_bDebug)
+    {
+        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+        curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, OnDebug);
+    }
+
+    curl_easy_setopt(curl, CURLOPT_URL, strUrl.c_str());
+    curl_easy_setopt(curl, CURLOPT_READFUNCTION, NULL);
+    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, OnWriteData);
+    curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&strResponse);
+    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+
+    if(NULL == pCaPath)
+    {
+        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false);
+        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, false);
+    }
+
+    else
+    {
+        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true);
+        curl_easy_setopt(curl, CURLOPT_CAINFO, pCaPath);
+    }
+
+    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 8);//连接超时,这个数值如果设置太短可能导致数据请求不到就断开了
+    curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);//接收数据时超时设置,如果10秒内数据未接收完,直接退出
+    res = curl_easy_perform(curl);
+    curl_easy_cleanup(curl);
+    return res;
 }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
 void CHttpClient::SetDebug(bool bDebug)
 {
-	m_bDebug = bDebug;
+    m_bDebug = bDebug;
 }

+ 39 - 39
lewaimai_pos_windows/network/CHttpClient.h

@@ -5,50 +5,50 @@ using namespace std;
 class CHttpClient
 {
 public:
-	CHttpClient();
-	~CHttpClient();
+    CHttpClient();
+    ~CHttpClient();
 
 public:
-	/**
-	* @brief HTTP POST请求
-	* @param strUrl 输入参数,请求的Url地址,如:http://www.baidu.com
-	* @param strPost 输入参数,使用如下格式para1=val1&para2=val2&…
-	* @param strResponse 输出参数,返回的内容
-	* @return 返回是否Post成功
-	*/
-	int Post(const std::string & strUrl, const std::string & strPost, std::string & strResponse);
-
-	/**
-	* @brief HTTP GET请求
-	* @param strUrl 输入参数,请求的Url地址,如:http://www.baidu.com
-	* @param strResponse 输出参数,返回的内容
-	* @return 返回是否Post成功
-	*/
-	int Get(const std::string & strUrl, std::string & strResponse);
-
-	/**
-	* @brief HTTPS POST请求,无证书版本
-	* @param strUrl 输入参数,请求的Url地址,如:https://www.alipay.com
-	* @param strPost 输入参数,使用如下格式ppara1=val1&para2=val2&…
-	* @param strResponse 输出参数,返回的内容
-	* @param pCaPath 输入参数,为CA证书的路径.如果输入为NULL,则不验证服务器端证书的有效性.
-	* @return 返回是否Post成功
-	*/
-	int Posts(const std::string & strUrl, const std::string & strPost, std::string & strResponse, const char * pCaPath = NULL);
-
-	/**
-	* @brief HTTPS GET请求,无证书版本
-	* @param strUrl 输入参数,请求的Url地址,如:https://www.alipay.com
-	* @param strResponse 输出参数,返回的内容
-	* @param pCaPath 输入参数,为CA证书的路径.如果输入为NULL,则不验证服务器端证书的有效性.
-	* @return 返回是否Post成功
-	*/
-	int Gets(const std::string & strUrl, std::string & strResponse, const char * pCaPath = NULL);
+    /**
+    * @brief HTTP POST请求
+    * @param strUrl 输入参数,请求的Url地址,如:http://www.baidu.com
+    * @param strPost 输入参数,使用如下格式para1=val1&para2=val2&…
+    * @param strResponse 输出参数,返回的内容
+    * @return 返回是否Post成功
+    */
+    int Post(const std::string & strUrl, const std::string & strPost, std::string & strResponse);
+
+    /**
+    * @brief HTTP GET请求
+    * @param strUrl 输入参数,请求的Url地址,如:http://www.baidu.com
+    * @param strResponse 输出参数,返回的内容
+    * @return 返回是否Post成功
+    */
+    int Get(const std::string & strUrl, std::string & strResponse);
+
+    /**
+    * @brief HTTPS POST请求,无证书版本
+    * @param strUrl 输入参数,请求的Url地址,如:https://www.alipay.com
+    * @param strPost 输入参数,使用如下格式ppara1=val1&para2=val2&…
+    * @param strResponse 输出参数,返回的内容
+    * @param pCaPath 输入参数,为CA证书的路径.如果输入为NULL,则不验证服务器端证书的有效性.
+    * @return 返回是否Post成功
+    */
+    int Posts(const std::string & strUrl, const std::string & strPost, std::string & strResponse, const char * pCaPath = NULL);
+
+    /**
+    * @brief HTTPS GET请求,无证书版本
+    * @param strUrl 输入参数,请求的Url地址,如:https://www.alipay.com
+    * @param strResponse 输出参数,返回的内容
+    * @param pCaPath 输入参数,为CA证书的路径.如果输入为NULL,则不验证服务器端证书的有效性.
+    * @return 返回是否Post成功
+    */
+    int Gets(const std::string & strUrl, std::string & strResponse, const char * pCaPath = NULL);
 
 public:
-	void SetDebug(bool bDebug);
+    void SetDebug(bool bDebug);
 
 private:
-	bool m_bDebug;
+    bool m_bDebug;
 };
 

+ 2 - 2
lewaimai_pos_windows/network/CMessagePush.cpp

@@ -177,8 +177,8 @@ void CMessagePush::KeepAlive()
 
 		//走到这里,说明心跳包发送成功了,socket是连通的
 
-		//休眠10秒钟,之后再发心跳包
-		CSystem::my_sleep(10);
+		//休眠30秒钟,之后再发心跳包
+		CSystem::my_sleep(30);
 	}
 
 	AddStopNum();

+ 67 - 8
lewaimai_pos_windows/wnd/CLoginWnd.cpp

@@ -354,12 +354,72 @@ void CLoginWnd::StartLogin()
 
 void CLoginWnd::HandleLogin()
 {
-	////真正登录前,先检测是否有需要更新
-	//CSystem::my_sleep(1);
+	CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
+
+	//真正登录前,先检测是否有需要更新
+	std::map<string, string> params;
+
+	std::string response;
+	bool ret = CLewaimaiHttpClient::Request("/version/getwindowsversion", params, response);
+	if (!ret)
+	{
+		pLoginResultLabel->SetText(std::wstring(_T("网络请求出错")).c_str());
+		pLoginResultLabel->SetVisible(true);
+
+		PostMessage(WM_LOGIN_ERROR);
+
+		return;
+	}
+
+	rapidjson::Document document;
+	document.Parse(response.c_str());
+
+	if (document.HasParseError())
+	{
+		pLoginResultLabel->SetText(std::wstring(_T("服务器返回数据格式错误")).c_str());
+		pLoginResultLabel->SetVisible(true);
+
+		PostMessage(WM_LOGIN_ERROR);
+
+		return;
+	}
+	else
+	{
+		if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
+		{
+			pLoginResultLabel->SetText(std::wstring(_T("服务器返回数据格式错误")).c_str());
+			pLoginResultLabel->SetVisible(true);
+
+			PostMessage(WM_LOGIN_ERROR);
+
+			return;
+		}
+
+		rapidjson::Value& v_errcode = document["errcode"];
+		int errcode = v_errcode.GetInt();
+		if (errcode != 0)
+		{
+			std::string errmsg = "response failed! message:" + string(document["errmsg"].GetString());
+			pLoginResultLabel->SetText(CLewaimaiString::UTF8ToUnicode(errmsg).c_str());
+			pLoginResultLabel->SetVisible(true);
 
-	////如果需要更新,那么就提示
-	//PostMessage(WM_NEED_UPDATE);
-	//return;
+			PostMessage(WM_LOGIN_ERROR);
+
+			return;
+		}
+
+		rapidjson::Value& data = document["data"];
+
+		std::string newest_version = data["newest_version"].GetString();
+		m_update_url = data["url"].GetString();
+
+		if (newest_version > CSystem::GetVersion())
+		{
+			//说明有新版本,要更新
+			PostMessage(WM_NEED_UPDATE);
+			return;
+		}
+	}
 
     //判断账号密码是否正确
     std::wstring account, password;
@@ -375,7 +435,7 @@ void CLoginWnd::HandleLogin()
         password = pPasswordEdit->GetText().GetData();
     }
 
-    LOG_INFO("account:" << account.c_str() << ", password:" << password.c_str());
+    //LOG_INFO("account:" << account.c_str() << ", password:" << password.c_str());
 
     string s_account = CLewaimaiString::UnicodeToUTF8(account);
     string s_password = CLewaimaiString::UnicodeToUTF8(password);
@@ -383,7 +443,6 @@ void CLoginWnd::HandleLogin()
 	CLewaimaiString::trim(s_account);
 	CLewaimaiString::trim(s_password);
 
-	CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
 	if (s_account.compare("") == 0)
 	{
 		pLoginResultLabel->SetText(std::wstring(_T("用户名不能为空")).c_str());
@@ -508,7 +567,7 @@ void CLoginWnd::Update()
 	TCHAR lpTempPathBuffer[MAX_PATH];
 	DWORD dwRetVal = GetTempPath(MAX_PATH, lpTempPathBuffer);
 
-	std::string url = "http://down10d.zol.com.cn/zoldownload_os/nsis3.04setup@81_262627.exe";
+	std::string url = m_update_url;
 	std::string filename = CLewaimaiString::UnicodeToANSI(lpTempPathBuffer);
 	pFrame->InitData(url, filename);
 

+ 2 - 0
lewaimai_pos_windows/wnd/CLoginWnd.h

@@ -63,5 +63,7 @@ public:
 
 public:
     CPaintManagerUI m_pm;
+
+	std::string m_update_url;
 };