panhui 6 年之前
父節點
當前提交
5545116956
共有 8 個文件被更改,包括 132 次插入43 次删除
  1. 二進制
      images/2x/pay1.png
  2. 二進制
      images/3x/pay1.png
  3. 二進制
      images/pay1.png
  4. 2 1
      lib/model/ProductInfo.dart
  5. 3 2
      lib/model/ProductInfo.g.dart
  6. 84 17
      lib/pages/ChoosePay.dart
  7. 1 1
      lib/pages/CompetitionInformation.dart
  8. 42 22
      lib/pages/ShoppingMall.dart

二進制
images/2x/pay1.png


二進制
images/3x/pay1.png


二進制
images/pay1.png


+ 2 - 1
lib/model/ProductInfo.dart

@@ -4,11 +4,12 @@ part 'ProductInfo.g.dart';
 
 @JsonSerializable()
 class ProductInfo {
-  ProductInfo(this.id, this.productName, this.money, this.typeFlag);
+  ProductInfo(this.id, this.productName, this.money, this.typeFlag,this.canUse);
   int id;
   String productName;//名称
   int money;//钱
   int typeFlag;//类型
+  bool canUse;//可用
   factory ProductInfo.fromJson(Map<String, dynamic> json) =>
       _$ProductInfoFromJson(json);
 

+ 3 - 2
lib/model/ProductInfo.g.dart

@@ -8,7 +8,7 @@ part of 'ProductInfo.dart';
 
 ProductInfo _$ProductInfoFromJson(Map<String, dynamic> json) {
   return ProductInfo(json['id'] as int, json['productName'] as String,
-      json['money'] as int, json['typeFlag'] as int);
+      json['money'] as int, json['typeFlag'] as int,json['canUse']==null?false: json['canUse'] as bool);
 }
 
 Map<String, dynamic> _$ProductInfoToJson(ProductInfo instance) =>
@@ -16,5 +16,6 @@ Map<String, dynamic> _$ProductInfoToJson(ProductInfo instance) =>
       'id': instance.id,
       'productName': instance.productName,
       'money': instance.money,
-      'typeFlag': instance.typeFlag
+      'typeFlag': instance.typeFlag,
+      'canUse':instance.canUse
     };

+ 84 - 17
lib/pages/ChoosePay.dart

@@ -19,12 +19,41 @@ class ChoosePay extends StatefulWidget {
 }
 
 class _ChoosePayState extends State<ChoosePay> with WidgetsBindingObserver {
-  String chooseKey = 'alipay';
+  String chooseKey = '';
+  bool isAlipay = false;
+  bool isWechat = false;
+  bool isCloud_flash = false;
+  bool isUnion_pay = false;
+  int userId = 0;
   Future<void> getUserInfo() async {
     Result res = await HttpManager.get('userInfo/getUserInfo');
     if (res.success) {
       print(res.data);
       StoreProvider.of<AppState>(context).dispatch(UpdateUserAction(UserInfo.fromJson(res.data)));
+      userId = res.data['id'];
+    } else {}
+  }
+
+  Future<void> getInfo() async {
+    Result res = await HttpManager.get('payCodeStock/allUsedPayType?moeny=${widget.chooseProduct.money}');
+    if (res.success) {
+      for (var item in res.data) {
+        setState(() {
+          if (item['payType'] == 'wechat') {
+            isWechat = true;
+          } else if (item['payType'] == 'alipay') {
+            isAlipay = true;
+          } else if (item['payType'] == 'cloud_flash') {
+            isCloud_flash = true;
+          } else if (item['payType'] == 'union_pay') {
+            isUnion_pay = true;
+          }
+
+          if (chooseKey == '') {
+            chooseKey = item['payType'];
+          }
+        });
+      }
     } else {}
   }
 
@@ -32,7 +61,10 @@ class _ChoosePayState extends State<ChoosePay> with WidgetsBindingObserver {
   void initState() {
     super.initState();
     // fluwx.register(appId: "wx62f8a9c1d3d70245");
-    Future.delayed(Duration.zero, () => getUserInfo());
+    Future.delayed(Duration.zero, () {
+      getUserInfo();
+      getInfo();
+    });
   }
 
   @override
@@ -63,16 +95,34 @@ class _ChoosePayState extends State<ChoosePay> with WidgetsBindingObserver {
                 ],
               ),
             ),
-            PayContent('支付宝', '支持有支付宝,网银的用户使用', 'images/icon_zhifubao.png', 'alipay', chooseKey, () {
-              setState(() {
-                chooseKey = 'alipay';
-              });
-            }),
-            PayContent('微信支付', '使用微信支付,方便快捷', 'images/icon_weixin.png', 'wxpay', chooseKey, () {
-              setState(() {
-                chooseKey = 'wxpay';
-              });
-            })
+            isAlipay
+                ? PayContent('支付宝', '支持有支付宝,网银的用户使用', 'images/icon_zhifubao.png', 'alipay', chooseKey, () {
+                    setState(() {
+                      chooseKey = 'alipay';
+                    });
+                  })
+                : Container(),
+            isWechat
+                ? PayContent('微信支付', '使用微信支付,方便快捷', 'images/icon_weixin.png', 'wechat', chooseKey, () {
+                    setState(() {
+                      chooseKey = 'wechat';
+                    });
+                  })
+                : Container(),
+            isCloud_flash
+                ? PayContent('云闪付', '支持各大银联银行支付', 'images/pay1.png', 'wechat', chooseKey, () {
+                    setState(() {
+                      chooseKey = 'wechat';
+                    });
+                  })
+                : Container(),
+            isUnion_pay
+                ? PayContent('银联支付', '支持各大银联银行支付', 'images/pay1.png', 'wechat', chooseKey, () {
+                    setState(() {
+                      chooseKey = 'wechat';
+                    });
+                  })
+                : Container()
           ],
         ),
       ),
@@ -85,12 +135,29 @@ class _ChoosePayState extends State<ChoosePay> with WidgetsBindingObserver {
           textColor: Colors.white,
           child: Text('立即支付'),
           onPressed: () async {
-            const url = 'https://flutter.dev';
-            if (await canLaunch(url)) {
-              await launch(url);
+            int stockId = 0;
+            Toast.show(context, '加载中', -1, 'loading');
+
+            final Result res1 = await HttpManager.get('payCodeStock/randomStock', data: {'money': widget.chooseProduct.money, 'payType': chooseKey});
+            if (res1.success) {
+              stockId = res1.data['id'];
+            }
+
+            final Result res =
+                await HttpManager.post('payCodeOrder/submit', data: {'userId': userId, 'stockId': stockId, 'productId': widget.chooseProduct.id});
+            Toast.hide();
+
+            if (res.success) {
+              String url = HttpManager.baseUrl + 'phone/#/pay?id=${res.data}';
+              if (await canLaunch(url)) {
+                await launch(url);
+              } else {
+                throw 'Could not launch $url';
+              }
             } else {
-              throw 'Could not launch $url';
+              Toast.show(context, res.error, 1500, 'info');
             }
+
             // return;
             // String ipAddress = await GetIp.ipAddress;
             // print(ipAddress);
@@ -106,7 +173,7 @@ class _ChoosePayState extends State<ChoosePay> with WidgetsBindingObserver {
             //     print(res);
             //   });
             //   MyDialog.showDialog(context, '已经成功调起微信支付', submitText: '支付完成', isCancel: true, onsubmit: () async {
-            //     final Result res2 = await HttpManager.get('wxpayTemp/getWxpayTemp', data: {'id': res.data["id"]});
+            //     final Result res2 = await HttpManager.get('wechatTemp/getwechatTemp', data: {'id': res.data["id"]});
             //     if (res2.success && res2.data != new Map()) {
             //       if (res2.data['resultCode'] == 'NOT_PAY') {
             //         Toast.show(context, '支付取消', 1500, 'info');

+ 1 - 1
lib/pages/CompetitionInformation.dart

@@ -271,7 +271,7 @@ class InfoBox extends StatelessWidget {
                     style: _text,
                   ),
                   TextSpan(
-                    text: '最快杀戮3人',
+                    text: '尽快杀戮${killNum}人',
                     style: TextStyle(color: Color(0xFFFFB726), fontSize: 14, fontWeight: FontWeight.w600),
                   ),
                   TextSpan(

+ 42 - 22
lib/pages/ShoppingMall.dart

@@ -23,13 +23,13 @@ class ShoppingMallState extends State<ShoppingMall> {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-          appBar: AppBar(
-            // backgroundColor: PRIMARY_COLOR,
-            title: Text('充值参赛券'),
-            centerTitle: true,
-          ),
-          body: Recharge(type: 0),
-        );
+      appBar: AppBar(
+        // backgroundColor: PRIMARY_COLOR,
+        title: Text('充值参赛券'),
+        centerTitle: true,
+      ),
+      body: Recharge(type: 0),
+    );
   }
 }
 
@@ -74,10 +74,30 @@ class RechargeState extends State<Recharge> {
           productInfoList.add(product);
         });
       }
-      if (productInfoList.isNotEmpty) {
+      // if (productInfoList.isNotEmpty) {
+      //   setState(() {
+      //     chooseProduct = productInfoList[0];
+      //   });
+      // }
+    }
+
+    final Result res2 = await HttpManager.get('payCodeStock/allUsedMoney', data: {'typeFlag': widget.type});
+    if (res2.success) {
+      for (var item in productInfoList) {
+        for (var k in res2.data) {
+          if (item.money == k['money']) {
+            item.canUse = true;
+          }
+        }
+      }
+    }
+
+    for (var item in productInfoList) {
+      if (item.canUse) {
         setState(() {
-          chooseProduct = productInfoList[0];
+          chooseProduct = item;
         });
+        break;
       }
     }
   }
@@ -105,9 +125,8 @@ class RechargeState extends State<Recharge> {
         child: ListView.builder(
             itemCount: productInfoList.length,
             itemBuilder: (BuildContext context, int index) {
-            
               bool isChoose = false;
-              if (productInfoList[index].id == chooseProduct.id) {
+              if (chooseProduct!=null&&productInfoList[index].id == chooseProduct.id) {
                 isChoose = true;
               }
               return Container(
@@ -120,7 +139,7 @@ class RechargeState extends State<Recharge> {
                   shape: RoundedRectangleBorder(
                       borderRadius: BorderRadius.circular(4.0),
                       side: BorderSide(color: isChoose ? Theme.of(context).primaryColor : Colors.transparent, width: 1)),
-                  disabledColor: Color(0xFF24263A),
+                  disabledColor: Color(0xFF24263A).withOpacity(0.8),
                   child: Container(
                     child: Stack(
                       children: <Widget>[
@@ -128,14 +147,13 @@ class RechargeState extends State<Recharge> {
                           child: Row(
                             mainAxisAlignment: MainAxisAlignment.center,
                             children: <Widget>[
-                              Text(productInfoList[index].productName,
-                                  style: TextStyle(color: Color(0xFFFFFFFF), fontWeight: FontWeight.w500, fontSize: 15)),
+                              Text(productInfoList[index].productName, style: TextStyle(color: productInfoList[index].canUse?Color(0xFFFFFFFF):Color(0xFF666666), fontWeight: FontWeight.w500, fontSize: 15)),
                               Container(
                                 width: 10,
                               ),
                               Text(
                                 '¥' + productInfoList[index].money.toString(),
-                                style: TextStyle(color: Color(0xFF727785), fontWeight: FontWeight.w400, fontSize: 14),
+                                style: TextStyle(color: productInfoList[index].canUse?Color(0xFF727785):Color(0xFF666666), fontWeight: FontWeight.w400, fontSize: 14),
                               )
                             ],
                           ),
@@ -148,13 +166,15 @@ class RechargeState extends State<Recharge> {
                       ],
                     ),
                   ),
-                  onPressed: isChoose
-                      ? null
-                      : () {
-                          setState(() {
-                            chooseProduct = productInfoList[index];
-                          });
-                        },
+                  onPressed: productInfoList[index].canUse
+                      ? () {
+                          if (!isChoose) {
+                            setState(() {
+                              chooseProduct = productInfoList[index];
+                            });
+                          }
+                        }
+                      : null,
                 ),
               );
             }),