huxiaoqiang před 4 roky
rodič
revize
de1e44f75e

+ 28 - 22
lib/paegs/home_page/home_page.dart

@@ -19,6 +19,7 @@ import 'package:bbyyy/my_tools/my_cookie.dart';
 import 'package:bbyyy/my_tools/my_tools.dart';
 import 'package:bbyyy/my_tools/my_views.dart';
 import 'package:bbyyy/paegs/gang_page/gang_in_page/scan_page/scan_page.dart';
+import 'package:bbyyy/paegs/home_page/qr_code_payment/qr_code_payment_page.dart';
 import 'package:bbyyy/paegs/home_page/recommended_today_page.dart';
 import 'package:bbyyy/paegs/root_page/root_page_view.dart';
 import 'package:flutter/cupertino.dart';
@@ -448,8 +449,7 @@ class _HomePageState extends State<HomePage>
                       top: 0,
                       right: 50,
                       child: Container(
-                        padding:
-                            EdgeInsets.only(left: 10, right: 10, top: 12),
+                        padding: EdgeInsets.only(left: 10, right: 10, top: 12),
                         child: GestureDetector(
                           onTap: () {
                             showS = !showS;
@@ -472,9 +472,7 @@ class _HomePageState extends State<HomePage>
                                       : 'images/svg/搜索.svg',
                                   height: 15,
                                   width: 15,
-                                  color: showS
-                                      ? MyColors.cFF4233
-                                      : Colors.white,
+                                  color: MyColors.cFF4233,
                                 ),
                                 Visibility(
                                   visible: showS,
@@ -525,8 +523,7 @@ class _HomePageState extends State<HomePage>
                                           .myText('搜索', Colors.white, 13),
                                       decoration: BoxDecoration(
                                         color: MyColors.cFF4233,
-                                        borderRadius:
-                                            BorderRadius.circular(20),
+                                        borderRadius: BorderRadius.circular(20),
                                       ),
                                       height: 40,
                                       width: 80,
@@ -542,15 +539,10 @@ class _HomePageState extends State<HomePage>
                                 : Alignment.centerLeft,
                             padding: EdgeInsets.only(left: !showS ? 0 : 12),
                             decoration: BoxDecoration(
-                                borderRadius:
-                                    BorderRadius.all(Radius.circular(20)),
-                                color:
-                                    showS ? Colors.white : MyColors.cFF4233,
-                                border: Border.all(
-                                    width: 0.5,
-                                    color: showS
-                                        ? MyColors.cf2f2f2
-                                        : MyColors.cFF4233)),
+                              borderRadius:
+                                  BorderRadius.all(Radius.circular(20)),
+                              color: Colors.white,
+                            ),
                             duration: Duration(milliseconds: 200),
                           ),
                         ),
@@ -561,14 +553,23 @@ class _HomePageState extends State<HomePage>
                       top: 0,
                       right: 0,
                       child: GestureDetector(
-                        onTap: (){
+                        onTap: () {
                           MyTools().toPage(context, ScanPage(), (then) {
                             if (then is String) {
-                              if (then.isNotEmpty &&
-                                  then != null) {
+                              if (then.isNotEmpty && then != null) {
                                 Timer(Duration(milliseconds: 200), () {
-                                  print(then);
+                                  if (then.contains(
+                                      'http://www.banghuo.net/bby/pay/pay.html?shop_uid=')) {
+                                  } else {
+                                    showToast('暂不支持该二维码');
+                                    return;
+                                  }
                                   MyTools().hideKeyboard(context);
+                                  int shopUid = int.parse(then.split('=')[1]);
+                                  print(shopUid);
+                                  MyTools().toPage(context, PayToTheGangPage(shopUid), (then){
+
+                                  });
                                 });
                               }
                             }
@@ -579,8 +580,13 @@ class _HomePageState extends State<HomePage>
                           margin: EdgeInsets.only(left: 10, right: 10, top: 12),
                           height: 40,
                           width: 40,
-                          child: SvgPicture.asset('images/svg/扫一扫_icon.svg',color: Colors.black,),
-                          padding: EdgeInsets.all(10),
+                          child: SvgPicture.asset(
+                            'images/svg/扫一扫_icon.svg',
+                            color: MyColors.cFF4233,
+                            height: 18,
+                            width: 18,
+                          ),
+                          alignment: Alignment.center,
                           decoration: BoxDecoration(
                               borderRadius: BorderRadius.circular(20),
                               color: Colors.white),

+ 244 - 0
lib/paegs/home_page/qr_code_payment/qr_code_payment_page.dart

@@ -0,0 +1,244 @@
+import 'dart:convert';
+
+import 'package:bbyyy/beans/my_shop_bean_entity.dart';
+import 'package:bbyyy/beans/offline_payment_bean_entity.dart';
+import 'package:bbyyy/beans/store_bean_entity.dart';
+import 'package:bbyyy/https/MyDio.dart';
+import 'package:bbyyy/https/url.dart';
+import 'package:bbyyy/my_tools/const.dart';
+import 'package:bbyyy/my_tools/dims.dart';
+import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
+import 'package:bbyyy/my_tools/my_colors.dart';
+import 'package:bbyyy/my_tools/my_cookie.dart';
+import 'package:bbyyy/my_tools/my_tools.dart';
+import 'package:bbyyy/my_tools/my_views.dart';
+import 'package:bbyyy/paegs/pay_page/order_information_page.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+
+class PayToTheGangPage extends StatefulWidget {
+  int shopUid;
+
+  PayToTheGangPage(this.shopUid);
+
+  @override
+  _PayToTheGangPageState createState() => _PayToTheGangPageState();
+}
+
+class _PayToTheGangPageState extends State<PayToTheGangPage> {
+  TextEditingController _controller = TextEditingController();
+  @override
+  void initState() {
+    // TODO: implement initState
+    super.initState();
+    Future.delayed(Duration.zero,(){
+      queryStoreInformation();
+    });
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return GestureDetector(
+      onTap: () {
+        MyTools().hideKeyboard(context);
+      },
+      behavior: HitTestBehavior.translucent,
+      child: Scaffold(
+        body: Column(
+          children: [
+            MyViews().myAppBar('付款给帮主', context, []),
+            Expanded(
+              child: Column(
+                children: [
+                  if(store!=null)
+                  Container(
+                    margin: EdgeInsets.fromLTRB(17, 24, 17, 0),
+                    child: Row(
+                      children: [
+                        ClipRRect(
+                          child: MyViews()
+                              .netImg(imgURL(store.picture), 24, 24),
+                          borderRadius: BorderRadius.circular(12),
+                        ),
+                        Container(
+                          child: MyViews().myText(
+                              store.name, MyColors.c666666, 15),
+                          margin: EdgeInsets.only(left: 10),
+                        ),
+                      ],
+                    ),
+                  ),
+                  Container(
+                    decoration: BoxDecoration(
+                        color: Colors.white,
+                        borderRadius: BorderRadius.circular(4)),
+                    margin: EdgeInsets.symmetric(horizontal: 17, vertical: 14),
+                    padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),
+                    child: Column(
+                      children: [
+                        MyViews().myText('付款金额', MyColors.c333333, 16),
+                        Container(
+                          margin: EdgeInsets.only(top: 15),
+                          child: Row(
+                            children: [
+                              Text(
+                                '¥',
+                                style: TextStyle(
+                                    color: MyColors.c333333, fontSize: 30),
+                              ),
+                              Expanded(
+                                child: TextField(
+                                  inputFormatters: [
+                                    FilteringTextInputFormatter.allow(
+                                        RegExp("[0-9.]")),
+                                  ],
+                                  controller: _controller,
+                                  cursorColor: MyColors.cFF4233,
+                                  cursorWidth: 1.0,
+                                  decoration: InputDecoration(
+                                      border: InputBorder.none,
+                                      disabledBorder: InputBorder.none,
+                                      enabledBorder: InputBorder.none,
+                                      focusedBorder: InputBorder.none,
+                                      hintText: '请输入金额',
+                                      hintStyle: TextStyle(
+                                          color: MyColors.c999999,
+                                          fontSize: 16),
+                                      isDense: true,
+                                      contentPadding: const EdgeInsets.fromLTRB(
+                                          14, 4.5, 8, 4.5)),
+                                  maxLines: 1,
+                                  style: TextStyle(
+                                      color: MyColors.c333333,
+                                      fontSize: 32,
+                                      fontWeight: FontWeight.bold,
+                                      height: 1.3,
+                                      letterSpacing: 0.2),
+                                  keyboardType: TextInputType.numberWithOptions(
+                                      decimal: true),
+                                  onChanged: (t) {
+                                    setState(() {});
+                                  },
+                                ),
+                              )
+                            ],
+                          ),
+                        ),
+                      ],
+                      crossAxisAlignment: CrossAxisAlignment.start,
+                    ),
+                  ),
+                  GestureDetector(
+                    onTap: () {
+                      generateOrders();
+                    },
+                    behavior: HitTestBehavior.translucent,
+                    child: Container(
+                      decoration: BoxDecoration(
+                          color: MyColors.cFF4233,
+                          borderRadius: BorderRadius.circular(20)),
+                      child: MyViews().myText('付款', Colors.white, 14),
+                      alignment: Alignment.center,
+                      height: 40,
+                      margin: EdgeInsets.only(
+                          top: 20, bottom: 15, left: 17, right: 17),
+                    ),
+                  ),
+                ],
+              ),
+            ),
+          ],
+        ),
+      ),
+    );
+  }
+
+  //生成订单
+  generateOrders() {
+    EasyLoading.show();
+    try {
+      amount = double.parse(_controller.text.toString());
+      MyDio().save({
+        'key': 'order',
+        'object': {
+          'uuid': generateMd5(reOS('付款给店主${DateTime.now()}')),
+          'shop_uid': store.uid,
+          'shop_pic': store.picture,
+          'shop_name': store.name,
+          'seller_pic': store.ownerPic,
+          'seller_uid': store.ownerUid,
+          'seller_name': store.ownerName,
+          'buyer_name': MyCookie().getName(),
+          'buyer_uid': MyCookie().getUID(),
+          'buyer_pic': MyCookie().userBean.picture,
+          'type': orderTypeOfflinePay,
+          'amount': amount
+        }
+      }, (response, hasError) {
+        if (!hasError) {
+          OfflinePaymentBeanEntity entity = OfflinePaymentBeanEntity()
+              .fromJson(json.decode(response.data.toString()));
+          payTheOrder(entity.data);
+        }
+      }, (error) {});
+    } catch (e) {
+      showToast('请输入正确的金额');
+    }
+  }
+
+  StoreBeanDataData store;
+  double amount;
+
+  void queryStoreInformation() {
+    MyDio().query({
+      "key": "shop",
+      "filters": {
+        "conditions": ["uid == ${widget.shopUid}"]
+      },
+      "dims": shopDims,
+      "paging": [1, 5]
+    }, (response, hasError) {
+      if (!hasError) {
+        StoreBeanEntity entity =
+        StoreBeanEntity().fromJson(json.decode(response.data.toString()));
+        store = entity.data.data[0];
+        setState(() {
+
+        });
+      }
+    }, (error) {});
+  }
+
+  void payTheOrder(int orderUID) {
+    _controller.clear();
+    MyTools().toPage(
+        context,
+        OrderInformationPage(
+          true,
+          orderType: orderTypeOfflineTransfer,
+          amount: amount,
+          uid: orderUID,
+          buyerUid: MyCookie().getUID(),
+          buyerName: MyCookie().getName(),
+          buyerPic: MyCookie().getPic(),
+          commodityCount: 1,
+          commodityTitle: '到店支付',
+          commodityCover: '',
+          sellName: store.ownerName,
+          sellPic: store.ownerPic,
+          sellUid: store.ownerUid,
+        ),
+            (then) {
+          if(then is int && then ==1){
+            Navigator.pop(context);
+          }
+        });
+    // MyTools().toPage(context, PayPage(orderUID, true, amount), (then) {
+    //   if (then is String) {
+    //     if (then == '支付成功') {
+    //       Navigator.pop(context);
+    //     }
+    //   }
+    // });
+  }
+}