| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381 |
- import 'dart:async';
- import 'dart:convert';
- import 'dart:io';
- import 'package:amap_location/amap_location.dart';
- import 'package:bbyyy/beans/access_bean_entity.dart';
- import 'package:bbyyy/beans/template_bean_entity.dart';
- import 'package:bbyyy/beans/w_x_bean_entity.dart';
- import 'package:bbyyy/https/url.dart';
- import 'package:bbyyy/my_tools/event_bus.dart';
- import 'package:bbyyy/my_tools/my_cookie.dart';
- import 'package:bbyyy/my_tools/my_tools.dart';
- import 'package:bbyyy/my_tools/order_processing/order_processing.dart';
- import 'package:bbyyy/paegs/login_page/login_page.dart';
- import 'package:bbyyy/paegs/pay_page/order_information_page.dart';
- import 'package:bbyyy/paegs/root_page/root_page.dart';
- import 'package:bbyyy/paegs/root_page/root_page_view.dart';
- import 'package:bbyyy/paegs/welcome_page/welcome_page.dart';
- import 'package:dio/dio.dart';
- import 'package:flustars/flustars.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_local_notifications/flutter_local_notifications.dart';
- import 'package:flutter_localizations/flutter_localizations.dart';
- import 'package:flutter_svg/flutter_svg.dart';
- import 'package:fluwx/fluwx.dart';
- import 'package:pull_to_refresh/pull_to_refresh.dart';
- import 'package:rxdart/rxdart.dart';
- import 'beans/app_store_review_bean_entity.dart';
- import 'beans/coupon_bean_entity.dart';
- import 'beans/my_shop_bean_entity.dart';
- import 'beans/new_order_bean_entity.dart';
- import 'beans/smart_order_bean_entity.dart';
- import 'beans/system_information_bean_entity.dart';
- import 'https/MyDio.dart';
- import 'https/my_request.dart';
- import 'my_tools/const.dart';
- import 'my_tools/dims.dart';
- import 'my_tools/easy_loading/easy_loading.dart';
- import 'my_tools/easy_loading/loading.dart';
- import 'my_tools/global.dart';
- import 'my_tools/my_colors.dart';
- import 'my_tools/my_views.dart';
- import 'my_tools/order.dart';
- import 'my_tools/pop_up_queue.dart';
- final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
- FlutterLocalNotificationsPlugin();
- final BehaviorSubject<ReceivedNotification> didReceiveLocalNotificationSubject =
- BehaviorSubject<ReceivedNotification>();
- final BehaviorSubject<String> selectNotificationSubject =
- BehaviorSubject<String>();
- class ReceivedNotification {
- ReceivedNotification({
- @required this.id,
- @required this.title,
- @required this.body,
- @required this.payload,
- });
- final int id;
- final String title;
- final String body;
- final String payload;
- }
- Future<void> main() async {
- if (Platform.isIOS) {
- AMapLocationClient.setApiKey('548414a843a2ec9c383e34341b8c84df');
- }
- WidgetsFlutterBinding.ensureInitialized();
- const AndroidInitializationSettings initializationSettingsAndroid =
- AndroidInitializationSettings('@mipmap/app_logo');
- /// Note: permissions aren't requested here just to demonstrate that can be
- /// done later
- final IOSInitializationSettings initializationSettingsIOS =
- IOSInitializationSettings(
- requestAlertPermission: true,
- requestBadgePermission: true,
- requestSoundPermission: true,
- onDidReceiveLocalNotification:
- (int id, String title, String body, String payload) async {
- didReceiveLocalNotificationSubject.add(ReceivedNotification(
- id: id, title: title, body: body, payload: payload));
- });
- const MacOSInitializationSettings initializationSettingsMacOS =
- MacOSInitializationSettings(
- requestAlertPermission: true,
- requestBadgePermission: true,
- requestSoundPermission: true);
- final InitializationSettings initializationSettings = InitializationSettings(
- android: initializationSettingsAndroid,
- iOS: initializationSettingsIOS,
- macOS: initializationSettingsMacOS);
- await flutterLocalNotificationsPlugin.initialize(initializationSettings,
- onSelectNotification: (String payload) async {
- if (payload != null) {
- if (payload == notifyTypeNewMsg) {
- RootPageView().bNIndex = 2;
- EventBus().emit('ChangePage');
- }
- debugPrint('notification payload: $payload');
- }
- selectNotificationSubject.add(payload);
- });
- runApp(MyApp());
- }
- class MyApp extends StatelessWidget with WidgetsBindingObserver {
- BuildContext buildContext;
- StateSetter ss;
- List<MyShopBeanDataData> shops = [];
- int shopIndex = 0;
- String clipboardT;
- int amountCompleted = 0;
- NewOrderBeanEntity newOrder;
- @override
- StatelessElement createElement() {
- // TODO: implement createElement
- WidgetsBinding.instance.addObserver(this);
- MyCookie().initP();
- _initFluwx();
- EventBus().on('hasNewOrder', (arg) {
- newOrder = arg;
- displayPendingOrders();
- });
- EventBus().on('systemInformation', (arg) {
- if (arg is SystemInformationBeanEntity) {
- showSystemMessages(arg);
- }
- });
- EventBus().on('检查粘贴板', (arg) {
- Timer(Duration(seconds: 1), () {
- getClipboardData();
- checkUnpaidThirdPartyOrders();
- });
- });
- EventBus().on('hasCoupon', (arg) {
- if (arg is CouponBeanDataData) {
- couponBulletBox(arg);
- }
- });
- isItUnderReview();
- return super.createElement();
- }
- @override
- Widget build(BuildContext context) {
- SystemChrome.setPreferredOrientations([
- DeviceOrientation.portraitUp, //只能纵向
- DeviceOrientation.portraitDown, //只能纵向
- ]);
- return RefreshConfiguration(
- child: MaterialApp(
- navigatorKey: navigatorKey,
- theme: ThemeData(fontFamily: 'PingFang'),
- debugShowCheckedModeBanner: false,
- home: WelcomePage(),
- routes: {
- '/loginPage': (context) => LoginPage(),
- '/rootPage': (context) => RootPage(),
- },
- supportedLocales: [const Locale('zh', 'CH')],
- localizationsDelegates: [
- RefreshLocalizations.delegate,
- GlobalMaterialLocalizations.delegate,
- GlobalWidgetsLocalizations.delegate,
- const FallbackCupertinoLocalisationsDelegate(),
- ],
- builder: (BuildContext context, Widget child) {
- buildContext = context;
- return MediaQuery(
- data: MediaQuery.of(context)
- .copyWith(textScaleFactor: 1.0), //设置字体不随系统字体大小改变
- child: FlutterEasyLoading(
- child: child,
- ),
- );
- },
- ),
- hideFooterWhenNotFull: true,
- footerBuilder: () {
- return ClassicFooter(
- loadStyle: LoadStyle.ShowWhenLoading,
- );
- },
- );
- }
- @override
- void didChangeAppLifecycleState(AppLifecycleState state) {
- super.didChangeAppLifecycleState(state);
- if (state == AppLifecycleState.paused) {
- print('went to Background');
- }
- if (state == AppLifecycleState.resumed) {
- print('came back to Foreground');
- if (MyCookie().loginInformation != null) {
- Timer(Duration(seconds: 1), () {
- getClipboardData();
- });
- }
- checkUnpaidThirdPartyOrders();
- }
- }
- //获取剪切板文字
- Future<void> getClipboardData() async {
- PopUpQueue().onShow = true;
- ClipboardData text = await Clipboard.getData(Clipboard.kTextPlain);
- try {
- print('Clipboard-----\n${text.text}');
- clipboardT = text.text;
- // Clipboard.setData(ClipboardData(text: ''));
- OrderProcessing().queryOrderTemplate(clipboardT,buildContext);
- // getOnlineTemplate();
- } catch (e) {
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- }
- }
- //获取线上模板
- void getOnlineTemplate() {
- MyDio().query({
- 'key': 'order_template',
- "dims":orderTemplateDims,
- "filters": {}
- }, (response, hasError) {
- if (!hasError) {
- TemplateBeanEntity entity = TemplateBeanEntity()
- .fromJson(json.decode(response.data.toString()));
- checkOrder(entity.data);
- } else {
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- }
- }, (error) {
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- });
- }
- var orderHash;
- //最大金额赢家数量 0---发送订单的人不是最大赢家 1---发订单的人是最大赢家 2---发订单的人是最大赢家且有两个一样的金额
- int commissionPayerNum = -1;
- //匹配模板去除不是自己的订单
- void checkOrder(List<TemplateBeanData> data) {
- commissionPayerNum = -1;
- bool hasMatch = false;
- w:
- for (int i = 0; i < data.length; i++) {
- try {
- var res = parseString2(
- data[i].template.replaceAll('\r', ''), '''$clipboardT''');
- if (res != null) {
- print('-----------data[i].template-----------');
- print(data[i].template);
- print('json.encode(res) =============\n${json.encode(res)}');
- var order = parse2(res);
- print('order.toString()=============\n${order.toString()}');
- var maxAmount = 0.0;
- int maxAmountNum = 0;
- List<String> maxAmountOwner = [];
- res.forEach((key, value) {
- if (key.contains('amount')) {
- try {
- if (double.parse(value) > maxAmount) {
- maxAmount = double.parse(value);
- maxAmountNum = 1;
- maxAmountOwner.clear();
- maxAmountOwner.add(res[key.replaceAll('amount', 'person')]);
- } else if (double.parse(value) == maxAmount) {
- maxAmountNum++;
- maxAmountOwner.add(res[key.replaceAll('amount', 'person')]);
- }
- } catch (e) {}
- }
- });
- // order.forEach((element) {
- // if (maxAmount < element.seller.amount) {
- // maxAmount = element.seller.amount;
- // maxAmountNum = 1;
- // } else if (maxAmount == element.seller.amount) {
- // maxAmountNum++;
- // }
- // });
- // print('maxAmount=========== $maxAmount');
- // print('maxAmountNum=========== $maxAmountNum');
- if(maxAmountOwner.isNotEmpty){
- maxAmountOwner.forEach((element) {
- if(MyCookie().getName().contains(element)||element.contains(MyCookie().getName())){
- commissionPayerNum = maxAmountNum;
- }
- });
- }
- // int meIsMaximum = order.indexWhere((element) =>
- // element.seller.amount == maxAmount &&
- // (element.seller.name
- // .contains(MyCookie().loginInformation.data.extra.name) ||
- // MyCookie()
- // .loginInformation
- // .data
- // .extra
- // .name
- // .contains(element.seller.name)));
- // print('meIsMaximum =========== $meIsMaximum');
- // if (meIsMaximum >= 0) {
- // commissionPayerNum = maxAmountNum;
- // }
- print('maxAmount============\n$maxAmount\n==============');
- print('maxAmountNum==============\n$maxAmountNum\n==============');
- print('maxAmountOwner==============\n${maxAmountOwner.toString()}\n==============');
- print('commissionPayerNum================ \n$commissionPayerNum\n==============');
- order.removeWhere((element) =>
- !element.seller.name
- .contains(MyCookie().loginInformation.data.extra.name) &&
- !MyCookie()
- .loginInformation
- .data
- .extra
- .name
- .contains(element.seller.name));
- if (order.length > 0) {
- hasMatch = true;
- orderHash = computeOrderHash(res);
- getShop(order);
- }
- break w;
- }
- } catch (e) {}
- }
- if (!hasMatch) {
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- }
- }
- //订单视图
- items(List<OrderInfo2> order) {
- List<Widget> items = [];
- order.forEach((element) {
- items.add(Container(
- child: Column(
- children: [
- Row(
- children: [
- Container(
- margin: EdgeInsets.only(left: 8, right: 7),
- child: ClipRRect(
- child: MyViews().netImg(
- imgURL(MyCookie().loginInformation.data.extra.picture),
- 35,
- 35),
- borderRadius: BorderRadius.circular(17.5),
- ),
- ),
- Expanded(
- child: Container(
- height: 35,
- child: Column(
- children: [
- Text(
- '付款人:${element.payer.name}',
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 13,
- decoration: TextDecoration.none,
- ),
- ),
- Text(
- '订单时间:${element.time}',
- style: TextStyle(
- color: MyColors.c666666,
- fontSize: 10,
- decoration: TextDecoration.none,
- ),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ),
- ),
- Container(
- margin: EdgeInsets.only(right: 10),
- child: Text(
- '¥${(element.payer.amount * element.factor).toStringAsFixed(2)}',
- style: TextStyle(
- color: MyColors.cFF4233,
- fontSize: 14,
- decoration: TextDecoration.none,
- ),
- ),
- ),
- ],
- crossAxisAlignment: CrossAxisAlignment.center,
- ),
- Container(
- height: 0.5,
- margin: EdgeInsets.only(right: 10, left: 50, top: 5),
- color: MyColors.cE7E7E7,
- )
- ],
- ),
- margin: EdgeInsets.only(top: 5),
- ));
- });
- return items;
- }
- bool saving = false;
- //获取用户所在店铺
- void getShop(List<OrderInfo2> order) {
- shopIndex = 0;
- MyDio().query({
- "key": "shop_user",
- "filters": {
- "or": true,
- "conditions": [
- "role!=0",
- "user_uid==${MyCookie().getUID()}",
- "review_state==1"
- ],
- "filters": [
- {
- "conditions": ["role==0", "user_uid==${MyCookie().getUID()}"]
- }
- ]
- },
- "dims": shopUserDims,
- "paging": [1, 20000]
- }, (response, hasError) {
- if (!hasError) {
- MyShopBeanEntity entity =
- MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
- shops = entity.data.data;
- shops.removeWhere((element) => !element.privateShop);
- if (shops.length == 0) {
- showToast('你还没有添加任何货帮,暂时不能发送智能订单');
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- } else {
- EasyLoading.instance
- ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
- ..alignment = Alignment.bottomCenter
- ..loadingStyle = EasyLoadingStyle.light
- ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
- EasyLoading.show(
- indicator: Material(
- color: Colors.white,
- child: StatefulBuilder(
- builder: (c, s) {
- ss = s;
- return Column(
- children: [
- Container(
- child: Stack(
- children: [
- Container(
- child: MyViews()
- .myText('智能订单', MyColors.c333333, 14),
- alignment: Alignment.center,
- height: 22,
- ),
- Positioned(
- right: 0,
- child: GestureDetector(
- onTap: () {
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- child: Icon(
- Icons.close,
- size: 20,
- color: Colors.white,
- ),
- decoration: BoxDecoration(
- color: MyColors.cB6B6B6,
- borderRadius: BorderRadius.circular(11)),
- height: 22,
- width: 22,
- ),
- ),
- )
- ],
- alignment: Alignment.center,
- ),
- height: 30,
- padding: EdgeInsets.symmetric(horizontal: 12),
- ),
- Container(
- height: 5,
- color: MyColors.cF7F7F7,
- margin: EdgeInsets.only(top: 10),
- ),
- Column(
- children: items(order),
- ),
- Container(
- height: 5,
- color: MyColors.cF7F7F7,
- margin: EdgeInsets.only(top: 10),
- ),
- Visibility(
- child: Column(
- children: [
- Container(
- child: MyViews()
- .myText('货帮选择', MyColors.c333333, 13),
- margin: EdgeInsets.only(left: 7, top: 11),
- ),
- Container(
- margin: EdgeInsets.symmetric(
- horizontal: 7, vertical: 10),
- height: (shops.length * 1.0 / 2).ceil() *
- (double.parse(
- '${MediaQuery.of(buildContext).size.width - 74}') /
- 2 /
- 3.8 +
- 10) -
- 10,
- child: GridView(
- gridDelegate:
- SliverGridDelegateWithFixedCrossAxisCount(
- crossAxisCount: 2, //横轴三个子widget
- childAspectRatio: 3.8,
- crossAxisSpacing: 10,
- mainAxisSpacing: 8 //宽高比为1时,子widget
- ),
- children: shop(shops),
- padding: EdgeInsets.all(0),
- ),
- ),
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- visible: shops.length != 1,
- ),
- Container(
- height: 0.5,
- color: MyColors.cF7F7F7,
- margin: EdgeInsets.only(bottom: 10),
- ),
- Container(
- child: GestureDetector(
- onTap: () {
- if (saving) {
- return;
- } else {
- saving = true;
- EventBus().on('saveOrder', (arg) {
- amountCompleted++;
- if (amountCompleted == order.length) {
- amountCompleted = 0;
- EasyLoading.dismiss();
- showToast('发送成功');
- clipboardT = '';
- saving = false;
- EventBus().off('saveOrder');
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- }
- });
- order.forEach((element) {
- sendOrder(element);
- });
- }
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- color: MyColors.cFF4233,
- borderRadius: BorderRadius.circular(20),
- ),
- height: 40,
- width: 150,
- child: MyViews().myText('发送订单', Colors.white, 14),
- alignment: Alignment.center,
- ),
- ),
- alignment: Alignment.center,
- )
- ],
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- );
- },
- ),
- ),
- );
- }
- } else {
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- }
- }, (error) {
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- });
- }
- //店铺视图
- shop(List<MyShopBeanDataData> shops) {
- List<Widget> items = [];
- for (int i = 0; i < shops.length; i++) {
- items.add(GestureDetector(
- onTap: () {
- shopIndex = i;
- ss(() {});
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- child: Row(
- children: [
- Container(
- margin: EdgeInsets.only(right: 5),
- child: ClipRRect(
- child: MyViews().netImg(imgURL(shops[i].shopPic), 30, 30),
- borderRadius: BorderRadius.circular(15),
- ),
- ),
- Expanded(
- child: Column(
- children: [
- Text(
- shops[i].shopName,
- style: TextStyle(
- color: i == shopIndex
- ? MyColors.cFF4233
- : MyColors.c666666,
- fontSize: 12,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- softWrap: true,
- ),
- Text(
- 'ID:${shops[i].shopUid}',
- style: TextStyle(
- color: i == shopIndex
- ? MyColors.cFF4233
- : MyColors.c666666,
- fontSize: 10,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- softWrap: true,
- ),
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ),
- ],
- ),
- decoration: BoxDecoration(
- color: i == shopIndex ? MyColors.cFFECEB : MyColors.cEDEDED,
- borderRadius: BorderRadius.circular(4),
- ),
- constraints: BoxConstraints(maxWidth: 150),
- padding: EdgeInsets.symmetric(horizontal: 6, vertical: 6),
- ),
- ));
- }
- return items;
- }
- //发送订单
- void sendOrder(OrderInfo2 element) {
- MyDio().save({
- 'key': 'order',
- 'object': {
- 'uuid': orderHash,
- 'shop_uid': shops[shopIndex].shopUid,
- 'shop_pic': shops[shopIndex].shopPic,
- 'shop_name': shops[shopIndex].shopName,
- 'seller_pic': MyCookie().loginInformation.data.extra.picture,
- 'seller_uid': MyCookie().getUID(),
- 'seller_name': MyCookie().loginInformation.data.extra.name,
- 'buyer_name': element.payer.name,
- 'type': orderTypeThirdPlatform,
- 'amount': NumUtil.multiply(element.payer.amount, element.factor),
- 'commission_payer_num': commissionPayerNum
- }
- }, (response, hasError) {
- if (!hasError) {
- EventBus().emit('saveOrder');
- }
- }, (error) {});
- }
- //待支付订单视图
- void displayPendingOrders() {
- EasyLoading.instance
- ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
- ..alignment = Alignment.bottomCenter
- ..loadingStyle = EasyLoadingStyle.light
- ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
- EasyLoading.show(
- indicator: Material(
- color: Colors.white,
- child: Column(
- children: [
- Container(
- padding: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- Container(
- margin: EdgeInsets.only(right: 7),
- child: ClipRRect(
- child: MyViews()
- .netImg(imgURL(newOrder.content.shopPic), 25, 25),
- borderRadius: BorderRadius.circular(12.5),
- ),
- ),
- MyViews().myText(
- '${newOrder.content.shopName}(${newOrder.content.shopUID})',
- MyColors.c333333,
- 14),
- ],
- ),
- ),
- Container(
- margin: EdgeInsets.only(top: 11, left: 12, right: 12, bottom: 11),
- height: 0.5,
- color: MyColors.cE7E7E7,
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- Container(
- child: SvgPicture.asset(
- newOrder.content.buyerPic == null
- ? 'images/svg/第三方.svg'
- : 'images/svg/线下付款.svg',
- height: 27,
- width: 27,
- ),
- margin: EdgeInsets.only(right: 8),
- height: 45,
- width: 45,
- decoration: BoxDecoration(
- border: Border.all(color: MyColors.cEBEBEB, width: 1)),
- alignment: Alignment.center,
- ),
- Expanded(
- child: Container(
- height: 45,
- child: Column(
- children: [
- MyViews().myText(
- newOrder.content.buyerPic == null
- ? '第三方订单'
- : '线下付款',
- MyColors.c333333,
- 13),
- Row(
- children: [
- MyViews().myText('¥${newOrder.content.amount}',
- MyColors.cFF4233, 12),
- MyViews().myText('x1', MyColors.c999999, 12),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ),
- ),
- ],
- ),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- MyViews().myText('卖家信息:', MyColors.c333333, 13),
- Row(
- children: [
- Container(
- margin: EdgeInsets.only(right: 5),
- child: ClipRRect(
- child: MyViews().netImg(
- imgURL(newOrder.content.sellerPic), 23, 23),
- borderRadius: BorderRadius.circular(11.5),
- ),
- ),
- MyViews().myText(
- '${newOrder.content.sellerName}(${hideUID(newOrder.content.sellerUID.toString())})',
- MyColors.c333333,
- 13),
- ],
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- MyViews().myText('买家信息:', MyColors.c333333, 13),
- Row(
- children: [
- Container(
- margin: EdgeInsets.only(right: 5),
- child: ClipRRect(
- child: MyViews().netImg(
- newOrder.content.buyerPic == null
- ? ''
- : imgURL(newOrder.content.buyerPic),
- 23,
- 23),
- borderRadius: BorderRadius.circular(11.5),
- ),
- ),
- MyViews().myText(
- '${newOrder.content.buyerName} ${newOrder.content.buyerUID != null && newOrder.content.buyerUID.toString().length > 0 ? '(${newOrder.content.buyerUID})' : ''}',
- MyColors.c333333,
- 13),
- ],
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 12),
- child: Row(
- children: [
- MyViews().myText('下单时间:', MyColors.c333333, 13),
- MyViews().myText(
- '${newOrder.content.createTime}', MyColors.c333333, 13)
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 20),
- child: Row(
- children: [
- Expanded(
- child: GestureDetector(
- onTap: () {
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(20),
- bottomLeft: Radius.circular(20),
- ),
- border: Border.all(
- color: MyColors.cFF4233, width: 1)),
- height: 40,
- child: MyViews().myText('与我无瓜', MyColors.cFF4233, 14),
- alignment: Alignment.center),
- ),
- ),
- Expanded(
- child: GestureDetector(
- onTap: () {
- if (newOrder.content.buyerName
- .contains(MyCookie().getName()) ||
- MyCookie()
- .getName()
- .contains(newOrder.content.buyerName)) {
- EasyLoading.dismiss();
- payTheOrder();
- } else {
- showToast('该订单与你无关');
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- }
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(20),
- bottomRight: Radius.circular(20),
- ),
- color: MyColors.cFF4233),
- height: 40,
- child: MyViews().myText('去支付', Colors.white, 14),
- alignment: Alignment.center),
- ),
- )
- ],
- ),
- )
- ],
- ),
- ),
- );
- }
- void payTheOrder() {
- //获取店铺信息
- MyDio().query({
- "key": "shop_user",
- "filters": {
- "conditions": ["shop_uid==${newOrder.content.shopUID}"]
- },
- "dims": shopUserDims,
- "paging": [1, 1],
- "order_by": ["shop_name,DESC"]
- }, (response, hasError) {
- if (!hasError) {
- MyShopBeanEntity entity =
- MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
- SmartOrderBeanDataData data = SmartOrderBeanDataData();
- data.sellerUid = newOrder.content.sellerUID;
- data.sellerName = newOrder.content.sellerName;
- data.sellerPic = newOrder.content.sellerPic;
- data.buyerUid = 0;
- data.buyerName = newOrder.content.buyerName;
- data.buyerPic = '';
- data.amount = newOrder.content.amount;
- data.uid = newOrder.content.uID;
- navigatorKey.currentState
- .push(MaterialPageRoute(
- builder: (context) => OrderInformationPage(
- false,
- orderType: orderTypeThirdPlatform,
- amount: newOrder.content.amount,
- uid: newOrder.content.uID,
- buyerUid: MyCookie().getUID(),
- buyerName: newOrder.content.buyerName,
- buyerPic: MyCookie().getPic(),
- commodityCount: 1,
- commodityTitle: '第三方订单',
- commodityCover: '',
- sellName: newOrder.content.sellerName,
- sellPic: newOrder.content.sellerPic,
- sellUid: newOrder.content.sellerUID,
- )))
- .then((value) {
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- });
- // navigatorKey.currentState.push(MaterialPageRoute(
- // builder: (context) =>
- // GangInPage(entity.data.data[0], newOrder.content)));
- }
- }, (error) {});
- // getUserWalletBalance((re, hE) {
- // if (!hE) {
- // UserBalanceEntity balance =
- // UserBalanceEntity().fromJson(json.decode(re.data.toString()));
- // if (balance.data >= newOrder.content.amount) {
- // payOrder(payWayWallet, newOrder.content.uID, (re, hE) {
- // if (!hE) {
- // showToast('支付成功');
- // EventBus().emit('payAnOrder');
- // }
- // }, (e) {}, context);
- // } else {
- // payOrder(payWayAliPay, newOrder.content.uID, (re, hE) {
- // if (!hE) {
- // PayByAlipayBeanEntity entity = PayByAlipayBeanEntity()
- // .fromJson(json.decode(re.data.toString()));
- // EventBus().on('alipayPaymentCallback', (arg) {
- // EventBus().off('alipayPaymentCallback');
- // EasyLoading.dismiss();
- // showToast('支付成功');
- // EventBus().emit('reNoPayOrder');
- // });
- // print(entity.data);
- // EasyLoading.instance
- // ..contentPadding =
- // EdgeInsets.symmetric(horizontal: 20, vertical: 12)
- // ..alignment = Alignment.center
- // ..contentMargin = EdgeInsets.all(20);
- // EasyLoading.show();
- // aliPay(entity.data).then((value) {
- // print(json.encode(value));
- // AlipayResultBeanEntity e = AlipayResultBeanEntity()
- // .fromJson(json.decode(json.encode(value)));
- // try {
- // int r = int.parse(e.resultStatus);
- // if (r == 9000) {
- // showToast('支付成功');
- // } else {
- // showToast(aliPayResultStatus(r));
- // resetOrder(newOrder.content.uID, context);
- // }
- // } catch (e) {
- // EasyLoading.dismiss();
- // }
- // });
- // // EventBus().emit('payAnOrder');
- // }
- // }, (e) {}, context);
- // // showToast('积分余额不足');
- // }
- // }
- // }, (e) {}, context);
- }
- void showSystemMessages(SystemInformationBeanEntity arg) {
- EasyLoading.instance
- ..contentPadding = EdgeInsets.symmetric(horizontal: 12, vertical: 12)
- ..alignment = Alignment.center
- ..loadingStyle = EasyLoadingStyle.custom
- ..backgroundColor = Colors.transparent
- ..indicatorColor = Colors.black
- ..progressColor = Colors.black
- ..maskColor = Colors.black
- ..textColor = Colors.black
- ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
- EasyLoading.show(
- indicator: Material(
- color: Colors.transparent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(16),
- ),
- height: MediaQuery.of(buildContext).size.height - 200,
- padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
- child: Column(
- children: [
- Expanded(child: Container()),
- Container(
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(16),
- ),
- child: Column(
- children: [
- Container(
- child: Text(
- '系统消息',
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 14,
- fontWeight: FontWeight.bold),
- ),
- margin:
- EdgeInsets.symmetric(horizontal: 26, vertical: 15),
- ),
- Container(
- child: Text(
- arg.content.content,
- style: TextStyle(color: MyColors.c333333, fontSize: 14),
- ),
- margin: EdgeInsets.symmetric(horizontal: 26),
- alignment: Alignment.centerLeft,
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.only(bottom: 12, top: 12),
- ),
- GestureDetector(
- onTap: () {
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- width: 150,
- margin: EdgeInsets.only(bottom: 14),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(20),
- border:
- Border.all(color: MyColors.cFF4233, width: 1.1),
- color: Colors.white),
- child: MyViews().myText('我知道了', MyColors.cFF4233, 14),
- height: 40,
- alignment: Alignment.center,
- ),
- )
- ],
- ),
- ),
- Expanded(child: Container()),
- ],
- ),
- alignment: Alignment.center,
- ),
- ),
- );
- }
- //优惠券弹框
- void couponBulletBox(CouponBeanDataData data) {
- EasyLoading.instance
- ..contentPadding = EdgeInsets.symmetric(horizontal: 12, vertical: 12)
- ..alignment = Alignment.center
- ..loadingStyle = EasyLoadingStyle.custom
- ..backgroundColor = Colors.transparent
- ..indicatorColor = Colors.black
- ..progressColor = Colors.black
- ..maskColor = Colors.black
- ..textColor = Colors.black
- ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
- EasyLoading.show(
- indicator: Material(
- color: Colors.transparent,
- child: Stack(
- children: [
- Image.asset(
- 'images/优惠券.png',
- height: 640,
- width: double.infinity,
- ),
- Container(
- height: 640,
- margin: EdgeInsets.only(top: 24),
- child: Column(
- children: [
- Container(
- margin: EdgeInsets.only(bottom: 5),
- child: Text(
- '抢红包啦',
- style: TextStyle(
- color: Colors.white,
- fontSize: 24,
- fontWeight: FontWeight.bold,
- shadows: [
- Shadow(
- offset: Offset(1.0, 1.0),
- blurRadius: 3.0,
- color: MyColors.cDC1717,
- )
- ]),
- ),
- ),
- Container(
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(8),
- ),
- height: 107,
- width: double.infinity,
- margin: EdgeInsets.symmetric(horizontal: 25, vertical: 27),
- child: Column(
- children: [
- Text(
- '平台红包大放送!',
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 16,
- fontWeight: FontWeight.bold),
- ),
- Text(
- '立即去抢最高${data.max}元消费红包',
- style: TextStyle(
- color: MyColors.cFF4233,
- fontSize: 14,
- fontWeight: FontWeight.bold),
- ),
- Text(
- '活动时间${data.distributeFromDate}至${data.distributeEndDate}',
- style: TextStyle(
- color: MyColors.c666666,
- fontSize: 11,
- fontWeight: FontWeight.bold),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.spaceEvenly,
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- padding: EdgeInsets.symmetric(horizontal: 26),
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 25),
- child: Row(
- children: [
- Expanded(
- child: GestureDetector(
- onTap: () {
- EasyLoading.dismiss();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- height: 34,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(
- topLeft: Radius.circular(17),
- bottomLeft: Radius.circular(17),
- ),
- border: Border.all(
- color: MyColors.cFFB455, width: 1),
- color: Colors.white),
- child: Text(
- '我已参与',
- style: TextStyle(
- color: MyColors.cFFB455,
- fontSize: 14,
- ),
- ),
- alignment: Alignment.center,
- ),
- ),
- ),
- Expanded(
- child: GestureDetector(
- onTap: () {
- grabACoupon(data.id);
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- height: 34,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.only(
- topRight: Radius.circular(17),
- bottomRight: Radius.circular(17),
- ),
- color: MyColors.cFFB455),
- child: Text(
- '立即去抢',
- style: TextStyle(
- color: Colors.white,
- fontSize: 14,
- ),
- ),
- alignment: Alignment.center,
- ),
- ),
- ),
- ],
- ),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.center,
- ),
- alignment: Alignment.center,
- )
- ],
- ),
- ),
- );
- }
- _initFluwx() async {
- await registerWxApi(
- appId: AppID,
- doOnAndroid: true,
- doOnIOS: true,
- universalLink: "https://oms.kunyueyun.com/");
- var result = await isWeChatInstalled;
- print("is installed $result");
- weChatResponseEventHandler.listen((res) {
- if (res is WeChatPaymentResponse) {
- // do something here
- print('res.type----${res.type}');
- print('res.extData----${res.extData}');
- print('res.errCode----${res.errCode}');
- print('res.errStr----${res.errStr}');
- print('res.isSuccessful----${res.isSuccessful}');
- EventBus().emit('WeChatPaymentResponse', res.isSuccessful);
- }
- if (res is WeChatAuthResponse) {
- print('res.type----${res.type}');
- print('res.country----${res.country}');
- print('res.lang----${res.lang}');
- print('res.code----${res.code}');
- print('res.state----${res.state}');
- print(
- 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=$AppID&secret=$AppSecret&code=${res.code}&grant_type=authorization_code');
- Dio()
- .get(
- 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=$AppID&secret=$AppSecret&code=${res.code}&grant_type=authorization_code')
- .then((value) {
- print(value);
- getWeChatInfo(value);
- });
- }
- });
- }
- //获取微信用户信息
- void getWeChatInfo(Response value) {
- AccessBeanEntity accessBeanEntity =
- AccessBeanEntity().fromJson(json.decode(value.toString()));
- Dio()
- .get(
- 'https://api.weixin.qq.com/sns/userinfo?access_token=${accessBeanEntity.accessToken}&openid=${accessBeanEntity.openid}')
- .then((value) {
- print(value);
- try {
- WXBeanEntity entity =
- WXBeanEntity().fromJson(json.decode(value.toString()));
- saveWXInfo(entity);
- } catch (e) {}
- });
- }
- void saveWXInfo(WXBeanEntity entity) {
- MyDio().update({
- "key": "user",
- "values": {
- "id": MyCookie().loginInformation.data.extra.id,
- "wx_picture": entity.headimgurl,
- "wx_name": entity.nickname,
- "wx_openid": entity.openid
- }
- }, (response, hasError) {
- if (!hasError) {
- MyCookie().userBean.wxOpenid = entity.openid;
- MyCookie().userBean.wxName = entity.nickname;
- MyCookie().userBean.wxPicture = entity.headimgurl;
- EventBus().emit('bindToWeChat');
- }
- }, (error) {});
- }
- void isItUnderReview() {
- MyDio().post('/model/appStoreReview', {}, (response, hasError) {
- if(!hasError){
- AppStoreReviewBeanEntity e = AppStoreReviewBeanEntity().fromJson(json.decode(response.data.toString()));
- print(e.data);
- if(e.data&&Platform.isIOS){
- MyCookie().underReview = true;
- }else{
- MyCookie().underReview = false;
- }
- EventBus().emit('appStoreReview');
- }
- }, (error) { });
- }
- }
- class FallbackCupertinoLocalisationsDelegate
- extends LocalizationsDelegate<CupertinoLocalizations> {
- const FallbackCupertinoLocalisationsDelegate();
- @override
- bool isSupported(Locale locale) => true;
- @override
- Future<CupertinoLocalizations> load(Locale locale) =>
- DefaultCupertinoLocalizations.load(locale);
- @override
- bool shouldReload(FallbackCupertinoLocalisationsDelegate old) => false;
- }
|