main.dart 42 KB

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