mine_page.dart 20 KB

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