mine_page.dart 18 KB

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