mine_page.dart 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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) {
  246. MyTools().toPage(context, SetAlipayPage(),
  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/钱包1.svg', '钱包', () {}),
  288. functionItem('images/svg/订单.svg', '订单', () {
  289. MyTools().toPage(context, OrderPage(), (then) {
  290. queryPersonalInformation();
  291. });
  292. }),
  293. functionItem('images/svg/绑定.svg', '提现账号', () {
  294. MyTools().toPage(context, BindAlipayPage(), (then) {
  295. queryPersonalInformation();
  296. });
  297. }),
  298. functionItem('images/svg/广告.svg', '广告', () {
  299. MyTools().toPage(context, AdvertisingPage(), (then) {});
  300. }),
  301. functionItem('images/svg/处罚.svg', '投诉', () {
  302. MyTools().toPage(context, PunishPage(), (then) {
  303. queryPersonalInformation();
  304. });
  305. }),
  306. functionItem('images/svg/客服.svg', '客服', () {
  307. MyShopBeanDataData chatWith = MyShopBeanDataData();
  308. chatWith.userName = '客服';
  309. chatWith.userUid = 0;
  310. chatWith.userPic = '';
  311. MyTools().toPage(context, ChatPage(chatWith, null), (then) {
  312. queryPersonalInformation();
  313. });
  314. }),
  315. functionItem('images/svg/推广下载.svg', '推广下载', () {
  316. MyTools().toPage(context, PromotionDownloadPage(), (then) {});
  317. }),
  318. GestureDetector(
  319. onTap: () {
  320. checkForUpdates(context,showT: true);
  321. },
  322. behavior: HitTestBehavior.translucent,
  323. child: Container(
  324. padding: EdgeInsets.only(left: 20, right: 20),
  325. child: Column(
  326. children: [
  327. Row(
  328. children: [
  329. Container(
  330. child: SvgPicture.asset(
  331. 'images/svg/更新.svg',
  332. color: MyColors.c333333,
  333. ),
  334. margin: EdgeInsets.only(
  335. right: 12, top: 15, bottom: 15),
  336. ),
  337. Expanded(
  338. child: Text(
  339. '更新',
  340. style: TextStyle(
  341. color: MyColors.c333333, fontSize: 15),
  342. )),
  343. Container(
  344. child: Text(
  345. MyCookie().packageInfo.version,
  346. style: TextStyle(
  347. color: MyColors.c333333, fontSize: 15),
  348. ),
  349. margin: EdgeInsets.only(right: 10),
  350. ),
  351. SvgPicture.asset('images/svg/箭头.svg')
  352. ],
  353. ),
  354. Container(
  355. height: 1,
  356. color: MyColors.cEFEFEF,
  357. )
  358. ],
  359. ),
  360. ),
  361. ),
  362. functionItem('images/svg/设置.svg', '设置', () {
  363. MyTools().toPage(context, SetPage(), (then) {
  364. queryPersonalInformation();
  365. });
  366. }),
  367. ],
  368. )
  369. ],
  370. ),
  371. ),
  372. ),
  373. );
  374. }
  375. functionItem(String svg, String title, onTap) {
  376. return GestureDetector(
  377. onTap: onTap,
  378. behavior: HitTestBehavior.translucent,
  379. child: Container(
  380. padding: EdgeInsets.only(left: 20, right: 20),
  381. child: Column(
  382. children: [
  383. Row(
  384. children: [
  385. Container(
  386. child: SvgPicture.asset(
  387. svg,
  388. color: MyColors.c333333,
  389. ),
  390. margin: EdgeInsets.only(right: 12, top: 15, bottom: 15),
  391. ),
  392. Expanded(
  393. child: Text(
  394. title,
  395. style: TextStyle(color: MyColors.c333333, fontSize: 15),
  396. )),
  397. SvgPicture.asset('images/svg/箭头.svg')
  398. ],
  399. ),
  400. Container(
  401. height: 1,
  402. color: MyColors.cEFEFEF,
  403. )
  404. ],
  405. ),
  406. ),
  407. );
  408. }
  409. void queryPersonalInformation() {
  410. MyDio().query({
  411. "key": "user",
  412. "filters": {
  413. "conditions": ["uid == ${MyCookie().getUID()}"]
  414. },
  415. "dims": userDims,
  416. "paging": [1, 20]
  417. }, (response, hasError) {
  418. if (!hasError) {
  419. UserBeanEntity entity =
  420. UserBeanEntity().fromJson(json.decode(response.data.toString()));
  421. MyCookie().userBean = entity.data.data[0];
  422. EventBus().emit('userChange');
  423. }
  424. endRe(controller);
  425. }, (error) {});
  426. }
  427. void onRefresh() {
  428. queryPersonalInformation();
  429. }
  430. }