main.dart 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372
  1. import 'dart:async';
  2. import 'dart:convert';
  3. import 'dart:io';
  4. import 'package:amap_flutter_location/amap_flutter_location.dart';
  5. import 'package:bbyyy/beans/access_bean_entity.dart';
  6. import 'package:bbyyy/beans/template_bean_entity.dart';
  7. import 'package:bbyyy/beans/w_x_bean_entity.dart';
  8. import 'package:bbyyy/https/url.dart';
  9. import 'package:bbyyy/my_tools/event_bus.dart';
  10. import 'package:bbyyy/my_tools/loacion_util.dart';
  11. import 'package:bbyyy/my_tools/my_cookie.dart';
  12. import 'package:bbyyy/my_tools/my_tools.dart';
  13. import 'package:bbyyy/my_tools/order_processing/order_processing.dart';
  14. import 'package:bbyyy/my_tools/providers.dart';
  15. import 'package:bbyyy/paegs/login_page/login_page.dart';
  16. import 'package:bbyyy/paegs/pay_page/order_information_page.dart';
  17. import 'package:bbyyy/paegs/root_page/root_page.dart';
  18. import 'package:bbyyy/paegs/root_page/root_page_view.dart';
  19. import 'package:bbyyy/paegs/welcome_page/welcome_page.dart';
  20. import 'package:dio/dio.dart';
  21. import 'package:flustars/flustars.dart';
  22. import 'package:flutter/cupertino.dart';
  23. import 'package:flutter/material.dart';
  24. import 'package:flutter/services.dart';
  25. import 'package:flutter_local_notifications/flutter_local_notifications.dart';
  26. import 'package:flutter_localizations/flutter_localizations.dart';
  27. import 'package:flutter_svg/flutter_svg.dart';
  28. import 'package:fluwx/fluwx.dart';
  29. import 'package:provider/provider.dart';
  30. import 'package:pull_to_refresh/pull_to_refresh.dart';
  31. import 'package:rxdart/rxdart.dart';
  32. import 'beans/app_store_review_bean_entity.dart';
  33. import 'beans/coupon_bean_entity.dart';
  34. import 'beans/my_shop_bean_entity.dart';
  35. import 'beans/new_order_bean_entity.dart';
  36. import 'beans/smart_order_bean_entity.dart';
  37. import 'beans/system_information_bean_entity.dart';
  38. import 'https/MyDio.dart';
  39. import 'https/my_request.dart';
  40. import 'my_tools/const.dart';
  41. import 'my_tools/daily_red_packet/daily_red_packet.dart';
  42. import 'my_tools/dims.dart';
  43. import 'my_tools/easy_loading/easy_loading.dart';
  44. import 'my_tools/easy_loading/loading.dart';
  45. import 'my_tools/global.dart';
  46. import 'my_tools/my_colors.dart';
  47. import 'my_tools/my_views.dart';
  48. import 'my_tools/order.dart';
  49. import 'my_tools/pop_up_queue.dart';
  50. final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
  51. FlutterLocalNotificationsPlugin();
  52. final BehaviorSubject<ReceivedNotification> didReceiveLocalNotificationSubject =
  53. BehaviorSubject<ReceivedNotification>();
  54. final BehaviorSubject<String> selectNotificationSubject =
  55. BehaviorSubject<String>();
  56. class ReceivedNotification {
  57. ReceivedNotification({
  58. @required this.id,
  59. @required this.title,
  60. @required this.body,
  61. @required this.payload,
  62. });
  63. final int id;
  64. final String title;
  65. final String body;
  66. final String payload;
  67. }
  68. Future<void> main() async {
  69. AMapFlutterLocation.setApiKey(
  70. "156e225e52517b76ac2222f035a9ce3e", "548414a843a2ec9c383e34341b8c84df");
  71. WidgetsFlutterBinding.ensureInitialized();
  72. const AndroidInitializationSettings initializationSettingsAndroid =
  73. AndroidInitializationSettings('@mipmap/app_logo');
  74. /// Note: permissions aren't requested here just to demonstrate that can be
  75. /// done later
  76. final IOSInitializationSettings initializationSettingsIOS =
  77. IOSInitializationSettings(
  78. requestAlertPermission: true,
  79. requestBadgePermission: true,
  80. requestSoundPermission: true,
  81. onDidReceiveLocalNotification:
  82. (int id, String title, String body, String payload) async {
  83. didReceiveLocalNotificationSubject.add(ReceivedNotification(
  84. id: id, title: title, body: body, payload: payload));
  85. });
  86. const MacOSInitializationSettings initializationSettingsMacOS =
  87. MacOSInitializationSettings(
  88. requestAlertPermission: true,
  89. requestBadgePermission: true,
  90. requestSoundPermission: true);
  91. final InitializationSettings initializationSettings = InitializationSettings(
  92. android: initializationSettingsAndroid,
  93. iOS: initializationSettingsIOS,
  94. macOS: initializationSettingsMacOS);
  95. await flutterLocalNotificationsPlugin.initialize(initializationSettings,
  96. onSelectNotification: (String payload) async {
  97. if (payload != null) {
  98. if (payload == notifyTypeNewMsg) {
  99. RootPageView().bNIndex = 2;
  100. EventBus().emit('ChangePage');
  101. }
  102. debugPrint('notification payload: $payload');
  103. }
  104. selectNotificationSubject.add(payload);
  105. });
  106. runApp(
  107. MultiProvider(
  108. providers: [
  109. ChangeNotifierProvider(create: (_) => MyLocationProvider()),
  110. ],
  111. child: MyApp(),
  112. ),
  113. );
  114. }
  115. class MyApp extends StatelessWidget with WidgetsBindingObserver {
  116. BuildContext buildContext;
  117. StateSetter ss;
  118. List<MyShopBeanDataData> shops = [];
  119. int shopIndex = 0;
  120. String clipboardT;
  121. int amountCompleted = 0;
  122. NewOrderBeanEntity newOrder;
  123. @override
  124. StatelessElement createElement() {
  125. // TODO: implement createElement
  126. WidgetsBinding.instance.addObserver(this);
  127. MyCookie().initP();
  128. _initFluwx();
  129. EventBus().on('hasNewOrder', (arg) {
  130. newOrder = arg;
  131. displayPendingOrders();
  132. });
  133. EventBus().on('systemInformation', (arg) {
  134. if (arg is SystemInformationBeanEntity) {
  135. showSystemMessages(arg);
  136. }
  137. });
  138. EventBus().on('检查粘贴板', (arg) {
  139. Timer(Duration(seconds: 1), () {
  140. getClipboardData();
  141. checkUnpaidThirdPartyOrders();
  142. });
  143. });
  144. EventBus().on('hasCoupon', (arg) {
  145. if (arg is CouponBeanDataData) {
  146. couponBulletBox(arg);
  147. }
  148. });
  149. EventBus().on('packageInfo', (arg) {
  150. isItUnderReview();
  151. });
  152. return super.createElement();
  153. }
  154. @override
  155. Widget build(BuildContext context) {
  156. SystemChrome.setPreferredOrientations([
  157. DeviceOrientation.portraitUp, //只能纵向
  158. DeviceOrientation.portraitDown, //只能纵向
  159. ]);
  160. return RefreshConfiguration(
  161. child: MaterialApp(
  162. // debugShowMaterialGrid: true,
  163. navigatorKey: navigatorKey,
  164. theme: ThemeData(fontFamily: 'PingFang'),
  165. debugShowCheckedModeBanner: false,
  166. home: WelcomePage(),
  167. routes: {
  168. '/loginPage': (context) => LoginPage(),
  169. '/rootPage': (context) => RootPage(),
  170. },
  171. supportedLocales: [const Locale('zh', 'CH')],
  172. localizationsDelegates: [
  173. RefreshLocalizations.delegate,
  174. GlobalMaterialLocalizations.delegate,
  175. GlobalWidgetsLocalizations.delegate,
  176. const FallbackCupertinoLocalisationsDelegate(),
  177. ],
  178. builder: (BuildContext context, Widget child) {
  179. buildContext = context;
  180. return MediaQuery(
  181. data: MediaQuery.of(context)
  182. .copyWith(textScaleFactor: 1.0), //设置字体不随系统字体大小改变
  183. child: FlutterEasyLoading(
  184. child: child,
  185. ),
  186. );
  187. },
  188. ),
  189. hideFooterWhenNotFull: true,
  190. footerBuilder: () {
  191. return ClassicFooter(
  192. loadStyle: LoadStyle.ShowWhenLoading,
  193. );
  194. },
  195. );
  196. }
  197. @override
  198. void didChangeAppLifecycleState(AppLifecycleState state) {
  199. super.didChangeAppLifecycleState(state);
  200. if (state == AppLifecycleState.paused) {
  201. print('went to Background');
  202. }
  203. if (state == AppLifecycleState.resumed) {
  204. print('came back to Foreground');
  205. if (MyCookie().loginInformation != null) {
  206. Timer(Duration(seconds: 1), () {
  207. getClipboardData();
  208. });
  209. }
  210. checkUnpaidThirdPartyOrders();
  211. }
  212. }
  213. //获取剪切板文字
  214. Future<void> getClipboardData() async {
  215. PopUpQueue().onShow = true;
  216. ClipboardData text = await Clipboard.getData(Clipboard.kTextPlain);
  217. try {
  218. print('Clipboard-----\n${text.text}');
  219. clipboardT = text.text;
  220. // Clipboard.setData(ClipboardData(text: ''));
  221. OrderProcessing().queryOrderTemplate(clipboardT, buildContext);
  222. // getOnlineTemplate();
  223. } catch (e) {
  224. PopUpQueue().onShow = false;
  225. PopUpQueue().showNext();
  226. }
  227. }
  228. //获取线上模板
  229. void getOnlineTemplate() {
  230. MyDio().query(
  231. {'key': 'order_template', "dims": orderTemplateDims, "filters": {}},
  232. (response, hasError) {
  233. if (!hasError) {
  234. TemplateBeanEntity entity = TemplateBeanEntity()
  235. .fromJson(json.decode(response.data.toString()));
  236. checkOrder(entity.data);
  237. } else {
  238. PopUpQueue().onShow = false;
  239. PopUpQueue().showNext();
  240. }
  241. }, (error) {
  242. PopUpQueue().onShow = false;
  243. PopUpQueue().showNext();
  244. });
  245. }
  246. var orderHash;
  247. //最大金额赢家数量 0---发送订单的人不是最大赢家 1---发订单的人是最大赢家 2---发订单的人是最大赢家且有两个一样的金额
  248. int commissionPayerNum = -1;
  249. //匹配模板去除不是自己的订单
  250. void checkOrder(List<TemplateBeanData> data) {
  251. commissionPayerNum = -1;
  252. bool hasMatch = false;
  253. w:
  254. for (int i = 0; i < data.length; i++) {
  255. try {
  256. var res = parseString2(
  257. data[i].template.replaceAll('\r', ''), '''$clipboardT''');
  258. if (res != null) {
  259. print('-----------data[i].template-----------');
  260. print(data[i].template);
  261. print('json.encode(res) =============\n${json.encode(res)}');
  262. var order = parse2(res);
  263. print('order.toString()=============\n${order.toString()}');
  264. var maxAmount = 0.0;
  265. int maxAmountNum = 0;
  266. List<String> maxAmountOwner = [];
  267. res.forEach((key, value) {
  268. if (key.contains('amount')) {
  269. try {
  270. if (double.parse(value) > maxAmount) {
  271. maxAmount = double.parse(value);
  272. maxAmountNum = 1;
  273. maxAmountOwner.clear();
  274. maxAmountOwner.add(res[key.replaceAll('amount', 'person')]);
  275. } else if (double.parse(value) == maxAmount) {
  276. maxAmountNum++;
  277. maxAmountOwner.add(res[key.replaceAll('amount', 'person')]);
  278. }
  279. } catch (e) {}
  280. }
  281. });
  282. if (maxAmountOwner.isNotEmpty) {
  283. maxAmountOwner.forEach((element) {
  284. if (MyCookie().getName().contains(element) ||
  285. element.contains(MyCookie().getName())) {
  286. commissionPayerNum = maxAmountNum;
  287. }
  288. });
  289. }
  290. print('maxAmount============\n$maxAmount\n==============');
  291. print('maxAmountNum==============\n$maxAmountNum\n==============');
  292. print(
  293. 'maxAmountOwner==============\n${maxAmountOwner.toString()}\n==============');
  294. print(
  295. 'commissionPayerNum================ \n$commissionPayerNum\n==============');
  296. order.removeWhere((element) =>
  297. !element.seller.name
  298. .contains(MyCookie().loginInformation.data.extra.name) &&
  299. !MyCookie()
  300. .loginInformation
  301. .data
  302. .extra
  303. .name
  304. .contains(element.seller.name));
  305. if (order.length > 0) {
  306. hasMatch = true;
  307. orderHash = computeOrderHash(res);
  308. getShop(order);
  309. }
  310. break w;
  311. }
  312. } catch (e) {}
  313. }
  314. if (!hasMatch) {
  315. PopUpQueue().onShow = false;
  316. PopUpQueue().showNext();
  317. }
  318. }
  319. //订单视图
  320. items(List<OrderInfo2> order) {
  321. List<Widget> items = [];
  322. order.forEach((element) {
  323. items.add(Container(
  324. child: Column(
  325. children: [
  326. Row(
  327. children: [
  328. Container(
  329. margin: EdgeInsets.only(left: 8, right: 7),
  330. child: ClipRRect(
  331. child: MyViews().netImg(
  332. imgURL(MyCookie().loginInformation.data.extra.picture),
  333. 35,
  334. 35),
  335. borderRadius: BorderRadius.circular(17.5),
  336. ),
  337. ),
  338. Expanded(
  339. child: Container(
  340. height: 35,
  341. child: Column(
  342. children: [
  343. Text(
  344. '付款人:${element.payer.name}',
  345. style: TextStyle(
  346. color: MyColors.c333333,
  347. fontSize: 13,
  348. decoration: TextDecoration.none,
  349. ),
  350. ),
  351. Text(
  352. '订单时间:${element.time}',
  353. style: TextStyle(
  354. color: MyColors.c666666,
  355. fontSize: 10,
  356. decoration: TextDecoration.none,
  357. ),
  358. ),
  359. ],
  360. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  361. crossAxisAlignment: CrossAxisAlignment.start,
  362. ),
  363. ),
  364. ),
  365. Container(
  366. margin: EdgeInsets.only(right: 10),
  367. child: Text(
  368. '¥${(element.payer.amount * element.factor).toStringAsFixed(2)}',
  369. style: TextStyle(
  370. color: MyColors.cFF4233,
  371. fontSize: 14,
  372. decoration: TextDecoration.none,
  373. ),
  374. ),
  375. ),
  376. ],
  377. crossAxisAlignment: CrossAxisAlignment.center,
  378. ),
  379. Container(
  380. height: 0.5,
  381. margin: EdgeInsets.only(right: 10, left: 50, top: 5),
  382. color: MyColors.cE7E7E7,
  383. )
  384. ],
  385. ),
  386. margin: EdgeInsets.only(top: 5),
  387. ));
  388. });
  389. return items;
  390. }
  391. bool saving = false;
  392. //获取用户所在店铺
  393. void getShop(List<OrderInfo2> order) {
  394. shopIndex = 0;
  395. MyDio().query({
  396. "key": "shop_user",
  397. "filters": {
  398. "or": true,
  399. "conditions": [
  400. "role!=0",
  401. "user_uid==${MyCookie().getUID()}",
  402. "review_state==1"
  403. ],
  404. "filters": [
  405. {
  406. "conditions": ["role==0", "user_uid==${MyCookie().getUID()}"]
  407. }
  408. ]
  409. },
  410. "dims": shopUserDims,
  411. "paging": [1, 20000]
  412. }, (response, hasError) {
  413. if (!hasError) {
  414. MyShopBeanEntity entity =
  415. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  416. shops = entity.data.data;
  417. shops.removeWhere((element) => !element.privateShop);
  418. if (shops.length == 0) {
  419. showToast('你还没有添加任何货帮,暂时不能发送智能订单');
  420. PopUpQueue().onShow = false;
  421. PopUpQueue().showNext();
  422. } else {
  423. EasyLoading.instance
  424. ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
  425. ..alignment = Alignment.bottomCenter
  426. ..loadingStyle = EasyLoadingStyle.light
  427. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  428. EasyLoading.show(
  429. indicator: Material(
  430. color: Colors.white,
  431. child: StatefulBuilder(
  432. builder: (c, s) {
  433. ss = s;
  434. return Column(
  435. children: [
  436. Container(
  437. child: Stack(
  438. children: [
  439. Container(
  440. child: MyViews()
  441. .myText('智能订单', MyColors.c333333, 14),
  442. alignment: Alignment.center,
  443. height: 22,
  444. ),
  445. Positioned(
  446. right: 0,
  447. child: GestureDetector(
  448. onTap: () {
  449. PopUpQueue().onShow = false;
  450. PopUpQueue().showNext();
  451. },
  452. behavior: HitTestBehavior.translucent,
  453. child: Container(
  454. child: Icon(
  455. Icons.close,
  456. size: 20,
  457. color: Colors.white,
  458. ),
  459. decoration: BoxDecoration(
  460. color: MyColors.cB6B6B6,
  461. borderRadius: BorderRadius.circular(11)),
  462. height: 22,
  463. width: 22,
  464. ),
  465. ),
  466. )
  467. ],
  468. alignment: Alignment.center,
  469. ),
  470. height: 30,
  471. padding: EdgeInsets.symmetric(horizontal: 12),
  472. ),
  473. Container(
  474. height: 5,
  475. color: MyColors.cF7F7F7,
  476. margin: EdgeInsets.only(top: 10),
  477. ),
  478. Column(
  479. children: items(order),
  480. ),
  481. Container(
  482. height: 5,
  483. color: MyColors.cF7F7F7,
  484. margin: EdgeInsets.only(top: 10),
  485. ),
  486. Visibility(
  487. child: Column(
  488. children: [
  489. Container(
  490. child: MyViews()
  491. .myText('货帮选择', MyColors.c333333, 13),
  492. margin: EdgeInsets.only(left: 7, top: 11),
  493. ),
  494. Container(
  495. margin: EdgeInsets.symmetric(
  496. horizontal: 7, vertical: 10),
  497. height: (shops.length * 1.0 / 2).ceil() *
  498. (double.parse(
  499. '${MediaQuery.of(buildContext).size.width - 74}') /
  500. 2 /
  501. 3.8 +
  502. 10) -
  503. 10,
  504. child: GridView(
  505. gridDelegate:
  506. SliverGridDelegateWithFixedCrossAxisCount(
  507. crossAxisCount: 2, //横轴三个子widget
  508. childAspectRatio: 3.8,
  509. crossAxisSpacing: 10,
  510. mainAxisSpacing: 8 //宽高比为1时,子widget
  511. ),
  512. children: shop(shops),
  513. padding: EdgeInsets.all(0),
  514. ),
  515. ),
  516. ],
  517. crossAxisAlignment: CrossAxisAlignment.start,
  518. ),
  519. visible: shops.length != 1,
  520. ),
  521. Container(
  522. height: 0.5,
  523. color: MyColors.cF7F7F7,
  524. margin: EdgeInsets.only(bottom: 10),
  525. ),
  526. Container(
  527. child: GestureDetector(
  528. onTap: () {
  529. if (saving) {
  530. return;
  531. } else {
  532. saving = true;
  533. EventBus().on('saveOrder', (arg) {
  534. amountCompleted++;
  535. if (amountCompleted == order.length) {
  536. amountCompleted = 0;
  537. EasyLoading.dismiss();
  538. showToast('发送成功');
  539. clipboardT = '';
  540. saving = false;
  541. EventBus().off('saveOrder');
  542. PopUpQueue().onShow = false;
  543. PopUpQueue().showNext();
  544. }
  545. });
  546. order.forEach((element) {
  547. sendOrder(element);
  548. });
  549. }
  550. },
  551. behavior: HitTestBehavior.translucent,
  552. child: Container(
  553. decoration: BoxDecoration(
  554. color: MyColors.cFF4233,
  555. borderRadius: BorderRadius.circular(20),
  556. ),
  557. height: 40,
  558. width: 150,
  559. child: MyViews().myText('发送订单', Colors.white, 14),
  560. alignment: Alignment.center,
  561. ),
  562. ),
  563. alignment: Alignment.center,
  564. )
  565. ],
  566. mainAxisAlignment: MainAxisAlignment.start,
  567. crossAxisAlignment: CrossAxisAlignment.start,
  568. );
  569. },
  570. ),
  571. ),
  572. );
  573. }
  574. } else {
  575. PopUpQueue().onShow = false;
  576. PopUpQueue().showNext();
  577. }
  578. }, (error) {
  579. PopUpQueue().onShow = false;
  580. PopUpQueue().showNext();
  581. });
  582. }
  583. //店铺视图
  584. shop(List<MyShopBeanDataData> shops) {
  585. List<Widget> items = [];
  586. for (int i = 0; i < shops.length; i++) {
  587. items.add(GestureDetector(
  588. onTap: () {
  589. shopIndex = i;
  590. ss(() {});
  591. },
  592. behavior: HitTestBehavior.translucent,
  593. child: Container(
  594. child: Row(
  595. children: [
  596. Container(
  597. margin: EdgeInsets.only(right: 5),
  598. child: ClipRRect(
  599. child: MyViews().netImg(imgURL(shops[i].shopPic), 30, 30),
  600. borderRadius: BorderRadius.circular(15),
  601. ),
  602. ),
  603. Expanded(
  604. child: Column(
  605. children: [
  606. Text(
  607. shops[i].shopName,
  608. style: TextStyle(
  609. color: i == shopIndex
  610. ? MyColors.cFF4233
  611. : MyColors.c666666,
  612. fontSize: 12,
  613. ),
  614. maxLines: 1,
  615. overflow: TextOverflow.ellipsis,
  616. softWrap: true,
  617. ),
  618. Text(
  619. 'ID:${shops[i].shopUid}',
  620. style: TextStyle(
  621. color: i == shopIndex
  622. ? MyColors.cFF4233
  623. : MyColors.c666666,
  624. fontSize: 10,
  625. ),
  626. maxLines: 1,
  627. overflow: TextOverflow.ellipsis,
  628. softWrap: true,
  629. ),
  630. ],
  631. crossAxisAlignment: CrossAxisAlignment.start,
  632. ),
  633. ),
  634. ],
  635. ),
  636. decoration: BoxDecoration(
  637. color: i == shopIndex ? MyColors.cFFECEB : MyColors.cEDEDED,
  638. borderRadius: BorderRadius.circular(4),
  639. ),
  640. constraints: BoxConstraints(maxWidth: 150),
  641. padding: EdgeInsets.symmetric(horizontal: 6, vertical: 6),
  642. ),
  643. ));
  644. }
  645. return items;
  646. }
  647. //发送订单
  648. void sendOrder(OrderInfo2 element) {
  649. MyDio().save({
  650. 'key': 'order',
  651. 'object': {
  652. 'uuid': orderHash,
  653. 'shop_uid': shops[shopIndex].shopUid,
  654. 'shop_pic': shops[shopIndex].shopPic,
  655. 'shop_name': shops[shopIndex].shopName,
  656. 'seller_pic': MyCookie().loginInformation.data.extra.picture,
  657. 'seller_uid': MyCookie().getUID(),
  658. 'seller_name': MyCookie().loginInformation.data.extra.name,
  659. 'buyer_name': element.payer.name,
  660. 'type': orderTypeThirdPlatform,
  661. 'amount': NumUtil.multiply(element.payer.amount, element.factor),
  662. 'commission_payer_num': commissionPayerNum
  663. }
  664. }, (response, hasError) {
  665. if (!hasError) {
  666. EventBus().emit('saveOrder');
  667. }
  668. }, (error) {});
  669. }
  670. //待支付订单视图
  671. void displayPendingOrders() {
  672. EasyLoading.instance
  673. ..contentPadding = EdgeInsets.symmetric(horizontal: 0, vertical: 12)
  674. ..alignment = Alignment.bottomCenter
  675. ..loadingStyle = EasyLoadingStyle.light
  676. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  677. EasyLoading.show(
  678. indicator: Material(
  679. color: Colors.white,
  680. child: Column(
  681. children: [
  682. Container(
  683. padding: EdgeInsets.symmetric(horizontal: 12),
  684. child: Row(
  685. children: [
  686. Container(
  687. margin: EdgeInsets.only(right: 7),
  688. child: ClipRRect(
  689. child: MyViews()
  690. .netImg(imgURL(newOrder.content.shopPic), 25, 25),
  691. borderRadius: BorderRadius.circular(12.5),
  692. ),
  693. ),
  694. MyViews().myText(
  695. '${newOrder.content.shopName}(${newOrder.content.shopUID})',
  696. MyColors.c333333,
  697. 14),
  698. ],
  699. ),
  700. ),
  701. Container(
  702. margin: EdgeInsets.only(top: 11, left: 12, right: 12, bottom: 11),
  703. height: 0.5,
  704. color: MyColors.cE7E7E7,
  705. ),
  706. Container(
  707. margin: EdgeInsets.symmetric(horizontal: 12),
  708. child: Row(
  709. children: [
  710. Container(
  711. child: SvgPicture.asset(
  712. newOrder.content.buyerPic == null
  713. ? 'images/svg/第三方.svg'
  714. : 'images/svg/线下付款.svg',
  715. height: 27,
  716. width: 27,
  717. ),
  718. margin: EdgeInsets.only(right: 8),
  719. height: 45,
  720. width: 45,
  721. decoration: BoxDecoration(
  722. border: Border.all(color: MyColors.cEBEBEB, width: 1)),
  723. alignment: Alignment.center,
  724. ),
  725. Expanded(
  726. child: Container(
  727. height: 45,
  728. child: Column(
  729. children: [
  730. MyViews().myText(
  731. newOrder.content.buyerPic == null
  732. ? '第三方订单'
  733. : '线下付款',
  734. MyColors.c333333,
  735. 13),
  736. Row(
  737. children: [
  738. MyViews().myText('¥${newOrder.content.amount}',
  739. MyColors.cFF4233, 12),
  740. MyViews().myText('x1', MyColors.c999999, 12),
  741. ],
  742. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  743. )
  744. ],
  745. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  746. crossAxisAlignment: CrossAxisAlignment.start,
  747. ),
  748. ),
  749. ),
  750. ],
  751. ),
  752. ),
  753. Container(
  754. height: 0.5,
  755. color: MyColors.cE7E7E7,
  756. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  757. ),
  758. Container(
  759. margin: EdgeInsets.symmetric(horizontal: 12),
  760. child: Row(
  761. children: [
  762. MyViews().myText('卖家信息:', MyColors.c333333, 13),
  763. Row(
  764. children: [
  765. Container(
  766. margin: EdgeInsets.only(right: 5),
  767. child: ClipRRect(
  768. child: MyViews().netImg(
  769. imgURL(newOrder.content.sellerPic), 23, 23),
  770. borderRadius: BorderRadius.circular(11.5),
  771. ),
  772. ),
  773. MyViews().myText(
  774. '${newOrder.content.sellerName}(${hideUID(newOrder.content.sellerUID.toString())})',
  775. MyColors.c333333,
  776. 13),
  777. ],
  778. )
  779. ],
  780. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  781. ),
  782. ),
  783. Container(
  784. height: 0.5,
  785. color: MyColors.cE7E7E7,
  786. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  787. ),
  788. Container(
  789. margin: EdgeInsets.symmetric(horizontal: 12),
  790. child: Row(
  791. children: [
  792. MyViews().myText('买家信息:', MyColors.c333333, 13),
  793. Row(
  794. children: [
  795. Container(
  796. margin: EdgeInsets.only(right: 5),
  797. child: ClipRRect(
  798. child: MyViews().netImg(
  799. newOrder.content.buyerPic == null
  800. ? ''
  801. : imgURL(newOrder.content.buyerPic),
  802. 23,
  803. 23),
  804. borderRadius: BorderRadius.circular(11.5),
  805. ),
  806. ),
  807. MyViews().myText(
  808. '${newOrder.content.buyerName} ${newOrder.content.buyerUID != null && newOrder.content.buyerUID.toString().length > 0 ? '(${newOrder.content.buyerUID})' : ''}',
  809. MyColors.c333333,
  810. 13),
  811. ],
  812. )
  813. ],
  814. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  815. ),
  816. ),
  817. Container(
  818. height: 0.5,
  819. color: MyColors.cE7E7E7,
  820. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  821. ),
  822. Container(
  823. margin: EdgeInsets.symmetric(horizontal: 12),
  824. child: Row(
  825. children: [
  826. MyViews().myText('下单时间:', MyColors.c333333, 13),
  827. MyViews().myText(
  828. '${newOrder.content.createTime}', MyColors.c333333, 13)
  829. ],
  830. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  831. ),
  832. ),
  833. Container(
  834. height: 0.5,
  835. color: MyColors.cE7E7E7,
  836. margin: EdgeInsets.symmetric(horizontal: 12, vertical: 11),
  837. ),
  838. Container(
  839. margin: EdgeInsets.symmetric(horizontal: 20),
  840. child: Row(
  841. children: [
  842. Expanded(
  843. child: GestureDetector(
  844. onTap: () {
  845. PopUpQueue().onShow = false;
  846. PopUpQueue().showNext();
  847. },
  848. behavior: HitTestBehavior.translucent,
  849. child: Container(
  850. decoration: BoxDecoration(
  851. borderRadius: BorderRadius.only(
  852. topLeft: Radius.circular(20),
  853. bottomLeft: Radius.circular(20),
  854. ),
  855. border: Border.all(
  856. color: MyColors.cFF4233, width: 1)),
  857. height: 40,
  858. child: MyViews().myText('与我无瓜', MyColors.cFF4233, 14),
  859. alignment: Alignment.center),
  860. ),
  861. ),
  862. Expanded(
  863. child: GestureDetector(
  864. onTap: () {
  865. if (newOrder.content.buyerName
  866. .contains(MyCookie().getName()) ||
  867. MyCookie()
  868. .getName()
  869. .contains(newOrder.content.buyerName)) {
  870. EasyLoading.dismiss();
  871. payTheOrder();
  872. } else {
  873. showToast('该订单与你无关');
  874. PopUpQueue().onShow = false;
  875. PopUpQueue().showNext();
  876. }
  877. },
  878. behavior: HitTestBehavior.translucent,
  879. child: Container(
  880. decoration: BoxDecoration(
  881. borderRadius: BorderRadius.only(
  882. topRight: Radius.circular(20),
  883. bottomRight: Radius.circular(20),
  884. ),
  885. color: MyColors.cFF4233),
  886. height: 40,
  887. child: MyViews().myText('去支付', Colors.white, 14),
  888. alignment: Alignment.center),
  889. ),
  890. )
  891. ],
  892. ),
  893. )
  894. ],
  895. ),
  896. ),
  897. );
  898. }
  899. void payTheOrder() {
  900. //获取店铺信息
  901. MyDio().query({
  902. "key": "shop_user",
  903. "filters": {
  904. "conditions": ["shop_uid==${newOrder.content.shopUID}"]
  905. },
  906. "dims": shopUserDims,
  907. "paging": [1, 1],
  908. "order_by": ["shop_name,DESC"]
  909. }, (response, hasError) {
  910. if (!hasError) {
  911. MyShopBeanEntity entity =
  912. MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
  913. SmartOrderBeanDataData data = SmartOrderBeanDataData();
  914. data.sellerUid = newOrder.content.sellerUID;
  915. data.sellerName = newOrder.content.sellerName;
  916. data.sellerPic = newOrder.content.sellerPic;
  917. data.buyerUid = 0;
  918. data.buyerName = newOrder.content.buyerName;
  919. data.buyerPic = '';
  920. data.amount = newOrder.content.amount;
  921. data.uid = newOrder.content.uID;
  922. navigatorKey.currentState
  923. .push(MaterialPageRoute(
  924. builder: (context) => OrderInformationPage(
  925. false,
  926. orderType: orderTypeThirdPlatform,
  927. amount: newOrder.content.amount,
  928. uid: newOrder.content.uID,
  929. buyerUid: MyCookie().getUID(),
  930. buyerName: newOrder.content.buyerName,
  931. buyerPic: MyCookie().getPic(),
  932. commodityCount: 1,
  933. commodityTitle: '第三方订单',
  934. commodityCover: '',
  935. sellName: newOrder.content.sellerName,
  936. sellPic: newOrder.content.sellerPic,
  937. sellUid: newOrder.content.sellerUID,
  938. )))
  939. .then((value) {
  940. PopUpQueue().onShow = false;
  941. PopUpQueue().showNext();
  942. });
  943. // navigatorKey.currentState.push(MaterialPageRoute(
  944. // builder: (context) =>
  945. // GangInPage(entity.data.data[0], newOrder.content)));
  946. }
  947. }, (error) {});
  948. // getUserWalletBalance((re, hE) {
  949. // if (!hE) {
  950. // UserBalanceEntity balance =
  951. // UserBalanceEntity().fromJson(json.decode(re.data.toString()));
  952. // if (balance.data >= newOrder.content.amount) {
  953. // payOrder(payWayWallet, newOrder.content.uID, (re, hE) {
  954. // if (!hE) {
  955. // showToast('支付成功');
  956. // EventBus().emit('payAnOrder');
  957. // }
  958. // }, (e) {}, context);
  959. // } else {
  960. // payOrder(payWayAliPay, newOrder.content.uID, (re, hE) {
  961. // if (!hE) {
  962. // PayByAlipayBeanEntity entity = PayByAlipayBeanEntity()
  963. // .fromJson(json.decode(re.data.toString()));
  964. // EventBus().on('alipayPaymentCallback', (arg) {
  965. // EventBus().off('alipayPaymentCallback');
  966. // EasyLoading.dismiss();
  967. // showToast('支付成功');
  968. // EventBus().emit('reNoPayOrder');
  969. // });
  970. // print(entity.data);
  971. // EasyLoading.instance
  972. // ..contentPadding =
  973. // EdgeInsets.symmetric(horizontal: 20, vertical: 12)
  974. // ..alignment = Alignment.center
  975. // ..contentMargin = EdgeInsets.all(20);
  976. // EasyLoading.show();
  977. // aliPay(entity.data).then((value) {
  978. // print(json.encode(value));
  979. // AlipayResultBeanEntity e = AlipayResultBeanEntity()
  980. // .fromJson(json.decode(json.encode(value)));
  981. // try {
  982. // int r = int.parse(e.resultStatus);
  983. // if (r == 9000) {
  984. // showToast('支付成功');
  985. // } else {
  986. // showToast(aliPayResultStatus(r));
  987. // resetOrder(newOrder.content.uID, context);
  988. // }
  989. // } catch (e) {
  990. // EasyLoading.dismiss();
  991. // }
  992. // });
  993. // // EventBus().emit('payAnOrder');
  994. // }
  995. // }, (e) {}, context);
  996. // // showToast('积分余额不足');
  997. // }
  998. // }
  999. // }, (e) {}, context);
  1000. }
  1001. void showSystemMessages(SystemInformationBeanEntity arg) {
  1002. EasyLoading.instance
  1003. ..contentPadding = EdgeInsets.symmetric(horizontal: 12, vertical: 12)
  1004. ..alignment = Alignment.center
  1005. ..loadingStyle = EasyLoadingStyle.custom
  1006. ..backgroundColor = Colors.transparent
  1007. ..indicatorColor = Colors.black
  1008. ..progressColor = Colors.black
  1009. ..maskColor = Colors.black
  1010. ..textColor = Colors.black
  1011. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  1012. EasyLoading.show(
  1013. indicator: Material(
  1014. color: Colors.transparent,
  1015. child: Container(
  1016. decoration: BoxDecoration(
  1017. borderRadius: BorderRadius.circular(16),
  1018. ),
  1019. height: MediaQuery.of(buildContext).size.height - 200,
  1020. padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
  1021. child: Column(
  1022. children: [
  1023. Expanded(child: Container()),
  1024. Container(
  1025. decoration: BoxDecoration(
  1026. color: Colors.white,
  1027. borderRadius: BorderRadius.circular(16),
  1028. ),
  1029. child: Column(
  1030. children: [
  1031. Container(
  1032. child: Text(
  1033. '系统消息',
  1034. style: TextStyle(
  1035. color: MyColors.c333333,
  1036. fontSize: 14,
  1037. fontWeight: FontWeight.bold),
  1038. ),
  1039. margin:
  1040. EdgeInsets.symmetric(horizontal: 26, vertical: 15),
  1041. ),
  1042. Container(
  1043. child: Text(
  1044. arg.content.content,
  1045. style: TextStyle(color: MyColors.c333333, fontSize: 14),
  1046. ),
  1047. margin: EdgeInsets.symmetric(horizontal: 26),
  1048. alignment: Alignment.centerLeft,
  1049. ),
  1050. Container(
  1051. height: 0.5,
  1052. color: MyColors.cE7E7E7,
  1053. margin: EdgeInsets.only(bottom: 12, top: 12),
  1054. ),
  1055. GestureDetector(
  1056. onTap: () {
  1057. PopUpQueue().onShow = false;
  1058. PopUpQueue().showNext();
  1059. },
  1060. behavior: HitTestBehavior.translucent,
  1061. child: Container(
  1062. width: 150,
  1063. margin: EdgeInsets.only(bottom: 14),
  1064. decoration: BoxDecoration(
  1065. borderRadius: BorderRadius.circular(20),
  1066. border:
  1067. Border.all(color: MyColors.cFF4233, width: 1.1),
  1068. color: Colors.white),
  1069. child: MyViews().myText('我知道了', MyColors.cFF4233, 14),
  1070. height: 40,
  1071. alignment: Alignment.center,
  1072. ),
  1073. )
  1074. ],
  1075. ),
  1076. ),
  1077. Expanded(child: Container()),
  1078. ],
  1079. ),
  1080. alignment: Alignment.center,
  1081. ),
  1082. ),
  1083. );
  1084. }
  1085. //优惠券弹框
  1086. void couponBulletBox(CouponBeanDataData data) {
  1087. EasyLoading.instance
  1088. ..contentPadding = EdgeInsets.symmetric(horizontal: 12, vertical: 12)
  1089. ..alignment = Alignment.center
  1090. ..loadingStyle = EasyLoadingStyle.custom
  1091. ..backgroundColor = Colors.transparent
  1092. ..indicatorColor = Colors.black
  1093. ..progressColor = Colors.black
  1094. ..maskColor = Colors.black
  1095. ..textColor = Colors.black
  1096. ..contentMargin = EdgeInsets.fromLTRB(20, 20, 20, 65);
  1097. EasyLoading.show(
  1098. indicator: Material(
  1099. color: Colors.transparent,
  1100. child: Stack(
  1101. children: [
  1102. Image.asset(
  1103. 'images/优惠券.png',
  1104. height: 640,
  1105. width: double.infinity,
  1106. ),
  1107. Container(
  1108. height: 640,
  1109. margin: EdgeInsets.only(top: 24),
  1110. child: Column(
  1111. children: [
  1112. Container(
  1113. margin: EdgeInsets.only(bottom: 5),
  1114. child: Text(
  1115. '抢红包啦',
  1116. style: TextStyle(
  1117. color: Colors.white,
  1118. fontSize: 24,
  1119. fontWeight: FontWeight.bold,
  1120. shadows: [
  1121. Shadow(
  1122. offset: Offset(1.0, 1.0),
  1123. blurRadius: 3.0,
  1124. color: MyColors.cDC1717,
  1125. )
  1126. ]),
  1127. ),
  1128. ),
  1129. Container(
  1130. decoration: BoxDecoration(
  1131. color: Colors.white,
  1132. borderRadius: BorderRadius.circular(8),
  1133. ),
  1134. height: 107,
  1135. width: double.infinity,
  1136. margin: EdgeInsets.symmetric(horizontal: 25, vertical: 27),
  1137. child: Column(
  1138. children: [
  1139. Text(
  1140. '平台红包大放送!',
  1141. style: TextStyle(
  1142. color: MyColors.c333333,
  1143. fontSize: 16,
  1144. fontWeight: FontWeight.bold),
  1145. ),
  1146. Text(
  1147. '立即去抢最高${data.max}元消费红包',
  1148. style: TextStyle(
  1149. color: MyColors.cFF4233,
  1150. fontSize: 14,
  1151. fontWeight: FontWeight.bold),
  1152. ),
  1153. Text(
  1154. '活动时间${data.distributeFromDate}至${data.distributeEndDate}',
  1155. style: TextStyle(
  1156. color: MyColors.c666666,
  1157. fontSize: 11,
  1158. fontWeight: FontWeight.bold),
  1159. ),
  1160. ],
  1161. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  1162. crossAxisAlignment: CrossAxisAlignment.start,
  1163. ),
  1164. padding: EdgeInsets.symmetric(horizontal: 26),
  1165. ),
  1166. Container(
  1167. margin: EdgeInsets.symmetric(horizontal: 25),
  1168. child: Row(
  1169. children: [
  1170. Expanded(
  1171. child: GestureDetector(
  1172. onTap: () {
  1173. EasyLoading.dismiss();
  1174. },
  1175. behavior: HitTestBehavior.translucent,
  1176. child: Container(
  1177. height: 34,
  1178. decoration: BoxDecoration(
  1179. borderRadius: BorderRadius.only(
  1180. topLeft: Radius.circular(17),
  1181. bottomLeft: Radius.circular(17),
  1182. ),
  1183. border: Border.all(
  1184. color: MyColors.cFFB455, width: 1),
  1185. color: Colors.white),
  1186. child: Text(
  1187. '我已参与',
  1188. style: TextStyle(
  1189. color: MyColors.cFFB455,
  1190. fontSize: 14,
  1191. ),
  1192. ),
  1193. alignment: Alignment.center,
  1194. ),
  1195. ),
  1196. ),
  1197. Expanded(
  1198. child: GestureDetector(
  1199. onTap: () {
  1200. grabACoupon(data.id);
  1201. },
  1202. behavior: HitTestBehavior.translucent,
  1203. child: Container(
  1204. height: 34,
  1205. decoration: BoxDecoration(
  1206. borderRadius: BorderRadius.only(
  1207. topRight: Radius.circular(17),
  1208. bottomRight: Radius.circular(17),
  1209. ),
  1210. color: MyColors.cFFB455),
  1211. child: Text(
  1212. '立即去抢',
  1213. style: TextStyle(
  1214. color: Colors.white,
  1215. fontSize: 14,
  1216. ),
  1217. ),
  1218. alignment: Alignment.center,
  1219. ),
  1220. ),
  1221. ),
  1222. ],
  1223. ),
  1224. )
  1225. ],
  1226. mainAxisAlignment: MainAxisAlignment.center,
  1227. ),
  1228. alignment: Alignment.center,
  1229. )
  1230. ],
  1231. ),
  1232. ),
  1233. );
  1234. }
  1235. _initFluwx() async {
  1236. await registerWxApi(
  1237. appId: AppID,
  1238. doOnAndroid: true,
  1239. doOnIOS: true,
  1240. universalLink: "https://oms.kunyueyun.com/");
  1241. var result = await isWeChatInstalled;
  1242. print("is installed $result");
  1243. weChatResponseEventHandler.listen((res) {
  1244. if (res is WeChatPaymentResponse) {
  1245. // do something here
  1246. print('res.type----${res.type}');
  1247. print('res.extData----${res.extData}');
  1248. print('res.errCode----${res.errCode}');
  1249. print('res.errStr----${res.errStr}');
  1250. print('res.isSuccessful----${res.isSuccessful}');
  1251. EventBus().emit('WeChatPaymentResponse', res.isSuccessful);
  1252. }
  1253. if (res is WeChatAuthResponse) {
  1254. print('res.type----${res.type}');
  1255. print('res.country----${res.country}');
  1256. print('res.lang----${res.lang}');
  1257. print('res.code----${res.code}');
  1258. print('res.state----${res.state}');
  1259. print(
  1260. 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=$AppID&secret=$AppSecret&code=${res.code}&grant_type=authorization_code');
  1261. Dio()
  1262. .get(
  1263. 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=$AppID&secret=$AppSecret&code=${res.code}&grant_type=authorization_code')
  1264. .then((value) {
  1265. print(value);
  1266. getWeChatInfo(value);
  1267. });
  1268. }
  1269. });
  1270. }
  1271. //获取微信用户信息
  1272. void getWeChatInfo(Response value) {
  1273. AccessBeanEntity accessBeanEntity =
  1274. AccessBeanEntity().fromJson(json.decode(value.toString()));
  1275. Dio()
  1276. .get(
  1277. 'https://api.weixin.qq.com/sns/userinfo?access_token=${accessBeanEntity.accessToken}&openid=${accessBeanEntity.openid}')
  1278. .then((value) {
  1279. print(value);
  1280. try {
  1281. WXBeanEntity entity =
  1282. WXBeanEntity().fromJson(json.decode(value.toString()));
  1283. saveWXInfo(entity);
  1284. } catch (e) {}
  1285. });
  1286. }
  1287. void saveWXInfo(WXBeanEntity entity) {
  1288. MyDio().update({
  1289. "key": "user",
  1290. "values": {
  1291. "id": MyCookie().loginInformation.data.extra.id,
  1292. "wx_picture": entity.headimgurl,
  1293. "wx_name": entity.nickname,
  1294. "wx_openid": entity.openid
  1295. }
  1296. }, (response, hasError) {
  1297. if (!hasError) {
  1298. MyCookie().userBean.wxOpenid = entity.openid;
  1299. MyCookie().userBean.wxName = entity.nickname;
  1300. MyCookie().userBean.wxPicture = entity.headimgurl;
  1301. EventBus().emit('bindToWeChat');
  1302. }
  1303. }, (error) {});
  1304. }
  1305. void isItUnderReview() {
  1306. MyDio().post(
  1307. '/model/appStoreReview', {'version': MyCookie().packageInfo.version},
  1308. (response, hasError) {
  1309. if (!hasError) {
  1310. AppStoreReviewBeanEntity e = AppStoreReviewBeanEntity()
  1311. .fromJson(json.decode(response.data.toString()));
  1312. print(e.data);
  1313. if (e.data && Platform.isIOS) {
  1314. MyCookie().underReview = true;
  1315. } else {
  1316. MyCookie().underReview = false;
  1317. }
  1318. EventBus().emit('appStoreReview');
  1319. }
  1320. }, (error) {});
  1321. }
  1322. }
  1323. class FallbackCupertinoLocalisationsDelegate
  1324. extends LocalizationsDelegate<CupertinoLocalizations> {
  1325. const FallbackCupertinoLocalisationsDelegate();
  1326. @override
  1327. bool isSupported(Locale locale) => true;
  1328. @override
  1329. Future<CupertinoLocalizations> load(Locale locale) =>
  1330. DefaultCupertinoLocalizations.load(locale);
  1331. @override
  1332. bool shouldReload(FallbackCupertinoLocalisationsDelegate old) => false;
  1333. }