main.dart 50 KB

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