import 'dart:convert'; import 'package:bbyyy/beans/my_shop_bean_entity.dart'; import 'package:bbyyy/beans/user_bean_entity.dart'; import 'package:bbyyy/https/MyDio.dart'; import 'package:bbyyy/https/my_request.dart'; import 'package:bbyyy/https/url.dart'; import 'package:bbyyy/my_tools/dims.dart'; import 'package:bbyyy/my_tools/event_bus.dart'; import 'package:bbyyy/my_tools/my_colors.dart'; import 'package:bbyyy/my_tools/my_cookie.dart'; import 'package:bbyyy/my_tools/my_tools.dart'; import 'package:bbyyy/my_tools/my_views.dart'; import 'package:bbyyy/paegs/chat_page/chat_page.dart'; import 'package:bbyyy/paegs/mine_page/my_goods_page/my_goods_page.dart'; import 'package:bbyyy/paegs/mine_page/my_information_page/my_information_page.dart'; import 'package:bbyyy/paegs/mine_page/order_page/order_page.dart'; import 'package:bbyyy/paegs/mine_page/punish_page/punish_page.dart'; import 'package:bbyyy/paegs/mine_page/set_page/set_page.dart'; import 'package:bbyyy/paegs/mine_page/wallet_page/wallet_page.dart'; import 'package:bbyyy/paegs/mine_page/wallet_page/withdraw_page/withdraw_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'advertising_page/advertising_page.dart'; import 'bind_alipay_page/bind_alipay_page.dart'; import 'bind_alipay_page/set_alipay_page.dart'; class MinePage extends StatefulWidget { @override _MinePageState createState() => _MinePageState(); } class _MinePageState extends State { @override void initState() { // TODO: implement initState super.initState(); EventBus().on('userChange', (arg) { setState(() {}); }); } @override void dispose() { // TODO: implement dispose super.dispose(); EventBus().off('userChange'); } RefreshController controller = RefreshController(); @override Widget build(BuildContext context) { return Scaffold( body: SmartRefresher( controller: controller, onRefresh: onRefresh, child: SingleChildScrollView( child: Stack( children: [ Image.asset( 'images/mine_bg.png', width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.width / 750 * 462, ), Column( children: [ SafeArea( child: Container( margin: EdgeInsets.only( top: 40, left: 20, right: 20, ), child: GestureDetector( onTap: () { MyTools().toPage(context, MyInformationPage(), (then) { queryPersonalInformation(); }); }, behavior: HitTestBehavior.translucent, child: Row( children: [ Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all( Radius.circular(30), ), ), height: 60, width: 60, child: ClipRRect( borderRadius: BorderRadius.all( Radius.circular(26), ), child: MyViews().netImg( imgURL(MyCookie() .loginInformation .data .extra .picture), 52, 52), ), alignment: Alignment.center, ), Expanded( child: Container( margin: EdgeInsets.only(left: 10), height: 68, child: Column( children: [ Row( children: [ Container( margin: EdgeInsets.only(right: 10), child: Text( MyCookie() .loginInformation .data .extra .name, style: TextStyle( color: Colors.white, fontSize: 18), maxLines: 1, overflow: TextOverflow.ellipsis, softWrap: true, ), ), SvgPicture.asset( 'images/svg/箭头.svg', color: Colors.white, width: 6, height: 11, ) ], ), Text( 'ID:${MyCookie().getUID()}', style: TextStyle( color: Colors.white, fontSize: 14, ), maxLines: 1, overflow: TextOverflow.ellipsis, softWrap: true, ), Text( '电话:${MyCookie().userBean.mobile}', style: TextStyle( color: Colors.white, fontSize: 14, ), maxLines: 1, overflow: TextOverflow.ellipsis, softWrap: true, ) ], crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, ), ), ), MyViews().myText('¥${MyCookie().userBean.balance}', Colors.white, 24) ], ), ), ), ), Card( margin: EdgeInsets.only( top: MediaQuery.of(context).size.width / 750 * 462 - 200, left: 20, right: 20), child: Padding( padding: EdgeInsets.only(top: 15, bottom: 13), child: Row( children: [ GestureDetector( onTap: () { MyTools().toPage(context, WalletPage(), (then) { queryPersonalInformation(); }); }, behavior: HitTestBehavior.translucent, child: Column( children: [ SvgPicture.asset('images/svg/钱包.svg'), Container( margin: EdgeInsets.only(top: 11), child: Text( '钱包', style: TextStyle( color: MyColors.c333333, fontSize: 14), ), ) ], ), ), // GestureDetector( // onTap: () { // MyTools().toPage(context, CouponPage(), (then) {queryPersonalInformation();}); // }, // behavior: HitTestBehavior.translucent, // child: Column( // children: [ // SvgPicture.asset('images/svg/优惠券.svg'), // Container( // margin: EdgeInsets.only(top: 11), // child: Text( // '优惠券', // style: TextStyle( // color: MyColors.c333333, fontSize: 14), // )) // ], // ), // ), GestureDetector( onTap: () { MyTools().toPage(context, MyGoodsPage(), (then) { queryPersonalInformation(); }); }, behavior: HitTestBehavior.translucent, child: Column( children: [ SvgPicture.asset('images/svg/商品.svg'), Container( margin: EdgeInsets.only(top: 11), child: Text( '商品', style: TextStyle( color: MyColors.c333333, fontSize: 14), )) ], ), ), GestureDetector( onTap: () { if (MyCookie().userBean.aliPayAccount.isEmpty) { MyTools().toPage(context, SetAlipayPage(), (then) { if (MyCookie() .userBean .aliPayAccount .isNotEmpty) { MyTools().toPage(context, WithdrawPage(), (then) { queryPersonalInformation(); }); } }); } else { MyTools().toPage(context, WithdrawPage(), (then) { queryPersonalInformation(); }); } }, behavior: HitTestBehavior.translucent, child: Column( children: [ SvgPicture.asset('images/svg/提现.svg'), Container( margin: EdgeInsets.only(top: 11), child: Text( '提现', style: TextStyle( color: MyColors.c333333, fontSize: 14), )) ], ), ) ], mainAxisAlignment: MainAxisAlignment.spaceAround, ), ), elevation: 2, shadowColor: MyColors.c21333333, ), // functionItem('images/svg/钱包1.svg', '钱包', () {}), functionItem('images/svg/订单.svg', '订单', () { MyTools().toPage(context, OrderPage(), (then) { queryPersonalInformation(); }); }), functionItem('images/svg/绑定.svg', '提现账号', () { MyTools().toPage(context, BindAlipayPage(), (then) { queryPersonalInformation(); }); }), functionItem('images/svg/广告.svg', '广告', () { MyTools().toPage(context, AdvertisingPage(), (then) {}); }), // functionItem('images/svg/隐私.svg', '隐私', () { // MyTools().toPage(context, PrivacyProtectionPropsPage(), (then){}); // }), // functionItem('images/svg/赔付.svg', '赔付', () { // MyTools().toPage(context, CompensatePage(), (then){}); // }), functionItem('images/svg/处罚.svg', '投诉', () { MyTools().toPage(context, PunishPage(), (then) { queryPersonalInformation(); }); }), functionItem('images/svg/客服.svg', '客服', () { MyShopBeanDataData chatWith = MyShopBeanDataData(); chatWith.userName = '客服'; chatWith.userUid = 0; chatWith.userPic = ''; MyTools().toPage(context, ChatPage(chatWith, null), (then) { queryPersonalInformation(); }); }), functionItem('images/svg/更新.svg', '更新', () { checkForUpdates(context); }), functionItem('images/svg/设置.svg', '设置', () { MyTools().toPage(context, SetPage(), (then) { queryPersonalInformation(); }); }), ], ) ], ), ), ), ); } functionItem(String svg, String title, onTap) { return GestureDetector( onTap: onTap, behavior: HitTestBehavior.translucent, child: Container( padding: EdgeInsets.only(left: 20, right: 20), child: Column( children: [ Row( children: [ Container( child: SvgPicture.asset( svg, color: MyColors.c333333, ), margin: EdgeInsets.only(right: 12, top: 15, bottom: 15), ), Expanded( child: Text( title, style: TextStyle(color: MyColors.c333333, fontSize: 15), )), SvgPicture.asset('images/svg/箭头.svg') ], ), Container( height: 1, color: MyColors.cEFEFEF, ) ], ), ), ); } void queryPersonalInformation() { MyDio().query({ "key": "user", "filters": { "conditions": ["uid == ${MyCookie().getUID()}"] }, "dims": userDims, "paging": [1, 20] }, (response, hasError) { if (!hasError) { UserBeanEntity entity = UserBeanEntity().fromJson(json.decode(response.data.toString())); MyCookie().userBean = entity.data.data[0]; EventBus().emit('userChange'); } endRe(controller); }, (error) {}); } void onRefresh() { queryPersonalInformation(); } }