main.dart 51 KB

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