Skip to content

Commit

Permalink
完成订单
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouweipei committed Jun 30, 2020
1 parent 225d39c commit bd271a8
Show file tree
Hide file tree
Showing 7 changed files with 254 additions and 15 deletions.
205 changes: 205 additions & 0 deletions Orderpage.qml
Original file line number Diff line number Diff line change
@@ -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}
}
##^##*/
21 changes: 11 additions & 10 deletions Test.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
}

Expand All @@ -269,11 +269,12 @@ Item {
anchors.top: parent.top
anchors.topMargin: 28
onClicked: {
element5.text++
element10.text++
}
}
}


}
Connections{
target: menu
Expand Down Expand Up @@ -307,7 +308,7 @@ Item {
anchors.right: parent.right
anchors.rightMargin: 0
onClicked: {

storePage.push("Orderpage.qml")
}
}
// Repeater{
Expand All @@ -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"
}
//}
}
Expand Down
2 changes: 1 addition & 1 deletion fanfou.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.0, 2020-06-29T01:26:59. -->
<!-- Written by QtCreator 4.11.0, 2020-06-30T03:07:23. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
1 change: 1 addition & 0 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ApplicationWindow {
id:business
Component.onCompleted: {
business.getblist()
console.log(user.username)
}
}
visible: true
Expand Down
26 changes: 26 additions & 0 deletions orderform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
}
}



13 changes: 9 additions & 4 deletions orderform.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
#ifndef ORDERFORM_H
#define ORDERFORM_H

#include "database.h"
#include <QObject>
#include <QTime>
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
1 change: 1 addition & 0 deletions qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
<file>Personalpage.qml</file>
<file>BussinessManage.qml</file>
<file>MenuManage.qml</file>
<file>Orderpage.qml</file>
</qresource>
</RCC>

0 comments on commit bd271a8

Please sign in to comment.