main.dart 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360
  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/paegs/login_page/login_page.dart';
  15. import 'package:bbyyy/paegs/pay_page/order_information_page.dart';
  16. import 'package:bbyyy/paegs/root_page/root_page.dart';
  17. import 'package:bbyyy/paegs/root_page/root_page_view.dart';
  18. import 'package:bbyyy/paegs/welcome_page/welcome_page.dart';
  19. import 'package:dio/dio.dart';
  20. import 'package:flustars/flustars.dart';
  21. import 'package:flutter/cupertino.dart';
  22. import 'package:flutter/material.dart';
  23. import 'package:flutter/services.dart';
  24. import 'package:flutter_local_notifications/flutter_local_notifications.dart';
  25. import 'package:flutter_localizations/flutter_localizations.dart';
  26. import 'package:flutter_svg/flutter_svg.dart';
  27. import 'package:fluwx/fluwx.dart';
  28. import 'package:pull_to_refresh/pull_to_refresh.dart';
  29. import 'package:rxdart/rxdart.dart';
  30. import 'beans/app_store_review_bean_entity.dart';
  31. import 'beans/coupon_bean_entity.dart';
  32. import 'beans/my_shop_bean_entity.dart';
  33. import 'beans/new_order_bean_entity.dart';
  34. import 'beans/smart_order_bean_entity.dart';
  35. import 'beans/system_information_bean_entity.dart';
  36. import 'https/MyDio.dart';
  37. import 'https/my_request.dart';
  38. import 'my_tools/const.dart';
  39. import 'my_tools/dims.dart';
  40. import 'my_tools/easy_loading/easy_loading.dart';
  41. import 'my_tools/easy_loading/loading.dart';
  42. import 'my_tools/global.dart';
  43. import 'my_tools/my_colors.dart';
  44. import 'my_tools/my_views.dart';
  45. import 'my_tools/order.dart';
  46. import 'my_tools/pop_up_queue.dart';
  47. final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
  48. FlutterLocalNotificationsPlugin();
  49. final BehaviorSubject<ReceivedNotification> didReceiveLocalNotificationSubject =
  50. BehaviorSubject<ReceivedNotification>();
  51. final BehaviorSubject<String> selectNotificationSubject =
  52. BehaviorSubject<String>();
  53. class ReceivedNotification {
  54. ReceivedNotification({
  55. @required this.id,
  56. @required this.title,
  57. @required this.body,
  58. @required this.payload,
  59. });
  60. final int id;
  61. final String title;
  62. final String body;
  63. final String payload;
  64. }
  65. Future<void> main() async {
  66. AMapFlutterLocation.setApiKey("156e225e52517b76ac2222f035a9ce3e", "548414a843a2ec9c383e34341b8c84df");
  67. WidgetsFlutterBinding.ensureInitialized();
  68. const AndroidInitializationSettings initializationSettingsAndroid =
  69. AndroidInitializationSettings('@mipmap/app_logo');
  70. /// Note: permissions aren't requested here just to demonstrate that can be
  71. /// done later
  72. final IOSInitializationSettings initializationSettingsIOS =
  73. IOSInitializationSettings(
  74. requestAlertPermission: true,
  75. requestBadgePermission: true,
  76. requestSoundPermission: true,
  77. onDidReceiveLocalNotification:
  78. (int id, String title, String body, String payload) async {
  79. didReceiveLocalNotificationSubject.add(ReceivedNotification(
  80. id: id, title: title, body: body, payload: payload));
  81. });
  82. const MacOSInitializationSettings initializationSettingsMacOS =
  83. MacOSInitializationSettings(
  84. requestAlertPermission: true,
  85. requestBadgePermission: true,
  86. requestSoundPermission: true);
  87. final InitializationSettings initializationSettings = InitializationSettings(
  88. android: initializationSettingsAndroid,
  89. iOS: initializationSettingsIOS,
  90. macOS: initializationSettingsMacOS);
  91. await flutterLocalNotificationsPlugin.initialize(initializationSettings,
  92. onSelectNotification: (String payload) async {
  93. if (payload != null) {
  94. if (payload == notifyTypeNewMsg) {
  95. RootPageView().bNIndex = 2;
  96. EventBus().emit('ChangePage');
  97. }
  98. debugPrint('notification payload: $payload');
  99. }
  100. selectNotificationSubject.add(payload);
  101. });
  102. runApp(MyApp());
  103. }
  104. class MyApp extends StatelessWidget with WidgetsBindingObserver {
  105. BuildContext buildContext;
  106. StateSetter ss;
  107. List<MyShopBeanDataData> shops = [];
  108. int shopIndex = 0;
  109. String clipboardT;
  110. int amountCompleted = 0;
  111. NewOrderBeanEntity newOrder;
  112. @override
  113. StatelessElement createElement() {
  114. // TODO: implement createElement
  115. WidgetsBinding.instance.addObserver(this);
  116. MyCookie().initP();
  117. _initFluwx();
  118. EventBus().on('hasNewOrder', (arg) {
  119. newOrder = arg;
  120. displayPendingOrders();
  121. });
  122. EventBus().on('systemInformation', (arg) {
  123. if (arg is SystemInformationBeanEntity) {
  124. showSystemMessages(arg);
  125. }
  126. });
  127. EventBus().on('检查粘贴板', (arg) {
  128. Timer(Duration(seconds: 1), () {
  129. getClipboardData();
  130. checkUnpaidThirdPartyOrders();
  131. });
  132. });
  133. EventBus().on('hasCoupon', (arg) {
  134. if (arg is CouponBeanDataData) {
  135. couponBulletBox(arg);
  136. }
  137. });
  138. EventBus().on('packageInfo', (arg) {
  139. isItUnderReview();
  140. });
  141. return super.createElement();
  142. }
  143. @override
  144. Widget build(BuildContext context) {
  145. SystemChrome.setPreferredOrientations([
  146. DeviceOrientation.portraitUp, //只能纵向
  147. DeviceOrientation.portraitDown, //只能纵向
  148. ]);
  149. return RefreshConfiguration(
  150. child: MaterialApp(
  151. // debugShowMaterialGrid: true,
  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. }