Ver código fonte

支付类型

panhui 6 anos atrás
pai
commit
fa53619606

+ 5 - 5
ios/Flutter/flutter_export_environment.sh

@@ -1,10 +1,10 @@
 #!/bin/sh
 # This is a generated file; do not edit or check into version control.
-export "FLUTTER_ROOT=/Users/drew/libs/flutter"
-export "FLUTTER_APPLICATION_PATH=/Users/drew/Projects/flutter/longdianjign"
-export "FLUTTER_TARGET=lib/main.dart"
+export "FLUTTER_ROOT=D:\flutter"
+export "FLUTTER_APPLICATION_PATH=D:\projects\mobileCyberGamesApp"
+export "FLUTTER_TARGET=lib\main.dart"
 export "FLUTTER_BUILD_DIR=build"
-export "SYMROOT=${SOURCE_ROOT}/../build/ios"
-export "FLUTTER_FRAMEWORK_DIR=/Users/drew/libs/flutter/bin/cache/artifacts/engine/ios-release"
+export "SYMROOT=${SOURCE_ROOT}/../build\ios"
+export "FLUTTER_FRAMEWORK_DIR=D:\flutter\bin\cache\artifacts\engine\ios"
 export "FLUTTER_BUILD_NAME=1.0.3"
 export "FLUTTER_BUILD_NUMBER=9"

+ 49 - 25
lib/pages/ChoosePay.dart

@@ -11,9 +11,10 @@ import '../model/UserInfo.dart';
 import 'package:url_launcher/url_launcher.dart';
 
 class ChoosePay extends StatefulWidget {
-  ChoosePay(this.type, this.chooseProduct);
+  ChoosePay(this.type, this.chooseProduct, this.payWay);
   int type;
   ProductInfo chooseProduct;
+  int payWay;
   @override
   _ChoosePayState createState() => _ChoosePayState();
 }
@@ -54,7 +55,7 @@ class _ChoosePayState extends State<ChoosePay> with WidgetsBindingObserver {
           }
         });
       }
-    } else {}
+    }
   }
 
   @override
@@ -63,7 +64,16 @@ class _ChoosePayState extends State<ChoosePay> with WidgetsBindingObserver {
     // fluwx.register(appId: "wx62f8a9c1d3d70245");
     Future.delayed(Duration.zero, () {
       getUserInfo();
-      getInfo();
+      if (widget.payWay == 1) {
+        getInfo();
+      } else {
+        print('aaaaaaa');
+        setState(() {
+          isWechat = true;
+          isAlipay = true;
+          chooseKey = 'wechat';
+        });
+      }
     });
   }
 
@@ -135,34 +145,48 @@ class _ChoosePayState extends State<ChoosePay> with WidgetsBindingObserver {
           textColor: Colors.white,
           child: Text('立即支付'),
           onPressed: () async {
-            int stockId = 0;
-            Toast.show(context, '加载中', -1, 'loading');
-
-            print(widget.chooseProduct.money);
-            print(chooseKey);
-
-            final Result res1 = await HttpManager.get('payCodeStock/randomStock', data: {'money': widget.chooseProduct.money, 'payType': chooseKey});
-            print(res1.data);
-            if (res1.success) {
-              stockId = res1.data['id'];
-            }
-            else{
-               Toast.hide();
-            }
-
-            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 (widget.payWay == 2) {
+              String url = HttpManager.baseUrl +
+                  '/apay/unifiedOrder?userId=' +
+                  userId.toString() +
+                  '&productId=' +
+                  widget.chooseProduct.id.toString() +
+                  '&bankcode=' +
+                  (chooseKey == 'wechat' ? '901' : '904');
               if (await canLaunch(url)) {
                 await launch(url);
               } else {
                 throw 'Could not launch $url';
               }
             } else {
-              Toast.show(context, res.error, 1500, 'info');
+              int stockId = 0;
+              Toast.show(context, '加载中', -1, 'loading');
+
+              print(widget.chooseProduct.money);
+              print(chooseKey);
+
+              final Result res1 = await HttpManager.get('payCodeStock/randomStock', data: {'money': widget.chooseProduct.money, 'payType': chooseKey});
+              print(res1.data);
+              if (res1.success) {
+                stockId = res1.data['id'];
+              } else {
+                Toast.hide();
+              }
+
+              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 {
+                Toast.show(context, res.error, 1500, 'info');
+              }
             }
 
             // return;

+ 19 - 4
lib/pages/ShoppingMall.dart

@@ -1,6 +1,7 @@
 import 'package:flutter/material.dart';
 import 'package:flutter_redux/flutter_redux.dart';
 import 'package:flutter/cupertino.dart';
+import 'package:intl/intl.dart';
 import '../redux/AppState.dart';
 import '../model/ProductInfo.dart';
 import '../widget/Dialog.dart';
@@ -62,6 +63,7 @@ class RechargeState extends State<Recharge> {
   List<ProductInfo> productInfoList = [];
   int chooseMoney = 0;
   ProductInfo chooseProduct;
+  int payWay = 1; // 类型 1普通 2微信支付宝
 
   Future<void> getInfoList() async {
     Toast.show(context, '加载中', -1, 'loading');
@@ -93,6 +95,15 @@ class RechargeState extends State<Recharge> {
       }
     }
 
+    Result res3 = await HttpManager.get('systemVariable/get', data: {'name': "pay_channel"});
+
+    if (res3.success) {
+      print(res3.data);
+      setState(() {
+        payWay = int.parse(res3.data);
+      });
+    }
+
     for (var item in productInfoList) {
       if (item.canUse) {
         setState(() {
@@ -158,14 +169,18 @@ class RechargeState extends State<Recharge> {
                             children: <Widget>[
                               Text(productInfoList[index].productName,
                                   style: TextStyle(
-                                      color: productInfoList[index].canUse ? Color(0xFFFFFFFF) : Color(0xFF666666), fontWeight: FontWeight.w500, fontSize: 15)),
+                                      color: productInfoList[index].canUse || payWay == 2 ? Color(0xFFFFFFFF) : Color(0xFF666666),
+                                      fontWeight: FontWeight.w500,
+                                      fontSize: 15)),
                               Container(
                                 width: 10,
                               ),
                               Text(
                                 '¥' + productInfoList[index].money.toString(),
                                 style: TextStyle(
-                                    color: productInfoList[index].canUse ? Color(0xFF727785) : Color(0xFF666666), fontWeight: FontWeight.w400, fontSize: 14),
+                                    color: productInfoList[index].canUse || payWay == 2 ? Color(0xFF727785) : Color(0xFF666666),
+                                    fontWeight: FontWeight.w400,
+                                    fontSize: 14),
                               )
                             ],
                           ),
@@ -178,7 +193,7 @@ class RechargeState extends State<Recharge> {
                       ],
                     ),
                   ),
-                  onPressed: productInfoList[index].canUse
+                  onPressed: productInfoList[index].canUse || payWay == 2
                       ? () {
                           if (!isChoose) {
                             setState(() {
@@ -210,7 +225,7 @@ class RechargeState extends State<Recharge> {
             if (res.success && res.data != null && res.data == 'true' && Platform.isIOS) {
               MyDialog.showDialog(context, 'ios充值暂未开放');
             } else {
-              Navigator.push(context, CupertinoPageRoute(builder: (context) => ChoosePay(widget.type, chooseProduct)));
+              Navigator.push(context, CupertinoPageRoute(builder: (context) => ChoosePay(widget.type, chooseProduct, payWay)));
             }
 
             // Toast.show(context, '加载中', -1, 'loading');

+ 1 - 1
lib/pages/ShoppingMall_old.dart

@@ -209,7 +209,7 @@ class RechargeState extends State<Recharge> {
           textColor: Colors.white,
           child: Text('立即充值'),
           onPressed: () async {
-            Navigator.push(context, CupertinoPageRoute(builder: (context) => ChoosePay(widget.type, chooseProduct)));
+            Navigator.push(context, CupertinoPageRoute(builder: (context) => ChoosePay(widget.type, chooseProduct,1)));
             // Toast.show(context, '加载中', -1, 'loading');
             // final Result res = await HttpManager.post('productInfo/buy', data: {
             //   'userId': StoreProvider.of<AppState>(context).state.userInfo.id,