main.dart 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
  1. import 'dart:async';
  2. import 'dart:convert';
  3. import 'package:bbyyy/beans/template_bean_entity.dart';
  4. import 'package:bbyyy/https/url.dart';
  5. import 'package:bbyyy/my_tools/event_bus.dart';
  6. import 'package:bbyyy/my_tools/my_cookie.dart';
  7. import 'package:bbyyy/my_tools/my_tools.dart';
  8. import 'package:bbyyy/paegs/gang_page/gang_in_page/gang_in_page.dart';
  9. import 'package:bbyyy/paegs/login_page/login_page.dart';
  10. import 'package:bbyyy/paegs/root_page/root_page_view.dart';
  11. import 'package:bbyyy/paegs/welcome_page/welcome_page.dart';
  12. import 'package:flustars/flustars.dart';
  13. import 'package:flutter/cupertino.dart';
  14. import 'package:flutter/material.dart';
  15. import 'package:flutter/services.dart';
  16. import 'package:flutter_local_notifications/flutter_local_notifications.dart';
  17. import 'package:flutter_localizations/flutter_localizations.dart';
  18. import 'package:flutter_svg/flutter_svg.dart';
  19. import 'package:pull_to_refresh/pull_to_refresh.dart';
  20. import 'package:rxdart/rxdart.dart';
  21. import 'beans/my_shop_bean_entity.dart';
  22. import 'beans/new_order_bean_entity.dart';
  23. import 'beans/system_information_bean_entity.dart';
  24. import 'https/MyDio.dart';
  25. import 'my_tools/const.dart';
  26. import 'my_tools/dims.dart';
  27. import 'my_tools/easy_loading/easy_loading.dart';
  28. import 'my_tools/easy_loading/loading.dart';
  29. import 'my_tools/global.dart';
  30. import 'my_tools/my_colors.dart';
  31. import 'my_tools/my_views.dart';
  32. import 'my_tools/order.dart';
  33. final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
  34. FlutterLocalNotificationsPlugin();
  35. final BehaviorSubject<ReceivedNotification> didReceiveLocalNotificationSubject =
  36. BehaviorSubject<ReceivedNotification>();
  37. final BehaviorSubject<String> selectNotificationSubject =
  38. BehaviorSubject<String>();
  39. class ReceivedNotification {
  40. ReceivedNotification({
  41. @required this.id,
  42. @required this.title,
  43. @required this.body,
  44. @required this.payload,
  45. });
  46. final int id;
  47. final String title;
  48. final String body;
  49. final String payload;
  50. }
  51. Future<void> main() async {
  52. WidgetsFlutterBinding.ensureInitialized();
  53. const AndroidInitializationSettings initializationSettingsAndroid =
  54. AndroidInitializationSettings('@mipmap/app_logo');
  55. /// Note: permissions aren't requested here just to demonstrate that can be
  56. /// done later
  57. final IOSInitializationSettings initializationSettingsIOS =
  58. IOSInitializationSettings(
  59. requestAlertPermission: true,
  60. requestBadgePermission: true,
  61. requestSoundPermission: true,
  62. onDidReceiveLocalNotification:
  63. (int id, String title, String body, String payload) async {
  64. didReceiveLocalNotificationSubject.add(ReceivedNotification(
  65. id: id, title: title, body: body, payload: payload));
  66. });
  67. const MacOSInitializationSettings initializationSettingsMacOS =
  68. MacOSInitializationSettings(
  69. requestAlertPermission: true,
  70. requestBadgePermission: true,
  71. requestSoundPermission: true);
  72. final InitializationSettings initializationSettings = InitializationSettings(
  73. android: initializationSettingsAndroid,
  74. iOS: initializationSettingsIOS,
  75. macOS: initializationSettingsMacOS);
  76. await flutterLocalNotificationsPlugin.initialize(initializationSettings,
  77. onSelectNotification: (String payload) async {
  78. if (payload != null) {
  79. if (payload == notifyTypeNewMsg) {
  80. RootPageView().bNIndex = 2;
  81. EventBus().emit('ChangePage');
  82. }
  83. debugPrint('notification payload: $payload');
  84. }
  85. selectNotificationSubject.add(payload);
  86. });
  87. runApp(MyApp());
  88. }
  89. class MyApp extends StatelessWidget with WidgetsBindingObserver {
  90. BuildContext buildContext;
  91. StateSetter ss;
  92. List<MyShopBeanDataData> shops = [];
  93. int shopIndex = 0;
  94. String clipboardT;
  95. int amountCompleted = 0;
  96. NewOrderBeanEntity newOrder;
  97. @override
  98. StatelessElement createElement() {
  99. // TODO: implement createElement
  100. WidgetsBinding.instance.addObserver(this);
  101. MyCookie().initP();
  102. EventBus().on('hasNewOrder', (arg) {
  103. print('fnlasnfiansfinasfnoasnfi---------1');
  104. newOrder = arg;
  105. displayPendingOrders();
  106. });
  107. EventBus().on('systemInformation', (arg) {
  108. print('systemInformationasdasdasd');
  109. if (arg is SystemInformationBeanEntity) {
  110. print(
  111. 'systemInformationasdasdasdcccccccccccccccccccccccccccccccccccccccc');
  112. showSystemMessages(arg);
  113. }
  114. });
  115. return super.createElement();
  116. }
  117. @override
  118. Widget build(BuildContext context) {
  119. return RefreshConfiguration(
  120. child: MaterialApp(
  121. navigatorKey: navigatorKey,
  122. theme: ThemeData(fontFamily: 'PingFang'),
  123. debugShowCheckedModeBanner: false,
  124. home: WelcomePage(),
  125. routes: {
  126. '/loginPage': (context) => LoginPage(),
  127. },
  128. supportedLocales: [const Locale('zh', 'CH')],
  129. localizationsDelegates: [
  130. RefreshLocalizations.delegate,
  131. GlobalMaterialLocalizations.delegate,
  132. GlobalWidgetsLocalizations.delegate,
  133. const FallbackCupertinoLocalisationsDelegate(),
  134. ],
  135. builder: (BuildContext context, Widget child) {
  136. buildContext = context;
  137. return MediaQuery(
  138. data: MediaQuery.of(context)
  139. .copyWith(textScaleFactor: 1.0), //设置字体不随系统字体大小改变
  140. child: FlutterEasyLoading(
  141. child: child,
  142. ),
  143. );
  144. },
  145. ),
  146. hideFooterWhenNotFull: true,
  147. footerBuilder: () {
  148. return ClassicFooter(
  149. loadStyle: LoadStyle.ShowWhenLoading,
  150. );
  151. },
  152. );
  153. }
  154. @override
  155. void didChangeAppLifecycleState(AppLifecycleState state) {
  156. super.didChangeAppLifecycleState(state);
  157. if (state == AppLifecycleState.paused) {
  158. print('went to Background');
  159. }
  160. if (state == AppLifecycleState.resumed) {
  161. print('came back to Foreground');
  162. if (MyCookie().loginInformation != null) {
  163. Timer(Duration(seconds: 1), () {
  164. getClipboardData();
  165. });
  166. }
  167. }
  168. }
  169. //获取剪切板文字
  170. Future<void> getClipboardData() async {
  171. ClipboardData text = await Clipboard.getData(Clipboard.kTextPlain);
  172. print('Clipboard-----\n${text.text}');
  173. clipboardT = text.text;
  174. Clipboard.setData(ClipboardData(text: ''));
  175. getOnlineTemplate();
  176. }
  177. //获取线上模板
  178. void getOnlineTemplate() {
  179. MyDio().query({
  180. 'key': 'order_template',
  181. "dims": ["id", "sid", "template"],
  182. "filters": {}
  183. }, (response, hasError) {
  184. if (!hasError) {
  185. TemplateBeanEntity entity = TemplateBeanEntity()
  186. .fromJson(json.decode(response.data.toString()));
  187. checkOrder(entity.data);
  188. }
  189. }, (error) {});
  190. }
  191. //匹配模板去除不是自己的订单
  192. void checkOrder(List<TemplateBeanData> data) {
  193. w:
  194. for (int i = 0; i < data.length; i++) {
  195. try {
  196. var res = parseString2(
  197. data[i].template.replaceAll('\r', ''), '''$clipboardT''');
  198. if (res != null) {
  199. print(data[i].template);
  200. print(json.encode(res));
  201. var order = parse2(res);
  202. order.removeWhere((element) =>
  203. !element.seller.name
  204. .contains(MyCookie().loginInformation.data.extra.name) &&
  205. !MyCookie()
  206. .loginInformation
  207. .data
  208. .extra
  209. .name
  210. .contains(element.seller.name));
  211. if (order.length > 0) {
  212. getShop(order);
  213. }
  214. break w;
  215. }
  216. } catch (e) {}
  217. }
  218. }
  219. //订单视图
  220. items(List<OrderInfo2> order) {
  221. List<Widget> items = [];
  222. order.forEach((element) {
  223. items.add(Container(
  224. child: Column(
  225. children: [
  226. Row(
  227. children: [
  228. Container(
  229. margin: EdgeInsets.only(left: 8, right: 7),
  230. child: ClipRRect(
  231. child: MyViews().netImg(
  232. imgURL(MyCookie().loginInformation.data.extra.picture),
  233. 35,
  234. 35),
  235. borderRadius: BorderRadius.circular(17.5),
  236. ),
  237. ),
  238. Expanded(
  239. child: Container(
  240. height: 35,
  241. child: Column(
  242. children: [
  243. Text(
  244. '付款人:${element.payer.name}',
  245. style: TextStyle(
  246. color: MyColors.c333333,
  247. fontSize: 13,
  248. decoration: TextDecoration.none,
  249. ),
  250. ),
  251. Text(
  252. '订单时间:${element.time}',
  253. style: TextStyle(
  254. color: MyColors.c666666,
  255. fontSize: 10,
  256. decoration: TextDecoration.none,
  257. ),
  258. ),
  259. ],
  260. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  261. crossAxisAlignment: CrossAxisAlignment.start,
  262. ),
  263. ),
  264. ),
  265. Container(
  266. margin: EdgeInsets.only(right: 10),
  267. child: Text(
  268. '¥${(element.payer.amount * element.factor).toStringAsFixed(2)}',
  269. style: TextStyle(
  270. color: MyColors.cFF4233,
  271. fontSize: 14,
  272. decoration: TextDecoration.none,
  273. ),
  274. ),
  275. ),
  276. ],
  277. crossAxisAlignment: CrossAxisAlignment.center,
  278. ),
  279. Container(
  280. height: 0.5,
  281. margin: EdgeInsets.only(right: 10, left: 50, top: 5),
  282. color: MyColors.cE7E7E7,
  283. )
  284. ],
  285. ),
  286. margin: EdgeInsets.only(top: 5),
  287. ));
  288. });
  289. return items;
  290. }
  291. //获取用户所在店铺
  292. void getShop(List<OrderInfo2> order) {
  293. shopIndex = 0;
  294. MyDio().query({
  295. "key": "shop_user",
  296. "filters": {
  297. "or": true,
  298. "conditions": [
  299. "role!=0",
  300. "user_uid==${MyCookie().getUID()}",
  301. "review_state==1"
  302. ],
  303. "filters": [
  304. {
  305. "conditions": ["role==0", "user_uid==${MyCookie().getUID()}"]
  306. }
  307. ]
  308. },
  309. "dims": shopUserDims,
  310. "paging": [1, 20000]
  311. }, (response, hasError) {
  312. if (!hasError) {
  313. MyShopBeanEntity entity =
  314. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  315. shops = entity.data.data;
  316. shops.removeWhere((element) => !element.privateShop);
  317. if (shops.length == 0) {
  318. showToast('你还没有添加任何货帮,暂时不能发送智能订单');
  319. } else {
  320. EasyLoading.instance
  321. ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
  322. ..alignment = Alignment.bottomCenter
  323. ..loadingStyle = EasyLoadingStyle.light
  324. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  325. EasyLoading.show(
  326. indicator: Material(
  327. color: Colors.white,
  328. child: StatefulBuilder(
  329. builder: (c, s) {
  330. ss = s;
  331. return Column(
  332. children: [
  333. Container(
  334. child: Stack(
  335. children: [
  336. Container(
  337. child: MyViews()
  338. .myText('智能订单', MyColors.c333333, 14),
  339. alignment: Alignment.center,
  340. height: 22,
  341. ),
  342. Positioned(
  343. right: 0,
  344. child: GestureDetector(
  345. onTap: () {
  346. EasyLoading.dismiss();
  347. },
  348. behavior: HitTestBehavior.translucent,
  349. child: Container(
  350. child: Icon(
  351. Icons.close,
  352. size: 20,
  353. color: Colors.white,
  354. ),
  355. decoration: BoxDecoration(
  356. color: MyColors.cB6B6B6,
  357. borderRadius: BorderRadius.circular(11)),
  358. height: 22,
  359. width: 22,
  360. ),
  361. ),
  362. )
  363. ],
  364. alignment: Alignment.center,
  365. ),
  366. height: 30,
  367. padding: EdgeInsets.symmetric(horizontal: 12),
  368. ),
  369. Container(
  370. height: 5,
  371. color: MyColors.cF7F7F7,
  372. margin: EdgeInsets.only(top: 10),
  373. ),
  374. Column(
  375. children: items(order),
  376. ),
  377. Container(
  378. height: 5,
  379. color: MyColors.cF7F7F7,
  380. margin: EdgeInsets.only(top: 10),
  381. ),
  382. Visibility(
  383. child: Column(
  384. children: [
  385. Container(
  386. child: MyViews()
  387. .myText('货帮选择', MyColors.c333333, 13),
  388. margin: EdgeInsets.only(left: 7, top: 11),
  389. ),
  390. Container(
  391. margin: EdgeInsets.symmetric(
  392. horizontal: 7, vertical: 10),
  393. height: (shops.length * 1.0 / 2).ceil() *
  394. (double.parse(
  395. '${MediaQuery.of(buildContext).size.width - 74}') /
  396. 2 /
  397. 3.8 +
  398. 10) -
  399. 10,
  400. child: GridView(
  401. gridDelegate:
  402. SliverGridDelegateWithFixedCrossAxisCount(
  403. crossAxisCount: 2, //横轴三个子widget
  404. childAspectRatio: 3.8,
  405. crossAxisSpacing: 10,
  406. mainAxisSpacing: 8 //宽高比为1时,子widget
  407. ),
  408. children: shop(shops),
  409. padding: EdgeInsets.all(0),
  410. ),
  411. ),
  412. ],
  413. crossAxisAlignment: CrossAxisAlignment.start,
  414. ),
  415. visible: shops.length != 1,
  416. ),
  417. Container(
  418. height: 0.5,
  419. color: MyColors.cF7F7F7,
  420. margin: EdgeInsets.only(bottom: 10),
  421. ),
  422. Container(
  423. child: GestureDetector(
  424. onTap: () {
  425. EventBus().on('saveOrder', (arg) {
  426. amountCompleted++;
  427. if (amountCompleted == order.length) {
  428. amountCompleted = 0;
  429. EasyLoading.dismiss();
  430. showToast('发送成功');
  431. clipboardT = '';
  432. EventBus().off('saveOrder');
  433. }
  434. });
  435. order.forEach((element) {
  436. sendOrder(element);
  437. });
  438. },
  439. behavior: HitTestBehavior.translucent,
  440. child: Container(
  441. decoration: BoxDecoration(
  442. color: MyColors.cFF4233,
  443. borderRadius: BorderRadius.circular(20),
  444. ),
  445. height: 40,
  446. width: 150,
  447. child: MyViews().myText('发送订单', Colors.white, 14),
  448. alignment: Alignment.center,
  449. ),
  450. ),
  451. alignment: Alignment.center,
  452. )
  453. ],
  454. mainAxisAlignment: MainAxisAlignment.start,
  455. crossAxisAlignment: CrossAxisAlignment.start,
  456. );
  457. },
  458. ),
  459. ),
  460. );
  461. }
  462. }
  463. }, (error) {});
  464. }
  465. //店铺视图
  466. shop(List<MyShopBeanDataData> shops) {
  467. List<Widget> items = [];
  468. for (int i = 0; i < shops.length; i++) {
  469. items.add(GestureDetector(
  470. onTap: () {
  471. shopIndex = i;
  472. ss(() {});
  473. },
  474. behavior: HitTestBehavior.translucent,
  475. child: Container(
  476. child: Row(
  477. children: [
  478. Container(
  479. margin: EdgeInsets.only(right: 5),
  480. child: ClipRRect(
  481. child: MyViews().netImg(imgURL(shops[i].shopPic), 30, 30),
  482. borderRadius: BorderRadius.circular(15),
  483. ),
  484. ),
  485. Expanded(
  486. child: Column(
  487. children: [
  488. Text(
  489. shops[i].shopName,
  490. style: TextStyle(
  491. color: i == shopIndex
  492. ? MyColors.cFF4233
  493. : MyColors.c666666,
  494. fontSize: 12,
  495. ),
  496. maxLines: 1,
  497. overflow: TextOverflow.ellipsis,
  498. softWrap: true,
  499. ),
  500. Text(
  501. 'ID:${shops[i].shopUid}',
  502. style: TextStyle(
  503. color: i == shopIndex
  504. ? MyColors.cFF4233
  505. : MyColors.c666666,
  506. fontSize: 10,
  507. ),
  508. maxLines: 1,
  509. overflow: TextOverflow.ellipsis,
  510. softWrap: true,
  511. ),
  512. ],
  513. crossAxisAlignment: CrossAxisAlignment.start,
  514. ),
  515. ),
  516. ],
  517. ),
  518. decoration: BoxDecoration(
  519. color: i == shopIndex ? MyColors.cFFECEB : MyColors.cEDEDED,
  520. borderRadius: BorderRadius.circular(4),
  521. ),
  522. constraints: BoxConstraints(maxWidth: 150),
  523. padding: EdgeInsets.symmetric(horizontal: 6, vertical: 6),
  524. ),
  525. ));
  526. }
  527. return items;
  528. }
  529. //发送订单
  530. void sendOrder(OrderInfo2 element) {
  531. MyDio().save({
  532. 'key': 'order',
  533. 'object': {
  534. 'uuid': generateMd5(reOS(clipboardT)),
  535. 'shop_uid': shops[shopIndex].shopUid,
  536. 'shop_pic': shops[shopIndex].shopPic,
  537. 'shop_name': shops[shopIndex].shopName,
  538. // 'seller_id': MyCookie().loginInformation.data.extra.id,
  539. 'seller_pic': MyCookie().loginInformation.data.extra.picture,
  540. 'seller_uid': MyCookie().getUID(),
  541. 'seller_name': MyCookie().loginInformation.data.extra.name,
  542. 'buyer_name': element.payer.name,
  543. 'type': orderTypeThirdPlatform,
  544. 'amount': NumUtil.multiply(element.payer.amount, element.factor)
  545. // 'amount':0.01
  546. }
  547. }, (response, hasError) {
  548. if (!hasError) {
  549. EventBus().emit('saveOrder');
  550. }
  551. }, (error) {});
  552. }
  553. //待支付订单视图
  554. void displayPendingOrders() {
  555. EasyLoading.instance
  556. ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
  557. ..alignment = Alignment.bottomCenter
  558. ..loadingStyle = EasyLoadingStyle.light
  559. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  560. EasyLoading.show(
  561. indicator: Material(
  562. color: Colors.white,
  563. child: Column(
  564. children: [
  565. Container(
  566. padding: EdgeInsets.symmetric(horizontal: 12),
  567. child: Row(
  568. children: [
  569. Container(
  570. margin: EdgeInsets.only(right: 7),
  571. child: ClipRRect(
  572. child: MyViews()
  573. .netImg(imgURL(newOrder.content.shopPic), 25, 25),
  574. borderRadius: BorderRadius.circular(12.5),
  575. ),
  576. ),
  577. MyViews().myText(
  578. '${newOrder.content.shopName}(${newOrder.content.shopUID})',
  579. MyColors.c333333,
  580. 14),
  581. ],
  582. ),
  583. ),
  584. Container(
  585. margin: EdgeInsets.only(top: 11, left: 12, right: 12, bottom: 11),
  586. height: 0.5,
  587. color: MyColors.cE7E7E7,
  588. ),
  589. Container(
  590. margin: EdgeInsets.symmetric(horizontal: 12),
  591. child: Row(
  592. children: [
  593. Container(
  594. child: SvgPicture.asset(
  595. 'images/svg/第三方.svg',
  596. height: 27,
  597. width: 27,
  598. ),
  599. margin: EdgeInsets.only(right: 8),
  600. height: 45,
  601. width: 45,
  602. decoration: BoxDecoration(
  603. border: Border.all(color: MyColors.cEBEBEB, width: 1)),
  604. alignment: Alignment.center,
  605. ),
  606. Expanded(
  607. child: Container(
  608. height: 45,
  609. child: Column(
  610. children: [
  611. MyViews().myText('第三方订单', MyColors.c333333, 13),
  612. Row(
  613. children: [
  614. MyViews().myText('¥${newOrder.content.amount}',
  615. MyColors.cFF4233, 12),
  616. MyViews().myText('x1', MyColors.c999999, 12),
  617. ],
  618. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  619. )
  620. ],
  621. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  622. crossAxisAlignment: CrossAxisAlignment.start,
  623. ),
  624. ),
  625. ),
  626. ],
  627. ),
  628. ),
  629. Container(
  630. height: 0.5,
  631. color: MyColors.cE7E7E7,
  632. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  633. ),
  634. Container(
  635. margin: EdgeInsets.symmetric(horizontal: 12),
  636. child: Row(
  637. children: [
  638. MyViews().myText('卖家信息:', MyColors.c333333, 13),
  639. Row(
  640. children: [
  641. Container(
  642. margin: EdgeInsets.only(right: 5),
  643. child: ClipRRect(
  644. child: MyViews().netImg(
  645. imgURL(newOrder.content.sellerPic), 23, 23),
  646. borderRadius: BorderRadius.circular(11.5),
  647. ),
  648. ),
  649. MyViews().myText(
  650. '${newOrder.content.sellerName}(${newOrder.content.sellerUID})',
  651. MyColors.c333333,
  652. 13),
  653. ],
  654. )
  655. ],
  656. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  657. ),
  658. ),
  659. Container(
  660. height: 0.5,
  661. color: MyColors.cE7E7E7,
  662. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  663. ),
  664. Container(
  665. margin: EdgeInsets.symmetric(horizontal: 12),
  666. child: Row(
  667. children: [
  668. MyViews().myText('买家信息:', MyColors.c333333, 13),
  669. Row(
  670. children: [
  671. Container(
  672. margin: EdgeInsets.only(right: 5),
  673. child: ClipRRect(
  674. child: MyViews().netImg('path', 23, 23),
  675. borderRadius: BorderRadius.circular(11.5),
  676. ),
  677. ),
  678. MyViews().myText('${newOrder.content.buyerName}',
  679. MyColors.c333333, 13),
  680. ],
  681. )
  682. ],
  683. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  684. ),
  685. ),
  686. Container(
  687. height: 0.5,
  688. color: MyColors.cE7E7E7,
  689. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  690. ),
  691. Container(
  692. margin: EdgeInsets.symmetric(horizontal: 12),
  693. child: Row(
  694. children: [
  695. MyViews().myText('下单时间:', MyColors.c333333, 13),
  696. MyViews().myText(
  697. '${newOrder.content.createTime}', MyColors.c333333, 13)
  698. ],
  699. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  700. ),
  701. ),
  702. Container(
  703. height: 0.5,
  704. color: MyColors.cE7E7E7,
  705. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  706. ),
  707. Container(
  708. margin: EdgeInsets.symmetric(horizontal: 20),
  709. child: Row(
  710. children: [
  711. Expanded(
  712. child: GestureDetector(
  713. onTap: () {
  714. EasyLoading.dismiss();
  715. },
  716. behavior: HitTestBehavior.translucent,
  717. child: Container(
  718. decoration: BoxDecoration(
  719. borderRadius: BorderRadius.only(
  720. topLeft: Radius.circular(20),
  721. bottomLeft: Radius.circular(20),
  722. ),
  723. border: Border.all(
  724. color: MyColors.cFF4233, width: 1)),
  725. height: 40,
  726. child: MyViews().myText('与我无瓜', MyColors.cFF4233, 14),
  727. alignment: Alignment.center),
  728. ),
  729. ),
  730. Expanded(
  731. child: GestureDetector(
  732. onTap: () {
  733. if (newOrder.content.buyerName
  734. .contains(MyCookie().getName()) ||
  735. MyCookie()
  736. .getName()
  737. .contains(newOrder.content.buyerName)) {
  738. EasyLoading.dismiss();
  739. payTheOrder();
  740. // showDialog(
  741. // context: buildContext,
  742. // builder: (BuildContext context) {
  743. // return Center(
  744. // child: Container(
  745. // decoration: BoxDecoration(
  746. // color: Colors.white,
  747. // borderRadius:
  748. // BorderRadius.all(Radius.circular(8))),
  749. // child: Column(
  750. // children: [
  751. // Expanded(
  752. // child: Center(
  753. // child: Padding(
  754. // padding: const EdgeInsets.only(
  755. // left: 15, right: 15),
  756. // child: Column(
  757. // children: [
  758. // Text(
  759. // '确认支付订单(${newOrder.content.uID})',
  760. // style: TextStyle(
  761. // color: MyColors.c333333,
  762. // fontSize: 16,
  763. // fontWeight:
  764. // FontWeight.normal,
  765. // decoration:
  766. // TextDecoration.none),
  767. // ),
  768. // Text(
  769. // '付款人:${newOrder.content.buyerName}',
  770. // style: TextStyle(
  771. // color: MyColors.c333333,
  772. // fontSize: 16,
  773. // fontWeight:
  774. // FontWeight.normal,
  775. // decoration:
  776. // TextDecoration.none),
  777. // ),
  778. // Text(
  779. // '收款人:${newOrder.content.sellerName}',
  780. // style: TextStyle(
  781. // color: MyColors.c333333,
  782. // fontSize: 16,
  783. // fontWeight:
  784. // FontWeight.normal,
  785. // decoration:
  786. // TextDecoration.none),
  787. // ),
  788. // ],
  789. // mainAxisAlignment:
  790. // MainAxisAlignment.center,
  791. // ),
  792. // ),
  793. // ),
  794. // ),
  795. // Container(
  796. // height: 0.5,
  797. // color: MyColors.cE7E7E7,
  798. // ),
  799. // Row(
  800. // children: [
  801. // Expanded(
  802. // child: GestureDetector(
  803. // onTap: () {
  804. // Navigator.pop(context);
  805. // },
  806. // behavior:
  807. // HitTestBehavior.translucent,
  808. // child: Container(
  809. // alignment: Alignment.center,
  810. // height: 55,
  811. // child: Text(
  812. // '取消',
  813. // style: TextStyle(
  814. // color: MyColors.c999999,
  815. // fontSize: 16,
  816. // fontWeight:
  817. // FontWeight.normal,
  818. // decoration:
  819. // TextDecoration.none),
  820. // ),
  821. // ),
  822. // )),
  823. // Container(
  824. // width: 0.5,
  825. // height: 55,
  826. // color: MyColors.cE7E7E7,
  827. // ),
  828. // Expanded(
  829. // child: GestureDetector(
  830. // onTap: () async {
  831. // Navigator.pop(context);
  832. // payTheOrder(context);
  833. // },
  834. // behavior:
  835. // HitTestBehavior.translucent,
  836. // child: Container(
  837. // alignment: Alignment.center,
  838. // height: 55,
  839. // child: Text(
  840. // '确定',
  841. // style: TextStyle(
  842. // color: MyColors.cFF4233,
  843. // fontSize: 16,
  844. // fontWeight:
  845. // FontWeight.normal,
  846. // decoration:
  847. // TextDecoration.none),
  848. // ),
  849. // ),
  850. // ),
  851. // ),
  852. // ],
  853. // )
  854. // ],
  855. // ),
  856. // height: 200,
  857. // margin: EdgeInsets.only(left: 48, right: 48),
  858. // ),
  859. // );
  860. // },
  861. // );
  862. } else {
  863. showToast('该订单与你无关');
  864. }
  865. },
  866. behavior: HitTestBehavior.translucent,
  867. child: Container(
  868. decoration: BoxDecoration(
  869. borderRadius: BorderRadius.only(
  870. topRight: Radius.circular(20),
  871. bottomRight: Radius.circular(20),
  872. ),
  873. color: MyColors.cFF4233),
  874. height: 40,
  875. child: MyViews().myText('立即支付', Colors.white, 14),
  876. alignment: Alignment.center),
  877. ),
  878. )
  879. ],
  880. ),
  881. )
  882. ],
  883. ),
  884. ),
  885. );
  886. }
  887. void payTheOrder() {
  888. //获取店铺信息
  889. MyDio().query({
  890. "key": "shop_user",
  891. "filters": {
  892. "conditions": ["shop_uid==${newOrder.content.shopUID}"]
  893. },
  894. "dims": shopUserDims,
  895. "paging": [1, 1],
  896. "order_by": ["shop_name,DESC"]
  897. }, (response, hasError) {
  898. if (!hasError) {
  899. MyShopBeanEntity entity =
  900. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  901. navigatorKey.currentState.push(MaterialPageRoute(
  902. builder: (context) =>
  903. GangInPage(entity.data.data[0], newOrder.content)));
  904. }
  905. }, (error) {});
  906. // getUserWalletBalance((re, hE) {
  907. // if (!hE) {
  908. // UserBalanceEntity balance =
  909. // UserBalanceEntity().fromJson(json.decode(re.data.toString()));
  910. // if (balance.data >= newOrder.content.amount) {
  911. // payOrder(payWayWallet, newOrder.content.uID, (re, hE) {
  912. // if (!hE) {
  913. // showToast('支付成功');
  914. // EventBus().emit('payAnOrder');
  915. // }
  916. // }, (e) {}, context);
  917. // } else {
  918. // payOrder(payWayAliPay, newOrder.content.uID, (re, hE) {
  919. // if (!hE) {
  920. // PayByAlipayBeanEntity entity = PayByAlipayBeanEntity()
  921. // .fromJson(json.decode(re.data.toString()));
  922. // EventBus().on('alipayPaymentCallback', (arg) {
  923. // EventBus().off('alipayPaymentCallback');
  924. // EasyLoading.dismiss();
  925. // showToast('支付成功');
  926. // EventBus().emit('reNoPayOrder');
  927. // });
  928. // print(entity.data);
  929. // EasyLoading.instance
  930. // ..contentPadding =
  931. // EdgeInsets.symmetric(horizontal: 20, vertical: 12)
  932. // ..alignment = Alignment.center
  933. // ..contentMargin = EdgeInsets.all(20);
  934. // EasyLoading.show();
  935. // aliPay(entity.data).then((value) {
  936. // print(json.encode(value));
  937. // AlipayResultBeanEntity e = AlipayResultBeanEntity()
  938. // .fromJson(json.decode(json.encode(value)));
  939. // try {
  940. // int r = int.parse(e.resultStatus);
  941. // if (r == 9000) {
  942. // showToast('支付成功');
  943. // } else {
  944. // showToast(aliPayResultStatus(r));
  945. // resetOrder(newOrder.content.uID, context);
  946. // }
  947. // } catch (e) {
  948. // EasyLoading.dismiss();
  949. // }
  950. // });
  951. // // EventBus().emit('payAnOrder');
  952. // }
  953. // }, (e) {}, context);
  954. // // showToast('积分余额不足');
  955. // }
  956. // }
  957. // }, (e) {}, context);
  958. }
  959. void showSystemMessages(SystemInformationBeanEntity arg) {
  960. EasyLoading.instance
  961. ..contentPadding = EdgeInsets.symmetric(horizontal: 12, vertical: 12)
  962. ..alignment = Alignment.center
  963. ..loadingStyle = EasyLoadingStyle.custom
  964. ..backgroundColor = Colors.transparent
  965. ..indicatorColor = Colors.black
  966. ..progressColor = Colors.black
  967. ..maskColor = Colors.black
  968. ..textColor = Colors.black
  969. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  970. EasyLoading.show(
  971. indicator: Material(
  972. color: Colors.transparent,
  973. child: Container(
  974. decoration: BoxDecoration(
  975. borderRadius: BorderRadius.circular(16),
  976. ),
  977. height: MediaQuery.of(buildContext).size.height - 200,
  978. padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
  979. child: Column(
  980. children: [
  981. Expanded(child: Container()),
  982. Container(
  983. decoration: BoxDecoration(
  984. color: Colors.white,
  985. borderRadius: BorderRadius.circular(16),
  986. ),
  987. child: Column(
  988. children: [
  989. Container(
  990. child: Text(
  991. '系统消息',
  992. style: TextStyle(
  993. color: MyColors.c333333,
  994. fontSize: 14,
  995. fontWeight: FontWeight.bold),
  996. ),
  997. margin:
  998. EdgeInsets.symmetric(horizontal: 26, vertical: 15),
  999. ),
  1000. Container(
  1001. child: Text(
  1002. arg.content,
  1003. style: TextStyle(color: MyColors.c333333, fontSize: 14),
  1004. ),
  1005. margin: EdgeInsets.symmetric(horizontal: 26),
  1006. alignment: Alignment.centerLeft,
  1007. ),
  1008. Container(
  1009. height: 0.5,
  1010. color: MyColors.cE7E7E7,
  1011. margin: EdgeInsets.only(bottom: 12, top: 12),
  1012. ),
  1013. GestureDetector(
  1014. onTap: () {
  1015. EasyLoading.dismiss();
  1016. },
  1017. behavior: HitTestBehavior.translucent,
  1018. child: Container(
  1019. width: 150,
  1020. margin: EdgeInsets.only(bottom: 14),
  1021. decoration: BoxDecoration(
  1022. borderRadius: BorderRadius.circular(20),
  1023. border:
  1024. Border.all(color: MyColors.cFF4233, width: 1.1),
  1025. color: Colors.white),
  1026. child: MyViews().myText('我知道了', MyColors.cFF4233, 14),
  1027. height: 40,
  1028. alignment: Alignment.center,
  1029. ),
  1030. )
  1031. ],
  1032. ),
  1033. ),
  1034. Expanded(child: Container()),
  1035. ],
  1036. ),
  1037. alignment: Alignment.center,
  1038. ),
  1039. ),
  1040. );
  1041. }
  1042. }
  1043. class FallbackCupertinoLocalisationsDelegate
  1044. extends LocalizationsDelegate<CupertinoLocalizations> {
  1045. const FallbackCupertinoLocalisationsDelegate();
  1046. @override
  1047. bool isSupported(Locale locale) => true;
  1048. @override
  1049. Future<CupertinoLocalizations> load(Locale locale) =>
  1050. DefaultCupertinoLocalizations.load(locale);
  1051. @override
  1052. bool shouldReload(FallbackCupertinoLocalisationsDelegate old) => false;
  1053. }