diff --git a/lib/pages/custom_page/custom_item_page.dart b/lib/pages/custom_page/custom_item_page.dart index 7620bde..db43bb0 100644 --- a/lib/pages/custom_page/custom_item_page.dart +++ b/lib/pages/custom_page/custom_item_page.dart @@ -6,6 +6,7 @@ import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:provider/provider.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:zhiying_base_widget/pages/main_page/notifier/main_page_notifier.dart'; +import 'package:zhiying_base_widget/widgets/custom/bottom_pic/bottom_pic.dart'; import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart'; import 'package:zhiying_base_widget/widgets/home/home_auth/home_auth.dart'; import 'package:zhiying_base_widget/widgets/refresh/refresh_header/refresh_gif_header.dart'; @@ -26,7 +27,7 @@ class CustomItemPage extends StatelessWidget { final String modPid; final String modId; final bool needBuildStatus; - Function(double) scroller; + Function(double) scroller; CustomItemPage(this.data, this.tabIndex, this.modId, this.modPid, this.needBuildStatus, {this.scroller}); @@ -38,7 +39,14 @@ class CustomItemPage extends StatelessWidget { ], child: BlocProvider( create: (_) => CustomItemPageBloc(CustomItemPageRepository(this.data, this.tabIndex, this.modId, this.modPid)), - child: _CustomItemPageContainer(this.data, this.tabIndex, this.modId, this.modPid, this.needBuildStatus,scroller: this.scroller,), + child: _CustomItemPageContainer( + this.data, + this.tabIndex, + this.modId, + this.modPid, + this.needBuildStatus, + scroller: this.scroller, + ), ), ); } @@ -94,8 +102,9 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit _controller = ScrollController(); _eventBus = EventBus(); _refreshController = RefreshController(initialRefresh: false); - _initEvent();_controller.addListener(() { - if(widget.scroller!=null){ + _initEvent(); + _controller.addListener(() { + if (widget.scroller != null) { widget?.scroller(_controller.offset); } }); @@ -186,6 +195,13 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit margin: const EdgeInsets.only(bottom: 8), child: _buildAuthWidget(model), ), //_buildAuthWidget(model), + ), + Align( + alignment: Alignment.bottomCenter, + child: Container( + margin: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), + child: _buildBottomPic(model), + ), //_buildAuthWidget(model), ) ], ), @@ -197,7 +213,7 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit List result = []; for (int i = 0; i < datas.length; i++) { WidgetModel item = WidgetModel.fromJson(Map.from(datas[i])); - if (item.modName == 'audit_tip') { + if (item.modName == 'audit_tip' || item.modName == "bottom_suspension") { Logger.debug('授权组件,跳过'); continue; } @@ -261,4 +277,20 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit return rlt ?? Container(); } + + /// 特殊的底部图片跳转 + Widget _buildBottomPic(final List> datas) { + int length = datas?.length ?? 0; + if (length == 0) return Container(); + Widget rlt; + for (int i = 0; i < datas.length; i++) { + WidgetModel item = WidgetModel.fromJson(Map.from(datas[i])); + if (item.modName == 'bottom_suspension') { + rlt = BottomPic(model: datas[i]); + break; + } + } + + return rlt ?? Container(); + } } diff --git a/lib/pages/custom_page/custom_page.dart b/lib/pages/custom_page/custom_page.dart index 8222b8c..be57a50 100644 --- a/lib/pages/custom_page/custom_page.dart +++ b/lib/pages/custom_page/custom_page.dart @@ -354,7 +354,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single return MyTab( icon: CachedNetworkImage( imageUrl: item['choose_image_url'] ?? '', - width: 14, + width: 16, ), text: item['name'], ); diff --git a/lib/pages/order_found_page/order_found_search_page/model/order_found_search_style.dart b/lib/pages/order_found_page/order_found_search_page/model/order_found_search_style.dart new file mode 100644 index 0000000..1023e12 --- /dev/null +++ b/lib/pages/order_found_page/order_found_search_page/model/order_found_search_style.dart @@ -0,0 +1,184 @@ +class OrderFoundSearchStyle { + Top top; + SearchCss searchCss; + RuleCss ruleCss; + FindRuleCss findRuleCss; + ResultCss resultCss; + FindRuleCss notFindRuleCss; + + OrderFoundSearchStyle( + {this.top, + this.searchCss, + this.ruleCss, + this.findRuleCss, + this.resultCss, + this.notFindRuleCss}); + + OrderFoundSearchStyle.fromJson(Map json) { + top = json['top'] != null ? new Top.fromJson(json['top']) : null; + searchCss = json['search_css'] != null + ? new SearchCss.fromJson(json['search_css']) + : null; + ruleCss = json['rule_css'] != null + ? new RuleCss.fromJson(json['rule_css']) + : null; + findRuleCss = json['find_rule_css'] != null + ? new FindRuleCss.fromJson(json['find_rule_css']) + : null; + resultCss = json['result_css'] != null + ? new ResultCss.fromJson(json['result_css']) + : null; + notFindRuleCss = json['not_find_rule_css'] != null + ? new FindRuleCss.fromJson(json['not_find_rule_css']) + : null; + } + + Map toJson() { + final Map data = new Map(); + if (this.top != null) { + data['top'] = this.top.toJson(); + } + if (this.searchCss != null) { + data['search_css'] = this.searchCss.toJson(); + } + if (this.ruleCss != null) { + data['rule_css'] = this.ruleCss.toJson(); + } + if (this.findRuleCss != null) { + data['find_rule_css'] = this.findRuleCss.toJson(); + } + if (this.resultCss != null) { + data['result_css'] = this.resultCss.toJson(); + } + if (this.notFindRuleCss != null) { + data['not_find_rule_css'] = this.notFindRuleCss.toJson(); + } + return data; + } +} + +class Top { + String bgColor; + String bgSubColor; + String str; + String strColor; + + Top({this.bgColor, this.bgSubColor, this.str, this.strColor}); + + Top.fromJson(Map json) { + bgColor = json['bg_color']; + bgSubColor = json['bg_sub_color']; + str = json['str']; + strColor = json['str_color']; + } + + Map toJson() { + final Map data = new Map(); + data['bg_color'] = this.bgColor; + data['bg_sub_color'] = this.bgSubColor; + data['str'] = this.str; + data['str_color'] = this.strColor; + return data; + } +} + +class SearchCss { + String str; + String bgColor; + String strColor; + String btnStr; + String btnStrColor; + String btnBgColor; + String btnBgSubColor; + + SearchCss( + {this.str, + this.bgColor, + this.strColor, + this.btnStr, + this.btnStrColor, + this.btnBgColor, + this.btnBgSubColor}); + + SearchCss.fromJson(Map json) { + str = json['str']; + bgColor = json['bg_color']; + strColor = json['str_color']; + btnStr = json['btn_str']; + btnStrColor = json['btn_str_color']; + btnBgColor = json['btn_bg_color']; + btnBgSubColor = json['btn_bg_sub_color']; + } + + Map toJson() { + final Map data = new Map(); + data['str'] = this.str; + data['bg_color'] = this.bgColor; + data['str_color'] = this.strColor; + data['btn_str'] = this.btnStr; + data['btn_str_color'] = this.btnStrColor; + data['btn_bg_color'] = this.btnBgColor; + data['btn_bg_sub_color'] = this.btnBgSubColor; + return data; + } +} + +class RuleCss { + String str; + String img; + String imgUrl; + + RuleCss({this.str, this.img, this.imgUrl}); + + RuleCss.fromJson(Map json) { + str = json['str']; + img = json['img']; + imgUrl = json['img_url']; + } + + Map toJson() { + final Map data = new Map(); + data['str'] = this.str; + data['img'] = this.img; + data['img_url'] = this.imgUrl; + return data; + } +} + +class FindRuleCss { + String title; + String content; + + FindRuleCss({this.title, this.content}); + + FindRuleCss.fromJson(Map json) { + title = json['title']; + content = json['content']; + } + + Map toJson() { + final Map data = new Map(); + data['title'] = this.title; + data['content'] = this.content; + return data; + } +} + +class ResultCss { + String btnBgColor; + String btnBgSubColor; + + ResultCss({this.btnBgColor, this.btnBgSubColor}); + + ResultCss.fromJson(Map json) { + btnBgColor = json['btn_bg_color']; + btnBgSubColor = json['btn_bg_sub_color']; + } + + Map toJson() { + final Map data = new Map(); + data['btn_bg_color'] = this.btnBgColor; + data['btn_bg_sub_color'] = this.btnBgSubColor; + return data; + } +} diff --git a/lib/pages/order_found_page/order_found_search_page/order_found_search_bloc.dart b/lib/pages/order_found_page/order_found_search_page/order_found_search_bloc.dart new file mode 100644 index 0000000..e0d17e3 --- /dev/null +++ b/lib/pages/order_found_page/order_found_search_page/order_found_search_bloc.dart @@ -0,0 +1,69 @@ +import 'dart:async'; +import 'dart:convert'; + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/dialog/loading/loading.dart'; +import 'package:zhiying_base_widget/pages/order_found_page/order_found_result/order_found_result_model.dart'; +import 'package:zhiying_base_widget/pages/order_found_page/order_found_result/order_found_result_page.dart'; +import 'package:zhiying_base_widget/pages/order_found_page/order_found_search_page/model/order_found_search_style.dart'; +import 'package:zhiying_comm/util/base_bloc.dart'; +import 'package:zhiying_comm/util/empty_util.dart'; +import 'package:zhiying_comm/util/log/let_log.dart'; +import 'package:zhiying_comm/util/net_util.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +class OrderFoundSearchBloc extends BlocBase { + StreamController streamController = StreamController.broadcast(); + + Stream get outData => streamController.stream; + + OrderFoundSearchStyle style; + + loadStyle() { + NetUtil.request("/api/v1/order/find/css", onSuccess: (data) { + style = OrderFoundSearchStyle.fromJson(json.decode(data['data'])); + streamController.add(style); + Logger.log(json.encode(data['data'])); + }); + } + + searchOrderById(BuildContext context, String id) { + var params = {"oid": id}; + Loading.show(context); + NetUtil.request("/api/v1/order/find/search", params: params, method: NetMethod.POST, onSuccess: (data) { + Loading.dismiss(); + if (EmptyUtil.isEmpty(data)) { + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => OrderFoundResultPage( + emptyOrderTitle: style?.notFindRuleCss?.title ?? '', + emptyOrderContent: style?.notFindRuleCss?.content ?? "", + ))); + } else { + Navigator.push( + context, + MaterialPageRoute( + builder: (_) => OrderFoundResultPage( + orderFoundResultModel: OrderFoundResultModel.fromJson(data), + emptyOrderTitle: style?.notFindRuleCss?.title ?? '', + emptyOrderContent: style?.notFindRuleCss?.content ?? "", + ))).then((value) { + if (value != null && value == "success") { + Navigator.pop(context); + } + }); + } + streamController.add(style); + Logger.log(json.encode(data['data'])); + }, onError: (e) { + Loading.dismiss(); + }); + } + + @override + void dispose() { + // TODO: implement dispose + } +} diff --git a/lib/pages/order_found_page/order_found_search_page/order_found_search_page.dart b/lib/pages/order_found_page/order_found_search_page/order_found_search_page.dart index 55fcd19..ca3b246 100644 --- a/lib/pages/order_found_page/order_found_search_page/order_found_search_page.dart +++ b/lib/pages/order_found_page/order_found_search_page/order_found_search_page.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:zhiying_base_widget/widgets/custom/ordedr_found/order_found_nav/order_found_nav.dart'; +import 'package:zhiying_base_widget/pages/order_found_page/order_found_search_page/order_found_search_bloc.dart'; import 'package:zhiying_comm/zhiying_comm.dart'; +import 'model/order_found_search_style.dart'; + ///订单搜索页 class OrderFoundSearchPage extends StatefulWidget { @override @@ -9,29 +11,60 @@ class OrderFoundSearchPage extends StatefulWidget { } class _OrderFoundSearchPageState extends State { + OrderFoundSearchBloc _bloc; + OrderFoundSearchStyle style; + TextEditingController textEditingController; + + @override + void initState() { + textEditingController = TextEditingController(); + _bloc = OrderFoundSearchBloc(); + _bloc.loadStyle(); + super.initState(); + } + @override Widget build(BuildContext context) { - return Stack( - children: [ - Scaffold( - appBar: _buildAppBar(), - body: Container( - child: ListView( - children: [ - _buildSearch(), - _buildCenter(), - _buildBottom(), - _buildTest() - ], - ), - ), - ), - ], - ); + return StreamBuilder( + stream: _bloc.outData, + builder: (context, asyn) { + if (asyn.data == null) { + return Container( + color: Colors.white, + ); + } + style = asyn.data; + return Stack( + children: [ + Container( + color: HexColor.fromHex("#f9f9f9"), + ), + Container( + height: 200, + width: MediaQuery.of(context).size.width, + decoration: BoxDecoration( + borderRadius: BorderRadius.only(bottomLeft: Radius.circular(6), bottomRight: Radius.circular(6)), + gradient: LinearGradient( + begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [HexColor.fromHex(style?.top?.bgColor), HexColor.fromHex(style?.top?.bgSubColor ?? '')])), + ), + Scaffold( + backgroundColor: Colors.transparent, + appBar: _buildAppBar(), + body: Container( + child: ListView( + children: [_buildSearch(), _buildCenter(), _buildBottom()], + ), + ), + ), + ], + ); + }); } _buildAppBar() { return AppBar( + backgroundColor: Colors.transparent, + elevation: 0, leading: Navigator.canPop(context) ? IconButton( icon: Icon( @@ -43,11 +76,20 @@ class _OrderFoundSearchPageState extends State { }) : Container(), title: Text( - "订单查询", - style: TextStyle(fontSize: 17), + style?.top?.str ?? '', + style: TextStyle(fontSize: 17, color: HexColor.fromHex(style?.top?.strColor)), ), centerTitle: true, - actions: [IconButton(icon: Icon(Icons.refresh), onPressed: () {})], + actions: [ + IconButton( + icon: Icon( + Icons.refresh, + color: HexColor.fromHex(style?.top?.strColor), + ), + onPressed: () { + _bloc?.loadStyle(); + }) + ], ); } @@ -55,23 +97,43 @@ class _OrderFoundSearchPageState extends State { _buildSearch() { return Container( height: 50, - decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(10), border: Border.all(color: Colors.white)), + decoration: BoxDecoration(color: HexColor.fromHex(style?.searchCss?.bgColor ?? ''), borderRadius: BorderRadius.circular(10), border: Border.all(color: Colors.white)), margin: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10), padding: EdgeInsets.only(left: 10, right: 4), child: Row( children: [ Expanded( child: TextField( - decoration: InputDecoration(border: InputBorder.none, hintText: "请输入或粘粘淘宝订单编号", hintStyle: TextStyle(color: HexColor.fromHex("#999999"), fontSize: 14), isDense: true), + controller: textEditingController, + decoration: InputDecoration( + border: InputBorder.none, + hintText: style?.searchCss?.str ?? '', + hintStyle: TextStyle(color: HexColor.fromHex(style?.searchCss?.strColor ?? ""), fontSize: 14), + isDense: true), )), - Container( - height: 42, - alignment: Alignment.center, - padding: EdgeInsets.only(left: 24, right: 24), - decoration: BoxDecoration(color: HexColor.fromHex("#FF2020"), borderRadius: BorderRadius.circular(10)), - child: Text( - "搜索", - style: TextStyle(color: HexColor.fromHex("#FFFFFF")), + GestureDetector( + onTap: () { + if (textEditingController?.text.trim().length == 0) { + Fluttertoast.showToast(msg: "请输入搜索的订单编号"); + return; + } + FocusScope.of(context).requestFocus(new FocusNode()); + _bloc.searchOrderById(context, textEditingController.text); + }, + child: Container( + height: 42, + alignment: Alignment.center, + padding: EdgeInsets.only(left: 24, right: 24), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + gradient: LinearGradient( + begin: Alignment.centerLeft, + end: Alignment.centerRight, + colors: [HexColor.fromHex(style?.searchCss?.btnBgColor), HexColor.fromHex(style?.searchCss?.btnBgSubColor ?? '')])), + child: Text( + style?.searchCss?.btnStr ?? "", + style: TextStyle(color: HexColor.fromHex(style?.searchCss?.btnStrColor ?? "")), + ), ), ), ], @@ -95,7 +157,7 @@ class _OrderFoundSearchPageState extends State { margin: EdgeInsets.only(right: 10), ), Text( - "如何获取订单编号?", + style?.ruleCss?.str ?? "", style: TextStyle(color: HexColor.fromHex("#333333"), fontSize: 15, fontWeight: FontWeight.w500), ) ], @@ -103,9 +165,14 @@ class _OrderFoundSearchPageState extends State { SizedBox( height: 16, ), - CachedNetworkImage( - imageUrl: "https://alipic.lanhuapp.com/SketchPng9ae52da74764fe05917a1d5a4a8d5eb94a9013106c4412056afa00340164bde5", - fit: BoxFit.fitWidth, + GestureDetector( + onTap: () { + PhotoPreview.showPhotoPreviewByimages(context, [style?.ruleCss?.img ?? ""]); + }, + child: CachedNetworkImage( + imageUrl: style?.ruleCss?.img ?? '', + fit: BoxFit.fitWidth, + ), ) ], ), @@ -128,7 +195,7 @@ class _OrderFoundSearchPageState extends State { decoration: BoxDecoration(color: HexColor.fromHex("#FF2020"), borderRadius: BorderRadius.circular(10)), ), Text( - "查询规则?", + style?.findRuleCss?.title ?? '', style: TextStyle(color: HexColor.fromHex("#333333"), fontSize: 15, fontWeight: FontWeight.w500), ) ], @@ -141,16 +208,7 @@ class _OrderFoundSearchPageState extends State { physics: NeverScrollableScrollPhysics(), children: [ Text( - ''' - 1.购买人没同步的订单可通过订单查询找回; -2.当查找人查找到订单,并且该订单在订单库确实找不到归 -属时,该订单归属到查找人; -3.当有多个用户输入同一订单号,以第一个输入人为准; -4.已归属的订单不支持继续查询; -5.建议购买人自查,运营商帮助超级会员查询时,不要点击 -确认找回,可让购买人自查并找回; -6.收益将按查找人的当前的用户关系进行归属。 - ''', + style?.findRuleCss?.content ?? "", style: TextStyle(color: HexColor.fromHex("#999999"), fontSize: 12, fontWeight: FontWeight.w500), ) ], @@ -160,7 +218,4 @@ class _OrderFoundSearchPageState extends State { ); } - _buildTest() { - return OrderFoundNav(); - } } diff --git a/lib/pages/orders_page/bloc/order_content_bloc.dart b/lib/pages/orders_page/bloc/order_content_bloc.dart index 0fdb46d..7265a84 100644 --- a/lib/pages/orders_page/bloc/order_content_bloc.dart +++ b/lib/pages/orders_page/bloc/order_content_bloc.dart @@ -9,7 +9,7 @@ import 'package:zhiying_comm/zhiying_comm.dart'; class OrderContentBloc extends BlocBase { final String skipIdentifier; - OrderContentBloc({this.skipIdentifier}); + OrderContentBloc({this.skipIdentifier,this.source}); List _orders = List(); @@ -21,6 +21,7 @@ class OrderContentBloc extends BlocBase { OrderFilterModel _filter; RefreshController refreshController = RefreshController(initialRefresh: false); + String source; @override void dispose() { _ordersController.close(); @@ -40,6 +41,9 @@ class OrderContentBloc extends BlocBase { params.removeWhere((key, value) => value == null || value == ''); params['state'] = _state; String reqUrl = skipIdentifier == 'pub.flutter.order_by_userlvup' ? '/api/v1/order_by_userlvup' : '/api/v1/order'; + if(skipIdentifier=="pub.flutter.order_list"){ + reqUrl="/api/v1/order_list/"+(source??""); + } NetUtil.request(reqUrl, method: NetMethod.POST, params: params, onCache: (data) { //_parseData(data); diff --git a/lib/pages/orders_page/bloc/order_page_bloc.dart b/lib/pages/orders_page/bloc/order_page_bloc.dart index 2eeed3e..634f715 100644 --- a/lib/pages/orders_page/bloc/order_page_bloc.dart +++ b/lib/pages/orders_page/bloc/order_page_bloc.dart @@ -19,13 +19,24 @@ class OrderPageBloc extends BlocBase { _styleController = null; } - void loadData(String skipIdentifier) async { - NetUtil.request('/api/v1/mod/${skipIdentifier.toString()}', - method: NetMethod.GET, onCache: (data) { - // _loadData(data); - }, onSuccess: (data) { - _loadData(data); - }); + void loadData(String skipIdentifier,{String source}) async { + if(skipIdentifier=="pub.flutter.order_list"){ + skipIdentifier="pub.flutter.my_order"; + NetUtil.request('/api/v1/mod/${skipIdentifier.toString()}?source_type='+source, + method: NetMethod.GET, onCache: (data) { + // _loadData(data); + }, onSuccess: (data) { + _loadData(data); + }); + }else{ + NetUtil.request('/api/v1/mod/${skipIdentifier.toString()}', + method: NetMethod.GET, onCache: (data) { + // _loadData(data); + }, onSuccess: (data) { + _loadData(data); + }); + } + } void _loadData(dynamic data) { diff --git a/lib/pages/orders_page/bloc/order_search_bloc.dart b/lib/pages/orders_page/bloc/order_search_bloc.dart index d0ceb84..9d33ac4 100644 --- a/lib/pages/orders_page/bloc/order_search_bloc.dart +++ b/lib/pages/orders_page/bloc/order_search_bloc.dart @@ -14,6 +14,7 @@ class OrderSearchBloc extends BlocBase { int _page = 1; String _keyword = ''; + String source; @override void dispose() { _ordersController.close(); diff --git a/lib/pages/orders_page/order_content_page.dart b/lib/pages/orders_page/order_content_page.dart index d90d3ee..eb89fe6 100644 --- a/lib/pages/orders_page/order_content_page.dart +++ b/lib/pages/orders_page/order_content_page.dart @@ -18,9 +18,10 @@ class OrderContentPage extends StatefulWidget { final int index; final EventBus eventBus; final String skipIdentifier; + final String source;///通过自定义页面订单分类进入的订单类型 const OrderContentPage(this.state, - {Key key, this.filter, this.style, this.index, this.eventBus, this.skipIdentifier}) + {Key key, this.filter, this.style, this.index, this.eventBus, this.skipIdentifier,this.source}) : super(key: key); @override @@ -31,7 +32,7 @@ class _OrderContentPageState extends State { @override Widget build(BuildContext context) { return BlocProvider( - bloc: OrderContentBloc(skipIdentifier: widget?.skipIdentifier), + bloc: OrderContentBloc(skipIdentifier: widget?.skipIdentifier,source: widget?.source), child: OrderContentContainer( widget.state, widget.filter, @@ -49,7 +50,6 @@ class OrderContentContainer extends StatefulWidget { final OrderPageStyleModel style; final int index; final EventBus eventBus; - const OrderContentContainer(this.state, this.filter, this.style, {Key key, this.index, this.eventBus}) : super(key: key); diff --git a/lib/pages/orders_page/orders_page.dart b/lib/pages/orders_page/orders_page.dart index 46f1b50..be73bd8 100644 --- a/lib/pages/orders_page/orders_page.dart +++ b/lib/pages/orders_page/orders_page.dart @@ -67,7 +67,7 @@ class _OrdersPageState extends State { ) : Container(), middle: Text( - widget.data['skip_identifier'] == 'pub.flutter.my_order' ? '我的订单' : '会员升级订单', + widget?.data["skip_name"] ??( widget.data['skip_identifier'] == 'pub.flutter.my_order' ? '我的订单' : '会员升级订单'), style: TextStyle( fontSize: 15, color: Color(0xff333333), @@ -86,8 +86,7 @@ class _OrdersContainer extends StatefulWidget { _OrdersContainerState createState() => _OrdersContainerState(); } -class _OrdersContainerState extends State<_OrdersContainer> - with TickerProviderStateMixin { +class _OrdersContainerState extends State<_OrdersContainer> with TickerProviderStateMixin { TabController _tabController; GlobalKey _tabKey = GlobalKey(); OrderPageBloc _bloc; @@ -100,11 +99,21 @@ class _OrdersContainerState extends State<_OrdersContainer> EventBus _eventBus = EventBus(); + String source; + @override void initState() { _bloc = BlocProvider.of(context); if (widget.data.containsKey('skip_identifier')) { - _bloc.loadData(widget.data['skip_identifier']); + String source = null; + if (widget?.data['data'] != null) { + source = widget?.data['data']['source_type']; + } + _bloc.loadData(widget.data['skip_identifier'], source: source); + } + + if(widget?.data['data']!=null&&widget.data['data']['source_type']!=null){ + source=widget.data['data']['source_type']; } super.initState(); @@ -128,8 +137,7 @@ class _OrdersContainerState extends State<_OrdersContainer> List type = model.filter.orderState; _tabController?.dispose(); - _tabController = - TabController(length: type?.length ?? 0, vsync: this); + _tabController = TabController(length: type?.length ?? 0, vsync: this); _tabController.addListener(() { Logger.debug('????? ${_tabController.index.toString()}'); }); @@ -143,6 +151,7 @@ class _OrdersContainerState extends State<_OrdersContainer> index: index, eventBus: _eventBus, skipIdentifier: widget.data['skip_identifier'], + source: source, ), ); @@ -155,13 +164,13 @@ class _OrdersContainerState extends State<_OrdersContainer> child: GestureDetector( child: OrderSearchWidget(model), onTap: () { - Navigator.of(context) - .push(CupertinoPageRoute(builder: (BuildContext context) { + Navigator.of(context).push(CupertinoPageRoute(builder: (BuildContext context) { return OrderSearchPage(model); })); }, ), ), + /// TabBar 分类导航 OrderTabbarWidget( model, @@ -174,6 +183,7 @@ class _OrdersContainerState extends State<_OrdersContainer> }); }, ), + /// TabView 子视图 Expanded( child: Stack( @@ -182,6 +192,7 @@ class _OrdersContainerState extends State<_OrdersContainer> children: _contents, controller: _tabController, ), + /// 筛选视图 Visibility( visible: _isFilterShow, diff --git a/lib/register.dart b/lib/register.dart index d59174e..59e91a5 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -43,6 +43,7 @@ import 'package:zhiying_base_widget/widgets/custom/banner/custom_banner_widget.d import 'package:zhiying_base_widget/widgets/custom/goods/custom_goods_creater.dart'; import 'package:zhiying_base_widget/widgets/custom/multi_nav/custom_quick_entry.dart'; import 'package:zhiying_base_widget/widgets/custom/notice/custom_notice_widget.dart'; +import 'package:zhiying_base_widget/widgets/custom/ordedr_class/order_class_nav/order_class_nav.dart'; import 'package:zhiying_base_widget/widgets/custom/search/custom_search_widget.dart'; import 'package:zhiying_base_widget/widgets/custom/share_content/share_content_widget.dart'; import 'package:zhiying_base_widget/widgets/custom/slide_banner/custom_slide_banner_creater.dart'; @@ -310,6 +311,12 @@ class BaseWidgetRegister { /// 通用模块 PageFactory.regist('pub.flutter.custom', (model) => CustomPage(model)); + + ///订单找回 + PageFactory.regist("pub.flutter.order_find", (model) => OrderFoundSearchPage()); + + /// 订单页面 + PageFactory.regist('pub.flutter.order_list', (model) => OrdersPage(model)); } // 注册控件 @@ -453,5 +460,7 @@ class BaseWidgetRegister { WidgetFactory.regist('audit_tip', DefaultWidgetCreater((model) => HomeAuth(model))); // 分享内容组件 WidgetFactory.regist('share_content', DefaultWidgetCreater((model) => CustomShareContentWidget(model))); + + WidgetFactory.regist('features_cate', DefaultWidgetCreater((model) => OrderClassNav(model))); } } diff --git a/lib/widgets/custom/bottom_pic/bottom_pic.dart b/lib/widgets/custom/bottom_pic/bottom_pic.dart new file mode 100644 index 0000000..21ff32d --- /dev/null +++ b/lib/widgets/custom/bottom_pic/bottom_pic.dart @@ -0,0 +1,42 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:zhiying_comm/util/log/let_log.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +import 'bottom_pic_style.dart'; + +class BottomPic extends StatelessWidget { + final Map model; + + BottomPic({Key key, this.model}) : super(key: key); + @override + BottomPicStyle style; + + Widget build(BuildContext context) { + style = BottomPicStyle.fromJson(json.decode(model['data'])); + Logger.log(model['data']); + if (style == null) { + return Container(); + } + return GestureDetector( + onTap: () { + RouterUtil.route(SkipModel.fromJson(style.toJson()), style.toJson(), context); + }, + child: Container( + margin: EdgeInsets.only( + left: double.tryParse(style?.leftRightMargin ?? "0"), right: double.tryParse(style?.leftRightMargin ?? "0"), top: double.tryParse(style?.topMargin ?? "0"), bottom: 0), + decoration: BoxDecoration( + color: HexColor.fromHex(style?.bgColor ?? ''), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(double.tryParse(style?.topLeftRadius ?? "0")), + topRight: Radius.circular(double.tryParse(style?.topRightRadius ?? "0")), + bottomLeft: Radius.circular(double.tryParse(style?.bottomLeftRadius ?? "0")), + bottomRight: Radius.circular(double.tryParse(style?.bottomRightRadius ?? "0")))), + child: CachedNetworkImage( + imageUrl: style?.bgImage ?? "", + ), + ), + ); + } +} diff --git a/lib/widgets/custom/bottom_pic/bottom_pic_style.dart b/lib/widgets/custom/bottom_pic/bottom_pic_style.dart new file mode 100644 index 0000000..92f08c0 --- /dev/null +++ b/lib/widgets/custom/bottom_pic/bottom_pic_style.dart @@ -0,0 +1,100 @@ +class BottomPicStyle { + String name; + String desc; + String moduleType; + String moduleKey; + String isTopMargin; + String isLeftRightMargin; + String isShow; + String topMargin; + String leftRightMargin; + String topLeftRadius; + String topRightRadius; + String bottomLeftRadius; + String bottomRightRadius; + String bgColor; + String bgImage; + String bgImageUrl; + String skipIdentifier; + String skipName; + String requiredLogin; + String requiredTaobaoAuth; + String isJump; + String cateTag; + + BottomPicStyle( + {this.name, + this.desc, + this.moduleType, + this.moduleKey, + this.isTopMargin, + this.isLeftRightMargin, + this.isShow, + this.topMargin, + this.leftRightMargin, + this.topLeftRadius, + this.topRightRadius, + this.bottomLeftRadius, + this.bottomRightRadius, + this.bgColor, + this.bgImage, + this.bgImageUrl, + this.skipIdentifier, + this.skipName, + this.requiredLogin, + this.requiredTaobaoAuth, + this.isJump, + this.cateTag}); + + BottomPicStyle.fromJson(Map json) { + name = json['name']; + desc = json['desc']; + moduleType = json['module_type']; + moduleKey = json['module_key']; + isTopMargin = json['is_top_margin']; + isLeftRightMargin = json['is_left_right_margin']; + isShow = json['is_show']; + topMargin = json['top_margin']; + leftRightMargin = json['left_right_margin']; + topLeftRadius = json['top_left_radius']; + topRightRadius = json['top_right_radius']; + bottomLeftRadius = json['bottom_left_radius']; + bottomRightRadius = json['bottom_right_radius']; + bgColor = json['bg_color']; + bgImage = json['bg_image']; + bgImageUrl = json['bg_image_url']; + skipIdentifier = json['skip_identifier']; + skipName = json['skip_name']; + requiredLogin = json['required_login']; + requiredTaobaoAuth = json['required_taobao_auth']; + isJump = json['is_jump']; + cateTag = json['cate_tag']; + } + + Map toJson() { + final Map data = new Map(); + data['name'] = this.name; + data['desc'] = this.desc; + data['module_type'] = this.moduleType; + data['module_key'] = this.moduleKey; + data['is_top_margin'] = this.isTopMargin; + data['is_left_right_margin'] = this.isLeftRightMargin; + data['is_show'] = this.isShow; + data['top_margin'] = this.topMargin; + data['left_right_margin'] = this.leftRightMargin; + data['top_left_radius'] = this.topLeftRadius; + data['top_right_radius'] = this.topRightRadius; + data['bottom_left_radius'] = this.bottomLeftRadius; + data['bottom_right_radius'] = this.bottomRightRadius; + data['bg_color'] = this.bgColor; + data['bg_image'] = this.bgImage; + data['bg_image_url'] = this.bgImageUrl; + data['skip_identifier'] = this.skipIdentifier; + data['skip_name'] = this.skipName; + data['required_login'] = this.requiredLogin; + data['required_taobao_auth'] = this.requiredTaobaoAuth; + data['is_jump'] = this.isJump; + data['cate_tag'] = this.cateTag; + return data; + } +} diff --git a/lib/widgets/custom/ordedr_class/order_class_nav/order_class_nav.dart b/lib/widgets/custom/ordedr_class/order_class_nav/order_class_nav.dart new file mode 100644 index 0000000..8573e1c --- /dev/null +++ b/lib/widgets/custom/ordedr_class/order_class_nav/order_class_nav.dart @@ -0,0 +1,133 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:zhiying_base_widget/widgets/custom/ordedr_class/order_class_nav/order_class_style.dart'; +import 'package:zhiying_comm/util/extension/color.dart'; +import 'package:zhiying_comm/zhiying_comm.dart'; + +///订单分类 +class OrderClassNav extends StatelessWidget { + final Map model; + + OrderClassNav(this.model, {Key key}) : super(key: key); + + OrderClassStyle style; + BuildContext context; + + @override + Widget build(BuildContext context) { + // Logger.log(model['data']); + style = OrderClassStyle.fromJson(json.decode(model['data'])); + if (style == null) { + return Container(); + } + this.context = context; + return Container( + margin: EdgeInsets.only( + left: double.tryParse(style?.leftRightMargin ?? "0"), right: double.tryParse(style?.leftRightMargin ?? "0"), top: double.tryParse(style?.topMargin ?? "0"), bottom: 0), + padding: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10), + decoration: BoxDecoration( + color: HexColor.fromHex(style?.bgColor ?? ''), + borderRadius: BorderRadius.only( + topLeft: Radius.circular(double.tryParse(style?.topLeftRadius ?? "0")), + topRight: Radius.circular(double.tryParse(style?.topRightRadius ?? "0")), + bottomLeft: Radius.circular(double.tryParse(style?.bottomLeftRadius ?? "0")), + bottomRight: Radius.circular(double.tryParse(style?.bottomRightRadius ?? "0")))), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Container( + width: 4, + height: 14, + decoration: BoxDecoration(color: HexColor.fromHex("#FF2020"), borderRadius: BorderRadius.circular(10)), + margin: EdgeInsets.only(right: 10), + ), + Text( + style?.title ?? "", + style: TextStyle(color: HexColor.fromHex("#333333"), fontSize: 15, fontWeight: FontWeight.w500), + ) + ], + ), + Padding( + padding: const EdgeInsets.only(left: 15), + child: Text( + style?.subTitle ?? "", + style: TextStyle(color: HexColor.fromHex("#999999"), fontSize: 12, fontWeight: FontWeight.w500), + ), + ), + SizedBox( + height: 10, + ), + createNav() + ], + ), + ); + } + + createNav() { + List listWidget = List(); + int row = (style?.listStyle?.length / style?.columSize).ceil(); + for (var index = 0; index < row; index++) { + listWidget.add(Row( + children: _buildRow(index), + )); + } + + return Column(children: listWidget); + } + + _buildRow(int index2) { + List listWidget = List(); + + int currentIndex = index2 * style?.columSize; + + for (var index = 0; index < style?.columSize; index++) { + var nowIndex = currentIndex + index; + listWidget.add(Expanded( + child: _buildItem(nowIndex), + )); + } + + return listWidget; + } + + _buildItem(int currentIndex) { + print(currentIndex.toString()); + if (currentIndex >= style?.listStyle?.length) { + return Container(); + } + + var item = style.listStyle[currentIndex]; + print(currentIndex.toString() + item?.title); + return GestureDetector( + onTap: () { + RouterUtil.route(SkipModel.fromJson(item.toJson() ?? ''), item.toJson(), context); + }, + child: Container( + margin: EdgeInsets.only(top: 10), + child: Column( + children: [ + CachedNetworkImage( + imageUrl: item?.img ?? "", + width: 40, + height: 40, + ), + SizedBox( + height: 6, + ), + Text( + item?.title, + style: TextStyle(color: HexColor.fromHex("#333333"), fontSize: 12), + ), + Text( + item?.subTitle, + style: TextStyle(color: HexColor.fromHex("#333333"), fontSize: 10), + ), + ], + ), + ), + ); + } +} diff --git a/lib/widgets/custom/ordedr_class/order_class_nav/order_class_style.dart b/lib/widgets/custom/ordedr_class/order_class_nav/order_class_style.dart new file mode 100644 index 0000000..cbb02bc --- /dev/null +++ b/lib/widgets/custom/ordedr_class/order_class_nav/order_class_style.dart @@ -0,0 +1,186 @@ +class OrderClassStyle { + String name; + String desc; + String title; + int customFeaturesCate; + String moduleType; + String moduleKey; + String isTopMargin; + String isLeftRightMargin; + String isShow; + String topMargin; + String leftRightMargin; + String topLeftRadius; + String topRightRadius; + String bottomLeftRadius; + String bottomRightRadius; + String bgColor; + String subTitle; + List listStyle; + int columSize; + + OrderClassStyle( + {this.name, + this.desc, + this.title, + this.customFeaturesCate, + this.moduleType, + this.moduleKey, + this.isTopMargin, + this.isLeftRightMargin, + this.isShow, + this.topMargin, + this.leftRightMargin, + this.topLeftRadius, + this.topRightRadius, + this.bottomLeftRadius, + this.bottomRightRadius, + this.bgColor, + this.subTitle, + this.listStyle, + this.columSize}); + + OrderClassStyle.fromJson(Map json) { + name = json['name']; + desc = json['desc']; + title = json['title']; + customFeaturesCate = json['custom_features_cate']; + moduleType = json['module_type']; + moduleKey = json['module_key']; + isTopMargin = json['is_top_margin']; + isLeftRightMargin = json['is_left_right_margin']; + isShow = json['is_show']; + topMargin = json['top_margin']; + leftRightMargin = json['left_right_margin']; + topLeftRadius = json['top_left_radius']; + topRightRadius = json['top_right_radius']; + bottomLeftRadius = json['bottom_left_radius']; + bottomRightRadius = json['bottom_right_radius']; + bgColor = json['bg_color']; + subTitle = json['sub_title']; + if (json['list_style'] != null) { + listStyle = new List(); + json['list_style'].forEach((v) { + listStyle.add(new ListStyle.fromJson(v)); + }); + } + columSize = json['colum_size']; + } + + Map toJson() { + final Map data = new Map(); + data['name'] = this.name; + data['desc'] = this.desc; + data['title'] = this.title; + data['custom_features_cate'] = this.customFeaturesCate; + data['module_type'] = this.moduleType; + data['module_key'] = this.moduleKey; + data['is_top_margin'] = this.isTopMargin; + data['is_left_right_margin'] = this.isLeftRightMargin; + data['is_show'] = this.isShow; + data['top_margin'] = this.topMargin; + data['left_right_margin'] = this.leftRightMargin; + data['top_left_radius'] = this.topLeftRadius; + data['top_right_radius'] = this.topRightRadius; + data['bottom_left_radius'] = this.bottomLeftRadius; + data['bottom_right_radius'] = this.bottomRightRadius; + data['bg_color'] = this.bgColor; + data['sub_title'] = this.subTitle; + if (this.listStyle != null) { + data['list_style'] = this.listStyle.map((v) => v.toJson()).toList(); + } + data['colum_size'] = this.columSize; + return data; + } +} + +class ListStyle { + String idx; + String title; + String img; + Data data; + String imgUrl; + String subTitle; + String isShow; + String rightIcon; + String rightIconUrl; + String skipIdentifier; + String requiredLogin; + String requiredTaobaoAuth; + String isJump; + String cateTag; + String skipName; + + ListStyle( + {this.idx, + this.title, + this.img, + this.data, + this.imgUrl, + this.subTitle, + this.isShow, + this.rightIcon, + this.rightIconUrl, + this.skipIdentifier, + this.requiredLogin, + this.requiredTaobaoAuth, + this.isJump, + this.cateTag, + this.skipName}); + + ListStyle.fromJson(Map json) { + idx = json['idx']; + title = json['title']; + img = json['img']; + data = json['data'] != null ? new Data.fromJson(json['data']) : null; + imgUrl = json['img_url']; + subTitle = json['sub_title']; + isShow = json['is_show']; + rightIcon = json['right_icon']; + rightIconUrl = json['right_icon_url']; + skipIdentifier = json['skip_identifier']; + requiredLogin = json['required_login']; + requiredTaobaoAuth = json['required_taobao_auth']; + isJump = json['is_jump']; + cateTag = json['cate_tag']; + skipName = json['skip_name']; + } + + Map toJson() { + final Map data = new Map(); + data['idx'] = this.idx; + data['title'] = this.title; + data['img'] = this.img; + if (this.data != null) { + data['data'] = this.data.toJson(); + } + data['img_url'] = this.imgUrl; + data['sub_title'] = this.subTitle; + data['is_show'] = this.isShow; + data['right_icon'] = this.rightIcon; + data['right_icon_url'] = this.rightIconUrl; + data['skip_identifier'] = this.skipIdentifier; + data['required_login'] = this.requiredLogin; + data['required_taobao_auth'] = this.requiredTaobaoAuth; + data['is_jump'] = this.isJump; + data['cate_tag'] = this.cateTag; + data['skip_name'] = this.skipName; + return data; + } +} + +class Data { + String sourceType; + + Data({this.sourceType}); + + Data.fromJson(Map json) { + sourceType = json['source_type']; + } + + Map toJson() { + final Map data = new Map(); + data['source_type'] = this.sourceType; + return data; + } +} diff --git a/lib/widgets/custom/ordedr_found/order_found_nav/order_found_nav.dart b/lib/widgets/custom/ordedr_found/order_found_nav/order_found_nav.dart deleted file mode 100644 index d650ded..0000000 --- a/lib/widgets/custom/ordedr_found/order_found_nav/order_found_nav.dart +++ /dev/null @@ -1,90 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:zhiying_comm/util/extension/color.dart'; -import 'package:zhiying_comm/zhiying_comm.dart'; - -class OrderFoundNav extends StatelessWidget { - @override - Widget build(BuildContext context) { - return Container( - margin: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10), - padding: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10), - decoration: BoxDecoration(color: HexColor.fromHex("#FFFFFF"), borderRadius: BorderRadius.circular(10)), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - children: [ - Container( - width: 4, - height: 14, - decoration: BoxDecoration(color: HexColor.fromHex("#FF2020"), borderRadius: BorderRadius.circular(10)), - margin: EdgeInsets.only(right: 10), - ), - Text( - "如何获取订单编号?", - style: TextStyle(color: HexColor.fromHex("#333333"), fontSize: 15, fontWeight: FontWeight.w500), - ) - ], - ), - Padding( - padding: const EdgeInsets.only(left: 15), - child: Text( - "美图、饿了么、权益等", - style: TextStyle(color: HexColor.fromHex("#999999"), fontSize: 12, fontWeight: FontWeight.w500), - ), - ), - SizedBox( - height: 10, - ), - createNav() - ], - ), - ); - } - - createNav() { - List listWidget = List(); - - for (var index = 0; index < 2; index++) { - listWidget.add(Row( - children: _buildRow(index), - )); - } - - return Column(children: listWidget); - } - - _buildRow(int index2) { - List listWidget = List(); - - for (var index = 0; index < 5; index++) { - listWidget.add(Expanded( - child: _buildItem(), - )); - } - - return listWidget; - } - - _buildItem() { - return Container( - margin: EdgeInsets.only(top: 10), - child: Column( - children: [ - CachedNetworkImage( - imageUrl: "https://alipic.lanhuapp.com/SketchPngcc0450a94dea814bcb680581f96ff1646a8b4f7c00a496f21e808f6c3dbfebe1", - width: 40, - height: 40, - ), - SizedBox( - height: 6, - ), - Text( - "苏宁", - style: TextStyle(color: HexColor.fromHex("#333333"), fontSize: 12), - ), - ], - ), - ); - } -}