mine_page.dart 17 KB

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