| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510 |
- 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/promotion_download_page/promotion_download_page.dart';
- import 'package:bbyyy/paegs/mine_page/punish_page/punish_page.dart';
- import 'package:bbyyy/paegs/mine_page/referrer_page/referrer_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';
- import 'coupon_page/coupon_page.dart';
- import 'my_information_page/my_qr_page.dart';
- class MinePage extends StatefulWidget {
- @override
- _MinePageState createState() => _MinePageState();
- }
- class _MinePageState extends State<MinePage> {
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- EventBus().on('userChange', (arg) {
- setState(() {});
- });
- EventBus().on('appStoreReview', (arg) {
- setState(() {
- });
- });
- checkIfThereIsAShop();
- }
- @override
- void dispose() {
- // TODO: implement dispose
- super.dispose();
- EventBus().off('userChange');
- EventBus().off('appStoreReview');
- }
- 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(
- bottom: false,
- child: Container(
- margin: EdgeInsets.only(
- top: 40,
- left: 20,
- right: 20,
- ),
- child: Row(
- children: [
- GestureDetector(
- onTap:(){
- MyTools().toPage(context, MyInformationPage(),
- (then) {
- queryPersonalInformation();
- });
- },behavior: HitTestBehavior.translucent,
- child: Container(
- margin: EdgeInsets.only(right: 10),
- 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(
- height: 60,
- child: Column(children: [
- Row(children: [
- Expanded(
- child: GestureDetector(
- onTap: () {
- MyTools().toPage(
- context, MyInformationPage(),
- (then) {
- queryPersonalInformation();
- });
- },
- child: 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,
- ),
- ),
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 20),
- child: MyViews().myText(
- '¥${MyCookie().userBean.balance}',
- Colors.white,
- 24),
- ),
- ],mainAxisAlignment: MainAxisAlignment.spaceBetween,),
- Row(children: [
- Text(
- 'ID:${MyCookie().getUID()}',
- style: TextStyle(
- color: Colors.white,
- fontSize: 14,
- ),
- maxLines: 1,
- overflow: TextOverflow.ellipsis,
- softWrap: true,
- ),
- GestureDetector(
- onTap: () {
- MyTools().toPage(
- context, MyQRPage(), (then) {});
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- child: Row(
- children: [
- SvgPicture.asset(
- 'images/svg/二维码.svg',
- color: Colors.white,
- ),
- Container(
- width: 20,
- ),
- SvgPicture.asset(
- 'images/svg/箭头.svg',
- color: Colors.white,
- height: 12,
- width: 8,
- )
- ],
- ),
- ),
- )
- ],mainAxisAlignment: MainAxisAlignment.spaceBetween,),
- ],mainAxisAlignment: MainAxisAlignment.spaceBetween,),
- ),
- ),
- ],
- ),
- ),
- ),
- 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),
- ),
- )
- ],
- ),
- ),
- if(!MyCookie().underReview) 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 &&
- MyCookie().userBean.wxOpenid.isEmpty) {
- MyTools().toPage(context, BindAlipayPage(),
- (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/订单.svg', '订单', () {
- MyTools().toPage(context, OrderPage(), (then) {
- queryPersonalInformation();
- });
- }),
- if(showRe)
- functionItem('images/svg/推荐人.svg', '推荐人', () {
- MyTools().toPage(context, ReferrerPage(), (then) {
- });
- }),
- functionItem('images/svg/绑定.svg', '提现账号', () {
- MyTools().toPage(context, BindAlipayPage(), (then) {
- queryPersonalInformation();
- });
- }),
- if(!MyCookie().underReview)functionItem('images/svg/广告.svg', '广告', () {
- MyTools().toPage(context, AdvertisingPage(), (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', '推广下载', () {
- MyTools()
- .toPage(context, PromotionDownloadPage(), (then) {});
- }),
- GestureDetector(
- onTap: () {
- checkForUpdates(context, showT: true);
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- padding: EdgeInsets.only(left: 20, right: 20),
- child: Column(
- children: [
- Row(
- children: [
- Container(
- child: SvgPicture.asset(
- 'images/svg/更新.svg',
- color: MyColors.c333333,
- ),
- margin: EdgeInsets.only(
- right: 12, top: 15, bottom: 15),
- ),
- Expanded(
- child: Text(
- '更新',
- style: TextStyle(
- color: MyColors.c333333, fontSize: 15),
- )),
- Container(
- child: Text(
- MyCookie().packageInfo.version,
- style: TextStyle(
- color: MyColors.c333333, fontSize: 15),
- ),
- margin: EdgeInsets.only(right: 10),
- ),
- SvgPicture.asset('images/svg/箭头.svg')
- ],
- ),
- Container(
- height: 1,
- color: MyColors.cEFEFEF,
- )
- ],
- ),
- ),
- ),
- 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();
- }
- bool showRe = false;
- void checkIfThereIsAShop() {
- MyDio().query({
- "key": "shop_user",
- "filters": {
- "conditions": [
- "review_state==1",
- "owner_uid==${MyCookie().getUID()}",
- "private_shop==true",
- "recommender_uid!=0"
- ]
- },
- "dims": shopUserDims,
- "paging": [1, 2000]
- }, (response, hasError) {
- if (!hasError) {
- MyShopBeanEntity entity =
- MyShopBeanEntity().fromJson(json.decode(response.data.toString()));
- if(entity.data.data==null||entity.data.data.isEmpty){
- showRe = false;
- }else{
- showRe = true;
- }
- setState(() {
- });
- }
- }, (error) { });
- }
- }
|