panhui 6 éve
szülő
commit
9787934c30

+ 3 - 0
lib/pages/ChoosePay.dart

@@ -146,6 +146,9 @@ class _ChoosePayState extends State<ChoosePay> with WidgetsBindingObserver {
             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});

+ 2 - 0
lib/pages/HomePage.dart

@@ -18,6 +18,7 @@ import 'dart:ui';
 import '../model/PhoneInfo.dart';
 import 'PhoneLogin.dart';
 import '../model/PopNotice.dart';
+import '../utils/Utils.dart';
 
 class HomePage extends StatefulWidget {
   @override
@@ -130,6 +131,7 @@ class _HomePageState extends State<HomePage> with SingleTickerProviderStateMixin
     controller = new TabController(length: 3, vsync: this);
     Future.delayed(Duration.zero, () async {
       await checkErrorPlayerInfo();
+      getVersion(context);
     });
   }
 

+ 12 - 0
lib/pages/LoginFirst.dart

@@ -8,6 +8,7 @@ import '../utils/Utils.dart';
 import '../widget/LinearButton.dart';
 import '../net/HttpManager.dart';
 import '../net/Result.dart';
+import '../utils/Utils.dart';
 
 class LoginFirst extends StatefulWidget {
   @override
@@ -17,6 +18,17 @@ class LoginFirst extends StatefulWidget {
 class LoginFirstState extends State<LoginFirst> {
   String inputVal;
 
+ 
+
+  @override
+  void initState() {
+    // TODO: implement initState
+    super.initState();
+    Future.delayed(Duration.zero, () {
+      getVersion(context);
+    });
+  }
+
   @override
   Widget build(BuildContext context) {
     return WillPopScope(

+ 138 - 118
lib/pages/MyCode.dart

@@ -11,6 +11,7 @@ import 'package:qr_flutter/qr_flutter.dart';
 import 'package:redux/redux.dart';
 import 'package:flutter_redux/flutter_redux.dart';
 import 'package:path_provider/path_provider.dart';
+import 'package:wanna_battle/widget/Dialog.dart';
 import '../redux/AppState.dart';
 import '../model/UserInfo.dart';
 import '../widget/LinearButton.dart';
@@ -25,7 +26,8 @@ class MyCode extends StatefulWidget {
 }
 
 class MyCodeState extends State<MyCode> {
-  ChannelInfo channelInfo;
+  ChannelInfo channelInfo = null;
+  num race = 10;
 
   GlobalKey globalKey = new GlobalKey();
 
@@ -49,11 +51,18 @@ class MyCodeState extends State<MyCode> {
     Toast.show(context, '加载中', -1, 'loading');
     Result res = await HttpManager.get('channelInfo/getOne', data: {'id': StoreProvider.of<AppState>(context).state.userInfo.channel});
     Toast.hide();
-    if (res.success) {
+    if (res.success && res.data != null) {
       setState(() {
         channelInfo = ChannelInfo.fromJson(res.data);
       });
     }
+
+    Result res2 = await HttpManager.get('systemVariable/get', data: {'name': "ticketPrice"});
+    if (res2.success) {
+      setState(() {
+        race = res2.data;
+      });
+    }
   }
 
   @override
@@ -73,130 +82,141 @@ class MyCodeState extends State<MyCode> {
         builder: (context, userInfo) {
           String qrstr = HttpManager.baseUrl + "share?userId=${userInfo.id}&channel=${userInfo.channel}";
           // final cryptor = new PlatformStringCryptor();
-          return Scaffold(
-              appBar: appbar,
-              body: Container(
-                color: Color(0xFF2B2B42),
-                height: double.infinity,
-                width: double.infinity,
-                child: SingleChildScrollView(
-                  child: Container(
-                    height: _height - 60,
-                    constraints: BoxConstraints(minHeight: 543),
-                    margin: EdgeInsets.symmetric(vertical: 30, horizontal: 30),
-                    color: Color(0xFF363759),
-                    child: Column(
-                      mainAxisAlignment: MainAxisAlignment.center,
-                      children: <Widget>[
-                        RepaintBoundary(
-                          key: globalKey,
-                          child: Container(
-                            width: 256,
-                            color: Color(0xFF363759),
-                            child: Column(
-                              children: <Widget>[
-                                Container(height: 36),
-                                Image.asset('images/text_yonghuduan.png'),
-                                Container(
-                                  height: 7,
-                                ),
-                                Text('扫描二维码加入 ${userInfo.nickname.length <= 5 ? userInfo.nickname : userInfo.nickname.substring(0, 4) + "..."} 的电竞团队',
-                                    style: TextStyle(color: Theme.of(context).primaryColor, fontSize: 14, fontWeight: FontWeight.w600)),
-                                Container(height: 25),
-                                Container(
-                                  width: 150,
-                                  height: 150,
-                                  color: Colors.white,
-                                  // padding: EdgeInsets.all(7),
-                                  child: QrImage(
-                                    data: qrstr,
-                                    size: 150.0,
-                                  ),
-                                ),
-                                Container(
-                                  height: 10,
+          return WillPopScope(
+              onWillPop: () {
+                Navigator.of(context).pop();
+                Toast.hide();
+              },
+              child: Scaffold(
+                  appBar: appbar,
+                  body: Container(
+                    color: Color(0xFF2B2B42),
+                    height: double.infinity,
+                    width: double.infinity,
+                    child: SingleChildScrollView(
+                      child: Container(
+                        height: _height - 60,
+                        constraints: BoxConstraints(minHeight: 543),
+                        margin: EdgeInsets.symmetric(vertical: 30, horizontal: 30),
+                        color: Color(0xFF363759),
+                        child: Column(
+                          mainAxisAlignment: MainAxisAlignment.center,
+                          children: <Widget>[
+                            RepaintBoundary(
+                              key: globalKey,
+                              child: Container(
+                                width: 256,
+                                color: Color(0xFF363759),
+                                child: Column(
+                                  children: <Widget>[
+                                    Container(height: 36),
+                                    Image.asset('images/text_yonghuduan.png'),
+                                    Container(
+                                      height: 7,
+                                    ),
+                                    Text('扫描二维码加入 ${userInfo.nickname.length <= 5 ? userInfo.nickname : userInfo.nickname.substring(0, 4) + "..."} 的电竞团队',
+                                        style: TextStyle(color: Theme.of(context).primaryColor, fontSize: 14, fontWeight: FontWeight.w600)),
+                                    Container(height: 25),
+                                    Container(
+                                      width: 150,
+                                      height: 150,
+                                      color: Colors.white,
+                                      // padding: EdgeInsets.all(7),
+                                      child: QrImage(
+                                        data: qrstr,
+                                        size: 150.0,
+                                      ),
+                                    ),
+                                    Container(
+                                      height: 10,
+                                    ),
+                                    Text(
+                                      '扫一扫下载APP',
+                                      style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
+                                    ),
+                                    Container(
+                                      height: 30,
+                                    )
+                                  ],
                                 ),
-                                Text(
-                                  '扫一扫下载APP',
-                                  style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
-                                ),
-                                Container(
-                                  height: 30,
-                                )
-                              ],
+                              ),
                             ),
-                          ),
-                        ),
 
-                        // Text(
-                        //   channelInfo != null ? '一级队员:每购买一张就会获得${1 * 10 * channelInfo.ratio}' : '',
-                        //   style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
-                        // ),
-                        // Text(
-                        //   channelInfo != null ? '二级队员:每购买一张就会获得${1 * 10 * channelInfo.ratio2}' : '',
-                        //   style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
-                        // ),
-                        Container(
-                          // margin: EdgeInsets.only(top: 30),
-                          width: 180,
-                          child: LinearButton(
-                            btntext: '立刻邀请',
-                            btnHeight: 44.0,
-                            colorList: [Color(0xFFD4504B), Color(0xFFD4504B)],
-                            onTapHomeMenu: () async {
-                              var permission = PermissionHandler().checkPermissionStatus(PermissionGroup.storage);
-                              await PermissionHandler().requestPermissions(<PermissionGroup>[
-                                PermissionGroup.storage, // 在这里添加需要的权限
-                              ]);
-                              // MyDialog.showDialog(context, '手动截图立即分享二维码给小伙伴吧!');
-                              Uint8List val = await _capturePng();
-                              print(val);
-                              final result = await ImagePickerSaver.saveFile(fileData: val);
-                              print(result);
-                              Toast.show(context, '保存成功', 1500, 'success');
-                            },
-                          ),
-                        ),
-                        Container(
-                          height: 13,
-                        ),
-                        InkWell(
-                          onTap: () {
-                            Navigator.of(context).push(PageRouteBuilder(
-                                opaque: false,
-                                transitionDuration: Duration(milliseconds: 300),
-                                transitionsBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
-                                  return FadeTransition(
-                                    opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
-                                    child: child,
-                                  );
+                            // Text(
+                            //   channelInfo != null ? '一级队员:每购买一张就会获得${1 * 10 * channelInfo.ratio}' : '',
+                            //   style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
+                            // ),
+                            // Text(
+                            //   channelInfo != null ? '二级队员:每购买一张就会获得${1 * 10 * channelInfo.ratio2}' : '',
+                            //   style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w500),
+                            // ),
+                            Container(
+                              // margin: EdgeInsets.only(top: 30),
+                              width: 180,
+                              child: LinearButton(
+                                btntext: '立刻邀请',
+                                btnHeight: 44.0,
+                                colorList: [Color(0xFFD4504B), Color(0xFFD4504B)],
+                                onTapHomeMenu: () async {
+                                  var permission = PermissionHandler().checkPermissionStatus(PermissionGroup.storage);
+                                  await PermissionHandler().requestPermissions(<PermissionGroup>[
+                                    PermissionGroup.storage, // 在这里添加需要的权限
+                                  ]);
+                                  // MyDialog.showDialog(context, '手动截图立即分享二维码给小伙伴吧!');
+                                  Uint8List val = await _capturePng();
+                                  print(val);
+                                  final result = await ImagePickerSaver.saveFile(fileData: val);
+                                  print(result);
+                                  // Toast.show(context, '保存成功', 1500, 'success');
+                                  MyDialog.showDialog(context, '分享二维码保存成功,请在照片图库中找到并分享给其他人吧。');
                                 },
-                                pageBuilder: (BuildContext context, _, __) {
-                                  return Rule(0.1 * channelInfo.ratio, 0.1 * channelInfo.ratio2);
-                                }));
-                          },
-                          child: Row(
-                            mainAxisAlignment: MainAxisAlignment.center,
-                            children: <Widget>[
-                              Text(
-                                '查看推广奖励规则',
-                                style: TextStyle(color: Theme.of(context).primaryColor),
                               ),
-                              Image.asset('images/icon_inter_hongse.png')
-                            ],
-                          ),
-                        ),
+                            ),
+                            Container(
+                              height: 13,
+                            ),
+                            InkWell(
+                              onTap: () {
+                                if (channelInfo == null) {
+                                  MyDialog.showDialog(context, '用户渠道信息为空,暂不能参与活动');
+                                } else {
+                                  Navigator.of(context).push(PageRouteBuilder(
+                                      opaque: false,
+                                      transitionDuration: Duration(milliseconds: 300),
+                                      transitionsBuilder:
+                                          (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
+                                        return FadeTransition(
+                                          opacity: CurvedAnimation(parent: animation, curve: Curves.linear),
+                                          child: child,
+                                        );
+                                      },
+                                      pageBuilder: (BuildContext context, _, __) {
+                                        return Rule(race * channelInfo.ratio / 100, race * channelInfo.ratio2 / 100);
+                                      }));
+                                }
+                              },
+                              child: Row(
+                                mainAxisAlignment: MainAxisAlignment.center,
+                                children: <Widget>[
+                                  Text(
+                                    '查看推广奖励规则',
+                                    style: TextStyle(color: Theme.of(context).primaryColor),
+                                  ),
+                                  Image.asset('images/icon_inter_hongse.png')
+                                ],
+                              ),
+                            ),
 
-                        Expanded(
-                          flex: 1,
-                          child: Container(),
+                            Expanded(
+                              flex: 1,
+                              child: Container(),
+                            ),
+                            Image.asset('images/img_0000.png'),
+                          ],
                         ),
-                        Image.asset('images/img_0000.png'),
-                      ],
+                      ),
                     ),
-                  ),
-                ),
-              ));
+                  )));
         });
   }
 }

+ 2 - 1
lib/pages/Setting.dart

@@ -19,6 +19,7 @@ import '../net/Result.dart';
 import '../redux/UserRedux.dart';
 import '../widget/Dialog.dart';
 import '../widget/LinearButton.dart';
+import '../utils/Utils.dart';
 
 class Setting extends StatefulWidget {
   @override
@@ -96,7 +97,7 @@ class SettingState extends State<Setting> {
                           _sectionDivier(),
                           _section([
                             _cell('检查更新', ' ', onTap: () {
-                              MyDialog.showDialog(context, '您已是最新版本。');
+                              getVersion(context);
                             }),
                             _cell('版本号', version, showBorder: false),
                           ]),

+ 18 - 2
lib/pages/ShoppingMall.dart

@@ -11,6 +11,7 @@ import '../net/HttpManager.dart';
 import '../net/Result.dart';
 import '../styles/totast.dart';
 import 'ChoosePay.dart';
+import 'dart:io';
 
 class ShoppingMall extends StatefulWidget {
   @override
@@ -123,8 +124,16 @@ class RechargeState extends State<Recharge> {
       body: Container(
         color: BG_COLOR,
         child: ListView.builder(
-            itemCount: productInfoList.length,
+            itemCount: productInfoList.length + 1,
             itemBuilder: (BuildContext context, int index) {
+              if (index == productInfoList.length) {
+                return Container(
+                  height: 80,
+                  child: Center(
+                    child: Text('0点至8点到账缓慢,请提前充值', style: TextStyle(color: Color(0xFF727785), fontSize: 14)),
+                  ),
+                );
+              }
               bool isChoose = false;
               if (chooseProduct != null && productInfoList[index].id == chooseProduct.id) {
                 isChoose = true;
@@ -196,7 +205,14 @@ class RechargeState extends State<Recharge> {
               return;
             }
 
-            Navigator.push(context, CupertinoPageRoute(builder: (context) => ChoosePay(widget.type, chooseProduct)));
+            Result res = await HttpManager.get('systemVariable/get', data: {'name': "iosPayHide"});
+
+            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)));
+            }
+
             // Toast.show(context, '加载中', -1, 'loading');
             // final Result res = await HttpManager.post('productInfo/buy', data: {
             //   'userId': StoreProvider.of<AppState>(context).state.userInfo.id,

+ 56 - 0
lib/utils/Utils.dart

@@ -1,3 +1,11 @@
+import 'package:flutter/material.dart';
+import '../widget/Dialog.dart';
+import 'dart:io';
+import 'package:url_launcher/url_launcher.dart';
+import 'package:package_info/package_info.dart';
+import '../net/HttpManager.dart';
+import '../net/Result.dart';
+
 bool checkPhone(phone) {
   bool result = false;
   RegExp exp = RegExp(r'^1[3-9]\d{9}$');
@@ -6,3 +14,51 @@ bool checkPhone(phone) {
   }
   return result;
 }
+
+int CompareVersion(String l, String r) {
+  l = l.trim();
+  r = r.trim();
+  if (l == r) {
+    return 0;
+  }
+
+  var lVers = l.split('.');
+  var rVers = r.split('.');
+  var length = lVers.length < rVers.length ? lVers.length : rVers.length;
+  for (int i = 0; i < length; i++) {
+    if (lVers[i] == rVers[i]) {
+      continue;
+    }
+
+    return int.parse(lVers[i]).compareTo(int.parse(rVers[i]));
+  }
+
+  var temp = lVers.length < rVers.length ? rVers : lVers;
+  for (int i = length; i < temp.length; i++) {
+    if (int.parse(temp[i]) != 0) {
+      return lVers.length < rVers.length ? -1 : 1;
+    }
+  }
+
+  return 0;
+}
+
+Future<void> getVersion(BuildContext context) async {
+  print('检查更新');
+  PackageInfo packageInfo = await PackageInfo.fromPlatform();
+  String version = packageInfo.version;
+  Result versionres = await HttpManager.get('appVersion/getAppVersion?id=1');
+  if (versionres.success&&versionres.data!=null) {
+    if ((CompareVersion(version, versionres.data['androidVersion']) < 0 && Platform.isAndroid) ||
+        (CompareVersion(version, versionres.data['iosVersion']) < 0 && Platform.isIOS)) {
+      MyDialog.showDialog(context, '检测到新版本,是否立即更新?', isCancel: true, onsubmit: () async {
+        String url = HttpManager.baseUrl + 'phone/#/downLoad';
+        if (await canLaunch(url)) {
+          await launch(url);
+        } else {
+          throw 'Could not launch $url';
+        }
+      });
+    }
+  }
+}

+ 1 - 1
pubspec.yaml

@@ -1,7 +1,7 @@
 name: wanna_battle
 description: A new Flutter project.
 
-version: 1.0.0+1
+version: 1.0.1+1
 
 environment:
   sdk: ">=2.1.0 <3.0.0"