Commit 932c2c54 by NitefullWind

1. 会员认证后,可选择使用代金券。

parent 2f954b44
......@@ -26,7 +26,8 @@ SOURCES += main.cpp\
fmloading.cpp \
fmcouponwidget.cpp \
backup/fmbackup.cpp \
backup/resend.cpp
backup/resend.cpp \
fmvipcouponlist.cpp
HEADERS += fmviporder.h \
fmviplogin.h \
......@@ -39,7 +40,8 @@ HEADERS += fmviporder.h \
fmloading.h \
fmcouponwidget.h \
backup/fmbackup.h \
backup/resend.h
backup/resend.h \
fmvipcouponlist.h
FORMS += forms/fmviporder.ui \
forms/fmviplogin.ui \
......@@ -47,7 +49,8 @@ FORMS += forms/fmviporder.ui \
forms/fmvipfund.ui \
forms/fmmsgwnd.ui \
forms/fmloading.ui \
forms/fmcouponwidget.ui
forms/fmcouponwidget.ui \
forms/fmvipcouponlist.ui
RESOURCES += \
res/FMVip.qrc
......
#include "fmvipcouponlist.h"
#include "fmmsgwnd.h"
#include "fmcouponwidget.h"
#include "ui_fmvipcouponlist.h"
#include <QDebug>
#include <QScrollBar>
FMVipCouponList::FMVipCouponList(QDialog *parent) :
FMVipWnd(parent),
ui(new Ui::FMVipCouponList)
{
ui->setupUi(this);
QString operator_id = SESSIONDATA_STRING("operator_id");
QString business_date = SESSIONDATA_STRING("business_date");
QString fm_id = SESSIONDATA_STRING("fm_open_id");
QString score_str = SESSIONDATA_STRING("score");
QString name = SESSIONDATA_STRING("name");
QString birthday = SESSIONDATA_STRING("birthday");
_couponMap = SESSIONDATA_COUPONMAP("couponMap");
ui->operator_label->setText(operator_id);
ui->bd_label->setText(business_date);
ui->id_label->setText(fm_id);
ui->point_label->setText(score_str);
ui->name_label->setText(name);
ui->bir_label->setText(birthday);
connect(ui->coupon_page, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(onItemClicked(QListWidgetItem*)));
initCouponItems();
}
FMVipCouponList::~FMVipCouponList()
{
delete ui;
}
void FMVipCouponList::onItemClicked(QListWidgetItem *item)
{
QString code = item->data(Qt::UserRole).toString(); // 如果代金券已被选中则取消,否则选中
if(_selectCouponMap.contains(code)) {
ui->coupon_page->itemWidget(item)->setStyleSheet("#FMCouponWidget{background-color: rgb(255, 255, 255); border: none; border-left: 5 solid rgb(255, 170, 37);}");
_selectCouponMap.remove(code);
}else{
ui->coupon_page->itemWidget(item)->setStyleSheet("#FMCouponWidget{background-color: rgb(255, 255, 255); border: none; border-image: url(:/coupon_select.png);}");
_selectCouponMap[code] = _couponMap[code];
}
}
void FMVipCouponList::initCouponItems()
{
for(Coupon coupon : _couponMap)
{
auto item = new QListWidgetItem();
item->setData(Qt::UserRole, coupon.code);
ui->coupon_page->addItem(item);
ui->coupon_page->update();
auto itemWidget = new FMCouponWidget(coupon);
ui->coupon_page->setItemWidget(item, itemWidget);
//item大小
item->setSizeHint (itemWidget->size());
}
}
void FMVipCouponList::on_coupon_prev_btn_clicked()
{
int pos = ui->coupon_page->verticalScrollBar()->value();
ui->coupon_page->verticalScrollBar()->setValue(pos - 125);
}
void FMVipCouponList::on_coupon_next_btn_clicked()
{
int pos = ui->coupon_page->verticalScrollBar()->value();
ui->coupon_page->verticalScrollBar()->setValue(pos + 125);
}
void FMVipCouponList::on_ok_btn_clicked()
{
SESSIONDATA_ADD("usedCoupons", _selectCouponMap);
close();
}
#ifndef FMVIPCOUPONLIST_H
#define FMVIPCOUPONLIST_H
#include <QListWidgetItem>
#include "fmvipwnd.h"
#include "fmvipforward.h"
#define MIN(a,b) ((a<b) ? a : b)
#define MAX(a,b) ((a<b) ? b : a)
#define DOUBLE_STR(num) QString::number(num, 'f', 2)
namespace Ui {
class FMVipCouponList;
}
class FMVipCouponList : public FMVipWnd
{
Q_OBJECT
public:
explicit FMVipCouponList(QDialog *parent = 0);
~FMVipCouponList();
public slots:
void onItemClicked(QListWidgetItem*);
void initCouponItems();
private slots:
void on_coupon_prev_btn_clicked();
void on_coupon_next_btn_clicked();
void on_ok_btn_clicked();
private:
Ui::FMVipCouponList *ui;
QMap<QString, Coupon> _couponMap, _selectCouponMap;
};
#endif // FMVIPCOUPONLIST_H
#include "fmvipdispatcher.h"
#include "fmvipdispatcher.h"
#include "fmviplogin.h"
#include "fmviporder.h"
#include "fmvipfund.h"
......@@ -219,12 +219,12 @@ void FMVipDispatcher::onServerResponsed(const QJsonObject &rspObj)
return;
}
// 成功,且是最后一步,则弹出认证信息
else if(isLastOne) {
QString account = SESSIONDATA_STRING("fm_open_id");
QString name = SESSIONDATA_STRING("name");
QString birthday = SESSIONDATA_STRING("birthday");
FMMsgWnd::LoginSuccess(account, name, birthday);
}
// else if(isLastOne) {
// QString account = SESSIONDATA_STRING("fm_open_id");
// QString name = SESSIONDATA_STRING("name");
// QString birthday = SESSIONDATA_STRING("birthday");
// FMMsgWnd::LoginSuccess(account, name, birthday);
// }
// 成功,是支付认证,但不能支付
else if(isPayLogin) {
if(canPay != 1) {
......
......@@ -13,6 +13,7 @@
#include <QFuture>
#include <QSharedPointer>
#include <QSemaphore>
#include "fmvipcouponlist.h"
#include "fmbackup.h"
#include <QDebug>
......@@ -391,9 +392,10 @@ void FMVipForward::logined(const QJsonObject &serverJob, QJsonObject &posJob)
QString codeStr = co["couponCode"].toString();
double amount = co["disAmount"].toInt()/100.0;
QString desc = co["desc"].toString();
QString pid = co["productCode"].toString();
QVariant v;
v.setValue(Coupon{codeStr, amount, desc});
v.setValue(Coupon{codeStr, amount, desc, pid});
couponMap[co["couponCode"].toString()] = v;
}
SESSIONDATA_ADD("couponMap", couponMap);
......@@ -407,6 +409,23 @@ void FMVipForward::logined(const QJsonObject &serverJob, QJsonObject &posJob)
SESSIONDATA_ADD("name", name);
SESSIONDATA_ADD("mobile", mobile);
SESSIONDATA_ADD("birthday", birthday);
// 展示用户代金券
if(SESSIONDATA_STRING("canPay")!="") {
FMVipCouponList couponListWnd;
couponListWnd.exec();
}
QJsonArray coupons;
QMap<QString, Coupon> selectCouponMap = SESSIONDATA_COUPONMAP("usedCoupons");
foreach (Coupon coupon, selectCouponMap) {
QJsonObject couponObj;
couponObj["code"] = coupon.code;
couponObj["pid"] = coupon.pid;
coupons.append(couponObj);
}
posJob["coupons"] = coupons;
}
void FMVipForward::funded(const QJsonObject &serverJob, QJsonObject &posJob)
......
......@@ -35,6 +35,7 @@ struct Coupon
QString code;
double disAmount;
QString desc;
QString pid;
};
Q_DECLARE_METATYPE(Coupon) // 使Coupon类型可以和QVariant类型互相转换
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FMVipCouponList</class>
<widget class="QWidget" name="FMVipCouponList">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>968</width>
<height>768</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>968</width>
<height>768</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="windowTitle">
<string>FMVipOrder</string>
</property>
<property name="styleSheet">
<string notr="true">QWidget {
font: normal 22px &quot;Microsoft YaHei&quot;;
color: rgb(90,90,90);
}
/*
* 标题栏
*/
#title {
background: rgb(154,200,50);
min-height: 62px; max-height: 62px;
border: 1 solid silver;
border-bottom: 0 solid silver;
}
#logo_label {
min-width: 153px; min-height: 69px;
border-image: url(&quot;:/img_logo.png&quot;);
}
#close_btn {
min-width: 53px; min-height: 53px;
border-image: url(&quot;:/btn_close.png&quot;);
}
#close_btn:hover{
min-width: 51px; min-height: 51px;
border-image: url(&quot;:/btn_alert_close.png&quot;);
}
/*
* 会员信息
*/
#profile{
background: rgb(240,242,237);
min-height: 82px; max-height: 82px;
border: 0 solid transparent;
border: 1px solid silver;
}
/*
* 优惠券
*/
#coupon {
min-height: 520px;
max-height: 520px;
border: 1 solid silver;
border-top: 0 solid silver;
background: rgb(223, 224, 223);
}
#coupon_desc_label {
background: white;
max-width: 200px;min-width: 200px;
color: rgb(120,120,120);
border: 1 solid silver;
border-top: 0 solid silver;
}
#coupon_page{
background: rgb(223, 224, 223);
border: 1 solid white;
border-right: 1 solid silver;
border-bottom: 1 solid silver;
border-left: 0 solid silver;
}
#coupon_label {
background: rgb(222,88,51);
min-height: 50px;
color: white;
font: 500 20px &quot;Microsoft YaHei&quot;;
}
#position_label {
font: 400 16px &quot;Microsoft YaHei&quot;;
min-height: 50px;
}
#coupon_prev_btn, #coupon_next_btn {
font: 400 16px &quot;Microsoft YaHei&quot;;
min-height: 60px; max-height: 60px;
min-width: 70px; max-width: 70px;
border: 1 solid rgb(228,228,228);
border-radius: 7px;
background: white;
}
#coupon_prev_btn:hover, #coupon_next_btn:hover {
background: rgb(154,200,50);
color: white;
}
/*
#coupon_prev_btn
{
margin-top: 35px;
}
#coupon_next_btn
{
margin-bottom: 35px;
}*/
/*
* 确定
*/
#okWidget {
min-height: 50px;
max-height: 50px;
border: 1 solid silver;
border-top: 0 solid silver;
background: rgb(223, 224, 223);
}
#ok_btn {
font: 400 16px &quot;Microsoft YaHei&quot;;
min-height: 45; max-height: 45;
min-width: 200px; max-width: 200px;
border: 1 solid rgb(228,228,228);
border-radius: 7px;
background: white;
}
#ok_btn:hover {
background: rgb(154,200,50);
color: white;
}
/*
* 信息
*/
#tip, #tip QLabel {
background: rgb(100,100,100);
color: rgb(252,252,252);
font-size: 18px;
border-bottom: 1 solid silver;
}
#tip {
border: 1 solid silver;
border-top: 0;
}
/*======Coupon======*/
#FMCouponWidget
{
border: 0 solid white;
border-left: 5 solid rgb(255, 170, 37);
background-color: rgb(255, 255, 255);
}
#code_lab
{
max-height: 15;
min-height: 15;
padding-bottom: 3px;
color: rgb(127,127,127);
font: 12px &quot;Microsoft YaHei&quot;;
}
#amount_lab, #currency
{
color: rgb(229, 11, 72);
font: bold 30px &quot;Microsoft YaHei&quot;;
}
#currency
{
font: bold 15px;
margin-top: 11px;
}
#desc_lab
{
max-height: 21;
min-height: 21;
color: rgb(252,255,255);
background-color: rgb(229, 11, 72);
font: bold 15px &quot;Microsoft YaHei&quot;;
margin-left: 4px;
margin-bottom: 3px;
padding: 0 10 0 10;
}
#coupon_separator
{
max-height: 1px;
border-image: url(:/coupon_separator.png);
margin: 0 6 10 6;
}</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<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="title" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_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="QLabel" name="logo_label">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="close_btn">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="profile" native="true">
<layout class="QHBoxLayout" name="profileLay">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>20</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="id_desc_label">
<property name="text">
<string>会员编号:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="id_label">
<property name="text">
<string>00000000000</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>122</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="bir_desc_label">
<property name="text">
<string>生日:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="bir_label">
<property name="text">
<string>2016-9-27</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_20">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>122</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="name_desc_label">
<property name="text">
<string>姓名:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="name_label">
<property name="text">
<string>未知</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>123</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="balance_desc_label">
<property name="text">
<string>余额:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="balance_label">
<property name="text">
<string>0.00</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>122</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="point_desc_label">
<property name="text">
<string>积分:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="point_label">
<property name="text">
<string>100000</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="coupon" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>521</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>521</height>
</size>
</property>
<layout class="QHBoxLayout" name="couponLay">
<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>
<layout class="QVBoxLayout" name="coupon_page_lay">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QListWidget" name="coupon_page">
<property name="minimumSize">
<size>
<width>0</width>
<height>550</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="autoScroll">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<property name="verticalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="horizontalScrollMode">
<enum>QAbstractItemView::ScrollPerItem</enum>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="spacing">
<number>10</number>
</property>
<property name="gridSize">
<size>
<width>230</width>
<height>124</height>
</size>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="modelColumn">
<number>0</number>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
<property name="currentRow">
<number>-1</number>
</property>
<property name="widgetResizable" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="pageCtrlLayLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="coupon_prev_btn">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>
</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="position_label">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="coupon_next_btn">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="mouseTracking">
<bool>false</bool>
</property>
<property name="text">
<string>
</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="okWidget" native="true">
<layout class="QHBoxLayout" name="okLay">
<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>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="ok_btn">
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="tip" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>44</height>
</size>
</property>
<layout class="QHBoxLayout" name="tipLay">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>20</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>20</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="operator_desc_label">
<property name="text">
<string>操作员:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="operator_label">
<property name="text">
<string>00000000</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="bd_desc_label">
<property name="text">
<string>营业日:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="bd_label">
<property name="text">
<string>0000-00-00</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
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