main.dart 51 KB

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