Commit 9d5f50fd by Carwyn

Merge remote-tracking branch 'origin/fmp_home'

parents 6f354728 181e0c38
...@@ -17,3 +17,10 @@ Level=1 ...@@ -17,3 +17,10 @@ Level=1
[Syncer] [Syncer]
Server=http://www.baidu.com Server=http://www.baidu.com
Timer=10 Timer=10
[Home]
Server=http://115.159.226.87:20001/api/user/login
StoreId=fm99999
PartnerId=1371
;动画开关,0:关闭 1:开启
Animation=1
\ No newline at end of file
#include "fmp_epay_p.h" #include "fmp_epay_p.h"
#include "fmp_pe_handlers.h"
class ctkPluginContext; class ctkPluginContext;
FMPePay::FMPePay(ctkPluginContext *context) FMPePay::FMPePay(ctkPluginContext *context)
: FMPePayInterface(context), : FMPePayInterface(context),
_inited(false), _inited(false),
d_ptr(new FMPePayPrivate) d_ptr(new FMPePayPrivate)
{ {
FMPStartEventHandler *ste_handler = new FMPStartEventHandler(_ctx, this);
} }
int FMPePay::StopService() int FMPePay::StopService()
......
...@@ -9,13 +9,15 @@ TEMPLATE = lib ...@@ -9,13 +9,15 @@ TEMPLATE = lib
SOURCES += \ SOURCES += \
fmp_epay.cpp \ fmp_epay.cpp \
fmp_epay_p.cpp \ fmp_epay_p.cpp \
fmp_epay_plugin.cpp fmp_epay_plugin.cpp \
fmp_pe_handlers.cpp
HEADERS +=\ HEADERS +=\
fmp_epay.h \ fmp_epay.h \
fmp_epay_i.h \ fmp_epay_i.h \
fmp_epay_p.h \ fmp_epay_p.h \
fmp_epay_plugin_p.h fmp_epay_plugin_p.h \
fmp_pe_handlers.h
unix { unix {
target.path = /usr/lib target.path = /usr/lib
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
#include <ctkPluginContext.h> #include <ctkPluginContext.h>
#include <ctkServiceReference.h> #include <ctkServiceReference.h>
#include <QDebug> #include <QDebug>
#include "fmp_pe_handlers.h"
int FMPePayPrivate::StartService() int FMPePayPrivate::StartService()
{ {
qDebug() << "======== ePay init ==========="; qDebug() << "======== ePay init ===========";
Q_Q(FMPePay); Q_Q(FMPePay);
q->_inited = true; q->_inited = true;
return FMP_SUCCESS; return FMP_SUCCESS;
} }
......
#include <fmp_logger_i.h>
#include "fmp_pe_handlers.h"
#include "fmp_epay.h"
FMPStartEventHandler::FMPStartEventHandler(ctkPluginContext *ctx, FMPePay *epay)
: FMPePayEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_ACK_START "/"
+ QString::number(ctx->getPlugin()->getPluginId()), epay),
_ctx(ctx)
{
FMPProps props;
props[ctkEventConstants::EVENT_TOPIC] = _topic;
_ctx->registerService<ctkEventHandler>(this, props);
}
void FMPStartEventHandler::handleEvent(const ctkEvent &event)
{
qDebug() << "=======-------";
if (_epay) {
if (event.getProperty(FMP_PROPKEY_AGREED).toBool()) {
// _epay->UpgradeOldPlugins(event.getProperty(FMP_PROPKEY_PID_LIST).toList());
_epay->Pay();
}
else {
FMP_WARN_CTX(_ctx) << "Refused start request" << event.getTopic();
}
}
else {
FMP_DEBUG_CTX(_ctx) << "No handler instance for event" << event.getTopic();
}
}
#ifndef FMP_MANAGER_EVENT_HANDLERS_H
#define FMP_MANAGER_EVENT_HANDLERS_H
#include <QObject>
#include <service/event/ctkEventConstants.h>
#include <service/event/ctkEventHandler.h>
class FMPePay;
class FMPePayEventHandler : public ctkEventHandler
{
public:
explicit FMPePayEventHandler(const QString &topic, FMPePay *epay) : _epay(epay), _topic(topic) {}
protected:
FMPePay* _epay;
const QString _topic;
};
/**
* 升级事件处理类
* @brief The FMPUpgradeEventHandler class
*/
class FMPStartEventHandler : public QObject, public FMPePayEventHandler
{
Q_OBJECT
Q_INTERFACES(ctkEventHandler)
public:
explicit FMPStartEventHandler(ctkPluginContext *ctx, FMPePay *epay);
void handleEvent(const ctkEvent &event);
private:
ctkPluginContext* _ctx;
};
#endif // FMP_MANAGER_EVENT_HANDLERS_H
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_REVISION 0 #define VER_REVISION 0
#define VER_BUILD 7 #define VER_BUILD 10
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #define _STR(S) #S
......
...@@ -20,12 +20,12 @@ FMNetwork::~FMNetwork() ...@@ -20,12 +20,12 @@ FMNetwork::~FMNetwork()
delete _req; delete _req;
} }
bool FMNetwork::post(const QString *url, const QByteArray *reqData, QByteArray *rspData) bool FMNetwork::post(const QString &url, const QByteArray *reqData, QByteArray *rspData)
{ {
qDebug() << "Post Url: " << *url; qDebug() << "Post Url: " << url;
qDebug() << "Post Data: " << *reqData; qDebug() << "Post Data: " << *reqData;
_req->setUrl(*url); _req->setUrl(url);
// 设置请求头 // 设置请求头
_req->setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); _req->setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
...@@ -47,7 +47,7 @@ bool FMNetwork::post(const QString *url, const QByteArray *reqData, QByteArray * ...@@ -47,7 +47,7 @@ bool FMNetwork::post(const QString *url, const QByteArray *reqData, QByteArray *
timer.stop(); timer.stop();
if (reply->error() == QNetworkReply::NoError) { if (reply->error() == QNetworkReply::NoError) {
*rspData = reply->readAll(); *rspData = reply->readAll();
qDebug() << tr("Recv data: %1") << *rspData; qDebug() << tr("Recv data: ") << QString::fromUtf8(*rspData);
} else { } else {
_errorString = reply->errorString(); _errorString = reply->errorString();
qDebug() << tr("Network error: %1").arg(_errorString); qDebug() << tr("Network error: %1").arg(_errorString);
......
...@@ -20,7 +20,7 @@ public: ...@@ -20,7 +20,7 @@ public:
* @param rspData 返回数据 * @param rspData 返回数据
* @return 是否有错误 * @return 是否有错误
*/ */
bool post(const QString *url, const QByteArray *reqData, QByteArray *rspData); bool post(const QString &url, const QByteArray *reqData, QByteArray *rspData);
QString errorString() const { return _errorString;} QString errorString() const { return _errorString;}
private: private:
......
#include <fmp_logger_i.h>
#include "fmp_he_handlers.h"
#include "fmp_home.h"
FMPStartEventHandler::FMPStartEventHandler(ctkPluginContext *ctx, FMPHome *home)
: FMPHomeEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_REQ_START "/*" , home),
_ctx(ctx)
{
FMPProps props;
props[ctkEventConstants::EVENT_TOPIC] = _topic;
_ctx->registerService<ctkEventHandler>(this, props);
}
void FMPStartEventHandler::handleEvent(const ctkEvent &event)
{
qDebug() << "===========";
if (_home) {
QString ack_topic = event.getTopic();
//! com/fmp/services/REQ_START/id
ack_topic.replace(FMPE_SERVICE_REQ_START, FMPE_SERVICE_ACK_START);
FMPProps props;
props[FMP_PROPKEY_AGREED] = _home->isLogined();
_home->PostEvent(ack_topic, props);
}
else {
FMP_DEBUG_CTX(_ctx) << "No handler instance for event" << event.getTopic();
}
}
#ifndef FMP_MANAGER_EVENT_HANDLERS_H
#define FMP_MANAGER_EVENT_HANDLERS_H
#include <QObject>
#include <service/event/ctkEventConstants.h>
#include <service/event/ctkEventHandler.h>
class FMPHome;
class FMPHomeEventHandler : public ctkEventHandler
{
public:
explicit FMPHomeEventHandler(const QString &topic, FMPHome *home) : _home(home), _topic(topic) {}
protected:
FMPHome* _home;
const QString _topic;
};
class FMPStartEventHandler : public QObject, public FMPHomeEventHandler
{
Q_OBJECT
Q_INTERFACES(ctkEventHandler)
public:
explicit FMPStartEventHandler(ctkPluginContext *ctx, FMPHome *home);
void handleEvent(const ctkEvent &event);
private:
ctkPluginContext* _ctx;
};
#endif // FMP_MANAGER_EVENT_HANDLERS_H
...@@ -27,3 +27,27 @@ int FMPHome::StopService() ...@@ -27,3 +27,27 @@ int FMPHome::StopService()
Q_D(FMPHome); Q_D(FMPHome);
return d->Uninit(); return d->Uninit();
} }
void FMPHome::StartPlugins(const QVariantList &pids)
{
Q_D(FMPHome);
d->StartPlugins(pids);
}
int FMPHome::login()
{
Q_D(FMPHome);
return d->login();
}
bool FMPHome::isLogined()
{
Q_D(FMPHome);
return d->_isLogined;
}
QString FMPHome::userName()
{
Q_D(FMPHome);
return d->_userName;
}
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
class ctkPluginContext; class ctkPluginContext;
class FMPHomePrivate; class FMPHomePrivate;
class FMPStartEventHandler;
class FMPHome : public QObject, public FMPHomeInterface class FMPHome : public QObject, public FMPHomeInterface
{ {
...@@ -21,12 +22,17 @@ public: ...@@ -21,12 +22,17 @@ public:
int StartService(); int StartService();
int StopService(); int StopService();
public: void StartPlugins(const QVariantList &pids);
int Login() {return 0;}
int login();
bool isLogined();
QString userName();
private: private:
FMPHomePrivate *d_ptr; FMPHomePrivate *d_ptr;
bool _inited; bool _inited;
friend class FMPStartEventHandler;
}; };
#endif // FMP_HOME_H #endif // FMP_HOME_H
...@@ -20,7 +20,8 @@ SOURCES +=\ ...@@ -20,7 +20,8 @@ SOURCES +=\
fmp_wnd.cpp \ fmp_wnd.cpp \
fmp_login.cpp \ fmp_login.cpp \
fmp_num_pad.cpp \ fmp_num_pad.cpp \
fmnetwork.cpp fmnetwork.cpp \
fmp_he_handlers.cpp
HEADERS += fmp_home.h \ HEADERS += fmp_home.h \
fmp_home_plugin_p.h \ fmp_home_plugin_p.h \
...@@ -31,7 +32,8 @@ HEADERS += fmp_home.h \ ...@@ -31,7 +32,8 @@ HEADERS += fmp_home.h \
fmp_login.h \ fmp_login.h \
menubutton.h \ menubutton.h \
fmp_num_pad.h \ fmp_num_pad.h \
fmnetwork.h fmnetwork.h \
fmp_he_handlers.h
FORMS += \ FORMS += \
fmp_home_navwindow.ui \ fmp_home_navwindow.ui \
......
...@@ -7,7 +7,9 @@ class FMPHomeInterface : public FMPluginInterface ...@@ -7,7 +7,9 @@ class FMPHomeInterface : public FMPluginInterface
{ {
public: public:
explicit FMPHomeInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx) {} explicit FMPHomeInterface(ctkPluginContext *ctx) : FMPluginInterface(ctx) {}
virtual int Login() = 0; virtual int login() = 0;
virtual bool isLogined() = 0;
virtual QString userName() = 0;
}; };
Q_DECLARE_INTERFACE(FMPHomeInterface, "com.fmp.home") Q_DECLARE_INTERFACE(FMPHomeInterface, "com.fmp.home")
......
...@@ -5,13 +5,15 @@ ...@@ -5,13 +5,15 @@
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QParallelAnimationGroup> #include <QParallelAnimationGroup>
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include <fmp_settings_i.h>
NavWindow::NavWindow(QWidget *parent) : NavWindow::NavWindow(FMPSettingsInterface *&settings, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::NavWindow), ui(new Ui::NavWindow),
_btn_group(new QButtonGroup(this)), _btn_group(new QButtonGroup(this)),
_animationShow(new QParallelAnimationGroup(this)), _animationShow(new QParallelAnimationGroup(this)),
PI(3.1415926) PI(3.1415926),
_settings(settings)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->navMainBtn->setMovedItem(this); ui->navMainBtn->setMovedItem(this);
...@@ -21,6 +23,7 @@ NavWindow::NavWindow(QWidget *parent) : ...@@ -21,6 +23,7 @@ NavWindow::NavWindow(QWidget *parent) :
MenuUiProp.distance = 100; MenuUiProp.distance = 100;
MenuUiProp.beginAngle = -(PI*0.45); MenuUiProp.beginAngle = -(PI*0.45);
MenuUiProp.endAngle = (PI*0.45); MenuUiProp.endAngle = (PI*0.45);
isUseAnimation = _settings->GetBool(FMP_INIKEY_HOMEANIMATION);
setNavStatus(Default); setNavStatus(Default);
...@@ -29,6 +32,11 @@ NavWindow::NavWindow(QWidget *parent) : ...@@ -29,6 +32,11 @@ NavWindow::NavWindow(QWidget *parent) :
connect(_btn_group, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(onMenuBtnClicked(QAbstractButton*))); connect(_btn_group, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(onMenuBtnClicked(QAbstractButton*)));
initMenu(); initMenu();
connect(this, SIGNAL(statusChanged(NavStatus)), this, SLOT(onStatusChanged(NavStatus)));
connect(_animationShow, &QParallelAnimationGroup::finished, this, [=](){
ui->navMainBtn->lower();
});
} }
NavWindow::~NavWindow() NavWindow::~NavWindow()
...@@ -41,22 +49,7 @@ NavWindow::~NavWindow() ...@@ -41,22 +49,7 @@ NavWindow::~NavWindow()
void NavWindow::setNavStatus(const NavStatus status) void NavWindow::setNavStatus(const NavStatus status)
{ {
this->_status = status; this->_status = status;
switch (status) { emit statusChanged(status);
case Default:
spreadMenus(false);
ui->navMainBtn->setStyleSheet("#navMainBtn{ border-image: url(:fm-icon_01)}");
break;
case Spread:
spreadMenus(true);
ui->navMainBtn->setStyleSheet("#navMainBtn{ border-image: url(:fm-icon_02)}");
break;
case Message:
ui->navMainBtn->setStyleSheet("#navMainBtn{ border-image: url(:xiaoxi)}");
break;
default:
ui->navMainBtn->setStyleSheet("#navMainBtn{ border-image: url(:fm-icon_01)}");
break;
}
} }
void NavWindow::on_navMainBtn_clicked() void NavWindow::on_navMainBtn_clicked()
...@@ -68,11 +61,14 @@ void NavWindow::on_navMainBtn_clicked() ...@@ -68,11 +61,14 @@ void NavWindow::on_navMainBtn_clicked()
void NavWindow::spreadMenus(const bool isSpread) void NavWindow::spreadMenus(const bool isSpread)
{ {
if(isSpread) { //! Start animation.
if(isSpread && isUseAnimation) {
ui->navMainBtn->raise();
_animationShow->start(); _animationShow->start();
} }
//! Set the menu btns are visible.
foreach (QAbstractButton *b , _btn_group->buttons()) { foreach (QAbstractButton *b , _btn_group->buttons()) {
QPushButton *btn = qobject_cast<QPushButton*>(b); auto btn = qobject_cast<QPushButton*>(b);
btn->setVisible(isSpread); btn->setVisible(isSpread);
} }
} }
...@@ -109,7 +105,6 @@ void NavWindow::initMenu() ...@@ -109,7 +105,6 @@ void NavWindow::initMenu()
animation->setEndValue(btn->geometry()); animation->setEndValue(btn->geometry());
_animationShow->addAnimation(animation); _animationShow->addAnimation(animation);
} }
ui->navMainBtn->raise();
} }
void NavWindow::onMenuBtnClicked(QAbstractButton *btn) void NavWindow::onMenuBtnClicked(QAbstractButton *btn)
...@@ -117,3 +112,23 @@ void NavWindow::onMenuBtnClicked(QAbstractButton *btn) ...@@ -117,3 +112,23 @@ void NavWindow::onMenuBtnClicked(QAbstractButton *btn)
QString btnName = btn->objectName(); QString btnName = btn->objectName();
emit menuBtnClicked(btnName); emit menuBtnClicked(btnName);
} }
void NavWindow::onStatusChanged(NavStatus status)
{
switch (status) {
case Default:
spreadMenus(false);
ui->navMainBtn->setStyleSheet("#navMainBtn{ border-image: url(:fm-icon_01)}");
break;
case Spread:
spreadMenus(true);
ui->navMainBtn->setStyleSheet("#navMainBtn{ border-image: url(:fm-icon_02)}");
break;
case Message:
ui->navMainBtn->setStyleSheet("#navMainBtn{ border-image: url(:xiaoxi)}");
break;
default:
ui->navMainBtn->setStyleSheet("#navMainBtn{ border-image: url(:fm-icon_01)}");
break;
}
}
...@@ -12,6 +12,7 @@ class NavWindow; ...@@ -12,6 +12,7 @@ class NavWindow;
class QButtonGroup; class QButtonGroup;
class QAbstractButton; class QAbstractButton;
class QParallelAnimationGroup; class QParallelAnimationGroup;
class FMPSettingsInterface;
class NavWindow : public QDialog class NavWindow : public QDialog
{ {
...@@ -30,7 +31,7 @@ public: ...@@ -30,7 +31,7 @@ public:
Message Message
}; };
explicit NavWindow(QWidget *parent = 0); explicit NavWindow(FMPSettingsInterface* &settings, QWidget *parent = 0);
~NavWindow(); ~NavWindow();
public slots: public slots:
...@@ -50,10 +51,12 @@ public slots: ...@@ -50,10 +51,12 @@ public slots:
signals: signals:
void menuBtnClicked(QString btnName); void menuBtnClicked(QString btnName);
void statusChanged(NavStatus status);
private slots: private slots:
void on_navMainBtn_clicked(); void on_navMainBtn_clicked();
void onMenuBtnClicked(QAbstractButton*); void onMenuBtnClicked(QAbstractButton*);
void onStatusChanged(NavStatus status);
private: private:
Ui::NavWindow *ui; Ui::NavWindow *ui;
...@@ -74,6 +77,9 @@ private: ...@@ -74,6 +77,9 @@ private:
double endAngle; double endAngle;
}; };
MenuUiProps MenuUiProp; MenuUiProps MenuUiProp;
bool isUseAnimation;
FMPSettingsInterface *_settings;
}; };
#endif // NAVWINDOW_H #endif // NAVWINDOW_H
...@@ -4,11 +4,16 @@ ...@@ -4,11 +4,16 @@
#include <ctkPluginContext.h> #include <ctkPluginContext.h>
#include <ctkServiceReference.h> #include <ctkServiceReference.h>
#include <QDebug> #include <QDebug>
#include <fmp_epay_i.h>
#include <fmp_settings_i.h>
#include "fmp_login.h" #include "fmp_login.h"
#include "fmp_he_handlers.h"
FMPHomePrivate::FMPHomePrivate(FMPHome *q) FMPHomePrivate::FMPHomePrivate(FMPHome *q)
: q_ptr(q), : q_ptr(q),
_navWindow(new NavWindow) _isLogined(false),
_userName(""),
_errorMsg("")
{ {
} }
...@@ -19,17 +24,18 @@ FMPHomePrivate::~FMPHomePrivate() ...@@ -19,17 +24,18 @@ FMPHomePrivate::~FMPHomePrivate()
int FMPHomePrivate::Init() int FMPHomePrivate::Init()
{ {
loginWnd = new FMPLogin; Q_Q(FMPHome);
int ret = loginWnd->exec(); _settings = q->GetService<FMPSettingsInterface>(q->_ctx);
delete loginWnd; _navWindow = new NavWindow(_settings);
loginWnd = nullptr;
if(ret == FMP_FAILURE) { FMPStartEventHandler* handler = new FMPStartEventHandler(q->_ctx, q);
if(login() != FMP_SUCCESS) {
return FMP_FAILURE; return FMP_FAILURE;
} }
_navWindow->show(); _navWindow->show();
connect(_navWindow, SIGNAL(menuBtnClicked(QString)), this, SLOT(onMenuBtnClicked(QString))); connect(_navWindow, SIGNAL(menuBtnClicked(QString)), this, SLOT(onMenuBtnClicked(QString)));
Q_Q(FMPHome);
q->_inited = true; q->_inited = true;
return FMP_SUCCESS; return FMP_SUCCESS;
} }
...@@ -49,13 +55,36 @@ int FMPHomePrivate::Uninit() ...@@ -49,13 +55,36 @@ int FMPHomePrivate::Uninit()
return FMP_SUCCESS; return FMP_SUCCESS;
} }
void FMPHomePrivate::StartPlugins(const QVariantList &pids)
{
qDebug() << pids;
}
int FMPHomePrivate::login()
{
FMPLogin loginWnd(_settings->GetString(FMP_INIKEY_LOGINSERVER),
_settings->GetString(FMP_INIKEY_LOGINSTOREID),
_settings->GetString(FMP_INIKEY_LOGINPARTNERID));
loginWnd.exec();
if(loginWnd.isLogined()) {
_isLogined = true;
_userName = loginWnd.userName();
return FMP_SUCCESS;
} else {
_isLogined = false;
return FMP_FAILURE;
}
}
void FMPHomePrivate::onMenuBtnClicked(QString btnName) void FMPHomePrivate::onMenuBtnClicked(QString btnName)
{ {
qDebug() << "====" << __FUNCTION__ << btnName;
Q_Q(FMPHome); Q_Q(FMPHome);
FMP_DEBUG_CTX(q->_ctx) << "Menu clicked: " << btnName;
if(btnName == "huiyuanshezhi") if(btnName == "payment") {
{ FMPePayInterface *e = q->GetService<FMPePayInterface>(q->_ctx);
FMP_DEBUG_CTX(q->_ctx) << "Menu clicked"; e->StartService();
} else if(btnName == "tool") {
qDebug() << "tool menu";
} }
} }
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
class NavWindow; class NavWindow;
class FMPLogin; class FMPLogin;
class FMPSettingsInterface;
class FMPHomePrivate : public QObject class FMPHomePrivate : public QObject
{ {
...@@ -16,15 +17,22 @@ public: ...@@ -16,15 +17,22 @@ public:
int Init(); int Init();
int Uninit(); int Uninit();
void StartPlugins(const QVariantList &pids);
int login();
public slots: public slots:
void onMenuBtnClicked(QString btnName); void onMenuBtnClicked(QString btnName);
public: public:
FMPHome *q_ptr; FMPHome *q_ptr;
bool _isLogined;
QString _userName;
QString _errorMsg;
private: private:
NavWindow *_navWindow; NavWindow *_navWindow;
FMPLogin *loginWnd; FMPSettingsInterface *_settings;
}; };
#endif // FMP_HOME_P_H #endif // FMP_HOME_P_H
...@@ -2,14 +2,22 @@ ...@@ -2,14 +2,22 @@
#include "ui_fmp_login.h" #include "ui_fmp_login.h"
#include <QMessageBox> #include <QMessageBox>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonParseError>
#include "fmp_num_pad.h" #include "fmp_num_pad.h"
#include "fmnetwork.h" #include "fmnetwork.h"
#include <QDebug> #include <QDebug>
FMPLogin::FMPLogin(QDialog *parent) : FMPLogin::FMPLogin(QString url, QString storeId, QString partnerId, QDialog *parent) :
FMPWnd(parent), FMPWnd(parent),
ui(new Ui::FMPLogin), ui(new Ui::FMPLogin),
_numPad(new FMNumPad) _numPad(new FMNumPad),
_userName(""),
_errorMsg(""),
_url(url),
_storeId(storeId),
_partnerId(partnerId)
{ {
ui->setupUi(this); ui->setupUi(this);
connect(_numPad, SIGNAL(digit_confirm()), this, SLOT(on_login_btn_clicked())); connect(_numPad, SIGNAL(digit_confirm()), this, SLOT(on_login_btn_clicked()));
...@@ -28,16 +36,45 @@ FMPLogin::~FMPLogin() ...@@ -28,16 +36,45 @@ FMPLogin::~FMPLogin()
void FMPLogin::on_login_btn_clicked() void FMPLogin::on_login_btn_clicked()
{ {
_numPad->close(); _numPad->close();
QString url = "http://115.159.142.32:30001/api/user/login"; this->setEnabled(false);
QByteArray reqData = "{\"StoreId\": \"123\",\"PartnerId\": \"123\",\"UserId\": \"123\",\"Pwd\": \"123\",\"ClassNo\": \"123\",\"DeviceId\": \"\"}";
if(login(ui->user_edit->text(), ui->pwd_edit->text())) {
this->close();
} else {
QMessageBox::critical(this, "Login Failed", _errorMsg);
this->setEnabled(true);
ui->pwd_edit->clear();
ui->pwd_edit->setFocus();
}
}
bool FMPLogin::login(QString userName, QString password)
{
_userName = "";
QByteArray reqData = tr("{\"StoreId\": \"%1\",\"PartnerId\": \"%2\",\"UserId\": \"%3\",\"Pwd\": \"%4\"}")
.arg(_storeId)
.arg(_partnerId)
.arg(userName)
.arg(password).toLatin1();
QByteArray rspData; QByteArray rspData;
FMNetwork net; FMNetwork net;
if(net.post(&url, &reqData, &rspData)) { if(net.post(_url, &reqData, &rspData)) {
QMessageBox::information(this, "Login", QString(rspData)); // 解析返回的数据
QJsonParseError error;
QJsonDocument json = QJsonDocument::fromJson(rspData, &error);
if(error.error == QJsonParseError::NoError) {
QJsonObject job = json.object();
if(job["Code"] == 1000) {
_userName = job["Data"].toObject()["UserId"].toString();
} else{
_errorMsg = job["Msg"].toString();
}
} else { } else {
QMessageBox::critical(this, "Login", net.errorString()); _errorMsg = error.errorString();
} }
this->close(); }
return isLogined();
} }
void FMPLogin::on_key_btn_clicked() void FMPLogin::on_key_btn_clicked()
......
...@@ -14,9 +14,20 @@ class FMPLogin : public FMPWnd ...@@ -14,9 +14,20 @@ class FMPLogin : public FMPWnd
Q_OBJECT Q_OBJECT
public: public:
explicit FMPLogin(QDialog *parent = 0); explicit FMPLogin(QString url, QString storeId, QString partnerId, QDialog *parent = 0);
~FMPLogin(); ~FMPLogin();
/**
* @brief login
* @param userName
* @param password
* @return
*/
bool login(QString userName, QString password);
bool isLogined() {return _userName != "";}
QString userName() {return _userName;}
QString errorMsg() {return _errorMsg;}
private slots: private slots:
void on_login_btn_clicked(); void on_login_btn_clicked();
...@@ -28,6 +39,12 @@ private: ...@@ -28,6 +39,12 @@ private:
Ui::FMPLogin *ui; Ui::FMPLogin *ui;
FMNumPad* _numPad; FMNumPad* _numPad;
QString _userName;
QString _errorMsg;
const QString _url;
const QString _storeId;
const QString _partnerId;
}; };
#endif // FMP_LOGIN_H #endif // FMP_LOGIN_H
...@@ -355,7 +355,11 @@ QLineEdit { ...@@ -355,7 +355,11 @@ QLineEdit {
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>user_edit</tabstop>
<tabstop>pwd_edit</tabstop>
<tabstop>login_btn</tabstop> <tabstop>login_btn</tabstop>
<tabstop>key_btn</tabstop>
<tabstop>key_btn_2</tabstop>
<tabstop>close_btn</tabstop> <tabstop>close_btn</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_REVISION 0 #define VER_REVISION 0
#define VER_BUILD 7 #define VER_BUILD 10
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #define _STR(S) #S
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_REVISION 0 #define VER_REVISION 0
#define VER_BUILD 7 #define VER_BUILD 10
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #define _STR(S) #S
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <fmp_logger_i.h> #include <fmp_logger_i.h>
#include <fmp_settings_i.h> #include <fmp_settings_i.h>
#include <fmp_syncer_i.h> #include <fmp_syncer_i.h>
#include <fmp_home_i.h>
FMPluginManager::FMPluginManager() : FMPluginManager::FMPluginManager() :
_ctx(nullptr), _ctx(nullptr),
...@@ -201,7 +200,7 @@ void FMPluginManager::OnPluginsChanged(const QString &path) ...@@ -201,7 +200,7 @@ void FMPluginManager::OnPluginsChanged(const QString &path)
if (!expired_plugins.isEmpty()) { if (!expired_plugins.isEmpty()) {
FMPProps props; FMPProps props;
props[FMP_PROPKEY_PID_LIST] = expired_plugins; props[FMP_PROPKEY_PID_LIST] = expired_plugins;
PostEvent(QString(FMP_TOPICS_SERVICES) + "/" + FMPE_SERVICE_REQ_UPDATE, props); PostEvent(QString(FMP_TOPICS_SERVICES) + FMPE_SERVICE_REQ_UPDATE, props);
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "fmp_manager.h" #include "fmp_manager.h"
FMPUpgradeEventHandler::FMPUpgradeEventHandler(ctkPluginContext *ctx, FMPluginManager *pm) FMPUpgradeEventHandler::FMPUpgradeEventHandler(ctkPluginContext *ctx, FMPluginManager *pm)
: FMPManagerEventHandler(FMP_TOPICS_SERVICES "/" FMPE_SERVICE_REQ_UPDATE, pm), : FMPManagerEventHandler(FMP_TOPICS_SERVICES FMPE_SERVICE_REQ_UPDATE, pm),
_ctx(ctx) _ctx(ctx)
{ {
FMPProps props; FMPProps props;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_REVISION 0 #define VER_REVISION 0
#define VER_BUILD 7 #define VER_BUILD 10
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #define _STR(S) #S
......
...@@ -20,5 +20,9 @@ ...@@ -20,5 +20,9 @@
#define FMP_INIKEY_LOGSIZE "Log/Size" #define FMP_INIKEY_LOGSIZE "Log/Size"
#define FMP_INIKEY_LOGLEVEL "Log/Level" #define FMP_INIKEY_LOGLEVEL "Log/Level"
#define FMP_INIKEY_LOGINSERVER "Home/Server"
#define FMP_INIKEY_LOGINSTOREID "Home/StoreId"
#define FMP_INIKEY_LOGINPARTNERID "Home/PartnerId"
#define FMP_INIKEY_HOMEANIMATION "Home/Animation"
#endif // FMP_SETTINGS_DEF_H #endif // FMP_SETTINGS_DEF_H
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_REVISION 0 #define VER_REVISION 0
#define VER_BUILD 7 #define VER_BUILD 10
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #define _STR(S) #S
......
...@@ -8,13 +8,11 @@ QT -= gui ...@@ -8,13 +8,11 @@ QT -= gui
TEMPLATE = lib TEMPLATE = lib
SOURCES += \ SOURCES += \
fmupdater.cpp \
fmp_syncer.cpp \ fmp_syncer.cpp \
fmp_syncer_p.cpp \ fmp_syncer_p.cpp \
fmp_syncer_plugin.cpp fmp_syncer_plugin.cpp
HEADERS += \ HEADERS += \
fmupdater.h \
fmp_syncer.h \ fmp_syncer.h \
fmp_syncer_i.h \ fmp_syncer_i.h \
fmp_syncer_p.h \ fmp_syncer_p.h \
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#define VER_MINOR 1 #define VER_MINOR 1
#define VER_REVISION 0 #define VER_REVISION 0
#define VER_BUILD 7 #define VER_BUILD 10
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #define _STR(S) #S
......
...@@ -21,7 +21,8 @@ public: ...@@ -21,7 +21,8 @@ public:
int StartService() int StartService()
{ {
QString topic = FMP_TOPICS_SERVICES; QString topic = FMP_TOPICS_SERVICES;
topic += QString::number(_ctx->getPlugin()->getPluginId()) + "/" + FMPE_SERVICE_REQ_START; topic += FMPE_SERVICE_REQ_START;
topic += "/" + QString::number(_ctx->getPlugin()->getPluginId());
return PostEvent(topic); return PostEvent(topic);
} }
......
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