mine_page.dart 20 KB

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