| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332 |
- 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/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/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);
- }
- });
- 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: ''));
- getOnlineTemplate();
- } catch (e) {
- PopUpQueue().onShow = false;
- PopUpQueue().showNext();
- }
- }
- //获取线上模板
- void getOnlineTemplate() {
- MyDio().query({
- 'key': 'order_template',
- "dims": ["id", "sid", "template"],
- "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));
- var order = parse2(res);
- print(order.toString());
- var maxAmount = 0;
- int maxAmountNum = 0;
- 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');
- 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)));
- if (meIsMaximum >= 0) {
- commissionPayerNum = maxAmountNum;
- }
- print('commissionPayerNum-----------$commissionPayerNum');
- 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) {});
- }
- }
- 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;
- }
|