main.dart 51 KB

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