jyj 4 vuotta sitten
vanhempi
commit
22a439ddbc
3 muutettua tiedostoa jossa 63 lisäystä ja 62 poistoa
  1. 56 56
      lib/internal/wode/page/wode_page.dart
  2. 3 2
      lib/utils/url.dart
  3. 4 4
      pubspec.yaml

+ 56 - 56
lib/internal/wode/page/wode_page.dart

@@ -21,8 +21,8 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
 import 'package:image_picker/image_picker.dart';
 import 'package:liftmanager/utils/toast.dart';
 import 'package:liftmanager/utils/utils.dart';
-// import 'package:barcode_scan/barcode_scan.dart';
-import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
+import 'package:barcode_scan/barcode_scan.dart';
+// import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
 import 'package:flutter/services.dart';
 import 'package:flustars/flustars.dart' as FlutterStars;
 import 'package:liftmanager/utils/fast_notification.dart';
@@ -87,55 +87,18 @@ class WodePageState extends State<WodePage> with AutomaticKeepAliveClientMixin {
     );
   }
 
-  // Future scan() async {
-  //   try {
-  //     // 此处为扫码结果,barcode为二维码的内容
-  //     String barcode = await BarcodeScanner.scan();
-  //     print(barcode);
-  //     // http://lift.whlhcx.com/h5/index.html?page=/wode/vip&id=1288674418578472962
-  //     // return;
-  //     // print('扫码结果: ' + jsonDecode(barcode)["url"]);
-  //     Uri u = Uri.parse(barcode);
-  //     String id = u.queryParameters['id'];
-  //     print('扫码结果: ' + id);
-  //     // print('扫码结果: ' + jsonDecode(barcode)["userId"].toString());
-
-  //     NewApiService().getUserRebates(id,
-  //         onSuccess: (res) {
-  //           toastsF(context,"你已成功接受${res!=null?res.toString():''}的邀请,立即成为会员!",timeInSecForIos:3);
-  //           // toasts("您已成为${res!=null?res.toString():''}的下级用户");
-  //       NavigatorUtils.push(context, "${WodeRouter.vip}?id=");
-  //     }, onError: (code, msg) {
-  //       toasts(msg);
-  //     });
-  //   } on PlatformException catch (e) {
-  //     if (e.code == BarcodeScanner.CameraAccessDenied) {
-  //       // 未授予APP相机权限
-  //       print('未授予APP相机权限');
-  //     } else {
-  //       // 扫码错误
-  //       print('扫码错误: $e');
-  //     }
-  //   } on FormatException {
-  //     // 进入扫码页面后未扫码就返回
-  //     print('进入扫码页面后未扫码就返回');
-  //   } catch (e) {
-  //     // 扫码错误
-  //     print('扫码错误: $e');
-  //   }
-  // }
-
-  Future<void> scan() async {
-    String barcodeScanRes;
-    // Platform messages may fail, so we use a try/catch PlatformException.
+  Future scan() async {
     try {
-      barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(
-          "#ff6666", "取消", true, ScanMode.BARCODE);
-      print(123456);
-      print(barcodeScanRes);
-      Uri u = Uri.parse(barcodeScanRes);
+      // 此处为扫码结果,barcode为二维码的内容
+      String barcode = await BarcodeScanner.scan();
+      print(barcode);
+      // http://lift.whlhcx.com/h5/index.html?page=/wode/vip&id=1288674418578472962
+      // return;
+      // print('扫码结果: ' + jsonDecode(barcode)["url"]);
+      Uri u = Uri.parse(barcode);
       String id = u.queryParameters['id'];
-      print("123456--" + id);
+      print('扫码结果: ' + id);
+      // print('扫码结果: ' + jsonDecode(barcode)["userId"].toString());
 
       NewApiService().getUserRebates(id,
           onSuccess: (res) {
@@ -145,16 +108,53 @@ class WodePageState extends State<WodePage> with AutomaticKeepAliveClientMixin {
       }, onError: (code, msg) {
         toasts(msg);
       });
-    } on PlatformException {
-      barcodeScanRes = 'Failed to get platform version.';
+    } on PlatformException catch (e) {
+      if (e.code == BarcodeScanner.CameraAccessDenied) {
+        // 未授予APP相机权限
+        print('未授予APP相机权限');
+      } else {
+        // 扫码错误
+        print('扫码错误: $e');
+      }
+    } on FormatException {
+      // 进入扫码页面后未扫码就返回
+      print('进入扫码页面后未扫码就返回');
+    } catch (e) {
+      // 扫码错误
+      print('扫码错误: $e');
     }
+  }
 
-    // If the widget was removed from the tree while the asynchronous platform
-    // message was in flight, we want to discard the reply rather than calling
-    // setState to update our non-existent appearance.
-    if (!mounted) return;
+  // Future<void> scan() async {
+  //   String barcodeScanRes;
+  //   // Platform messages may fail, so we use a try/catch PlatformException.
+  //   try {
+  //     barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(
+  //         "#ff6666", "取消", true, ScanMode.BARCODE);
+  //     print(123456);
+  //     print(barcodeScanRes);
+  //     Uri u = Uri.parse(barcodeScanRes);
+  //     String id = u.queryParameters['id'];
+  //     print("123456--" + id);
 
-  }
+  //     NewApiService().getUserRebates(id,
+  //         onSuccess: (res) {
+  //           toastsF(context,"你已成功接受${res!=null?res.toString():''}的邀请,立即成为会员!",timeInSecForIos:3);
+  //           // toasts("您已成为${res!=null?res.toString():''}的下级用户");
+  //       NavigatorUtils.push(context, "${WodeRouter.vip}?id=");
+  //     }, onError: (code, msg) {
+  //       toasts(msg);
+  //     });
+  //   } on PlatformException {
+  //     barcodeScanRes = 'Failed to get platform version.';
+  //   }
+
+  //   // If the widget was removed from the tree while the asynchronous platform
+  //   // message was in flight, we want to discard the reply rather than calling
+  //   // setState to update our non-existent appearance.
+  //   if (!mounted) return;
+
+  // }
 
   Future getCoupon() async {
     await NewApiService().getUserCoupons(onSuccess: (res) {

+ 3 - 2
lib/utils/url.dart

@@ -3,9 +3,10 @@
 const String imgFontUrl = "http://sellerAdminpp.udreamtech.com/files/ty/";
 // const String socketUrl = "ws://192.168.1.4:20226/ws";
 // const String socketUrl = "ws://192.168.1.111:8002/ws";
-const String socketUrl = "ws://111.47.6.224:8002/ws";
+const String socketUrl = "ws://220.249.127.210:8002/ws";
 const String jumpUrl = "http://lift.whlhcx.com";
-const String baseUrl = "http://111.47.6.224:10227";
+const String baseUrl = "http://220.249.127.210:10227";
+// const String baseUrl = "http://111.47.6.224:10227";
 const String ossUrl = "http://ty-oss-file.oss-cn-hangzhou.aliyuncs.com";
 // const String socketUrl = "ws://221.234.44.30:8002/ws";
 // const String socketUrl = "ws://lift.whlhcx.com:8002/ws";

+ 4 - 4
pubspec.yaml

@@ -64,10 +64,10 @@ dependencies:
   # 启动URL的插件
   url_launcher: ^5.4.2
   # 扫码
-  flutter_barcode_scanner: ^1.0.1
-  # barcode_scan:
-  #   git:
-  #     url: https://github.com/simplezhli/flutter_barcode_reader.git
+  # flutter_barcode_scanner: ^1.0.1
+  barcode_scan:
+    git:
+      url: https://github.com/simplezhli/flutter_barcode_reader.git
   # 图片选择插件
   image_picker: 0.6.2+1
   # 网络状态