|
@@ -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) {
|