From bd271a8ab403203237d44286d586b005905bc120 Mon Sep 17 00:00:00 2001 From: zhouweipei <2631255083@qq.com> Date: Tue, 30 Jun 2020 12:25:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Orderpage.qml | 205 ++++++++++++++++++++++++++++++++++++++++++++++++ Test.qml | 21 ++--- fanfou.pro.user | 2 +- main.qml | 1 + orderform.cpp | 26 ++++++ orderform.h | 13 ++- qml.qrc | 1 + 7 files changed, 254 insertions(+), 15 deletions(-) create mode 100644 Orderpage.qml diff --git a/Orderpage.qml b/Orderpage.qml new file mode 100644 index 0000000..541bc03 --- /dev/null +++ b/Orderpage.qml @@ -0,0 +1,205 @@ +import QtQuick 2.0 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 +Item { + id: order + ToolBar { + id:toolbar + ToolButton { + text: qsTr("‹") + onClicked:storePage.pop() + } + } + Rectangle { + id: rectangle + height: 101 + color: "#ffffff" + radius: 10 + border.color: "#e72929" + border.width: 2 + anchors.top: toolbar.bottom + anchors.topMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.left: parent.left + anchors.leftMargin: 0 + + TextField { + text:"111" + id: address + height: 40 + placeholderText: "请输入地址" + horizontalAlignment: Text.AlignLeft + anchors.top: parent.top + anchors.topMargin: 8 + anchors.right: parent.right + anchors.rightMargin: 8 + anchors.left: parent.left + anchors.leftMargin: 8 + } + + TextField { + id: name + width: parent.width/3 + height: 40 + placeholderText: "请输入收货人姓名" + anchors.left: parent.left + anchors.leftMargin: 8 + anchors.top: address.bottom + anchors.topMargin: 6 + } + + TextField { + width: parent.width/2 + height: 40 + text: qsTr("") + anchors.right: parent.right + anchors.rightMargin: 72 + id: tel + x: 248 + placeholderText: "请输入收货人电话号码" + anchors.top: address.bottom + anchors.topMargin: 6 + } + + + } + + Rectangle { + id: select_rectangle + height: 78 + color: "#ffffff" + anchors.top: rectangle.bottom + anchors.topMargin: 6 + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + + TextField { + id: name_dish + width: parent.width/4 + height: 40 + placeholderText:"请输入菜名" + anchors.left: parent.left + anchors.leftMargin: 8 + anchors.top: parent.top + anchors.topMargin: 16 + } + + TextField { + id: num + width: parent.width/5 + height: 40 + placeholderText:"请输入数量" + anchors.left: name_dish.right + anchors.leftMargin: 19 + anchors.top: parent.top + anchors.topMargin: 16 + } + + Button { + id: button + text: qsTr("添加到购物车") + anchors.left: num.right + anchors.leftMargin: 21 + anchors.top: parent.top + anchors.topMargin: 19 + } + } + ListView{ + id:orderList + width: parent.width + height: parent.height + anchors.top: select_rectangle.bottom + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.rightMargin: 0 + anchors.bottomMargin: 0 + anchors.leftMargin: 0 + anchors.topMargin: 5 + spacing: 5 + delegate: listDelegate + } + Component{ + id:listDelegate + Rectangle{ + border.color: "lightblue" + id:listItem + width: menuList.width + height: 50 + Image{ + id:pic + height: parent.height + width: height + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin:10 + source: model.modelData.image + } + RowLayout { + id: content + anchors.top: parent.top + anchors.left: pic.right + anchors.leftMargin: 5 + anchors.topMargin: 15 + width: parent.width - pic.width - 50 + height: parent.height + spacing: 5 + Text { + id: textname + font.family: "microsoft yahei" + font.pointSize: 12 + height: parent.height + width:parent.width/5 + text: model.modelData.name + color: "green" + verticalAlignment: Text.AlignVCenter + } + Text { + font.family: "microsoft yahei" + font.pointSize: 20 + height: parent.height + width:parent.width/5 + text: "✖" + verticalAlignment: Text.AlignVCenter + } + + Text { + id: textnum + font.family: "microsoft yahei" + font.pointSize: 12 + height: parent.height + width:parent.width/5 + text: '¥' + model.modelData.price + color: "red" + verticalAlignment: Text.AlignVCenter + } + Rectangle{ + height: width + width:parent.width/10 + Image{ + anchors.verticalCenter: parent.verticalCenter + source:"file:///F:/text/fanfou/images/del.png" + } + MouseArea{ + anchors.fill: parent + onClicked: { + menu.delete_menu(businessName,textname.text) + } + } + } + + } + + } + } +} + +/*##^## +Designer { + D{i:0;autoSize:true;height:480;width:640}D{i:5;anchors_y:54}D{i:6;anchors_y:54}D{i:9;anchors_x:394} +D{i:10;anchors_x:521} +} +##^##*/ diff --git a/Test.qml b/Test.qml index 79b105d..d74f4dd 100644 --- a/Test.qml +++ b/Test.qml @@ -226,11 +226,11 @@ Item { anchors.topMargin: 28 onClicked: { - if(element5.text!=0) + if(element10.text!=0) { - element5.text-- - var amount= element5.text + element10.text-- + var amount= element10.text } console.log(amount) } @@ -247,14 +247,14 @@ Item { anchors.topMargin: 22 Text { - id: element5 + id: element10 verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter anchors.fill: parent font.pixelSize: 12 MouseArea{ anchors.fill: parent - onClicked: console.log(element5.text) + onClicked: console.log(element10.text) } } @@ -269,11 +269,12 @@ Item { anchors.top: parent.top anchors.topMargin: 28 onClicked: { - element5.text++ + element10.text++ } } } + } Connections{ target: menu @@ -307,7 +308,7 @@ Item { anchors.right: parent.right anchors.rightMargin: 0 onClicked: { - + storePage.push("Orderpage.qml") } } // Repeater{ @@ -320,9 +321,9 @@ Item { anchors.leftMargin: 51 anchors.top: parent.top anchors.topMargin: 16 - font.pixelSize: 12 - text: "name" - + font.pixelSize: 20 + text: "¥" + color: "red" } //} } diff --git a/fanfou.pro.user b/fanfou.pro.user index 94105f1..6cde245 100644 --- a/fanfou.pro.user +++ b/fanfou.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/main.qml b/main.qml index d303ae8..5cfd68e 100644 --- a/main.qml +++ b/main.qml @@ -14,6 +14,7 @@ ApplicationWindow { id:business Component.onCompleted: { business.getblist() + console.log(user.username) } } visible: true diff --git a/orderform.cpp b/orderform.cpp index 83c1fd4..4477f27 100644 --- a/orderform.cpp +++ b/orderform.cpp @@ -8,3 +8,29 @@ Orderform::Orderform(QObject *parent) Orderform::~Orderform() {} +void Orderform::select_dish(QString Bname, QString name, int number, QString username, QString usertele, QString addr) +{ + businessname=Bname; + dishName=name; + num =number; + user_name=username; + user_address=addr; + usertele=tel; + QString menudata="Menu_Data_"; + menudata+=Bname; + menudata+=".db"; + menu_data=menuopen.initDatabase(menudata); + QSqlQuery query(menu_data); + query.exec("select *from menu"); + while(query.next()) + { + if(dishName==query.value(0).toString()) + { + pic=query.value(3).toString(); + + } + } +} + + + diff --git a/orderform.h b/orderform.h index bb5afce..ddb10d1 100644 --- a/orderform.h +++ b/orderform.h @@ -1,23 +1,28 @@ #ifndef ORDERFORM_H #define ORDERFORM_H - +#include "database.h" #include #include class Orderform:public QObject { Q_OBJECT + public: Orderform(QObject *parent =nullptr); ~Orderform(); - + Q_INVOKABLE void select_dish(QString Bname,QString name,int number,QString username,QString usertele,QString addr); private: int num; QString dishName; int totalprice; QTime m_time; - QString username; + QString user_name; QString businessname; - + QString tel; + QString user_address; + QString pic; + QSqlDatabase menu_data; + Database menuopen; }; #endif // ORDERFORM_H diff --git a/qml.qrc b/qml.qrc index 76b7536..8d89c8c 100644 --- a/qml.qrc +++ b/qml.qrc @@ -28,5 +28,6 @@ Personalpage.qml BussinessManage.qml MenuManage.qml + Orderpage.qml