Commit 58466bdf by NitefllWind

1.新增loading界面。

2.新增自定义弹窗。
3.所有返回POS接口新增prompt字段。
4.操作成功时不再弹窗提示。
5.修改会员认证接口。
6.给输入框设定默认焦点。
parent da6c1b8f
......@@ -21,7 +21,9 @@ SOURCES += main.cpp\
fmvippanel.cpp \
fmvipfund.cpp \
fmvipdispatcher.cpp \
fmvipforward.cpp
fmvipforward.cpp \
fmmsgwnd.cpp \
fmloading.cpp
HEADERS += fmviporder.h \
fmviplogin.h \
......@@ -29,19 +31,23 @@ HEADERS += fmviporder.h \
fmvippanel.h \
fmvipfund.h \
fmvipdispatcher.h \
fmvipforward.h
fmvipforward.h \
fmmsgwnd.h \
fmloading.h
FORMS += forms/fmviporder.ui \
forms/fmviplogin.ui \
forms/fmvippanel.ui \
forms/fmvipfund.ui
forms/fmvipfund.ui \
forms/fmmsgwnd.ui \
forms/fmloading.ui
RESOURCES += \
res/FMVip.qrc
INCLUDEPATH += ../FMVipDC/
LIBS += -L..\FMVipTest -lFMVipDC
win32 {
RC_FILE = res/FMVip.rc
......@@ -50,4 +56,14 @@ RC_FILE = res/FMVip.rc
SUBDIRS += \
../FMVipDC/FMVipDC.pro
DESTDIR += ../FMVipTest
CONFIG(debug, debug|release) {
DESTDIR = $$PWD/../FMVipTest/Debug
TARGET = fmvip
LIBS += -L..\FMVipTest\Debug -lFMVipDC
} else {
DESTDIR = $$PWD/../FMVipTest/Release
TARGET = fmvip
LIBS += -L..\FMVipTest\Release -lFMVipDC
}
#include "fmloading.h"
#include "ui_fmloading.h"
FMLoading::FMLoading(QDialog *parent) :
QDialog(parent),
ui(new Ui::FMLoading)
{
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);
movie = new QMovie(":/loading.gif");
movie->start();
ui->loading_lbl->setMovie(movie);
}
FMLoading::~FMLoading()
{
if(movie != NULL) {
delete movie;
movie = NULL;
}
delete ui;
}
#ifndef FMLOADING_H
#define FMLOADING_H
#include <QDialog>
#include <QMovie>
namespace Ui {
class FMLoading;
}
class FMLoading : public QDialog
{
Q_OBJECT
public:
explicit FMLoading(QDialog *parent = 0);
~FMLoading();
private:
Ui::FMLoading *ui;
QMovie *movie;
};
#endif // FMLOADING_H
#include "fmmsgwnd.h"
#include "ui_fmmsgwnd.h"
FMMsgWnd::FMMsgWnd(FMVipWnd *parent) :
FMVipWnd(parent),
ui(new Ui::FMMsgWnd)
{
ui->setupUi(this);
}
FMMsgWnd::~FMMsgWnd()
{
delete ui;
}
void FMMsgWnd::show(InfoType type, const QString &info)
{
switch (type) {
case InfoType::T_Normal:
ui->title_lbl->setText("");
break;
case InfoType::T_Success:
ui->title_lbl->setText("成功");
break;
case InfoType::T_Failure:
ui->title_lbl->setText("失败");
break;
default:
break;
}
ui->info_lbl->setText(info);
this->exec();
}
void FMMsgWnd::on_ok_btn_clicked()
{
this->close();
}
#ifndef FMMSGWND_H
#define FMMSGWND_H
#include "fmvipwnd.h"
namespace Ui {
class FMMsgWnd;
}
class FMMsgWnd : public FMVipWnd
{
Q_OBJECT
public:
explicit FMMsgWnd(FMVipWnd *parent = 0);
~FMMsgWnd();
enum InfoType
{
T_Normal,
T_Success,
T_Failure
};
void show(InfoType type = T_Normal, const QString &info = "");
private slots:
void on_ok_btn_clicked();
private:
Ui::FMMsgWnd *ui;
};
#endif // FMMSGWND_H
......@@ -4,6 +4,7 @@
#include "fmviporder.h"
#include "fmvipfund.h"
#include "fmvipforward.h"
#include "fmmsgwnd.h"
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
......@@ -28,6 +29,9 @@ FMVipDispatcher::FMVipDispatcher(QObject *parent)
_sysIcon->setToolTip("FMVIP");
QMenu *menu = new QMenu();
QAction *action = new QAction("退出", this);
connect(action, SIGNAL(triggered(bool)), this, SLOT(onQuit()));
menu->addAction(action);
// menu->addAction(addAction("退出", [=](){
// this->_ParseRequest("{\"fm_cmd\":\"-1\"}");
// });)
......@@ -37,6 +41,11 @@ FMVipDispatcher::FMVipDispatcher(QObject *parent)
_sysIcon->show();
}
void FMVipDispatcher::onQuit()
{
this->_ParseRequest("{\"fm_cmd\":\"-1\"}");
}
void FMVipDispatcher::onActiveSysTrayIcon(QSystemTrayIcon::ActivationReason reason)
{
switch (reason) {
......@@ -59,7 +68,7 @@ INT FMVipDispatcher::_ParseRequest(LPSTR data)
FMVipForward::instance()->resetSessionData(_posReqObj);
isLastOne = true;
isOnlyForward = false;
_serverRspData.clear();
// 唤起客户端界面
emit requested(_posReqObj);
......@@ -72,10 +81,12 @@ BOOL FMVipDispatcher::_GetResponse(LPSTR &rsp, UINT &len)
{
qDebug() << __FUNCTION__;
// 服务器还未返回则一直阻塞
mutex.lock();
if(_serverRspData.isEmpty())
{
// 服务器还未返回则一直阻塞
serverIsBusy.wait(&mutex);
}
rsp = _serverRspData.data();
len = _serverRspData.length();
mutex.unlock();
......@@ -139,7 +150,6 @@ void FMVipDispatcher::onRequest(const QJsonObject &jsonObj)
FMVipForward::instance()->clearSessionData();
} else {
_serverRspData = Err_ErrorFMCMD;
serverIsBusy.wakeAll();
}
}
......@@ -164,6 +174,7 @@ void FMVipDispatcher::onFinished()
void FMVipDispatcher::onServerResponsed(const QJsonObject &rspObj)
{
if(_vindow != 0) {
_vindow->setIsBusy(false);
_vindow->deleteLater();
}
......@@ -171,34 +182,42 @@ void FMVipDispatcher::onServerResponsed(const QJsonObject &rspObj)
QByteArray rspData = rspDoc.toJson();
_serverRspData = rspData;
if( isLastOne ) {
serverIsBusy.wakeAll();
}
int status = rspObj["statusCode"].toInt();
if(status == 100) {
if(isLastOne && !isOnlyForward) {
QMessageBox msgBox;
msgBox.setWindowTitle("提示");
msgBox.setText("操作成功");
msgBox.setAttribute(Qt::WA_QuitOnClose, false);
msgBox.exec();
}
}
else {
int prompt = rspObj["prompt"].toInt();
// if(status == 100) {
// if(isLastOne && prompt == 0) {
// FMMsgWnd msgWnd;
// msgWnd.show(FMMsgWnd::T_Success, "操作成功");
// QMessageBox msgBox(_vindow);
// msgBox.setWindowTitle("提示");
// msgBox.setText("操作成功");
// msgBox.setAttribute(Qt::WA_QuitOnClose, false);
// msgBox.exec();
// }
// }
if(status != 100) {
if(prompt == 0)
{
QString msg = rspObj["msg"].toString();
QMessageBox msgBox;
msgBox.setWindowTitle("错误");
msgBox.setText(msg);
msgBox.setAttribute(Qt::WA_QuitOnClose, false);
msgBox.exec();
FMMsgWnd msgWnd;
msgWnd.show(FMMsgWnd::T_Failure, msg);
// QMessageBox msgBox;
// msgBox.setWindowTitle("错误");
// msgBox.setText(msg);
// msgBox.setAttribute(Qt::WA_QuitOnClose, false);
// msgBox.exec();
}
requestSuccess = false;
_vindow = 0;
serverIsBusy.wakeAll();
}
if( isLastOne ) {
serverIsBusy.wakeAll();
}
}
// 向服务器发送请求
......@@ -220,7 +239,6 @@ void FMVipDispatcher::login()
void FMVipDispatcher::coupon()
{
isOnlyForward = true;
onDoPost();
}
......@@ -268,19 +286,16 @@ void FMVipDispatcher::fund()
void FMVipDispatcher::final()
{
isOnlyForward = true;
onDoPost();
}
void FMVipDispatcher::orderRefund()
{
isOnlyForward = true;
onDoPost();
}
void FMVipDispatcher::orderRevoke()
{
isOnlyForward = true;
onDoPost();
}
......
......@@ -8,8 +8,8 @@
#include <QMutex>
#include <QWaitCondition>
#define Err_WindowClose "{\"statusCode\":1001,\"msg\":\"窗口异常关闭\"}"
#define Err_ErrorFMCMD "{\"statusCode\":1002,\"msg\":\"无法识别的请求类型\"}"
#define Err_WindowClose "{\"statusCode\":1001, \"prompt\":0, \"msg\":\"窗口异常关闭\"}"
#define Err_ErrorFMCMD "{\"statusCode\":1002, \"prompt\":1, \"msg\":\"无法识别的请求类型\"}"
#define _DEBUG
......@@ -49,6 +49,8 @@ private slots:
void onDoPost();
void onActiveSysTrayIcon(QSystemTrayIcon::ActivationReason);
void onQuit();
private:
FMVipWnd *_vindow;
QJsonObject _posReqObj;
......@@ -61,8 +63,6 @@ private:
QMutex mutex;
QWaitCondition serverIsBusy;
BOOL requestSuccess;
BOOL isOnlyForward;
};
#endif // FMVIPDISPATCHER_H
......@@ -164,8 +164,7 @@ void FMVipForward::login(const QJsonObject &job, QJsonObject &fmjob)
{
Q_UNUSED(job);
fmjob["reqType"] = FM_VIP_LOGIN;
fmjob["payCode"] = sessionData("payCode");
fmjob["mobile"] = sessionData("mobile");
fmjob["code"] = sessionData("code");
}
void FMVipForward::fund(const QJsonObject &job, QJsonObject &fmjob)
{
......@@ -270,6 +269,7 @@ void FMVipForward::logined(const QJsonObject &serverJob, QJsonObject &posJob)
{
QJsonObject memberObj = serverJob["memberInfo"].toObject();
posJob["fm_open_id"] = memberObj["account"];
posJob["prompt"] = 0;
addSessionData("fm_open_id", memberObj["account"].toString());
addSessionData("amount", getString(memberObj["amount"].toInt()));
......@@ -283,16 +283,19 @@ void FMVipForward::funded(const QJsonObject &serverJob, QJsonObject &posJob)
posJob["fm_id"] = cardInfo["memberTransId"];
posJob["fm_open_id"] = cardInfo["account"];
posJob["print"] = serverJob["print"];
posJob["prompt"] = 0;
}
void FMVipForward::couponed(const QJsonObject &serverJob, QJsonObject &posJob)
{
posJob["pid"] = serverJob["productCode"];
posJob["fm_open_id"] = serverJob["account"];
posJob["prompt"] = 1;
}
void FMVipForward::payed(const QJsonObject &serverJob, QJsonObject &posJob)
{
posJob["prompt"] = 0;
int codeAmount = serverJob["codeAmount"].toInt();
int scoreAmount = serverJob["scoreAmount"].toInt();
int paid_total_amount = sessionDataInt("paid_amount") + codeAmount + scoreAmount;
......@@ -328,6 +331,7 @@ void FMVipForward::payed(const QJsonObject &serverJob, QJsonObject &posJob)
void FMVipForward::finaled(const QJsonObject &serverJob, QJsonObject &posJob)
{
posJob["prompt"] = 1;
posJob["fm_id"] = serverJob["memberTransId"];
posJob["print1"] = serverJob["print1"];
posJob["print2"] = serverJob["print2"];
......@@ -335,14 +339,14 @@ void FMVipForward::finaled(const QJsonObject &serverJob, QJsonObject &posJob)
void FMVipForward::orderRefunded(const QJsonObject &serverJob, QJsonObject &posJob)
{
posJob["prompt"] = 1;
Q_UNUSED(serverJob);
Q_UNUSED(posJob);
}
void FMVipForward::orderRevoked(const QJsonObject &serverJob, QJsonObject &posJob)
{
posJob["prompt"] = 1;
Q_UNUSED(serverJob);
Q_UNUSED(posJob);
}
......
......@@ -25,6 +25,8 @@ FMVipFund::FMVipFund(QDialog *parent) :
ui->id_label->setText(fm_id);
ui->balance_label->setText(show_amount_str);
ui->amount_edit->setText(show_charge_amount_str);
ui->fund_btn->setFocus();
}
FMVipFund::~FMVipFund()
......@@ -47,5 +49,6 @@ void FMVipFund::on_fund_btn_clicked()
ui->fund_btn->setEnabled(false);
setIsBusy(true);
emit doPost();
}
......@@ -7,6 +7,7 @@
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include "fmvipforward.h"
#include "fmloading.h"
FMVipLogin::FMVipLogin(QDialog *parent) :
FMVipWnd(parent),
......@@ -17,6 +18,7 @@ FMVipLogin::FMVipLogin(QDialog *parent) :
QString operator_id = FMVipForward::instance()->sessionData("operator_id");
QString business_date = FMVipForward::instance()->sessionData("business_date");
ui->login_edit->setFocus();
ui->operator_label->setText(operator_id);
ui->bd_label->setText(business_date);
}
......@@ -32,19 +34,12 @@ void FMVipLogin::on_login_btn_clicked()
qDebug() << __FUNCTION__;
QString id = ui->login_edit->text();
// 手机号登陆
if(id.length() == 11) {
FMVipForward::instance()->addSessionData("mobile", id);
}
// 支付码登陆
else if(id.length() == 20) {
FMVipForward::instance()->addSessionData("payCode", id);
}
FMVipForward::instance()->addSessionData("code", id);
ui->login_btn->setEnabled(false);
ui->login_edit->setEnabled(false);
setIsBusy(true);
emit doPost();
}
......
......@@ -26,9 +26,13 @@ FMVipOrder::FMVipOrder(QDialog *parent) :
ui->point_label->setText(score_str);
ui->balance_label->setText(orderInfo->getAmountStr());
ui->price_label->setText(orderInfo->getNeedPayStr());
ui->standard_label->setText(QString("满%1元可享受优惠").arg(standard_amount));
if(standard_amount > 0) {
ui->standard_label->setText(QString("满%1元可享受储值金满额支付优惠").arg(standard_amount));
}
ui->pay_edit->setText(orderInfo->getPayAmountStr());
ui->pay_edit->setFocus();
}
FMVipOrder::~FMVipOrder()
......@@ -59,6 +63,7 @@ void FMVipOrder::on_pay_btn_clicked()
ui->pay_btn->setEnabled(false);
ui->pay_chk->setEnabled(false);
setIsBusy(true);
emit doPost();
}
......
......@@ -10,9 +10,10 @@
#endif
FMVipWnd::FMVipWnd(QDialog *parent) :
QDialog(parent)
QDialog(parent),
loadingWindow(new FMLoading(parent))
{
setWindowFlags(Qt::FramelessWindowHint);
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_QuitOnClose, false);
setIsBusy(false);
}
......@@ -47,7 +48,12 @@ void FMVipWnd::on_close_btn_clicked()
void FMVipWnd::setIsBusy(const bool isBusy)
{
Q_UNUSED(isBusy);
if(isBusy)
{
loadingWindow->show();
}else{
loadingWindow->hide();
}
}
int FMVipWnd::exec()
......@@ -68,7 +74,7 @@ int FMVipWnd::exec()
::AttachThreadInput(dwCurID,dwForeID,FALSE);
this->setFocus();
// this->setFocus();
return QDialog::exec();
}
......
......@@ -5,6 +5,7 @@
#include <QJsonObject>
#include <QMap>
#include <QDebug>
#include "fmloading.h"
class FMVipWnd : public QDialog
{
......@@ -14,13 +15,15 @@ public:
//! Set current user profile (Json data)
bool setProfile(const QByteArray&);
void setIsBusy(const bool isBusy);
void setIsBusy(const bool isBusy = true);
int exec();
signals:
void doPost();
public slots:
void on_close_btn_clicked();
private:
FMLoading* loadingWindow;
#ifdef Q_OS_WIN
protected:
bool nativeEvent(const QByteArray &eventType, void *message, long *result);
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FMLoading</class>
<widget class="QWidget" name="FMLoading">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>124</width>
<height>124</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="loading_lbl">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>124</width>
<height>124</height>
</rect>
</property>
<property name="text">
<string>loading...</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FMMsgWnd</class>
<widget class="QWidget" name="FMMsgWnd">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="info_lbl">
<property name="geometry">
<rect>
<x>90</x>
<y>100</y>
<width>211</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QPushButton" name="ok_btn">
<property name="geometry">
<rect>
<x>150</x>
<y>170</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>OK</string>
</property>
</widget>
<widget class="QPushButton" name="close_btn">
<property name="geometry">
<rect>
<x>360</x>
<y>0</y>
<width>31</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>X</string>
</property>
</widget>
<widget class="QLabel" name="title_lbl">
<property name="geometry">
<rect>
<x>150</x>
<y>30</y>
<width>91</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
......@@ -351,6 +351,11 @@
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<tabstops>
<tabstop>login_edit</tabstop>
<tabstop>login_btn</tabstop>
<tabstop>close_btn</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
......@@ -462,7 +462,7 @@
</size>
</property>
<property name="text">
<string>满 0 元可享受优惠</string>
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
......
FMVip/res/loading.gif

38.7 KB | W: | H:

FMVip/res/loading.gif

3.81 KB | W: | H:

FMVip/res/loading.gif
FMVip/res/loading.gif
FMVip/res/loading.gif
FMVip/res/loading.gif
  • 2-up
  • Swipe
  • Onion skin
QT -= core
TARGET = FMVipDC
TEMPLATE = lib
CONFIG += dll
......@@ -25,4 +25,11 @@ INCLUDEPATH += include
LIBS += -lwinhttp -lws2_32
DESTDIR += ../FMVipTest
CONFIG(debug, debug|release) {
DESTDIR = $$PWD/../FMVipTest/Debug
TARGET = FMVipDC
} else {
DESTDIR = $$PWD/../FMVipTest/Release
TARGET = FMVipDC
}
#include "fmsockserver.h"
#include <fmutils/fmutils.hpp>
FMSockServer::FMSockServer(FMApiRelay *relay) :
_worker(0),
_port(0),
......@@ -114,9 +113,10 @@ BOOL FMSockServer::_Listen()
io_data->socket = sclient;
WSARecv(sclient, &io_data->buffer, 1, NULL, &io_data->flags, &io_data->overlap, FMSockServer::RecvRoutine);
DWORD res = SleepEx(1000, TRUE);
while (res != WAIT_IO_COMPLETION) {
FMLOG(_T("Rewaiting for I/O completion..."));
FMLOG(_T("_Listen Rewaiting for I/O completion..."));
res = SleepEx(1000, TRUE);
}
}
......@@ -149,7 +149,6 @@ void FMSockServer::RecvRoutine(DWORD err, DWORD bytes, LPWSAOVERLAPPED overlappe
HeapFree(GetProcessHeap(), 0, io_data);
return;
}
FMLOG(_T("Received bytes: %ld."), bytes);
if (io_data->header.flag == FMSOCKFLAG) {
......@@ -175,9 +174,11 @@ void FMSockServer::RecvRoutine(DWORD err, DWORD bytes, LPWSAOVERLAPPED overlappe
io_new_data->header = io_data->header;
WSARecv(io_new_data->socket, &io_new_data->buffer, 1, NULL, &io_new_data->flags, &io_new_data->overlap, FMSockServer::RecvRoutine);
DWORD res = SleepEx(1000, TRUE);
while (res != WAIT_IO_COMPLETION) {
FMLOG(_T("Rewaiting for I/O completion..."));
FMLOG(_T("RecvRoutine 1 Rewaiting for I/O completion..."));
res = SleepEx(1000, TRUE);
}
}
......@@ -192,19 +193,19 @@ void FMSockServer::RecvRoutine(DWORD err, DWORD bytes, LPWSAOVERLAPPED overlappe
if (response) {
send(io_data->socket, response, len, 0);
// LPFMSOCKDATA io_new_data = NULL;
// io_new_data = (LPFMSOCKDATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMSOCKDATA));
// //! Receive length first
// io_new_data->buffer.len = sizeof(io_new_data->header);
// io_new_data->buffer.buf = (char*)&io_new_data->header;
// io_new_data->relay = io_data->relay;
// io_new_data->socket = io_data->socket;
// WSARecv(io_new_data->socket, &io_new_data->buffer, 1, NULL, &io_new_data->flags, &io_new_data->overlap, FMSockServer::RecvRoutine);
// DWORD res = SleepEx(1000, TRUE);
// while (res != WAIT_IO_COMPLETION) {
// FMLOG(_T("Rewaiting for I/O completion..."));
// res = SleepEx(1000, TRUE);
// }
LPFMSOCKDATA io_new_data = NULL;
io_new_data = (LPFMSOCKDATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(FMSOCKDATA));
//! Receive length first
io_new_data->buffer.len = sizeof(io_new_data->header);
io_new_data->buffer.buf = (char*)&io_new_data->header;
io_new_data->relay = io_data->relay;
io_new_data->socket = io_data->socket;
WSARecv(io_new_data->socket, &io_new_data->buffer, 1, NULL, &io_new_data->flags, &io_new_data->overlap, FMSockServer::RecvRoutine);
DWORD res = SleepEx(1000, TRUE);
while (res != WAIT_IO_COMPLETION) {
FMLOG(_T("RecvRoutine Rewaiting for I/O completion..."));
res = SleepEx(1000, TRUE);
}
}
else {
FMLOG(_T("Failed to determine response data."));
......
......@@ -38,6 +38,7 @@ typedef struct
FMSOCKHEADER header;
char msg[1];
}FMSOCKDATA, *LPFMSOCKDATA;
......@@ -72,6 +73,8 @@ private:
HANDLE _worker;
FMApiRelay *_relay;
CRITICAL_SECTION _cs;
};
//#ifdef __cplusplus
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment