mine_page.dart 20 KB

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