mine_page.dart 18 KB

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