main.dart 41 KB

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