mine_page.dart 21 KB

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