mine_page.dart 17 KB

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