From ac4ba5c0982dd032884ad71caea08fc93d2f02ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8D=8E=E8=BD=A9?= <646903573@qq.com> Date: Mon, 28 Sep 2020 17:33:47 +0800 Subject: [PATCH] =?UTF-8?q?1.=E9=92=B1=E5=8C=85=20-=20=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E9=A1=B5=E9=9D=A2=202.=E8=B4=A6=E5=8D=95?= =?UTF-8?q?=E6=98=8E=E7=BB=86=20-=20=E6=9E=84=E5=BB=BA=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=203.=E6=99=BA=E8=83=BD=E7=B2=98=E8=B4=B4?= =?UTF-8?q?=E6=9D=BF=20-=20=E6=9E=84=E5=BB=BA=E5=9F=BA=E6=9C=AC=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=EF=BC=8C=E7=BC=96=E5=86=99=E5=9F=BA=E6=9C=AC=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../intellect_create.dart | 115 ++++++++ .../intellect_search_goods_dialog.dart | 246 ++++++++++++++++++ .../intellect_search_no_goods_dialog.dart | 183 +++++++++++++ .../model/Intellect_search_set_model.dart | 50 ++++ .../select_date_ym_dialog.dart | 209 +++++++++++++++ .../bil_detail_page/bil_detail_page.dart | 134 ++++++++++ .../bil_detail_page/bil_detail_page_bloc.dart | 53 ++++ .../model/bil_detail_page_model.dart | 5 + lib/pages/home_page/home_page.dart | 1 + lib/pages/main_page/main_page.dart | 18 +- lib/pages/wallet_page/wallet_page.dart | 124 +++++++-- lib/pages/wallet_page/wallet_page_bloc.dart | 24 +- lib/register.dart | 24 +- lib/utils/contants.dart | 18 ++ .../home_slide_banner/home_slide_banner.dart | 2 +- .../mine_header/mine_header_container.dart | 3 +- .../model/WalletAppbarModel.dart | 25 ++ .../wallet/wallet_appbar/wallet_appbar.dart | 34 +++ .../wallet_bil/model/wallet_bli_model.dart | 25 ++ lib/widgets/wallet/wallet_bil/wallet_bil.dart | 46 ++++ .../model/wallet_header_model.dart | 93 +++++++ .../wallet/wallet_data/wallet_data.dart | 112 +++++++- .../wallet_data/wallet_data_creater.dart | 2 +- .../model/wallet_detail_model.dart | 226 ++++++++++++++++ .../wallet/wallet_detail/wallet_detail.dart | 182 ++++++++++++- pubspec.yaml | 9 +- 26 files changed, 1908 insertions(+), 55 deletions(-) create mode 100644 lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart create mode 100644 lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart create mode 100644 lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart create mode 100644 lib/dialog/global_dialog/intellect_search_goods_dialog/model/Intellect_search_set_model.dart create mode 100644 lib/dialog/select_date_ym_dialog/select_date_ym_dialog.dart create mode 100644 lib/pages/bil_detail_page/bil_detail_page.dart create mode 100644 lib/pages/bil_detail_page/bil_detail_page_bloc.dart create mode 100644 lib/pages/bil_detail_page/model/bil_detail_page_model.dart create mode 100644 lib/utils/contants.dart create mode 100644 lib/widgets/wallet/wallet_appbar/model/WalletAppbarModel.dart create mode 100644 lib/widgets/wallet/wallet_appbar/wallet_appbar.dart create mode 100644 lib/widgets/wallet/wallet_bil/model/wallet_bli_model.dart create mode 100644 lib/widgets/wallet/wallet_bil/wallet_bil.dart create mode 100644 lib/widgets/wallet/wallet_data/model/wallet_header_model.dart create mode 100644 lib/widgets/wallet/wallet_detail/model/wallet_detail_model.dart diff --git a/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart new file mode 100644 index 0000000..283c0e7 --- /dev/null +++ b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart @@ -0,0 +1,115 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/model/Intellect_search_set_model.dart'; +import 'package:zhiying_base_widget/utils/contants.dart'; +import 'package:zhiying_comm/util/shared_prefe_util.dart'; + +import 'intellect_search_goods_dialog.dart'; +import 'intellect_search_no_goods_dialog.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:string_validator/string_validator.dart'; + +class IntellectCreate { + static IntellectSearchSetModel _setModel; + + ///判断规则 + static checkAndCreate(AppLifecycleState state, BuildContext context) async { + if (state == AppLifecycleState.resumed && + !Constants.isShowIntellectDialog) { + _requestSetData(context); + } + } + + ///请求设置参数 + static _requestSetData(BuildContext context) async { + if (_setModel == null) { + var param = {"webId": ""}; + + //请求参数 + NetUtil.request('/api/v1/cfg/app_clipboard', params: param, + onSuccess: (data) async { + print("设置参数" + data.toString()); + + ///检查是否已缓存过设置信息 + String result = await SharedPreferencesUtil.getStringValue( + Constants.spIsCacheSetModel); + _setModel = IntellectSearchSetModel.fromJson(data); + if (result.isEmpty) { + validate(context, _setModel); + } + SharedPreferencesUtil.setNetCacheResult( + Constants.spIsCacheSetModel, json.encode(data)); + }); + + ///拿缓存数据 + var cacheData = await SharedPreferencesUtil.getNetCacheResult( + Constants.spIsCacheSetModel); + ///如果存在缓存直接进入验证阶段 + if (cacheData.isNotEmpty) { + _setModel = IntellectSearchSetModel.fromJson(cacheData); + validate(context, _setModel); + } + } else { + validate(context, _setModel); + } + } + + static checkAndCreateFirst(BuildContext context) async { + ///检查规则 + IntellectCreate.checkAndCreate(AppLifecycleState.resumed, context); + } + + ///请求数据打开弹窗 + static requestDialog(BuildContext context, String content) async { + Constants.isShowIntellectDialog = true; + await showDialog(context: context, child: IntellectSearchGoodsDialog()); + Constants.isShowIntellectDialog = false; + } + + ///检查字段是否被监听 + static void validate( + BuildContext context, IntellectSearchSetModel setModel) async { + ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); + String content = data.text; + //是否监听 + if (setModel.state != "1") { + return; + } + + ///长度大小限制 + if (setModel.keywordLimitState == "1" && + (int.tryParse(setModel.keywordLimitMin) < content.length) || + (int.tryParse(setModel.keywordLimitMax) > content.length)) { + return; + } + + //是否纯数字 + if (setModel.keywordNum == "1" && isNumeric(content)) { + return; + } + + ///是否纯字母 + if (setModel.keywordAlpha == "1" && isAlpha(content)) { + return; + } + + ///是否仅包含数字和字母 + if (setModel.keywordAlphanum == "1" && isAlphanumeric(content)) { + return; + } + + ///是否包含某个排除词 + if (setModel.exclude.length > 0) { + for (var item in setModel.exclude) { + if (contains(content, item)) { + return; + } + } + } + requestDialog(context, content); + } +} diff --git a/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart new file mode 100644 index 0000000..b1ef5b7 --- /dev/null +++ b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart @@ -0,0 +1,246 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart'; +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class IntellectSearchGoodsDialog extends StatefulWidget { + @override + _IntellectSearchGoodsDialogState createState() => + _IntellectSearchGoodsDialogState(); +} + +class _IntellectSearchGoodsDialogState + extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.transparent, + body: InkWell( + onTap: () { + Navigator.of(context).pop(); + }, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + GestureDetector( + onTap: () {}, + child: Stack( + children: [ + Container( + margin: EdgeInsets.only(top: 38.h, left: 92.w, right: 92.w), + padding: EdgeInsets.only( + top: (38 + 38).h, + left: 30.w, + right: 30.w, + bottom: 48.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16)), + width: double.infinity, + child: Column( + children: [_bulidTopItem(), _buildBottomItem()], + ), + ), + Container( + height: 76.h, + child: Center( + child: Container( + color: Colors.red, + height: 76.h, + width: 216.w, + child: CachedNetworkImage( + imageUrl: "", + ), + )), + ), + ], + ), + ) + ], + ), + ), + ); + } + + _bulidTopItem() { + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + color: Colors.red, + width: 160.w, + height: 160.w, + ), + SizedBox( + width: 19.w, + ), + Expanded( + child: Container( + child: Column( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Column( + children: [ + Text( + "2020新款春款波点连衣裙新短发dfasdfas短发时代发发呆发顺丰的打算萨阿啊", + maxLines: 2, + overflow: TextOverflow.ellipsis, + style: TextStyle(color: Colors.black, fontSize: 24.sp), + ), + SizedBox( + height: 5.h, + ), + Row( + children: [ + Container( + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(2)), + padding: EdgeInsets.all(2), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + width: 30.w, + height: 30.w, + decoration: BoxDecoration(color: Colors.white), + child: Center( + child: Text( + "券", + style: TextStyle( + color: Colors.red, fontSize: 20.sp), + ), + ), + ), + Padding( + padding: const EdgeInsets.only(left: 4, right: 4), + child: Text( + "¥100", + style: TextStyle( + color: Colors.white, fontSize: 20.sp), + ), + ) + ], + ), + ), + SizedBox( + width: 12.w, + ), + Container( + decoration: BoxDecoration( + color: HexColor.fromHex("#FFFFF6C1"), + borderRadius: BorderRadius.circular(2)), + padding: EdgeInsets.all(2), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + SizedBox( + height: 30.w, + ), + Center( + child: Padding( + padding: + const EdgeInsets.only(left: 4, right: 4), + child: Text( + "预计返", + style: TextStyle( + color: Colors.deepOrangeAccent, + fontSize: 20.sp), + ), + ), + ) + ], + ), + ) + ], + ), + ], + ), + SizedBox( + height: 10.h, + ), + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.only(bottom: 2), + child: Text( + "券后", + style: TextStyle(fontSize: 20.sp, color: Colors.red), + ), + ), + Padding( + padding: + const EdgeInsets.only(bottom: 2, left: 4, right: 4), + child: Text( + "¥", + style: TextStyle(fontSize: 20.sp, color: Colors.red), + ), + ), + Text( + "999", + style: TextStyle( + fontSize: 32.sp, + color: Colors.red, + ), + ) + ], + ) + ], + ), + )) + ], + ); + } + + _buildBottomItem() { + return Column( + children: [ + SizedBox( + height: 24, + ), + Row( + children: [ + Expanded( + child: Container( + margin: EdgeInsets.only(left: 20.w, right: 20.w), + decoration: BoxDecoration( + color: Colors.red, borderRadius: BorderRadius.circular(50)), + child: Center( + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Text( + "合法化 ", + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + )), + )) + ], + ), + SizedBox( + height: 16, + ), + Row( + children: [ + Expanded( + child: Container( + margin: EdgeInsets.only(left: 20.w, right: 20.w), + decoration: BoxDecoration( + color: Colors.red, borderRadius: BorderRadius.circular(50)), + child: Center( + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Text( + "合法化 ", + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + )), + )) + ], + ) + ], + ); + } +} diff --git a/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart new file mode 100644 index 0000000..b449217 --- /dev/null +++ b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart @@ -0,0 +1,183 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart'; +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class IntellectSearchNoGoodsDialog extends StatefulWidget { + @override + _IntellectSearchNoGoodsDialogState createState() => + _IntellectSearchNoGoodsDialogState(); +} + +class _IntellectSearchNoGoodsDialogState + extends State { + TextEditingController _textEditingController; + + @override + void initState() { + _textEditingController = TextEditingController(); + _getClipBoardData(); + super.initState(); + } + + ///获取粘贴板内容 + _getClipBoardData() async { + ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); + _textEditingController.text = data.text; + setState(() {}); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.transparent, + body: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Stack( + children: [ + Container( + margin: EdgeInsets.only(top: 38.h, left: 92.w, right: 92.w), + padding: EdgeInsets.only( + top: (38 + 15).h, left: 30.w, right: 30.w, bottom: 48.h), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16)), + width: double.infinity, + child: Column( + children: [_buildTopItem(), _buildBottomItem()], + ), + ), + Container( + height: 76.h, + child: Center( + child: Container( + color: Colors.red, + height: 76.h, + width: 216.w, + child: CachedNetworkImage( + imageUrl: "", + ), + )), + ), + ], + ) + ], + ), + ); + } + + _buildTopItem() { + return Container( + decoration: BoxDecoration(), + child: Column( + children: [ + Text( + "猜你要搜索以下商品", + style: TextStyle(color: Colors.red, fontSize: 30.sp), + ), + Container( + margin: EdgeInsets.only(top: 12), + decoration: BoxDecoration( + color: Colors.deepOrangeAccent, + borderRadius: BorderRadius.circular(10)), + child: TextField( + controller: _textEditingController, + textAlign: TextAlign.start, + decoration: InputDecoration( + contentPadding: EdgeInsets.only(left: 10, top: 10, bottom: 4), + border: InputBorder.none, + ), + maxLines: 5, + ), + ) + ], + ), + ); + } + + _buildBottomItem() { + return Column( + children: [ + SizedBox( + height: 24, + ), + Row( + children: [ + Expanded( + child: Container( + decoration: BoxDecoration( + color: Colors.red, borderRadius: BorderRadius.circular(50)), + child: Center( + child: Padding( + padding: const EdgeInsets.all(12.0), + child: Text( + "立即搜索 ", + style: TextStyle(color: Colors.white, fontSize: 24.sp), + ), + )), + )) + ], + ), + SizedBox( + height: 16, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + height: 1, + width: 137.w, + color: Colors.deepOrange, + ), + Text("搜索平台"), + Container( + height: 1, + width: 137.w, + color: Colors.deepOrange, + ), + ], + ), + SizedBox( + height: 24, + ), + Container( + height: 100.w, + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: 10, + itemBuilder: _buildBottomListItem), + ) + ], + ); + } + + Widget _buildBottomListItem(BuildContext context, int index) { + return Container( + margin: EdgeInsets.only(left: 11,right: 11), + child: Column( + children: [ + Container( + color: Colors.deepOrange, + child: Image.network( + "", + width: 60.w, + height: 60.w, + fit: BoxFit.fill, + ), + ), + SizedBox( + height: 2, + ), + Text( + "淘宝", + style: TextStyle(fontSize: 22.sp), + ) + ], + ), + ); + } +} diff --git a/lib/dialog/global_dialog/intellect_search_goods_dialog/model/Intellect_search_set_model.dart b/lib/dialog/global_dialog/intellect_search_goods_dialog/model/Intellect_search_set_model.dart new file mode 100644 index 0000000..f314b53 --- /dev/null +++ b/lib/dialog/global_dialog/intellect_search_goods_dialog/model/Intellect_search_set_model.dart @@ -0,0 +1,50 @@ +///智能粘贴板设置参数 +///杨华轩 +class IntellectSearchSetModel { + List exclude; + String keywordAlpha; + String keywordAlphanum; + String keywordLimitMax; + String keywordLimitMin; + String keywordLimitState; + String keywordNum; + List pvd; + String state; + + IntellectSearchSetModel( + {this.exclude, + this.keywordAlpha, + this.keywordAlphanum, + this.keywordLimitMax, + this.keywordLimitMin, + this.keywordLimitState, + this.keywordNum, + this.pvd, + this.state}); + + IntellectSearchSetModel.fromJson(Map json) { + exclude = json['exclude'].cast(); + keywordAlpha = json['keyword_alpha'].toString(); + keywordAlphanum = json['keyword_alphanum'].toString(); + keywordLimitMax = json['keyword_limit_max'].toString(); + keywordLimitMin = json['keyword_limit_min'].toString(); + keywordLimitState = json['keyword_limit_state'].toString(); + keywordNum = json['keyword_num'].toString(); + pvd = json['pvd'].cast(); + state = json['state'].toString(); + } + + Map toJson() { + final Map data = new Map(); + data['exclude'] = this.exclude; + data['keyword_alpha'] = this.keywordAlpha; + data['keyword_alphanum'] = this.keywordAlphanum; + data['keyword_limit_max'] = this.keywordLimitMax; + data['keyword_limit_min'] = this.keywordLimitMin; + data['keyword_limit_state'] = this.keywordLimitState; + data['keyword_num'] = this.keywordNum; + data['pvd'] = this.pvd; + data['state'] = this.state; + return data; + } +} diff --git a/lib/dialog/select_date_ym_dialog/select_date_ym_dialog.dart b/lib/dialog/select_date_ym_dialog/select_date_ym_dialog.dart new file mode 100644 index 0000000..c5bb69a --- /dev/null +++ b/lib/dialog/select_date_ym_dialog/select_date_ym_dialog.dart @@ -0,0 +1,209 @@ +import 'dart:async'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:zhiying_comm/util/extension/color.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class SelectDateYMDialog extends StatefulWidget { + int currentYear; + + int currentMonth; + + SelectDateYMDialog({Key key, this.currentYear = 0, this.currentMonth = 0}) + : super(key: key) { + var date = DateTime.now(); + if (currentYear == 0) { + currentYear = date.year; + } + if (currentMonth == 0) { + currentMonth = date.month; + } + } + + @override + _SelectDateYMDialogState createState() => _SelectDateYMDialogState(); +} + +class _SelectDateYMDialogState extends State + with TickerProviderStateMixin { + List yearDate = List(); + List monthDate = List(); + + int selectYearIndex = 0; + + int selectMonthIndex = 0; + + ScrollController _yearScrollController; + + ScrollController _monthScrollController; + + double _containerHeight = 0; + AnimationController _animationController; + Animation _animation; + + @override + void initState() { + _monthScrollController = FixedExtentScrollController(); + for (int index = 0; index < 200; index++) { + yearDate.add(index + 1900); + if (index + 1900 == widget.currentYear) { + selectYearIndex = index; + } + } + + for (int index = 0; index < 12; index++) { + monthDate.add(index + 1); + if (index + 1 == widget.currentMonth) { + selectMonthIndex = index; + } + } + _yearScrollController = + FixedExtentScrollController(initialItem: selectYearIndex); + + _monthScrollController = + FixedExtentScrollController(initialItem: selectMonthIndex); + + _animationController = new AnimationController( + duration: const Duration(milliseconds: 500), vsync: this); + final CurvedAnimation curve = + new CurvedAnimation(parent: _animationController, curve: Curves.ease); + _animation = new Tween(begin: 0.0, end: 250.0).animate(curve); + _animation.addListener(() { + setState(() {}); + }); + _animationController.forward(); + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Colors.transparent, + body: Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Container( + height: 56, + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.only( + topLeft: Radius.circular(20), + topRight: Radius.circular(20))), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + GestureDetector( + child: Padding( + padding: const EdgeInsets.only( + left: 16, top: 8, bottom: 8, right: 16), + child: Text( + "取消", + style: TextStyle( + color: HexColor.fromHex("#FF999999"), + fontSize: 35.sp), + ), + ), + onTap: () { + Navigator.pop(context); + }, + ), + Text("选择日期"), + GestureDetector( + child: Padding( + padding: const EdgeInsets.only( + right: 16, left: 16, bottom: 8, top: 8), + child: Text( + "确定", + style: TextStyle( + color: HexColor.fromHex("#FFFF4242"), + fontSize: 35.sp), + ), + ), + onTap: () { + Navigator.of(context).pop({ + "year": yearDate[selectYearIndex].toString(), + "month": monthDate[selectMonthIndex].toString() + }); + }, + ) + ], + ), + ), + Container( + height: _animation.value, + color: Colors.white, + child: Row( + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: CupertinoPicker( + scrollController: _yearScrollController, + backgroundColor: Colors.white, + itemExtent: 40, + onSelectedItemChanged: (index) { + selectYearIndex = index; + setState(() {}); + }, + children: _buildItem(context))), + flex: 1, + ), + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: CupertinoPicker( + scrollController: _monthScrollController, + backgroundColor: Colors.white, + itemExtent: 40, + onSelectedItemChanged: (index) { + selectMonthIndex = index; + setState(() {}); + }, + children: _buildItem2(context), + )), + flex: 1, + ) + ], + ), + ) + ], + ), + ); + } + + _buildItem(BuildContext context) { + List listWidget = List(); + + for (int index = 0; index < yearDate.length; index++) { + listWidget.add(Container( + height: 40, + child: Center( + child: Text( + yearDate[index].toString() + "", + style: TextStyle( + color: + index == selectYearIndex ? Colors.redAccent : Colors.black26), + )), + )); + } + return listWidget; + } + + _buildItem2(BuildContext context) { + List listWidget = List(); + + for (int index = 0; index < monthDate.length; index++) { + listWidget.add(Container( + height: 40, + child: Center( + child: Text(monthDate[index].toString() + "月", + style: TextStyle( + color: index == selectMonthIndex + ? Colors.redAccent + : Colors.black26))))); + } + return listWidget; + } +} diff --git a/lib/pages/bil_detail_page/bil_detail_page.dart b/lib/pages/bil_detail_page/bil_detail_page.dart new file mode 100644 index 0000000..0a30322 --- /dev/null +++ b/lib/pages/bil_detail_page/bil_detail_page.dart @@ -0,0 +1,134 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; +import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:zhiying_base_widget/dialog/select_date_ym_dialog/select_date_ym_dialog.dart'; +import 'package:zhiying_base_widget/pages/bil_detail_page/bil_detail_page_bloc.dart'; +import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; +import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; +import 'package:zhiying_base_widget/utils/contants.dart'; +import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/util/custom_sliver_persistent_header_delegate.dart'; + +class BilDetailPage extends StatefulWidget { + final Map data; + + const BilDetailPage(this.data, {Key key}) : super(key: key); + + @override + _BilDetailPageState createState() => _BilDetailPageState(); +} + +class _BilDetailPageState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: Color(0xfff9f9f9), + body: MultiProvider( + providers: [ + ChangeNotifierProvider.value(value: MainPageNotifier()), + ChangeNotifierProvider.value(value: MainPageBgNotifier()), + ], + child: BlocProvider( + bloc: BilDetailPageBloc(), + child: BilDetailPageContainer(data: widget.data), + ), + ), + ); + } +} + +class BilDetailPageContainer extends StatefulWidget { + final Map data; + + const BilDetailPageContainer({Key key, this.data}) : super(key: key); + + @override + _BilDetailPageContainerState createState() => _BilDetailPageContainerState(); +} + +class _BilDetailPageContainerState extends State { + BilDetailPageBloc _bloc; + + String showDate; + + @override + void initState() { + _bloc = BlocProvider.of(context); + showDate=DateForm DateTime.now() + super.initState(); + } + + @override + Widget build(BuildContext context) { + return StreamBuilder( + builder: (context, sny) { + return Scaffold( + appBar: AppBar( + centerTitle: true, + title: Text("明细"), + ), + body: Container( + child: ListView( + shrinkWrap: true, + children: [ + _buildType(), + ], + ), + ), + ); + }, + ); + } + + _buildType() { + return Row( + children: [ + SizedBox(width: 12.5), + InkWell( + onTap: (){ + ///显示日期选择弹窗 + _selectDate(); + }, + child: Padding( + padding: const EdgeInsets.only(top: 8,bottom: 8), + child: Text("2020-08"), + ), + ), + Icon(Icons.arrow_drop_down), + Expanded( + child: Container( + height: 50, + child: ListView.builder( + scrollDirection: Axis.horizontal, + shrinkWrap: true, + itemCount: 3, + itemBuilder: (context, index) { + return Container( + margin: + EdgeInsets.only(top: 10, left: 8, right: 8, bottom: 10), + decoration: BoxDecoration( + color: Colors.grey[200], + borderRadius: BorderRadius.circular(50)), + child: Padding( + padding: const EdgeInsets.only(left: 16, right: 16), + child: Center( + child: Text( + "推广", + style: TextStyle(color: Colors.grey), + )), + ), + ); + }), + )) + ], + ); + } + + void _selectDate() { + showDialog(context: context, builder: (context)=>SelectDateYMDialog()); + } +} diff --git a/lib/pages/bil_detail_page/bil_detail_page_bloc.dart b/lib/pages/bil_detail_page/bil_detail_page_bloc.dart new file mode 100644 index 0000000..9623a0e --- /dev/null +++ b/lib/pages/bil_detail_page/bil_detail_page_bloc.dart @@ -0,0 +1,53 @@ +import 'dart:async'; + +import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class BilDetailPageBloc extends BlocBase { + List> _tabs = List(); + + StreamController>> _tabController = + StreamController>>(); + + Stream>> get outData => _tabController.stream; + + + + @override + void dispose() { + _tabController.close(); + _tabController = null; + } + + loadData(String skipIdentifier) { + + NetUtil.request('/api/v1/mod/${skipIdentifier}', method: NetMethod.GET, + onCache: (data) { + _loadData(data); + }, onSuccess: (data) { + _loadData(data); + }); + } + + void refresh() {} + + ///处理加载的数据 + void _loadData(data) { + print(data["mod_lis"]); + var list = List.from(data["mod_list"]).map((v) { + return Map.from(v); + }).toList(); + _tabController.add(list); + } + + void dateChange(DateChangeEvent dateChangeEvent){ + ///日期变更后 + + } + +} + +class DateChangeEvent{ + String date; + DateChangeEvent(this.date); +} \ No newline at end of file diff --git a/lib/pages/bil_detail_page/model/bil_detail_page_model.dart b/lib/pages/bil_detail_page/model/bil_detail_page_model.dart new file mode 100644 index 0000000..2665e85 --- /dev/null +++ b/lib/pages/bil_detail_page/model/bil_detail_page_model.dart @@ -0,0 +1,5 @@ + + +class BilDetailPageModel{ + +} \ No newline at end of file diff --git a/lib/pages/home_page/home_page.dart b/lib/pages/home_page/home_page.dart index 09bfad1..41d0c9f 100644 --- a/lib/pages/home_page/home_page.dart +++ b/lib/pages/home_page/home_page.dart @@ -36,6 +36,7 @@ class _HomePageState extends State { @override Widget build(BuildContext context) { + ScreenUtil.init(context, width: 750, height: 1334); print('home_page build'); List> tabs = _data; if (tabs == null || tabs.length == 0) { diff --git a/lib/pages/main_page/main_page.dart b/lib/pages/main_page/main_page.dart index 3057731..3dfde50 100644 --- a/lib/pages/main_page/main_page.dart +++ b/lib/pages/main_page/main_page.dart @@ -2,9 +2,13 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; +import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart'; +import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart'; +import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart'; import 'package:zhiying_base_widget/pages/main_page/main_page_bloc.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; +import 'package:zhiying_base_widget/utils/contants.dart'; import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; import 'package:zhiying_comm/util/base_bloc.dart'; @@ -47,7 +51,8 @@ class _MainPageContainer extends StatefulWidget { _MainPageContainerState createState() => _MainPageContainerState(); } -class _MainPageContainerState extends State<_MainPageContainer> { +class _MainPageContainerState extends State<_MainPageContainer> + with WidgetsBindingObserver { bool _isEnded = false; ScrollController _controller = ScrollController(); MainPageBloc _bloc; @@ -62,9 +67,17 @@ class _MainPageContainerState extends State<_MainPageContainer> { // _refreshController.loadComplete(); } + @override + void didChangeAppLifecycleState(AppLifecycleState state) async { + ///智能粘贴板 + // IntellectCreate.checkAndCreate(state, context); + super.didChangeAppLifecycleState(state); + } + @override void dispose() { _controller.dispose(); + WidgetsBinding.instance.removeObserver(this); super.dispose(); } @@ -88,6 +101,9 @@ class _MainPageContainerState extends State<_MainPageContainer> { Provider.of(context, listen: false).reset(); } }); + ///监听app生命周期变化 + // WidgetsBinding.instance.addObserver(this); + IntellectCreate.checkAndCreateFirst(context); super.initState(); } diff --git a/lib/pages/wallet_page/wallet_page.dart b/lib/pages/wallet_page/wallet_page.dart index df95e6c..b7e7ae2 100644 --- a/lib/pages/wallet_page/wallet_page.dart +++ b/lib/pages/wallet_page/wallet_page.dart @@ -4,10 +4,20 @@ import 'package:provider/provider.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_bg_notifier.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; +import 'package:zhiying_base_widget/utils/contants.dart'; import 'package:zhiying_base_widget/widgets/others/mine_header_bg_widget.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; +import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/util/custom_sliver_persistent_header_delegate.dart'; + +import 'wallet_page_bloc.dart'; +import 'wallet_page_bloc.dart'; class WalletPage extends StatefulWidget { + final Map data; + + const WalletPage({Key key, this.data}) : super(key: key); + @override _WalletPageState createState() => _WalletPageState(); } @@ -22,14 +32,19 @@ class _WalletPageState extends State { ChangeNotifierProvider.value(value: MainPageNotifier()), ChangeNotifierProvider.value(value: MainPageBgNotifier()), ], - child: _WalletPageContainer(), + child: BlocProvider( + bloc: WalletPageBloc(), + child: _WalletPageContainer(data: widget.data), + ), ), ); } } class _WalletPageContainer extends StatefulWidget { - _WalletPageContainer({Key key}) : super(key: key); + _WalletPageContainer({Key key, this.data}) : super(key: key); + + final Map data; @override _WalletPageContainerState createState() => _WalletPageContainerState(); @@ -40,8 +55,14 @@ class _WalletPageContainerState extends State<_WalletPageContainer> { final RefreshController _refreshController = RefreshController(initialRefresh: false); + WalletPageBloc _pageBloc; + @override void initState() { + _pageBloc = BlocProvider.of(context); + if (widget.data.containsKey(Constants.SkipIdentifierName)) { + _pageBloc.loadData(widget.data[Constants.SkipIdentifierName]); + } super.initState(); } @@ -53,6 +74,7 @@ class _WalletPageContainerState extends State<_WalletPageContainer> { @override Widget build(BuildContext context) { + ScreenUtil.init(context, width: 750, height: 1334); return SmartRefresher( controller: _refreshController, enablePullDown: false, @@ -67,39 +89,87 @@ class _WalletPageContainerState extends State<_WalletPageContainer> { MineHeaderBgWidget( controller: _controller, ), - CustomScrollView( - slivers: _createContent(context), - ), + StreamBuilder( + stream: _pageBloc.outData, + builder: (context, asyncSnapshot) { + var model = asyncSnapshot.data; + return CustomScrollView( + slivers: _createContent(context, model), + ); + }, + ) ], ), ), ); } - List _createContent(BuildContext context) { + List _createContent( + BuildContext context, List> model) { List list = List(); + if (model == null) { + list.addAll(WidgetFactory.create( + 'normal_nav', + isSliver: true, + model: Map(), + )); + list.addAll(WidgetFactory.create( + 'wallet_data', + isSliver: true, + model: Map(), + )); + list.addAll(WidgetFactory.create( + 'wallet_detail', + isSliver: true, + model: Map(), + )); - list.addAll(WidgetFactory.create( - 'normal_nav', - isSliver: true, - model: Map(), - )); - list.addAll(WidgetFactory.create( - 'wallet_data', - isSliver: true, - model: Map(), - )); - list.addAll(WidgetFactory.create( - 'wallet_detail', - isSliver: true, - model: Map(), - )); - - list.addAll(WidgetFactory.create( - 'wallet_income', - isSliver: true, - model: Map(), - )); + list.addAll(WidgetFactory.create( + 'wallet_income', + isSliver: true, + model: Map(), + )); + } else { + for (var item in model) { + WidgetModel widgetModel = + WidgetModel.fromJson(Map.from(item)); + if (item.containsKey("mod_name")&&item['mod_name']=="my_wallet_appbar") { + list.add(SliverPersistentHeader( + delegate: _SilverAppBarDelegate(context, + WidgetFactory.create(widgetModel.modName, + isSliver: false, model: item)[0]),pinned: true,)); + continue; + } + list.addAll(WidgetFactory.create(widgetModel.modName, + isSliver: true, model: item)); + } + } return list; } } + +class _SilverAppBarDelegate extends SliverPersistentHeaderDelegate { + _SilverAppBarDelegate(BuildContext context,this.child){ + this.context=context; + } + BuildContext context; + final Widget child; + + @override + double get minExtent => MediaQuery.of(context).padding.top+44; + + @override + double get maxExtent => MediaQuery.of(context).padding.top+44; + + @override + Widget build( + BuildContext context, double shrinkOffset, bool overlapsContent) { + return child; + + } + + @override + bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) { + return false; + } +} diff --git a/lib/pages/wallet_page/wallet_page_bloc.dart b/lib/pages/wallet_page/wallet_page_bloc.dart index af99197..d1bf439 100644 --- a/lib/pages/wallet_page/wallet_page_bloc.dart +++ b/lib/pages/wallet_page/wallet_page_bloc.dart @@ -17,13 +17,23 @@ class WalletPageBloc extends BlocBase { _tabController = null; } - void refresh() { - NetUtil.request('/api/v1/config.json', onSuccess: (data) { - List list = data; - _tabs = list.map((item) { - return Map.from(item); - }).toList(); - _tabController.add(_tabs); + loadData(String skipIdentifier) { + NetUtil.request('/api/v1/mod/${skipIdentifier}', method: NetMethod.GET, + onCache: (data) { + _loadData(data); + }, onSuccess: (data) { + _loadData(data); }); } + + void refresh() {} + + ///处理加载的数据 + void _loadData(data) { + print(data["mod_lis"]); + var list = List.from(data["mod_list"]).map((v) { + return Map.from(v); + }).toList(); + _tabController.add(list); + } } diff --git a/lib/register.dart b/lib/register.dart index 31f58a2..16390b2 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -1,5 +1,7 @@ import 'package:sharesdk_plugin/sharesdk_plugin.dart'; +import 'package:zhiying_base_widget/pages/bil_detail_page/bil_detail_page.dart'; import 'package:zhiying_base_widget/pages/favorite_page/favorite_page.dart'; +import 'package:flutter/cupertino.dart'; import 'package:zhiying_base_widget/pages/goods_details_page/goods_details_page.dart'; import 'package:zhiying_base_widget/pages/invited_friends/invited_friends.dart'; import 'package:zhiying_base_widget/pages/launch_page/launch_page.dart'; @@ -34,6 +36,8 @@ import 'package:zhiying_base_widget/widgets/others/normal_nav/normal_nav_creater import 'package:zhiying_base_widget/widgets/search/appbar/search_appbar_creater.dart'; import 'package:zhiying_base_widget/widgets/search/input/search_input_creater.dart'; import 'package:zhiying_base_widget/widgets/search/tabbar/search_tab_creater.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_appbar/wallet_appbar.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_bil/wallet_bil.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income.dart'; @@ -79,7 +83,8 @@ class BaseWidgetRegister { PageFactory.regist('homePage', (model) => LaunchPage()); PageFactory.regist('pub.flutter.index', (model) => MainPage(model)); PageFactory.regist('pub.flutter.profile', (model) => MainPage(model)); - PageFactory.regist('pub.flutter.my_wallet', (model) => WalletPage()); + PageFactory.regist( + 'pub.flutter.my_wallet', (model) => BilDetailPage(model)); PageFactory.regist('goods_details', (model) => GoodsDetailsPage(model)); PageFactory.regist('sreach', (model) => SearchPage(model)); PageFactory.regist('sreach_result', (model) => SreachResultPage()); @@ -206,16 +211,23 @@ class BaseWidgetRegister { // ==================== 钱包 WidgetFactory.regist( - 'wallet_data', DefaultWidgetCreater((model) => WalletData())); + 'my_wallet_appbar', + DefaultWidgetCreater((model) => WalletAppbar( + data: model, + ))); + WidgetFactory.regist( + 'my_wallet_header', DefaultWidgetCreater((model) => WalletData(model))); + WidgetFactory.regist( + 'my_wallet_bil', DefaultWidgetCreater((model) => WalletBil(model))); // WidgetFactory.regist( // 'wallet_detail', DefaultWidgetCreater((model) => WalletDetail())); // WidgetFactory.regist('wallet_detail', HomeAuthCreater()); - WidgetFactory.regist( - 'wallet_data', DefaultWidgetCreater((model) => WalletData())); - WidgetFactory.regist( - 'wallet_detail', DefaultWidgetCreater((model) => WalletDetail())); + WidgetFactory.regist('my_wallet_providers', + DefaultWidgetCreater((model) => WalletDetail(model))); WidgetFactory.regist( 'wallet_income', DefaultWidgetCreater((model) => WalletIncome())); + + //======================= 账单明细 } } diff --git a/lib/utils/contants.dart b/lib/utils/contants.dart new file mode 100644 index 0000000..69b4250 --- /dev/null +++ b/lib/utils/contants.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; + +///通用配置,避免一些多次重复的字符串被写在代码中 +class Constants { + ///获取模块类型 + static const String SkipIdentifierName = "skip_identifier"; + ///全局context + + //==============================智能粘贴版===================================start + static BuildContext context; + ///智能搜索版是否弹起 + static bool isShowIntellectDialog=false; + ///是否缓存设置信息 + static String spIsCacheSetModel="spIsCacheSetModel"; + + //==============================智能粘贴版===================================end + +} diff --git a/lib/widgets/home/home_slide_banner/home_slide_banner.dart b/lib/widgets/home/home_slide_banner/home_slide_banner.dart index c959382..24a51cf 100644 --- a/lib/widgets/home/home_slide_banner/home_slide_banner.dart +++ b/lib/widgets/home/home_slide_banner/home_slide_banner.dart @@ -100,7 +100,7 @@ class _HomeSlideBannerContainerState extends State { onTap: (index) => _itemOnClick(datas.index_carousel_list[index]), pagination: _getSwiperStyleByType(datas, datas?.index_carousel_list?.length ?? 0), onIndexChanged: (index) { - print('切换下一页'); + //print('切换下一页'); Provider.of(context, listen: false).switchBg(Container( width: double.infinity, height: 200, diff --git a/lib/widgets/mine/mine_header/mine_header_container.dart b/lib/widgets/mine/mine_header/mine_header_container.dart index 14cfc71..1e9513c 100644 --- a/lib/widgets/mine/mine_header/mine_header_container.dart +++ b/lib/widgets/mine/mine_header/mine_header_container.dart @@ -64,7 +64,8 @@ class _MineHeaderContainerState extends State { ), ), onTap: () async { - await RouterUtil.route(SkipModel.fromJson(widget.json), widget.json, context); + await RouterUtil.route(SkipModel.fromJson(widget.json), + widget.json, context); _bloc.loadData(); }, ), diff --git a/lib/widgets/wallet/wallet_appbar/model/WalletAppbarModel.dart b/lib/widgets/wallet/wallet_appbar/model/WalletAppbarModel.dart new file mode 100644 index 0000000..1268007 --- /dev/null +++ b/lib/widgets/wallet/wallet_appbar/model/WalletAppbarModel.dart @@ -0,0 +1,25 @@ +class WalletAppbarModel { + String appBarName; + String appBarNameColor; + String appBarBgColor; + String bgImg; + + WalletAppbarModel( + {this.appBarName, this.appBarNameColor, this.appBarBgColor, this.bgImg}); + + WalletAppbarModel.fromJson(Map json) { + appBarName = json['app_bar_name']; + appBarNameColor = json['app_bar_name_color']; + appBarBgColor = json['app_bar_bg_color']; + bgImg = json['bg_img']; + } + + Map toJson() { + final Map data = new Map(); + data['app_bar_name'] = this.appBarName; + data['app_bar_name_color'] = this.appBarNameColor; + data['app_bar_bg_color'] = this.appBarBgColor; + data['bg_img'] = this.bgImg; + return data; + } +} diff --git a/lib/widgets/wallet/wallet_appbar/wallet_appbar.dart b/lib/widgets/wallet/wallet_appbar/wallet_appbar.dart new file mode 100644 index 0000000..718950b --- /dev/null +++ b/lib/widgets/wallet/wallet_appbar/wallet_appbar.dart @@ -0,0 +1,34 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_appbar/model/WalletAppbarModel.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class WalletAppbar extends StatelessWidget { + final Map data; + + const WalletAppbar({Key key, this.data}) : super(key: key); + + @override + Widget build(BuildContext context) { + var model = WalletAppbarModel.fromJson(json.decode(data['data'])); + return Container( + height: MediaQuery.of(context).padding.top + 56, + child: AppBar( + leading: Navigator.canPop(context) + ? IconButton( + icon: Icon(Icons.arrow_back_ios), + onPressed: () { + Navigator.of(context).pop(); + }) + : Container(), + backgroundColor: HexColor.fromHex(model.appBarBgColor), + centerTitle: true, + title: Text( + model.appBarName, + style: TextStyle(color: HexColor.fromHex(model.appBarNameColor)), + ), + ), + ); + } +} diff --git a/lib/widgets/wallet/wallet_bil/model/wallet_bli_model.dart b/lib/widgets/wallet/wallet_bil/model/wallet_bli_model.dart new file mode 100644 index 0000000..bc0767c --- /dev/null +++ b/lib/widgets/wallet/wallet_bil/model/wallet_bli_model.dart @@ -0,0 +1,25 @@ +class WalletBilModel { + String bilText; + String bilIcon; + String skipText; + String skipIdentifier; + + WalletBilModel( + {this.bilText, this.bilIcon, this.skipText, this.skipIdentifier}); + + WalletBilModel.fromJson(Map json) { + bilText = json['bil_text']; + bilIcon = json['bil_icon']; + skipText = json['skip_text']; + skipIdentifier = json['skip_identifier']; + } + + Map toJson() { + final Map data = new Map(); + data['bil_text'] = this.bilText; + data['bil_icon'] = this.bilIcon; + data['skip_text'] = this.skipText; + data['skip_identifier'] = this.skipIdentifier; + return data; + } +} diff --git a/lib/widgets/wallet/wallet_bil/wallet_bil.dart b/lib/widgets/wallet/wallet_bil/wallet_bil.dart new file mode 100644 index 0000000..613f1f3 --- /dev/null +++ b/lib/widgets/wallet/wallet_bil/wallet_bil.dart @@ -0,0 +1,46 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_bil/model/wallet_bli_model.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_income/wallet_income_sk.dart'; + +import 'package:zhiying_comm/zhiying_comm.dart'; + +///查看明细部件 +class WalletBil extends StatelessWidget { + Map data; + + WalletBil(this.data, {Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + WalletBilModel model; + if (data != null) { + model = WalletBilModel.fromJson(json.decode(data['data'])); + } + return data == null + ? WalletIncomeSkeleton() + : Container( + decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.circular(8)), + margin: EdgeInsets.only(left: 12.5, right: 12.5,top: 10), + child: ListTile( + title: Row( + mainAxisSize: MainAxisSize.min, + children: [ + CachedNetworkImage( + imageUrl: model.bilIcon, + width: 36.w, + height: 36.w, + fit: BoxFit.fill, + ), + SizedBox(width: 15.w,), + Text(model.bilText,style: TextStyle(fontSize: 24.sp),), + ], + ), + trailing: InkWell(child: Text(model.skipText,style: TextStyle(color: Colors.grey),),onTap: (){ + ///跳转??? + },), + )); + } +} diff --git a/lib/widgets/wallet/wallet_data/model/wallet_header_model.dart b/lib/widgets/wallet/wallet_data/model/wallet_header_model.dart new file mode 100644 index 0000000..4fbd0a9 --- /dev/null +++ b/lib/widgets/wallet/wallet_data/model/wallet_header_model.dart @@ -0,0 +1,93 @@ +class WalletHeaderModel { + String headerImg; + String headerAvatar; + String headerCashOutText; + String headerCashOutTextColor; + String headerCashOutBtnImg; + List headerBottomList; + + WalletHeaderModel( + {this.headerImg, + this.headerAvatar, + this.headerCashOutText, + this.headerCashOutTextColor, + this.headerCashOutBtnImg, + this.headerBottomList}); + + WalletHeaderModel.fromJson(Map json) { + headerImg = json['header_img']; + headerAvatar = json['header_avatar']; + headerCashOutText = json['header_cash_out_text']; + headerCashOutTextColor = json['header_cash_out_text_color']; + headerCashOutBtnImg = json['header_cash_out_btn_img']; + if (json['header_bottom_list'] != null) { + headerBottomList = new List(); + json['header_bottom_list'].forEach((v) { + headerBottomList.add(new HeaderBottomList.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['header_img'] = this.headerImg; + data['header_avatar'] = this.headerAvatar; + data['header_cash_out_text'] = this.headerCashOutText; + data['header_cash_out_text_color'] = this.headerCashOutTextColor; + data['header_cash_out_btn_img'] = this.headerCashOutBtnImg; + if (this.headerBottomList != null) { + data['header_bottom_list'] = + this.headerBottomList.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class HeaderBottomList { + String totalText; + String totalTextColor; + String totalValueColor; + String cashOutText; + String cashOutTextColor; + String cashOutValueColor; + String unfinalText; + String unfinalTextColor; + String unfinalValueColor; + + HeaderBottomList( + {this.totalText, + this.totalTextColor, + this.totalValueColor, + this.cashOutText, + this.cashOutTextColor, + this.cashOutValueColor, + this.unfinalText, + this.unfinalTextColor, + this.unfinalValueColor}); + + HeaderBottomList.fromJson(Map json) { + totalText = json['total_text']; + totalTextColor = json['total_text_color']; + totalValueColor = json['total_value_color']; + cashOutText = json['cash_out_text']; + cashOutTextColor = json['cash_out_text_color']; + cashOutValueColor = json['cash_out_value_color']; + unfinalText = json['unfinal_text']; + unfinalTextColor = json['unfinal_text_color']; + unfinalValueColor = json['unfinal_value_color']; + } + + Map toJson() { + final Map data = new Map(); + data['total_text'] = this.totalText; + data['total_text_color'] = this.totalTextColor; + data['total_value_color'] = this.totalValueColor; + data['cash_out_text'] = this.cashOutText; + data['cash_out_text_color'] = this.cashOutTextColor; + data['cash_out_value_color'] = this.cashOutValueColor; + data['unfinal_text'] = this.unfinalText; + data['unfinal_text_color'] = this.unfinalTextColor; + data['unfinal_value_color'] = this.unfinalValueColor; + return data; + } +} diff --git a/lib/widgets/wallet/wallet_data/wallet_data.dart b/lib/widgets/wallet/wallet_data/wallet_data.dart index 806ca4c..eb1a4a3 100644 --- a/lib/widgets/wallet/wallet_data/wallet_data.dart +++ b/lib/widgets/wallet/wallet_data/wallet_data.dart @@ -1,13 +1,123 @@ +import 'dart:convert'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_data/model/wallet_header_model.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_data/wallet_data_sk.dart'; +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; class WalletData extends StatelessWidget { + final Map data; + + const WalletData(this.data, {Key key}) : super(key: key); + @override Widget build(BuildContext context) { + + print(data); + Map temp = json.decode(data['data']); + var model = WalletHeaderModel.fromJson(temp); return Container( width: double.infinity, - child: WalletDataSkeleton(), + child: data == null + ? WalletDataSkeleton() + : Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5,top: 10), + padding: EdgeInsets.only(left: 36.w, right: 26.w), + decoration: BoxDecoration( + image: DecorationImage( + image: CachedNetworkImageProvider(model.headerImg),fit: BoxFit.fill)), + height: 290.h, + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + CachedNetworkImage( + imageUrl: model.headerAvatar, + height: 66.h, + width: 52.w, + ), + Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + model.headerCashOutText, + style: TextStyle( + fontSize: 25.sp, + color: HexColor.fromHex( + model.headerCashOutTextColor)), + ), + Text( + "没数据", + style: TextStyle( + fontSize: 25.sp, + color: HexColor.fromHex( + model.headerCashOutTextColor)), + ), + ], + ), + ) + ], + ), + GestureDetector( + child: Container( + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(10), + image: DecorationImage( + image: CachedNetworkImageProvider(""), + fit: BoxFit.fill)), + child: Padding( + padding: EdgeInsets.only( + left: 29.w, + right: 29.w, + top: 20.w, + bottom: 20.w), + child: Text( + "提现", + style: TextStyle(color: Colors.white), + ), + ), + ), + ) + ], + ), + Divider( + height: 1, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: _buildTopListItem(model?.headerBottomList)) + ], + ), + ), ); } + + ///构建顶部Item + _buildTopListItem(List list) { + List listWidget = List(); + for (var item in list) { + listWidget.add(Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + "9999", + style: TextStyle(color: Colors.red, fontSize: 30.sp), + ), + Text( + "累计到账(元)", + style: TextStyle(color: Colors.grey, fontSize: 22.sp), + ), + ], + )); + } + return listWidget; + } } diff --git a/lib/widgets/wallet/wallet_data/wallet_data_creater.dart b/lib/widgets/wallet/wallet_data/wallet_data_creater.dart index b917d7e..cf2f551 100644 --- a/lib/widgets/wallet/wallet_data/wallet_data_creater.dart +++ b/lib/widgets/wallet/wallet_data/wallet_data_creater.dart @@ -6,7 +6,7 @@ class WalletDataCreater extends WidgetCreater { @override List createWidgets(Map model) { return [ - WalletData(), + WalletData(model), ]; } } diff --git a/lib/widgets/wallet/wallet_detail/model/wallet_detail_model.dart b/lib/widgets/wallet/wallet_detail/model/wallet_detail_model.dart new file mode 100644 index 0000000..37432a8 --- /dev/null +++ b/lib/widgets/wallet/wallet_detail/model/wallet_detail_model.dart @@ -0,0 +1,226 @@ +class WalletDetailModel { + List providers; + List dateList; + ProviderDashbord providerDashbord; + + WalletDetailModel({this.providers, this.dateList, this.providerDashbord}); + + WalletDetailModel.fromJson(Map json) { + if (json['providers'] != null) { + providers = new List(); + json['providers'].forEach((v) { + providers.add(new Providers.fromJson(v)); + }); + } + if (json['date_list'] != null) { + dateList = new List(); + json['date_list'].forEach((v) { + dateList.add(new DateList.fromJson(v)); + }); + } + providerDashbord = json['provider_dashbord'] != null + ? new ProviderDashbord.fromJson(json['provider_dashbord']) + : null; + } + + Map toJson() { + final Map data = new Map(); + if (this.providers != null) { + data['providers'] = this.providers.map((v) => v.toJson()).toList(); + } + if (this.dateList != null) { + data['date_list'] = this.dateList.map((v) => v.toJson()).toList(); + } + if (this.providerDashbord != null) { + data['provider_dashbord'] = this.providerDashbord.toJson(); + } + return data; + } +} + +class Providers { + String type; + String name; + String unselectColor; + String selectColor; + String lineColor; + + Providers( + {this.type, + this.name, + this.unselectColor, + this.selectColor, + this.lineColor}); + + Providers.fromJson(Map json) { + type = json['type']; + name = json['name']; + unselectColor = json['unselect_color']; + selectColor = json['select_color']; + lineColor = json['line_color']; + } + + Map toJson() { + final Map data = new Map(); + data['type'] = this.type; + data['name'] = this.name; + data['unselect_color'] = this.unselectColor; + data['select_color'] = this.selectColor; + data['line_color'] = this.lineColor; + return data; + } +} + +class DateList { + String text; + String textSelectColor; + String textUnselectColor; + String btnImg; + + DateList( + {this.text, this.textSelectColor, this.textUnselectColor, this.btnImg}); + + DateList.fromJson(Map json) { + text = json['text']; + textSelectColor = json['text_select_color']; + textUnselectColor = json['text_unselect_color']; + btnImg = json['btn_img']; + } + + Map toJson() { + final Map data = new Map(); + data['text'] = this.text; + data['text_select_color'] = this.textSelectColor; + data['text_unselect_color'] = this.textUnselectColor; + data['btn_img'] = this.btnImg; + return data; + } +} + +class ProviderDashbord { + Finish finish; + SelfBuy selfBuy; + SelfBuy directPromote; + SelfBuy indirectPromote; + + ProviderDashbord( + {this.finish, this.selfBuy, this.directPromote, this.indirectPromote}); + + ProviderDashbord.fromJson(Map json) { + finish = + json['finish'] != null ? new Finish.fromJson(json['finish']) : null; + selfBuy = json['self_buy'] != null + ? new SelfBuy.fromJson(json['self_buy']) + : null; + directPromote = json['direct_promote'] != null + ? new SelfBuy.fromJson(json['direct_promote']) + : null; + indirectPromote = json['indirect_promote'] != null + ? new SelfBuy.fromJson(json['indirect_promote']) + : null; + } + + Map toJson() { + final Map data = new Map(); + if (this.finish != null) { + data['finish'] = this.finish.toJson(); + } + if (this.selfBuy != null) { + data['self_buy'] = this.selfBuy.toJson(); + } + if (this.directPromote != null) { + data['direct_promote'] = this.directPromote.toJson(); + } + if (this.indirectPromote != null) { + data['indirect_promote'] = this.indirectPromote.toJson(); + } + return data; + } +} + +class Finish { + String text; + String textColor; + String valueColor; + String bgImg; + + Finish({this.text, this.textColor, this.valueColor, this.bgImg}); + + Finish.fromJson(Map json) { + text = json['text']; + textColor = json['text_color']; + valueColor = json['value_color']; + bgImg = json['bg_img']; + } + + Map toJson() { + final Map data = new Map(); + data['text'] = this.text; + data['text_color'] = this.textColor; + data['value_color'] = this.valueColor; + data['bg_img'] = this.bgImg; + return data; + } +} + +class SelfBuy { + String title; + String titleColor; + String leftBgImg; + String rightBgImg; + List itemList; + + SelfBuy( + {this.title, + this.titleColor, + this.leftBgImg, + this.rightBgImg, + this.itemList}); + + SelfBuy.fromJson(Map json) { + title = json['title']; + titleColor = json['title_color']; + leftBgImg = json['left_bg_img']; + rightBgImg = json['right_bg_img']; + if (json['list'] != null) { + itemList = new List(); + json['list'].forEach((v) { + itemList.add(new ItemList.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + data['title'] = this.title; + data['title_color'] = this.titleColor; + data['left_bg_img'] = this.leftBgImg; + data['right_bg_img'] = this.rightBgImg; + if (this.itemList != null) { + data['list'] = this.itemList.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class ItemList { + String text; + String textColor; + String valueColor; + + ItemList({this.text, this.textColor, this.valueColor}); + + ItemList.fromJson(Map json) { + text = json['text']; + textColor = json['text_color']; + valueColor = json['value_color']; + } + + Map toJson() { + final Map data = new Map(); + data['text'] = this.text; + data['text_color'] = this.textColor; + data['value_color'] = this.valueColor; + return data; + } +} diff --git a/lib/widgets/wallet/wallet_detail/wallet_detail.dart b/lib/widgets/wallet/wallet_detail/wallet_detail.dart index 179c219..2f350c9 100644 --- a/lib/widgets/wallet/wallet_detail/wallet_detail.dart +++ b/lib/widgets/wallet/wallet_detail/wallet_detail.dart @@ -1,18 +1,184 @@ +import 'dart:convert'; + import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:zhiying_base_widget/pages/withdraw_page/withdraw_page.dart'; +import 'package:zhiying_base_widget/widgets/home/home_quick_entry/cached_network_image_util.dart'; +import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/model/wallet_detail_model.dart'; import 'package:zhiying_base_widget/widgets/wallet/wallet_detail/wallet_detail_sk.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class WalletDetail extends StatefulWidget { + final Map data; + + const WalletDetail( + this.data, { + Key key, + }) : super(key: key); + + @override + _WalletDetailState createState() => _WalletDetailState(); +} + +class _WalletDetailState extends State + with TickerProviderStateMixin { + WalletDetailModel _model; + TabController _tabController; + @override + void initState() { + if (widget.data != null) { + _model = WalletDetailModel.fromJson(json.decode(widget.data['data'])); + _tabController = + TabController(length: _model.providers.length, vsync: this); + } + super.initState(); + } -class WalletDetail extends StatelessWidget { @override Widget build(BuildContext context) { - return GestureDetector( - child: WalletDetailSkeleton(), - onTap: () { - Navigator.push(context, MaterialPageRoute(builder: (context) { - return WithdrawPage(); - })); - }, + return Container( + margin: EdgeInsets.only(left: 12.5, right: 12.5), + child: Column( + children: [ + Container( + child: TabBar( + // isScrollable: true, + controller: _tabController, + tabs: _buildTabs()), + ), + Container( + height: 75.h, + child: ListView.builder( + padding: EdgeInsets.only(top: 16), + itemCount: _model.dateList.length, + scrollDirection: Axis.horizontal, + itemBuilder: _buildTimeItem), + ), + Container( + height: 126.h, + margin: EdgeInsets.only(top: 16), + width: double.infinity, + decoration: BoxDecoration( + image: DecorationImage( + image: CachedNetworkImageProvider( + _model.providerDashbord.finish.bgImg), + fit: BoxFit.fill)), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "已结算", + style: TextStyle(color: Colors.black, fontSize: 22.sp), + ), + InkWell( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: CachedNetworkImage( + imageUrl: "", + width: 20.h, + height: 20.h, + fit: BoxFit.fill, + ), + ), + onTap: () { + ///问好 + }) + ], + ), + Text( + "158", + style: TextStyle(color: Colors.red, fontSize: 40.sp), + ) + ], + ), + ), + Container( + child: ListView.builder( + itemCount: 3, + shrinkWrap: true, + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, index) { + return _buildBottomItem( + context, index, _model.providerDashbord); + }), + ) + ], + ), + ); + } + + _buildTabs() { + List listWidget = List(); + for (var item in _model.providers) { + listWidget.add(Tab( + child: Text( + item.name, + style: TextStyle(color: Colors.grey), + ), + )); + } + return listWidget; + } + + Widget _buildTimeItem(BuildContext context, int index) { + var item = _model.dateList[index]; + return Container( + margin: EdgeInsets.only(top: 0, left: 8, right: 8), + decoration: BoxDecoration( + color: Colors.grey[200], borderRadius: BorderRadius.circular(50)), + child: Padding( + padding: const EdgeInsets.only(left: 16, right: 16), + child: Center( + child: Text( + item.text, + style: TextStyle(color: Colors.grey), + )), + ), + ); + } + + Widget _buildBottomItem( + BuildContext context, int index, ProviderDashbord dashbord) { + var item = dashbord.selfBuy; + return Container( + child: Column( + children: [ + Text( + item.title, + style: TextStyle(color: HexColor.fromHex(item.titleColor)), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Expanded( + child: Container( + height: 123.h, + margin: EdgeInsets.only(right: 8), + decoration: BoxDecoration( + image: DecorationImage( + image: CachedNetworkImageProvider(item.leftBgImg), + fit: BoxFit.fill)), + child: Center(child: Text("ddd")), + ), + ), + Expanded( + child: Container( + height: 123.h, + margin: EdgeInsets.only(left: 8), + decoration: BoxDecoration( + image: DecorationImage( + image: CachedNetworkImageProvider(item.rightBgImg))), + child: Center(child: Text("dddd")), + )) + ], + ) + ], + ), ); } } diff --git a/pubspec.yaml b/pubspec.yaml index a245a4e..bab13ee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,13 +26,18 @@ dependencies: ref: '1.2.3+1' # mob 分享sdk sharesdk_plugin: ^1.2.8 + flutter_native_image: ^0.0.5 + #字符检测 + string_validator: 0.1.4 + intl: 0.15.7 + + zhiying_comm: + path: ../zhiying_comm dev_dependencies: flutter_test: sdk: flutter - zhiying_comm: - path: ../zhiying_comm # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec