Commit 089ae624 by gujin.wang

添加卡券核销功能

parent 92f1b12a
......@@ -46,7 +46,13 @@ SOURCES += main.cpp\
windows/fmvipsetting.cpp \
task/taskconfirmrecharge.cpp \
windows/fmconfirmwnd.cpp \
windows/fmaboutwnd.cpp
windows/fmaboutwnd.cpp \
task/fmp_redeem.cpp \
windows/consumokdialog.cpp \
windows/consumptiondialog.cpp \
windows/couponkeypad.cpp \
windows/errcodedialog.cpp \
windows/scanningdialog.cpp
HEADERS += \
task/fmtask.h \
......@@ -82,7 +88,13 @@ HEADERS += \
windows/fmvipsetting.h \
task/taskconfirmrecharge.h \
windows/fmconfirmwnd.h \
windows/fmaboutwnd.h
windows/fmaboutwnd.h \
task/fmp_redeem.h \
windows/consumokdialog.h \
windows/consumptiondialog.h \
windows/couponkeypad.h \
windows/errcodedialog.h \
windows/scanningdialog.h
FORMS += \
windows/forms/fmloading.ui \
......@@ -94,9 +106,14 @@ FORMS += \
windows/forms/fmnumpad.ui \
windows/forms/fmvipsetting.ui \
windows/forms/fmconfirmwnd.ui \
windows/forms/fmaboutwnd.ui
windows/forms/fmaboutwnd.ui \
windows/forms/consumokdialog.ui \
windows/forms/consumptiondialog.ui \
windows/forms/couponkeypad.ui \
windows/forms/errcodedialog.ui \
windows/forms/scanningdialog.ui
INCLUDEPATH += ../FMVipDC/ ./task ./windows ./backup
INCLUDEPATH += ../FMVipDC/ ./task ./windows ./backup ../FMCoupon
SUBDIRS += \
../FMVipDC/FMVipDC.pro
......
......@@ -10,6 +10,7 @@
#include "taskothers.h"
#include "fmprinter.h"
#include "fmaboutwnd.h"
#include "fmp_redeem.h"
FMVipDispatcher::FMVipDispatcher(QObject *parent) :
QObject(parent),
......@@ -59,6 +60,30 @@ void FMVipDispatcher::onDoTask()
{
qDebug() << "===============";
qDebug() << "Recv POS reqData: " << reqData.data();
//-----添加卡券核销功能-----
QJsonParseError e;
QJsonDocument doc = QJsonDocument::fromJson(reqData, &e);
if(e.error != QJsonParseError::NoError)
{
FMMsgWnd::FailureWnd("fmv:请求数据解析失败.\n" + e.errorString());
rspData = "{\"msg:\":\"未知的请求类型\"}";
return;
}
QJsonObject jsonObj = doc.object();
if(jsonObj["fm_cmd"].toInt() == FM_NotVipCoupon)
{
fmTask = new FMPRedeem(jsonObj);
rspData = fmTask->doTask();
qDebug() << "Send to pos: " << rspData.data();
qDebug() << "===============";
condition.wakeAll();
del_p(fmTask);
return;
}
//----------------------------------------
fmTask = TaskFactory::Task(reqData);
......@@ -96,7 +121,7 @@ void FMVipDispatcher::onDoTask()
QJsonDocument doc(rspObj);
rspData = doc.toJson(QJsonDocument::Compact);
backupReqObj = QJsonObject();
} else {
}else {
rspData = fmTask->doTask();
if(fmTask->FM_Type() == FM_Manage) {
......
......@@ -12,6 +12,9 @@
#define KEY_CODE "ad124d4e-5f5a-450b-aa4b-902dfdb4631e"
//#define PARTNER_ID "a8bee0dd-09d1-4fa9-a9eb-80cb36d3d611"
#define COUPON_SERVER "Coupon/Server"
#define PAY_PARTNER_ID 1224
// 请求类型链表
const static QStringList FM_Type_List = QString(
"member_manage_request,"
......@@ -46,7 +49,8 @@ enum FM_TYPE {
FM_Card_Lock,
FM_Card_Active,
FM_Coupon,
FM_Reversal // 充值、支付冲正
FM_Reversal, // 充值、支付冲正
FM_NotVipCoupon = 10032 //非VIP卡券核销请求
};
enum Member_Type {
......
......@@ -17,5 +17,21 @@
<file>img_logo.png</file>
<file>FreemudPOS.ico</file>
<file>fm-icon.png</file>
<file>img/bg.png</file>
<file>img/bg_be_invalid.png</file>
<file>img/bg_exchange.png</file>
<file>img/bg_invalid_code.png</file>
<file>img/bg_no_exchange.png</file>
<file>img/bg_sanning.png</file>
<file>img/bg_working.png</file>
<file>img/btn_canel.png</file>
<file>img/btn_consumption.png</file>
<file>img/btn_consumption_invalid.png</file>
<file>img/btn_manual.png</file>
<file>img/close.png</file>
<file>img/consumption_ok.png</file>
<file>img/folat_be_invalid.png</file>
<file>img/ma_bg.png</file>
<file>img/scanning_bar.png</file>
</qresource>
</RCC>
#ifndef FMP_REDEEM_H
#define FMP_REDEEM_H
#include "fmtask.h"
#include <QJsonObject>
#include <QJsonArray>
#include <QObject>
class FMPRedeem : public FMTask
{
Q_OBJECT
enum {
FM_API_SUCCESS = 100,
FM_API_ERROR,
FM_API_TIMEOUT,
FM_API_BADJSON,
FM_API_NETWORKERROR,
FM_API_SERVERERROR,
FM_API_WINDOWCLOSE,
FM_API_TYPEERROR
};
public:
explicit FMPRedeem(QJsonObject &jsonObj, QObject* parent = 0);
virtual ~FMPRedeem();
QJsonObject Redeem(const QJsonObject& request); //券码核销
QJsonObject Reverse(QJsonObject request);
QJsonObject GetRedeemJson()const;
QByteArray doTask();
protected:
virtual void packageServerReq(){}
virtual void packagePOSRsp(){}
private:
QJsonObject SendRequest(const QByteArray &reqData);
QJsonObject ShowForUnConsum(QJsonObject json);
QJsonObject ShowForHasConsum(QJsonObject json);
QJsonObject ShowForInvalid(QJsonObject json);
QJsonObject ShowForExpird(QJsonObject json);
QJsonObject ShowForErr(QJsonObject json);
QJsonObject ShowForMismatch(QJsonObject json);
int ZH_caclChkValue(char * pJsonData, int startPos, int endPos);
QByteArray CheckSendArray( QByteArray & jsonArray);
QJsonValue SearchJsonObject(QJsonObject& searchJson, QString searchKey);
QJsonValue SearchJsonArray(QJsonArray& searchJson, QString searchKey);
private:
QString _store_id;
QString _station_id;
QString _operator_id;
QString _coupon;
int _partner_id;
QString _url;
QJsonArray _products_info;
QJsonObject _redeem_json; //存放核销请求字符串
int _clientReqCount;
};
#endif // FMP_REDEEM_H
......@@ -5,6 +5,7 @@
#include "taskfinal.h"
#include "taskothers.h"
#include "taskconfirmrecharge.h"
#include "fmp_redeem.h"
#include "global.h"
#include "fmmsgwnd.h"
#include <QJsonDocument>
......
#include "consumokdialog.h"
#include "ui_consumokdialog.h"
ConsumOkDialog::ConsumOkDialog(QWidget * parent, Qt::WindowFlags f) :
QDialog(parent, f),
ui(new Ui::ConsumOkDialog)
{
ui->setupUi(this);
setWindowTitle(QString::fromLocal8Bit("非码卡券"));
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
setAutoFillBackground(false); //这个不设置的话就背景变黑
setAttribute(Qt::WA_TranslucentBackground,true);
setAttribute(Qt::WA_QuitOnClose, false);
connect( ui->btnConsumOk, &QPushButton::clicked, this, &ConsumOkDialog::accept);
}
ConsumOkDialog::~ConsumOkDialog()
{
delete ui;
}
void ConsumOkDialog::showConsumOk(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent)
{
ConsumOkDialog v(parent);
// v.setGeometry( 0,0,350,470);
v.ui->labCode->setText( coupon);
v.ui->labActName->setText( act_name);
v.ui->labTime->setText( time_name);
v.ui->labCodeName->setText( code_name);
v.exec();
}
\ No newline at end of file
#ifndef CONSUMOKDIALOG_H
#define CONSUMOKDIALOG_H
#include <QDialog>
namespace Ui {
class ConsumOkDialog;
}
class ConsumOkDialog : public QDialog
{
Q_OBJECT
public:
explicit ConsumOkDialog(QWidget * parent = 0, Qt::WindowFlags f = 0);
~ConsumOkDialog();
static void showConsumOk(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent = 0);
private:
Ui::ConsumOkDialog *ui;
};
#endif // CONSUMOKDIALOG_H
#include "consumptiondialog.h"
#include "ui_consumptiondialog.h"
ConsumptionDialog::ConsumptionDialog(QWidget * parent, Qt::WindowFlags f) :
QDialog(parent, f),
ui(new Ui::ConsumptionDialog)
{
ui->setupUi(this);
setWindowTitle(QString::fromLocal8Bit("非码卡券"));
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
setAutoFillBackground(false); //这个不设置的话就背景变黑
setAttribute(Qt::WA_TranslucentBackground,true);
setAttribute(Qt::WA_QuitOnClose, false);
connect( ui->btnConsumption, &QPushButton::clicked, this, &ConsumptionDialog::accept);
connect( ui->btnCannel, &QPushButton::clicked, this, &ConsumptionDialog::reject);
}
ConsumptionDialog::~ConsumptionDialog()
{
delete ui;
}
bool ConsumptionDialog::ShowForUnConsum(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent)
{
ConsumptionDialog v(parent);
// v.setGeometry( 0,0,350,470);
v.ui->topNoConsumeWidget->setObjectName( "topNoConsumeWidget");
v.ui->topNoConsumeWidget->setStyleSheet( v.ui->topNoConsumeWidget->styleSheet());
v.ui->btnConsumption->setObjectName( "btnConsumption");
v.ui->btnConsumption->setStyleSheet( v.ui->btnConsumption->styleSheet());
v.ui->btnConsumption->setEnabled( true);
v.setData( act_name,code_name ,time_name,coupon );
if( v.exec() == QDialog::Accepted){
return true;
}
return false;
}
bool ConsumptionDialog::ShowForHasConsum(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent)
{
ConsumptionDialog v(parent);
// v.setGeometry( 0,0,350,470);
v.ui->topNoConsumeWidget->setObjectName( "topHasConsumeWidget");
v.ui->topNoConsumeWidget->setStyleSheet( v.ui->topNoConsumeWidget->styleSheet());
v.ui->btnConsumption->setObjectName( "btnConsumNull");
v.ui->btnConsumption->setStyleSheet( v.ui->btnConsumption->styleSheet());
v.ui->btnConsumption->setEnabled( false);
v.setData( act_name,code_name ,time_name,coupon );
if( v.exec() == QDialog::Accepted){
return true;
}
return false;
}
void ConsumptionDialog::setData(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon)
{
ui->labCode->setText( coupon);
ui->labCodeName->setText( code_name);
ui->labActName->setText( act_name);
ui->labTime->setText( time_name);
}
\ No newline at end of file
#ifndef CONSUMPTIONDIALOG_H
#define CONSUMPTIONDIALOG_H
#include <QDialog>
class WorkObject;
namespace Ui {
class ConsumptionDialog;
}
class ConsumptionDialog : public QDialog
{
Q_OBJECT
public:
explicit ConsumptionDialog(QWidget * parent = 0, Qt::WindowFlags f = 0);
~ConsumptionDialog();
void setData(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon);
static bool ShowForUnConsum(const QString &act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent = 0);
static bool ShowForHasConsum(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent = 0);
signals:
void sgBtnOk();
void sgBtnCannel();
private:
Ui::ConsumptionDialog *ui;
};
#endif // CONSUMPTIONDIALOG_H
#include "couponkeypad.h"
#include "ui_couponkeypad.h"
CouponKeypad::CouponKeypad(QWidget *parent, Qt::WindowFlags f) :
QDialog(parent, f),
ui(new Ui::CouponKeypad)
{
ui->setupUi(this);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
connect(ui->d0, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d1, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d2, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d3, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d4, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d5, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d6, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d7, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d8, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
connect(ui->d9, SIGNAL(clicked(bool)), SLOT(onDigitClicked()));
}
CouponKeypad::~CouponKeypad()
{
delete ui;
}
void CouponKeypad::on_btnOK_clicked()
{
code = ui->text->text();
accept();
}
void CouponKeypad::on_btnCancel_clicked()
{
reject();
}
void CouponKeypad::on_btnDelete_clicked()
{
QString text = ui->text->text();
text = text.mid(0, text.length() - 1);
ui->text->setText(text);
}
void CouponKeypad::on_btnClear_clicked()
{
ui->text->setText("");
}
void CouponKeypad::onDigitClicked()
{
QPushButton *btn = qobject_cast<QPushButton*>(sender());
ui->text->setText(ui->text->text() + btn->text());
}
\ No newline at end of file
#ifndef COUPONKEYPAD_H
#define COUPONKEYPAD_H
#include <QDialog>
namespace Ui {
class CouponKeypad;
}
class CouponKeypad : public /*QWidget*/QDialog
{
Q_OBJECT
public:
explicit CouponKeypad(QWidget *parent = 0, Qt::WindowFlags f = 0);
~CouponKeypad();
public slots:
void on_btnOK_clicked();
void on_btnCancel_clicked();
void on_btnDelete_clicked();
void on_btnClear_clicked();
void onDigitClicked();
public:
QString code;
private:
Ui::CouponKeypad *ui;
};
#endif // COUPONKEYPAD_H
#include "errcodedialog.h"
#include "ui_errcodedialog.h"
ErrCodeDialog::ErrCodeDialog(QWidget * parent, Qt::WindowFlags f) :
QDialog(parent, f),
ui(new Ui::ErrCodeDialog)
{
ui->setupUi(this);
setWindowTitle(QString::fromLocal8Bit("非码卡券"));
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
setAutoFillBackground(false); //这个不设置的话就背景变黑
setAttribute(Qt::WA_TranslucentBackground,true);
setAttribute(Qt::WA_QuitOnClose, false);
connect( ui->btnCannel, &QPushButton::clicked, this, &ErrCodeDialog::accept);
}
ErrCodeDialog::~ErrCodeDialog()
{
delete ui;
}
void ErrCodeDialog::showForInvalid(const QString& coupon, QWidget *parent)
{
ErrCodeDialog v(parent);
// v.setGeometry( 0,0,350,470);
v.ui->topInvalidWidget->setObjectName("topInvalidWidget");
v.ui->topInvalidWidget->setStyleSheet( v.ui->topInvalidWidget->styleSheet());
v.ui->labTime->setVisible( false);
v.ui->labActName->setVisible( false);
v.ui->labCodeName->setVisible( false);
v.ui->labFolat->setVisible( false);
v.ui->labCode->setText(coupon );
v.exec();
}
void ErrCodeDialog::showForExpird(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent)
{
ErrCodeDialog v(parent);
// v.setGeometry( 0,0,350,470);
v.ui->topInvalidWidget->setObjectName("topExpirdWidget");
v.ui->topInvalidWidget->setStyleSheet( v.ui->topInvalidWidget->styleSheet());
v.ui->labTime->setVisible( true);
v.ui->labActName->setVisible( true);
v.ui->labCodeName->setVisible( true);
v.ui->labCode->setText(coupon );
v.ui->labTime->setText( time_name);
v.ui->labActName->setText( act_name);
v.ui->labCodeName->setText( code_name);
v.exec();
}
void ErrCodeDialog::showForErr(const QString& coupon, const QString& mess, QWidget *parent)
{
ErrCodeDialog v(parent);
// v.setGeometry( 0,0,350,470);
v.ui->topInvalidWidget->setObjectName("topExpirdWidget");
v.ui->topInvalidWidget->setStyleSheet( v.ui->topInvalidWidget->styleSheet());
v.ui->labTime->setVisible( false);
v.ui->labCodeName->setVisible( false);
v.ui->labFolat->setVisible( false);
v.ui->labActName->setVisible( true);
v.ui->labCode->setText(coupon );
v.ui->labActName->setText( mess);
v.exec();
}
void ErrCodeDialog::showForMismatch(const QString &coupon, const QString &mess, QWidget *parent)
{
ErrCodeDialog v(parent);
// v.setGeometry( 0,0,350,470);
v.ui->topInvalidWidget->setObjectName("topExpirdWidget");
v.ui->topInvalidWidget->setStyleSheet( v.ui->topInvalidWidget->styleSheet());
v.ui->labTime->setVisible( false);
v.ui->labCodeName->setVisible( false);
v.ui->labFolat->setVisible( false);
v.ui->labActName->setVisible( true);
v.ui->labCode->setText(coupon );
v.ui->labActName->setText( mess);
v.exec();
}
#ifndef ERRCODEDIALOG_H
#define ERRCODEDIALOG_H
#include <QDialog>
namespace Ui {
class ErrCodeDialog;
}
class ErrCodeDialog : public QDialog
{
Q_OBJECT
public:
explicit ErrCodeDialog(QWidget * parent = 0, Qt::WindowFlags f = 0);
~ErrCodeDialog();
static void showForInvalid(const QString& coupon, QWidget *parent = 0);
static void showForExpird(const QString& act_name, const QString& code_name, const QString& time_name, const QString& coupon, QWidget *parent = 0);
static void showForErr(const QString& coupon, const QString& mess, QWidget *parent = 0);
static void showForMismatch(const QString& coupon, const QString& mess, QWidget *parent = 0);
private:
Ui::ErrCodeDialog *ui;
};
#endif // ERRCODEDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConsumOkDialog</class>
<widget class="QDialog" name="ConsumOkDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>470</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">#ConsumptionDialog{
border: none;
background-color: transparent;
}
#BgWidget{
border: none; background-color: transparent;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
/**/
#topNoConsumeWidget{
background-image: url(:/img/bg_no_exchange.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
#topHasConsumeWidget{
background-image: url(:/img/bg_exchange.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
/**/
#labActName{
font-size:30px;
font-family:&quot;微软雅黑&quot;;
font-weight:bold;
color: rgb(255, 255, 0);
}
#labCodeName{
font: 72 23pt &quot;微软雅黑&quot;;
color: rgb(146, 53, 50);
}
#labTime{
background-color: rgb(146, 53, 50);
font: 16pt &quot;微软雅黑&quot;;
color: rgb(255, 255, 255);
}
#labCode{
background-image: url(:/img/ma_bg.png);
font: 17pt &quot;微软雅黑&quot;;
color: rgb(33, 33, 33);
}
#btnCannel{
border:none;
background-image: url(:/img/btn_canel.png);
}
/**/
#btnConsumOk{
border:none;
background-image: url(:/img/consumption_ok.png);
}
/**/
</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QWidget" name="BgWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="topHasConsumeWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QLabel" name="labActName">
<property name="geometry">
<rect>
<x>0</x>
<y>105</y>
<width>330</width>
<height>80</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>5元脆骨鸡</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="labCodeName">
<property name="geometry">
<rect>
<x>0</x>
<y>200</y>
<width>330</width>
<height>37</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="text">
<string>键位促销</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="labTime">
<property name="geometry">
<rect>
<x>0</x>
<y>270</y>
<width>330</width>
<height>30</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>上海金桥店 2016.2.2</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="labCode">
<property name="minimumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>123456789</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="btnConsumOk">
<property name="minimumSize">
<size>
<width>330</width>
<height>99</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>99</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConsumptionDialog</class>
<widget class="QDialog" name="ConsumptionDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>470</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">#ConsumptionDialog{
border: none;
background-color: transparent;
}
#BgWidget{
border: none; background-color: transparent;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
/**/
#topNoConsumeWidget{
background-image: url(:/img/bg_no_exchange.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
#topHasConsumeWidget{
background-image: url(:/img/bg_exchange.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
/**/
#labActName{
/*font: 30 bold &quot;微软雅黑&quot;;*/
font-size:30px;
font-family:&quot;微软雅黑&quot;;
font-weight:bold;
color: rgb(255, 255, 0);
border:none;
}
#labCodeName{
font: 72 25pt &quot;微软雅黑&quot;;
color: rgb(146, 53, 50);
border:none;
}
#labTime{
background-color: rgb(146, 53, 50);
font: 11pt &quot;FZLanTingHei-H-GBK&quot;;
color: rgb(255, 255, 255);
border:none;
}
#labCode{
background-image: url(:/img/ma_bg.png);
font: 17pt &quot;FZLanTingHei-H-GBK&quot;;
color: rgb(33, 33, 33);
border:none;
}
#btnCannel{
border:none;
background-image: url(:/img/btn_canel.png);
}
/**/
#btnConsumption{
border:none;
background-image: url(:/img/btn_consumption.png);
}
#btnConsumNull{
border:none;
background-image: url(:/img/btn_consumption_invalid.png);
}
/**/</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QWidget" name="BgWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="topNoConsumeWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QLabel" name="labActName">
<property name="geometry">
<rect>
<x>0</x>
<y>105</y>
<width>330</width>
<height>80</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>查询中...</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="labTime">
<property name="geometry">
<rect>
<x>0</x>
<y>270</y>
<width>330</width>
<height>30</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>9992(4) 2016.2.28/23.59</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="labCodeName">
<property name="geometry">
<rect>
<x>0</x>
<y>205</y>
<width>330</width>
<height>37</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>键位促销</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="labCode">
<property name="minimumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>132456789</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="btnCannel">
<property name="minimumSize">
<size>
<width>111</width>
<height>99</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>111</width>
<height>99</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnConsumption">
<property name="minimumSize">
<size>
<width>219</width>
<height>99</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>219</width>
<height>99</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ErrCodeDialog</class>
<widget class="QDialog" name="ErrCodeDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>470</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>470</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true">#ConsumptionDialog{
border: none;
background-color: transparent;
}
#BgWidget{
border: none; background-color: transparent;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
/**/
#topInvalidWidget{
background-image: url(:/img/bg_invalid_code.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
#topExpirdWidget{
background-image: url(:/img/bg_be_invalid.png);
border:none;
border-top-left-radius:12px;
border-top-right-radius:12px;
}
#labFolat{
border:none;
background-image: url(:/img/folat_be_invalid.png);
}
/**/
#labCode{
background-image: url(:/img/ma_bg.png);
}
#labTime{
background-color: rgb(81, 81, 81);
}
/*label*/
#labActName{
font: 75 30pt &quot;微软雅黑&quot;;
color: rgb(81, 81, 81);
}
#labCodeName{
font: 72 25pt &quot;微软雅黑&quot;;
color: rgb(81, 81, 81);
}
#labTime{
font: 16pt &quot;微软雅黑&quot;;
color: rgb(255, 255, 255);
}
#labCode{
background-image: url(:/img/ma_bg.png);
font: 17pt &quot;微软雅黑&quot;;
color: rgb(33, 33, 33);
}
/*label*/
#btnCannel{
border:none;
background-image: url(:/img/btn_canel.png);
}
/**/
#btnConsumption{
border:none;
background-image: url(:/img/btn_consumption.png);
}
#btnConsumNull{
border:none;
background-image: url(:/img/btn_consumption_invalid.png);
}
/**/</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>10</number>
</property>
<property name="topMargin">
<number>10</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<property name="bottomMargin">
<number>10</number>
</property>
<item>
<widget class="QWidget" name="BgWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>450</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="topInvalidWidget" native="true">
<property name="minimumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>300</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QLabel" name="labTime">
<property name="geometry">
<rect>
<x>0</x>
<y>270</y>
<width>330</width>
<height>30</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>有效期至:2016.2.28/23.59</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="labActName">
<property name="geometry">
<rect>
<x>0</x>
<y>90</y>
<width>330</width>
<height>80</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>5元脆骨鸡</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="labCodeName">
<property name="geometry">
<rect>
<x>0</x>
<y>190</y>
<width>330</width>
<height>37</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>37</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>键位促销</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="labFolat">
<property name="geometry">
<rect>
<x>68</x>
<y>0</y>
<width>262</width>
<height>167</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>262</width>
<height>167</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>262</width>
<height>167</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="labCode">
<property name="minimumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>330</width>
<height>51</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>123456789</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="btnCannel">
<property name="minimumSize">
<size>
<width>111</width>
<height>99</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>111</width>
<height>99</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnConsumNull">
<property name="minimumSize">
<size>
<width>219</width>
<height>99</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>219</width>
<height>99</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ScanningDialog</class>
<widget class="QDialog" name="ScanningDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>449</width>
<height>502</height>
</rect>
</property>
<property name="windowTitle">
<string>ScanningDialog</string>
</property>
<property name="styleSheet">
<string notr="true">#ScanningDialog{
border:none;
background-color: transparent;
}
#widget{
border:none;
background-color:transparent;
border-radius:12px;
background-image:url(:/img/bg_sanning.png);
background-repeat:no-repeat;
}
#btnClose{
border: none;
image: url(:/img/close.png);
padding-left: 28px;
padding-bottom:28px;
}
#labScaningBar{
border: none;
background-image: url(:/img/scanning_bar.png);
}
#btnManual{
border: 0 solid red;
/*background: rgb(231,68,59);*/
background-image: url(:/img/btn_manual.png);
color: rgb(253,197,24);
font: normal 18px &quot;微软雅黑&quot;;
}</string>
</property>
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>49</x>
<y>19</y>
<width>331</width>
<height>451</height>
</rect>
</property>
<widget class="QPushButton" name="btnClose">
<property name="geometry">
<rect>
<x>261</x>
<y>2</y>
<width>75</width>
<height>61</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="labScaningBar">
<property name="geometry">
<rect>
<x>2</x>
<y>312</y>
<width>331</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="btnManual">
<property name="geometry">
<rect>
<x>30</x>
<y>220</y>
<width>273</width>
<height>77</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
#include "scanningdialog.h"
#include "ui_scanningdialog.h"
#include "couponkeypad.h"
#include <QDebug>
#include <Windows.h>
#include <QTimer>
ScanningDialog::ScanningDialog(QWidget * parent, Qt::WindowFlags f) :
QDialog(parent, f),
ui(new Ui::ScanningDialog)
{
ui->setupUi(this);
//setGeometry(0, 0, 350, 470);
setWindowTitle(QString::fromLocal8Bit("非码卡券"));
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint);
//setWindowFlags(Qt::FramelessWindowHint);
//setAutoFillBackground(false); //这个不设置的话就背景变黑
setAttribute(Qt::WA_TranslucentBackground,true);
setAttribute(Qt::WA_QuitOnClose, false);
//扫描动画
scanningBar = new QPropertyAnimation( ui->labScaningBar, "geometry",this);
connect( scanningBar, &QPropertyAnimation::finished, this, &ScanningDialog::animationEnd);
animationUp = true;
animationEnd();
ui->labScaningBar->setFocus();
//关闭按钮
connect(ui->btnClose, &QPushButton::clicked, this, &ScanningDialog::onClose);
//手动输入按钮
connect(ui->btnManual, &QPushButton::clicked, this, &ScanningDialog::manualInput);
QTimer::singleShot(1000, this, &ScanningDialog::timeOut);
}
void ScanningDialog::animationEnd()
{
scanningBar->setDuration(1500);
if(animationUp)
{
scanningBar->setStartValue( QRect( 0,310, 330,33));
scanningBar->setEndValue( QRect( 0,407,330,33));
}
else
{
scanningBar->setStartValue( QRect( 0,407,330,33));
scanningBar->setEndValue( QRect( 0,310, 330,33));
}
animationUp = !animationUp;
scanningBar->start();
}
void ScanningDialog::manualInput()
{
CouponKeypad keypad(this);
if(keypad.exec() == QDialog::Accepted)
{
code = keypad.code;
accept();
}
}
void ScanningDialog::keyPressEvent(QKeyEvent *e)
{
if( e->key() == Qt::Key_Enter || e->key() == Qt::Key_End || e->key() == 16777220 )
{
accept();
return;
}
code.append( e->text());
}
void ScanningDialog::onClose()
{
scanningBar->stop();
close();
}
void ScanningDialog::timeOut()
{
HWND hForeWnd = ::GetForegroundWindow();
DWORD dwForeID = ::GetWindowThreadProcessId(hForeWnd,NULL);
DWORD dwCurID = ::GetCurrentThreadId();
::AttachThreadInput(dwCurID,dwForeID,TRUE);
::SetWindowPos( (HWND)effectiveWinId(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
showNormal();
::SetForegroundWindow((HWND)this->effectiveWinId());
::AttachThreadInput(dwCurID,dwForeID,FALSE);
this->setFocus();
ui->labScaningBar->setFocus();
}
ScanningDialog::~ScanningDialog()
{
delete ui;
}
\ No newline at end of file
#ifndef SCANNINGDIALOG_H
#define SCANNINGDIALOG_H
#include <QDialog>
#include <QPropertyAnimation>
#include <QKeyEvent>
#include <QMouseEvent>
#include "couponkeypad.h"
namespace Ui {
class ScanningDialog;
}
class ScanningDialog : public QDialog
{
Q_OBJECT
public:
explicit ScanningDialog(QWidget * parent = 0, Qt::WindowFlags f = 0);
~ScanningDialog();
protected:
void keyPressEvent(QKeyEvent* e);
private slots:
void animationEnd();
void manualInput();
void onClose();
void timeOut();
public:
QString code;
private:
Ui::ScanningDialog *ui;
QPropertyAnimation *scanningBar;
bool animationUp;
};
#endif // SCANNINGDIALOG_H
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