Forráskód Böngészése

明天继续弄自动升级的

zhangyang 6 éve
szülő
commit
ad187969db

BIN
bin/Win32/Debug/zhipuzi_pos_windows/db/pos.db


+ 9 - 4
bin/Win32/Debug/zhipuzi_pos_windows/skin/login.xml

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<Window size="520,360" caption="0,0,0,36" roundcorner="4,4" >
+<Window size="520,410" caption="0,0,0,36" roundcorner="4,4" >
+	<Font shared="true" id="0" name="微软雅黑" size="20" />
 	<VerticalLayout bkimage="file='Dialog_BG2.png' corner='4,48,4,4'" >
 		<HorizontalLayout height="44">
 			<Label text="智铺子收银软件" width="90" height="44" valign="center" padding="10,0,0,0" textcolor="#FFFFFFFF"/>
@@ -8,13 +9,13 @@
 			<Button name="closebtn" width="42" height="18" padding="0,6,0,0" tooltip="关闭收银软件" normalimage="file='frame_btn_close_normal.bmp' mask='#FFFF00FF'" hotimage="file='frame_btn_close_hot.bmp' mask='#FFFF00FF'" pushedimage="file='frame_btn_close_down.bmp' mask='#FFFF00FF'"/>
 		</HorizontalLayout>
 		
-		<HorizontalLayout height="60">
+		<HorizontalLayout height="80">
 			<Control></Control>
-			<HorizontalLayout bkimage="file='logo_guanwang.png'" width="202" height="43" padding="0,8,0,0"></HorizontalLayout>
+			<HorizontalLayout bkimage="file='logo_guanwang.png'" width="202" height="43" padding="0,18,0,0"></HorizontalLayout>
 			<Control></Control>
 		</HorizontalLayout>
 		
-		<VerticalLayout height="200">
+		<VerticalLayout name="login_input" height="200">
 			<HorizontalLayout height="50">
 				<Label text="账号:" float="true" pos="123,12,228,40"/>
 				<Combo name="accountcombo" float="true" pos="183, 12, 398, 38" tooltip="请点击这里选择您的登录账号" normalimage="file='Setting_Combox_Normal.png' corner='2,2,24,2'" hotimage="file='Setting_Combox_Hover.png' corner='2,2,24,2'" pushedimage="Setting_Combox_Click.png' corner='2,2,24,2'" textpadding="10,1,1,1" >
@@ -45,6 +46,10 @@
 			</HorizontalLayout>			
 		</VerticalLayout>
 		
+		<VerticalLayout name="login_loading" height="200">
+			<Label text="登录中..." align="center" padding="0,150,0,0" font="0"></Label>
+		</VerticalLayout>
+		
 		<HorizontalLayout height="50">
 			<Control></Control>
 			<Label name="loginresult" width="400" height="50" multiline="true" text="" visible="false" textcolor="#FF0000" align="center" />

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


+ 7 - 0
zhipuzi_pos_windows/helper/define.h

@@ -1,3 +1,10 @@
 #pragma once
 
+#define WM_SHOWTASK 10001
+#define WM_ONCLOSE 10002
+
+#define WM_LOGIN_ERROR 10003
+#define WM_LOGIN_SUCCESS 10004
+#define WM_NEED_UPDATE 10005
+
 

+ 19 - 0
zhipuzi_pos_windows/network/CUpdateCheck.cpp

@@ -0,0 +1,19 @@
+#include "CUpdateCheck.h"
+
+CUpdateCheck::CUpdateCheck()
+{
+	
+}
+
+
+CUpdateCheck::~CUpdateCheck()
+{
+}
+
+/*
+ *źě˛éĘǡńĐčŇŞ¸üĐÂ
+ **/
+bool CUpdateCheck::StartCheck()
+{
+	return true;	
+}

+ 13 - 0
zhipuzi_pos_windows/network/CUpdateCheck.h

@@ -0,0 +1,13 @@
+#pragma once
+
+#include "../pch/pch.h"
+
+class CUpdateCheck
+{
+public:
+	CUpdateCheck();
+	~CUpdateCheck();
+
+	bool StartCheck();
+};
+

+ 84 - 14
zhipuzi_pos_windows/wnd/CLoginWnd.cpp

@@ -54,7 +54,15 @@ void CLoginWnd::Init()
 
 	if (CSetting::GetParam("setting_is_auto_login") == "1")
 	{
-		HandleLogin();
+		StartLogin();
+	}
+	else
+	{
+		CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
+		pInput->SetVisible(true);
+
+		CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
+		pLoading->SetVisible(false);
 	}
 }
 
@@ -69,7 +77,7 @@ void CLoginWnd::Notify(TNotifyUI& msg)
         }
         else if(msg.pSender->GetName() == _T("loginBtn"))
         {
-            HandleLogin();
+			StartLogin();
             return;
         }
 		else if (msg.pSender->GetName() == _T("login_auto_login"))
@@ -305,11 +313,51 @@ LRESULT CLoginWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool&
         }
 
     }
+	else if (uMsg == WM_LOGIN_SUCCESS)
+	{
+		LoginSuccess();
+		return true;
+	}
+	else if (uMsg == WM_LOGIN_ERROR)
+	{
+		LoginError();
+		return true;
+	}
+	else if (uMsg == WM_NEED_UPDATE)
+	{
+		//说明需要升级了
+
+
+	}
+
     return false;
 }
 
+void CLoginWnd::StartLogin()
+{
+	//隐藏密码输入框,显示进度条
+	CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
+	pInput->SetVisible(false);
+
+	CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
+	pLoading->SetVisible(true);
+
+	CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
+	pLoginResultLabel->SetVisible(false);
+
+	//开启一个线程,开始处理登录
+	std::thread(&CLoginWnd::HandleLogin, this).detach();
+}
+
 void CLoginWnd::HandleLogin()
 {
+	//真正登录前,先检测是否有需要更新
+	CSystem::my_sleep(1);
+
+	//如果需要更新,那么就提示
+	PostMessage(WM_NEED_UPDATE);
+	return;
+
     //判断账号密码是否正确
     std::wstring account, password;
     CEditUI* pAccountEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("accountedit")));
@@ -338,6 +386,8 @@ void CLoginWnd::HandleLogin()
 		pLoginResultLabel->SetText(std::wstring(_T("用户名不能为空")).c_str());
 		pLoginResultLabel->SetVisible(true);
 
+		PostMessage(WM_LOGIN_ERROR);
+
 		return;
 	}
 
@@ -346,6 +396,8 @@ void CLoginWnd::HandleLogin()
 		pLoginResultLabel->SetText(std::wstring(_T("密码不能为空")).c_str());
 		pLoginResultLabel->SetVisible(true);
 
+		PostMessage(WM_LOGIN_ERROR);
+
 		return;
 	}
 
@@ -397,19 +449,9 @@ void CLoginWnd::HandleLogin()
 		//把用户名和密码保存起来
 		CSetting::SetLoginInfo(s_account, s_password);
 
-        CMainWnd* pFrame = new CMainWnd();
-        if(pFrame == NULL)
-        {
-            return;
-        }
-
-        pFrame->SetIcon(IDI_ICON_DUILIB);
-        pFrame->Create(NULL, _T("智铺子收银软件"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 1024, 768);
-        pFrame->CenterWindow();
+		PostMessage(WM_LOGIN_SUCCESS);
 
-        ::ShowWindow(*pFrame, SW_SHOWMAXIMIZED);
-
-        Close();
+		return;
     }
     else
     {
@@ -418,9 +460,37 @@ void CLoginWnd::HandleLogin()
 
         pLoginResultLabel->SetText(std::wstring(_T("登录失败:") + CLewaimaiString::UTF8ToUnicode(errmsg)).c_str());
         pLoginResultLabel->SetVisible(true);
+
+		PostMessage(WM_LOGIN_ERROR);
     }
 }
 
+void CLoginWnd::LoginSuccess()
+{
+	CMainWnd* pFrame = new CMainWnd();
+	if (pFrame == NULL)
+	{
+		return;
+	}
+
+	pFrame->SetIcon(IDI_ICON_DUILIB);
+	pFrame->Create(NULL, _T("智铺子收银软件"), UI_WNDSTYLE_FRAME, 0L, 0, 0, 1024, 768);
+	pFrame->CenterWindow();
+
+	::ShowWindow(*pFrame, SW_SHOWMAXIMIZED);
+
+	Close();
+}
+
+void CLoginWnd::LoginError()
+{
+	CVerticalLayoutUI* pInput = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_input")));
+	pInput->SetVisible(true);
 
+	CVerticalLayoutUI* pLoading = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_loading")));
+	pLoading->SetVisible(false);
 
+	CLabelUI* pLoginResultLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("loginresult")));
+	pLoginResultLabel->SetVisible(true);
+}
 

+ 6 - 0
zhipuzi_pos_windows/wnd/CLoginWnd.h

@@ -51,8 +51,14 @@ public:
 
 	LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
 
+	void StartLogin();
+
     void HandleLogin();
 
+	void LoginSuccess();
+
+	void LoginError();
+
 public:
     CPaintManagerUI m_pm;
 };

+ 0 - 3
zhipuzi_pos_windows/wnd/CMainWnd.h

@@ -8,9 +8,6 @@
 
 #include <ShellAPI.h>
 
-#define WM_SHOWTASK 10001
-#define WM_ONCLOSE 10002
-
 class CMessagePush;
 
 class CMainWnd : public CWindowWnd, public INotifyUI

+ 1 - 0
zhipuzi_pos_windows/zhipuzi_pos_windows.cpp

@@ -1,6 +1,7 @@
 #include "pch/pch.h"
 
 #include "wnd/CLoginWnd.h"
+#include "network/CUpdateCheck.h"
 
 int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                       _In_opt_ HINSTANCE hPrevInstance,

+ 2 - 0
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj

@@ -202,6 +202,7 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     </PostBuildEvent>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="network\CUpdateCheck.h" />
     <ClInclude Include="wnd\CWaimaiOrderFailReasonWnd.h" />
     <ClInclude Include="network\PosMessage.h" />
     <ClInclude Include="wnd\CChufangSettingWnd.h" />
@@ -230,6 +231,7 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     <ClInclude Include="control\OrderListUI.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="network\CUpdateCheck.cpp" />
     <ClCompile Include="wnd\CWaimaiOrderFailReasonWnd.cpp" />
     <ClCompile Include="wnd\CChufangSettingWnd.cpp" />
     <ClCompile Include="control\CWaimaiOrderInfoUI.cpp" />

+ 6 - 0
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj.filters

@@ -93,6 +93,9 @@
     <ClInclude Include="wnd\CWaimaiOrderFailReasonWnd.h">
       <Filter>头文件</Filter>
     </ClInclude>
+    <ClInclude Include="network\CUpdateCheck.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="pch\pch.cpp">
@@ -164,6 +167,9 @@
     <ClCompile Include="wnd\CWaimaiOrderFailReasonWnd.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
+    <ClCompile Include="network\CUpdateCheck.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <Image Include="resource\zhipuzi.ico">