check_out.dart 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import 'package:flutter/material.dart';
  2. import 'package:fooddeliveryapp/constants.dart';
  3. import 'package:fooddeliveryapp/model/table.dart';
  4. import 'package:fooddeliveryapp/model/tableDetail.dart';
  5. import 'package:provider/provider.dart';
  6. class CheckOut extends StatelessWidget {
  7. final int index;
  8. static final routeName = "/checkout";
  9. const CheckOut({Key key, this.index}) : super(key: key);
  10. @override
  11. Widget build(BuildContext context) {
  12. TableStatusList myTableStatusList = Provider.of<TableStatusList>(context);
  13. TableDetail myTableDetail = Provider.of<TableDetail>(context);
  14. return Scaffold(
  15. backgroundColor: Colors.green,
  16. body: Container(
  17. margin: EdgeInsets.fromLTRB(
  18. kDefaultPaddin, kDefaultPaddin * 2, kDefaultPaddin, kDefaultPaddin),
  19. padding: EdgeInsets.all(kDefaultPaddin),
  20. decoration: BoxDecoration(
  21. color: Colors.white,
  22. borderRadius: BorderRadius.all(Radius.circular(24))),
  23. child: Column(
  24. children: [
  25. Text(
  26. "订单支付页面",
  27. style: Theme.of(context)
  28. .textTheme
  29. .headline4
  30. .copyWith(color: Colors.black, fontWeight: FontWeight.normal),
  31. ),
  32. Container(
  33. decoration: BoxDecoration(
  34. // shape: BoxShape.circle,
  35. border: Border.all(color: Colors.white),
  36. ),
  37. child: Padding(
  38. padding: const EdgeInsets.all(8.0),
  39. child: Image.asset("assets/images/qc_code.png"),
  40. )),
  41. TotalPrices(),
  42. Text(
  43. "开台时间:" +
  44. myTableDetail
  45. .getOpenTime()
  46. .toIso8601String()
  47. .split("T")[1]
  48. .substring(0, 8),
  49. ),
  50. Text("闭台时间:" +
  51. DateTime.now().toIso8601String().split("T")[1].substring(0, 8)),
  52. Text("服务工号:" + 8.toString()),
  53. FlatButton(
  54. shape: RoundedRectangleBorder(
  55. borderRadius: BorderRadius.circular(18)),
  56. // color: product.color,
  57. color: Colors.red,
  58. onPressed: () {
  59. ///加入购物车
  60. print("支付完成");
  61. myTableStatusList.deletetable(myTableDetail.getTableId());
  62. print("订单cart清空");
  63. myTableDetail.endCart();
  64. Navigator.pop(context);
  65. },
  66. child: Text(
  67. "支付完成".toUpperCase(),
  68. style: TextStyle(
  69. fontSize: 17,
  70. fontWeight: FontWeight.bold,
  71. color: Colors.white,
  72. ),
  73. ),
  74. ),
  75. ],
  76. ),
  77. ),
  78. );
  79. }
  80. }
  81. class TotalPrices extends StatelessWidget {
  82. const TotalPrices({
  83. Key key,
  84. }) : super(key: key);
  85. @override
  86. Widget build(BuildContext context) {
  87. return Consumer<TableDetail>(builder: (context, cart, child) {
  88. return Center(child: Text("¥${cart.getTotalPrices()}"));
  89. });
  90. }
  91. }