mine_page.dart 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. import 'dart:convert';
  2. import 'package:bbyyy/beans/my_shop_bean_entity.dart';
  3. import 'package:bbyyy/beans/user_bean_entity.dart';
  4. import 'package:bbyyy/https/MyDio.dart';
  5. import 'package:bbyyy/https/my_request.dart';
  6. import 'package:bbyyy/https/url.dart';
  7. import 'package:bbyyy/my_tools/dims.dart';
  8. import 'package:bbyyy/my_tools/event_bus.dart';
  9. import 'package:bbyyy/my_tools/my_colors.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/my_views.dart';
  13. import 'package:bbyyy/paegs/chat_page/chat_page.dart';
  14. import 'package:bbyyy/paegs/mine_page/my_goods_page/my_goods_page.dart';
  15. import 'package:bbyyy/paegs/mine_page/my_information_page/my_information_page.dart';
  16. import 'package:bbyyy/paegs/mine_page/order_page/order_page.dart';
  17. import 'package:bbyyy/paegs/mine_page/promotion_download_page/promotion_download_page.dart';
  18. import 'package:bbyyy/paegs/mine_page/punish_page/punish_page.dart';
  19. import 'package:bbyyy/paegs/mine_page/referrer_page/referrer_page.dart';
  20. import 'package:bbyyy/paegs/mine_page/set_page/set_page.dart';
  21. import 'package:bbyyy/paegs/mine_page/wallet_page/wallet_page.dart';
  22. import 'package:bbyyy/paegs/mine_page/wallet_page/withdraw_page/withdraw_page.dart';
  23. import 'package:flutter/material.dart';
  24. import 'package:flutter_svg/flutter_svg.dart';
  25. import 'package:pull_to_refresh/pull_to_refresh.dart';
  26. import 'advertising_page/advertising_page.dart';
  27. import 'bind_alipay_page/bind_alipay_page.dart';
  28. import 'bind_alipay_page/set_alipay_page.dart';
  29. import 'coupon_page/coupon_page.dart';
  30. import 'my_information_page/my_qr_page.dart';
  31. class MinePage extends StatefulWidget {
  32. @override
  33. _MinePageState createState() => _MinePageState();
  34. }
  35. class _MinePageState extends State<MinePage> {
  36. @override
  37. void initState() {
  38. // TODO: implement initState
  39. super.initState();
  40. EventBus().on('userChange', (arg) {
  41. setState(() {});
  42. });
  43. EventBus().on('appStoreReview', (arg) {
  44. setState(() {
  45. });
  46. });
  47. }
  48. @override
  49. void dispose() {
  50. // TODO: implement dispose
  51. super.dispose();
  52. EventBus().off('userChange');
  53. EventBus().off('appStoreReview');
  54. }
  55. RefreshController controller = RefreshController();
  56. @override
  57. Widget build(BuildContext context) {
  58. return Scaffold(
  59. body: SmartRefresher(
  60. controller: controller,
  61. onRefresh: onRefresh,
  62. child: SingleChildScrollView(
  63. child: Stack(
  64. children: [
  65. Image.asset(
  66. 'images/mine_bg.png',
  67. width: MediaQuery.of(context).size.width,
  68. height: MediaQuery.of(context).size.width / 750 * 462,
  69. ),
  70. Column(
  71. children: [
  72. SafeArea(
  73. bottom: false,
  74. child: Container(
  75. margin: EdgeInsets.only(
  76. top: 40,
  77. left: 20,
  78. right: 20,
  79. ),
  80. child: Row(
  81. children: [
  82. GestureDetector(
  83. onTap:(){
  84. MyTools().toPage(context, MyInformationPage(),
  85. (then) {
  86. queryPersonalInformation();
  87. });
  88. },behavior: HitTestBehavior.translucent,
  89. child: Container(
  90. margin: EdgeInsets.only(right: 10),
  91. decoration: BoxDecoration(
  92. color: Colors.white,
  93. borderRadius: BorderRadius.all(
  94. Radius.circular(30),
  95. ),
  96. ),
  97. height: 60,
  98. width: 60,
  99. child: ClipRRect(
  100. borderRadius: BorderRadius.all(
  101. Radius.circular(26),
  102. ),
  103. child: MyViews().netImg(
  104. imgURL(MyCookie()
  105. .loginInformation
  106. .data
  107. .extra
  108. .picture),
  109. 52,
  110. 52),
  111. ),
  112. alignment: Alignment.center,
  113. ),
  114. ),
  115. Expanded(
  116. child: Container(
  117. height: 60,
  118. child: Column(children: [
  119. Row(children: [
  120. Expanded(
  121. child: GestureDetector(
  122. onTap: () {
  123. MyTools().toPage(
  124. context, MyInformationPage(),
  125. (then) {
  126. queryPersonalInformation();
  127. });
  128. },
  129. child: Container(
  130. margin: EdgeInsets.only(right: 10),
  131. child: Text(
  132. MyCookie()
  133. .loginInformation
  134. .data
  135. .extra
  136. .name,
  137. style: TextStyle(
  138. color: Colors.white,
  139. fontSize: 18),
  140. maxLines: 1,
  141. overflow: TextOverflow.ellipsis,
  142. softWrap: true,
  143. ),
  144. ),
  145. ),
  146. ),
  147. Container(
  148. margin: EdgeInsets.only(left: 20),
  149. child: MyViews().myText(
  150. '¥${MyCookie().userBean.balance}',
  151. Colors.white,
  152. 24),
  153. ),
  154. ],mainAxisAlignment: MainAxisAlignment.spaceBetween,),
  155. Row(children: [
  156. Text(
  157. 'ID:${MyCookie().getUID()}',
  158. style: TextStyle(
  159. color: Colors.white,
  160. fontSize: 14,
  161. ),
  162. maxLines: 1,
  163. overflow: TextOverflow.ellipsis,
  164. softWrap: true,
  165. ),
  166. GestureDetector(
  167. onTap: () {
  168. MyTools().toPage(
  169. context, MyQRPage(), (then) {});
  170. },
  171. behavior: HitTestBehavior.translucent,
  172. child: Container(
  173. child: Row(
  174. children: [
  175. SvgPicture.asset(
  176. 'images/svg/二维码.svg',
  177. color: Colors.white,
  178. ),
  179. Container(
  180. width: 20,
  181. ),
  182. SvgPicture.asset(
  183. 'images/svg/箭头.svg',
  184. color: Colors.white,
  185. height: 12,
  186. width: 8,
  187. )
  188. ],
  189. ),
  190. ),
  191. )
  192. ],mainAxisAlignment: MainAxisAlignment.spaceBetween,),
  193. ],mainAxisAlignment: MainAxisAlignment.spaceBetween,),
  194. ),
  195. ),
  196. ],
  197. ),
  198. ),
  199. ),
  200. Card(
  201. margin: EdgeInsets.only(
  202. top:
  203. MediaQuery.of(context).size.width / 750 * 462 - 200,
  204. left: 20,
  205. right: 20),
  206. child: Padding(
  207. padding: EdgeInsets.only(top: 15, bottom: 13),
  208. child: Row(
  209. children: [
  210. GestureDetector(
  211. onTap: () {
  212. MyTools().toPage(context, WalletPage(), (then) {
  213. queryPersonalInformation();
  214. });
  215. },
  216. behavior: HitTestBehavior.translucent,
  217. child: Column(
  218. children: [
  219. SvgPicture.asset('images/svg/钱包.svg'),
  220. Container(
  221. margin: EdgeInsets.only(top: 11),
  222. child: Text(
  223. '流水',
  224. style: TextStyle(
  225. color: MyColors.c333333, fontSize: 14),
  226. ),
  227. )
  228. ],
  229. ),
  230. ),
  231. if(!MyCookie().underReview) GestureDetector(
  232. onTap: () {
  233. MyTools().toPage(context, CouponPage(), (then) {
  234. queryPersonalInformation();
  235. });
  236. },
  237. behavior: HitTestBehavior.translucent,
  238. child: Column(
  239. children: [
  240. SvgPicture.asset('images/svg/优惠券.svg'),
  241. Container(
  242. margin: EdgeInsets.only(top: 11),
  243. child: Text(
  244. '优惠券',
  245. style: TextStyle(
  246. color: MyColors.c333333,
  247. fontSize: 14),
  248. ))
  249. ],
  250. ),
  251. ),
  252. GestureDetector(
  253. onTap: () {
  254. MyTools().toPage(context, MyGoodsPage(), (then) {
  255. queryPersonalInformation();
  256. });
  257. },
  258. behavior: HitTestBehavior.translucent,
  259. child: Column(
  260. children: [
  261. SvgPicture.asset('images/svg/商品.svg'),
  262. Container(
  263. margin: EdgeInsets.only(top: 11),
  264. child: Text(
  265. '商品',
  266. style: TextStyle(
  267. color: MyColors.c333333,
  268. fontSize: 14),
  269. ))
  270. ],
  271. ),
  272. ),
  273. GestureDetector(
  274. onTap: () {
  275. if (MyCookie().userBean.aliPayAccount.isEmpty &&
  276. MyCookie().userBean.wxOpenid.isEmpty) {
  277. MyTools().toPage(context, BindAlipayPage(),
  278. (then) {
  279. if (MyCookie()
  280. .userBean
  281. .aliPayAccount
  282. .isNotEmpty) {
  283. MyTools().toPage(context, WithdrawPage(),
  284. (then) {
  285. queryPersonalInformation();
  286. });
  287. }
  288. });
  289. } else {
  290. MyTools().toPage(context, WithdrawPage(),
  291. (then) {
  292. queryPersonalInformation();
  293. });
  294. }
  295. },
  296. behavior: HitTestBehavior.translucent,
  297. child: Column(
  298. children: [
  299. SvgPicture.asset('images/svg/提现.svg'),
  300. Container(
  301. margin: EdgeInsets.only(top: 11),
  302. child: Text(
  303. '提现',
  304. style: TextStyle(
  305. color: MyColors.c333333,
  306. fontSize: 14),
  307. ))
  308. ],
  309. ),
  310. )
  311. ],
  312. mainAxisAlignment: MainAxisAlignment.spaceAround,
  313. ),
  314. ),
  315. elevation: 2,
  316. shadowColor: MyColors.c21333333,
  317. ),
  318. functionItem('images/svg/订单.svg', '订单', () {
  319. MyTools().toPage(context, OrderPage(), (then) {
  320. queryPersonalInformation();
  321. });
  322. }),
  323. functionItem('images/svg/推荐人.svg', '推荐人', () {
  324. MyTools().toPage(context, ReferrerPage(), (then) {
  325. });
  326. }),
  327. functionItem('images/svg/绑定.svg', '提现账号', () {
  328. MyTools().toPage(context, BindAlipayPage(), (then) {
  329. queryPersonalInformation();
  330. });
  331. }),
  332. if(!MyCookie().underReview)functionItem('images/svg/广告.svg', '广告', () {
  333. MyTools().toPage(context, AdvertisingPage(), (then) {});
  334. }),
  335. functionItem('images/svg/处罚.svg', '投诉', () {
  336. MyTools().toPage(context, PunishPage(), (then) {
  337. queryPersonalInformation();
  338. });
  339. }),
  340. functionItem('images/svg/客服.svg', '客服', () {
  341. MyShopBeanDataData chatWith = MyShopBeanDataData();
  342. chatWith.userName = '客服';
  343. chatWith.userUid = 0;
  344. chatWith.userPic = '';
  345. MyTools().toPage(context, ChatPage(chatWith, null), (then) {
  346. queryPersonalInformation();
  347. });
  348. }),
  349. functionItem('images/svg/推广下载.svg', '推广下载', () {
  350. MyTools()
  351. .toPage(context, PromotionDownloadPage(), (then) {});
  352. }),
  353. GestureDetector(
  354. onTap: () {
  355. checkForUpdates(context, showT: true);
  356. },
  357. behavior: HitTestBehavior.translucent,
  358. child: Container(
  359. padding: EdgeInsets.only(left: 20, right: 20),
  360. child: Column(
  361. children: [
  362. Row(
  363. children: [
  364. Container(
  365. child: SvgPicture.asset(
  366. 'images/svg/更新.svg',
  367. color: MyColors.c333333,
  368. ),
  369. margin: EdgeInsets.only(
  370. right: 12, top: 15, bottom: 15),
  371. ),
  372. Expanded(
  373. child: Text(
  374. '更新',
  375. style: TextStyle(
  376. color: MyColors.c333333, fontSize: 15),
  377. )),
  378. Container(
  379. child: Text(
  380. MyCookie().packageInfo.version,
  381. style: TextStyle(
  382. color: MyColors.c333333, fontSize: 15),
  383. ),
  384. margin: EdgeInsets.only(right: 10),
  385. ),
  386. SvgPicture.asset('images/svg/箭头.svg')
  387. ],
  388. ),
  389. Container(
  390. height: 1,
  391. color: MyColors.cEFEFEF,
  392. )
  393. ],
  394. ),
  395. ),
  396. ),
  397. functionItem('images/svg/设置.svg', '设置', () {
  398. MyTools().toPage(context, SetPage(), (then) {
  399. queryPersonalInformation();
  400. });
  401. }),
  402. ],
  403. )
  404. ],
  405. ),
  406. ),
  407. ),
  408. );
  409. }
  410. functionItem(String svg, String title, onTap) {
  411. return GestureDetector(
  412. onTap: onTap,
  413. behavior: HitTestBehavior.translucent,
  414. child: Container(
  415. padding: EdgeInsets.only(left: 20, right: 20),
  416. child: Column(
  417. children: [
  418. Row(
  419. children: [
  420. Container(
  421. child: SvgPicture.asset(
  422. svg,
  423. color: MyColors.c333333,
  424. ),
  425. margin: EdgeInsets.only(right: 12, top: 15, bottom: 15),
  426. ),
  427. Expanded(
  428. child: Text(
  429. title,
  430. style: TextStyle(color: MyColors.c333333, fontSize: 15),
  431. )),
  432. SvgPicture.asset('images/svg/箭头.svg')
  433. ],
  434. ),
  435. Container(
  436. height: 1,
  437. color: MyColors.cEFEFEF,
  438. )
  439. ],
  440. ),
  441. ),
  442. );
  443. }
  444. void queryPersonalInformation() {
  445. MyDio().query({
  446. "key": "user",
  447. "filters": {
  448. "conditions": ["uid == ${MyCookie().getUID()}"]
  449. },
  450. "dims": userDims,
  451. "paging": [1, 20]
  452. }, (response, hasError) {
  453. if (!hasError) {
  454. UserBeanEntity entity =
  455. UserBeanEntity().fromJson(json.decode(response.data.toString()));
  456. MyCookie().userBean = entity.data.data[0];
  457. EventBus().emit('userChange');
  458. }
  459. endRe(controller);
  460. }, (error) {});
  461. }
  462. void onRefresh() {
  463. queryPersonalInformation();
  464. }
  465. }