Commit 26425661 by NitefullWind

1. 认证和支付界面添加虚拟键盘。

parent 5ed20300
......@@ -14,5 +14,6 @@
<file>img/tip_error.png</file>
<file>img/tip_ok.png</file>
<file>img/tip_warning.png</file>
<file>img/num_del.png</file>
</qresource>
</RCC>
......@@ -117,7 +117,7 @@ bool FMTask::sendToServer(bool isShowMsg)
QByteArray data = json.toJson(QJsonDocument::Compact);
#ifdef FMTEST
url = "http://115.159.124.30:8732/pos/member/" + ReqUrl.at(FM_Type());
url = "http://127.0.0.1:5000/vip/" + ReqUrl.at(FM_Type());
#else
url = FMPVipSettings::instance()->getServerUrl() + "/" + ReqUrl.at(FM_Type());
#endif
......@@ -276,9 +276,10 @@ QString FMTask::Sign(const QJsonObject &signJsonObj)
bool FMTask::checkReqJson()
{
bool isOk = false;
QFile jsonFile("FMCMDKeys.json");
QString filePath = qApp->applicationDirPath()+"/FMCMDKeys.json";
QFile jsonFile(filePath);
if(!jsonFile.open(QFile::ReadOnly)) {
setError(FM_API_BADJSON, QString::fromLocal8Bit("读取FMCMDKeys.json失败(%1)").arg(jsonFile.errorString()));
setError(FM_API_BADJSON, QString::fromLocal8Bit("读取%1失败(%2).").arg(filePath).arg(jsonFile.errorString()));
} else {
QByteArray jsonArray = jsonFile.readAll();
QJsonParseError error;
......
#include "fmnumpad.h"
#include "ui_fmnumpad.h"
#include <QDebug>
FMNumPad::FMNumPad(QDialog *parent) :
FMVipWnd(parent),
......@@ -20,18 +21,22 @@ bool FMNumPad::initWnd(Session *session)
{
Q_UNUSED(session)
ui->setupUi(this);
connect(ui->no0, &QPushButton::clicked, this, &FMNumPad::on_digit_clicked);
connect(ui->no1, &QPushButton::clicked, this, &FMNumPad::on_digit_clicked);
connect(ui->no2, &QPushButton::clicked, this, &FMNumPad::on_digit_clicked);
connect(ui->no3, &QPushButton::clicked, this, &FMNumPad::on_digit_clicked);
connect(ui->no4, &QPushButton::clicked, this, &FMNumPad::on_digit_clicked);
connect(ui->no5, &QPushButton::clicked, this, &FMNumPad::on_digit_clicked);
connect(ui->no6, &QPushButton::clicked, this, &FMNumPad::on_digit_clicked);
connect(ui->no7, &QPushButton::clicked, this, &FMNumPad::on_digit_clicked);
connect(ui->no8, &QPushButton::clicked, this, &FMNumPad::on_digit_clicked);
connect(ui->no9, &QPushButton::clicked, this, &FMNumPad::on_digit_clicked);
connect(ui->dot, &QPushButton::clicked, this, &FMNumPad::on_digit_clicked);
setFocusPolicy(Qt::NoFocus);
setWindowFlags(windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
_btnGroup.addButton(ui->no0);
_btnGroup.addButton(ui->no1);
_btnGroup.addButton(ui->no2);
_btnGroup.addButton(ui->no3);
_btnGroup.addButton(ui->no4);
_btnGroup.addButton(ui->no5);
_btnGroup.addButton(ui->no6);
_btnGroup.addButton(ui->no7);
_btnGroup.addButton(ui->no8);
_btnGroup.addButton(ui->no9);
_btnGroup.addButton(ui->dot);
connect(&_btnGroup, static_cast<void(QButtonGroup::*)(QAbstractButton *)>(&QButtonGroup::buttonClicked), this, &FMNumPad::onDigitClicked);
return true;
}
......@@ -40,12 +45,20 @@ FMNumPad::~FMNumPad()
delete ui;
}
void FMNumPad::on_digit_clicked()
void FMNumPad::setLineEdit(QLineEdit *lineEidt)
{
QString num_str = qobject_cast<QPushButton*>(sender())->text();
Q_ASSERT(lineEidt!=nullptr);
this->_lineEdit = lineEidt;
}
void FMNumPad::onDigitClicked(QAbstractButton *button)
{
QString num_str = button->text();
emit digit_click(num_str);
if(_lineEdit != nullptr) {
_lineEdit->insert(num_str);
_lineEdit->setFocus();
}
}
......@@ -54,6 +67,7 @@ void FMNumPad::on_backspace_btn_clicked()
emit digit_delete();
if(_lineEdit != nullptr) {
_lineEdit->backspace();
_lineEdit->setFocus();
}
}
......@@ -62,10 +76,14 @@ void FMNumPad::on_clear_btn_clicked()
emit digit_clear();
if(_lineEdit != nullptr) {
_lineEdit->clear();
_lineEdit->setFocus();
}
}
void FMNumPad::on_confirm_btn_clicked()
{
emit digit_confirm();
if(_lineEdit != nullptr) {
_lineEdit->setFocus();
}
}
......@@ -3,6 +3,7 @@
#include "fmvipwnd.h"
#include <QLineEdit>
#include <QButtonGroup>
namespace Ui {
class FMNumPad;
......@@ -18,6 +19,8 @@ public:
~FMNumPad();
void setLineEdit(QLineEdit *lineEidt);
private:
bool initWnd(Session *session);
......@@ -28,7 +31,7 @@ signals:
void digit_confirm();
private slots:
void on_digit_clicked();
void onDigitClicked(QAbstractButton *button);
void on_backspace_btn_clicked();
......@@ -40,6 +43,7 @@ private:
Ui::FMNumPad *ui;
QLineEdit *_lineEdit;
QButtonGroup _btnGroup;
};
#endif // FMNUMPAD_H
......@@ -4,17 +4,27 @@
#include <QFile>
#include <QMutex>
#include "fmloading.h"
#include "fmnumpad.h"
FMVipLogin::FMVipLogin(QDialog *parent) :
FMVipWnd(parent),
ui(new Ui::FMVipLogin)
{
ui->setupUi(this);
_numpad = new FMNumPad(ui->login_edit, this);
connect(this, &FMVipLogin::rejected, [=](){
_numpad->close();
});
connect(this, &FMVipLogin::accepted, [=](){
_numpad->close();
});
}
FMVipLogin::~FMVipLogin()
{
delete ui;
delete _numpad;
}
bool FMVipLogin::initWnd(Session *session)
......@@ -68,3 +78,12 @@ void FMVipLogin::resetWnd()
ui->login_edit->clear();
ui->login_edit->setFocus();
}
void FMVipLogin::on_login_key_clicked()
{
if(_numpad->isVisible()) {
_numpad->hide();
} else {
_numpad->exec();
}
}
......@@ -4,6 +4,7 @@
#include "fmvipwnd.h"
class QNetworkReply;
class FMNumPad;
namespace Ui {
class FMVipLogin;
......@@ -26,8 +27,13 @@ signals:
void login();
public slots:
void on_login_btn_clicked();
private slots:
void on_login_key_clicked();
private:
Ui::FMVipLogin *ui;
FMNumPad *_numpad;
};
#endif // FMVIPLOGIN_H
......@@ -3,6 +3,7 @@
#include "ui_fmviporder.h"
#include "itemdelegate.h"
#include "couponmodel.h"
#include "fmnumpad.h"
#include <QScrollBar>
#include <QItemSelectionModel>
......@@ -11,12 +12,22 @@ FMVipOrder::FMVipOrder(QDialog *parent) :
ui(new Ui::FMVipOrder)
{
ui->setupUi(this);
_numpad = new FMNumPad(ui->pay_edit, this);
connect(this, &FMVipOrder::rejected, [=](){
_numpad->close();
});
connect(this, &FMVipOrder::accepted, [=](){
_numpad->close();
});
}
FMVipOrder::~FMVipOrder()
{
del_p(orderInfo);
delete ui;
delete _numpad;
}
bool FMVipOrder::initWnd(Session *session)
......@@ -217,3 +228,12 @@ void FMVipOrder::on_score_edit_textChanged(const QString &scoreStr)
oldPayText = DOUBLE_STR(orderInfo->getMaxWillPay());
setWillPayText();
}
void FMVipOrder::on_pay_key_clicked()
{
if(_numpad->isVisible()) {
_numpad->hide();
} else {
_numpad->exec();
}
}
......@@ -7,6 +7,7 @@
class CouponModel;
class QItemSelectionModel;
class FMNumPad;
#define MIN(a,b) ((a<b) ? a : b)
#define MAX(a,b) ((a<b) ? b : a)
......@@ -46,6 +47,8 @@ private slots:
void on_score_edit_textChanged(const QString &scoreStr);
void on_pay_key_clicked();
private:
class OrderInfo
{
......@@ -191,6 +194,8 @@ private:
QItemSelectionModel *selectionModel;
CouponModel *couponModel;
QModelIndex selectedIndex;
FMNumPad *_numpad;
};
#endif // FMVIPORDER_H
......@@ -13,7 +13,7 @@ FMVipWnd::FMVipWnd(QDialog *parent) :
QDialog(parent),
loadingWindow(new FMLoading(this))
{
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_QuitOnClose, false);
setAttribute(Qt::WA_DeleteOnClose, false);
setIsBusy(false);
......
......@@ -14,7 +14,7 @@
<string>Form</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget {
<string notr="true"> QWidget {
font: normal 22px &quot;Microsoft YaHei&quot;;
color: rgb(90,90,90);
}
......@@ -41,8 +41,13 @@
min-width: 32;max-width: 32;
min-height: 32;max-height: 32;
image: url(&quot;:/img/btn_close.png&quot;);
background: rgb(56, 56, 64);
border: 0 solid silver;
border-top: 1 solid silver;
border-right: 1 solid silver;
border-radius: 0;
}
#close_btn:hover {
background: rgb(56, 56, 64);
padding: 0;
}
......@@ -56,14 +61,15 @@ QPushButton {
}
QPushButton:hover {
background: #7aad65;
color: white;
padding: 2 0 0 2;
background: rgb(85, 255, 127);
}
#no0 {
min-width: 106px;
max-width: 106px;}
max-width: 106px;
}
#backspace_btn, #clear_btn {
font: normal 16px &quot;Microsoft YaHei&quot;;
}
......@@ -142,14 +148,14 @@ QPushButton:hover {
<widget class="QPushButton" name="close_btn">
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
<width>33</width>
<height>33</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
<width>33</width>
<height>33</height>
</size>
</property>
<property name="cursor">
......
......@@ -76,7 +76,7 @@
color: rgb(50,50,50);
background: white;
border: 1 solid silver;
border-left: 0;
border-width: 1 0;
}
#login_btn {
......@@ -241,6 +241,35 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="login_key">
<property name="minimumSize">
<size>
<width>51</width>
<height>51</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">#login_key {
border: 1 solid silver;
border-left: 0px;
color: rgb(130,130,130);
background-color: rgb(255, 255, 255);
font: 13px &quot;微软雅黑&quot;;
}
#login_key:hover {
color: rgb(37, 176, 246);
}</string>
</property>
<property name="text">
<string>键盘</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
......
......@@ -179,9 +179,10 @@
color: red;
}
#pay_edit {
#pay_edit, #score_edit {
min-height: 45px;
border: 1 solid silver;
border-width: 1 0 1 1;
text-align: center;
font: 500 30px blod &quot;Microsoft YaHei&quot;;
color: rgb(50,50,50);
......@@ -736,13 +737,13 @@
<number>60</number>
</property>
<property name="topMargin">
<number>10</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>60</number>
</property>
<property name="bottomMargin">
<number>5</number>
<number>0</number>
</property>
<item>
<widget class="QLabel" name="pay_max">
......@@ -755,23 +756,59 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="pay_edit">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="inputMask">
<string/>
</property>
<property name="text">
<string>0.00</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<item>
<widget class="QLineEdit" name="pay_edit">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="inputMask">
<string/>
</property>
<property name="text">
<string>0.00</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pay_key">
<property name="minimumSize">
<size>
<width>40</width>
<height>47</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">#pay_key {
border: 1 solid silver;
border-left: 0px;
color: rgb(130,130,130);
background-color: rgb(255, 255, 255);
font: 13px &quot;微软雅黑&quot;;
}
#pay_key:hover {
color: rgb(37, 176, 246);
}</string>
</property>
<property name="text">
<string>键盘</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="standard_label">
......@@ -790,26 +827,68 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="score_edit">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
</size>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<item>
<widget class="QLineEdit" name="score_edit">
<property name="minimumSize">
<size>
<width>0</width>
<height>47</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="score_key">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">#score_key {
border: 1 solid silver;
border-left: 0px;
color: rgb(130,130,130);
background-color: rgb(255, 255, 255);
font: 13px &quot;微软雅黑&quot;;
}
#score_key:hover {
color: rgb(37, 176, 246);
}</string>
</property>
<property name="text">
<string>键盘</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="score_label">
......
......@@ -18,20 +18,19 @@ private:
FMVipDispatcher fmvip;
private slots:
private:
void initTestCase();
void cleanupTestCase();
void test_dotask_data();
void test_dotask();
void test_Sign_data();
void test_Sign();
void test_JsonObjToMap_data();
void test_JsonObjToMap();
void test_Sign_data();
void test_Sign();
void test_numpad_data();
void test_numpad();
private slots:
void test_dotask_data();
void test_dotask();
};
TestPlugin::TestPlugin()
......@@ -58,13 +57,13 @@ void TestPlugin::test_dotask_data()
{
QTest::addColumn<QByteArray>("reqData");
QTest::newRow("Refund") << QByteArray("{\"fm_cmd\": 1004,\"order_id\": \"20171018003\"}");
QTest::newRow("Refund not") << QByteArray("{\"fm_cmd\": 1004,\"order_id\": \"12345\"}");
QTest::newRow("SetStoreInfo") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"99999\",\"pos_id\": \"1\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
QTest::newRow("SetStoreInfo_need_posId") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"pos_id\": \"\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
QTest::newRow("SetStoreInfo_notnull_posId") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
QTest::newRow("SetStoreInfo_error_type") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"pos_id\": 1,\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
QTest::newRow("Login") << QByteArray("{\"fm_cmd\": 1001}");
// QTest::newRow("Refund") << QByteArray("{\"fm_cmd\": 1004,\"order_id\": \"20171018003\"}");
// QTest::newRow("Refund not") << QByteArray("{\"fm_cmd\": 1004,\"order_id\": \"12345\"}");
// QTest::newRow("SetStoreInfo") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"99999\",\"pos_id\": \"1\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
// QTest::newRow("SetStoreInfo_need_posId") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"pos_id\": \"\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
// QTest::newRow("SetStoreInfo_notnull_posId") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
// QTest::newRow("SetStoreInfo_error_type") << QByteArray("{\"fm_cmd\": 1000,\"store_id\": \"fm9999\",\"pos_id\": 1,\"business_date\": \"20171016\",\"operator_id\": \"001\"}");
// QTest::newRow("Login") << QByteArray("{\"fm_cmd\": 1001}");
QTest::newRow("Pay") << QByteArray("{"
" \"fm_cmd\": 1003,"
" \"order_amount\":900,"
......@@ -87,9 +86,9 @@ void TestPlugin::test_dotask_data()
" }"
" ]"
"}");
QTest::newRow("Order") << QByteArray("{\"fm_cmd\": 1007,\"order_id\": \"20171018003\"}");
QTest::newRow("Fund") << QByteArray("{\"fm_cmd\": 1002,\"order_id\": \"20171018001\"}");
QTest::newRow("CouponPay") << QByteArray("{\"fm_cmd\": 10032}");
// QTest::newRow("Order") << QByteArray("{\"fm_cmd\": 1007,\"order_id\": \"20171018003\"}");
// QTest::newRow("Fund") << QByteArray("{\"fm_cmd\": 1002,\"order_id\": \"20171018001\"}");
// QTest::newRow("CouponPay") << QByteArray("{\"fm_cmd\": 10032}");
}
void TestPlugin::test_dotask()
......@@ -152,20 +151,6 @@ void TestPlugin::test_Sign()
QCOMPARE(FMTask::Sign(jsonObj1), SignStr);
}
void TestPlugin::test_numpad_data()
{
}
void TestPlugin::test_numpad()
{
QLineEdit *edit = new QLineEdit();
FMNumPad pad(edit);
pad.show();
edit->show();
QTest::qWait(1000 * 60 *2);
}
QTEST_MAIN(TestPlugin)
#include "tst_testplugin.moc"
......@@ -5,7 +5,7 @@
#define VER_MINOR 1
#define VER_REVISION 0
#define VER_BUILD 29
#define VER_BUILD 30
//! Convert version numbers to string
#define _STR(S) #S
......
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