@@ -37,7 +37,7 @@ class CustomPageBloc extends Bloc<CustomPageEvent, CustomPageState> { | |||||
var result = await repository.fetchInitData(); | var result = await repository.fetchInitData(); | ||||
if (!EmptyUtil.isEmpty(result)) { | if (!EmptyUtil.isEmpty(result)) { | ||||
yield CustomPageRefreshSuccessState(); | yield CustomPageRefreshSuccessState(); | ||||
yield CustomPageLoadedState(model: result); | |||||
yield CustomPageLoadedState(model: result.modList,backgroundModel: result.backgroundModel); | |||||
} else { | } else { | ||||
yield CustomPageRefreshErrorState(); | yield CustomPageRefreshErrorState(); | ||||
yield CustomPageErrorState(); | yield CustomPageErrorState(); | ||||
@@ -48,17 +48,17 @@ class CustomPageBloc extends Bloc<CustomPageEvent, CustomPageState> { | |||||
Stream<CustomPageState> _mapInitToState(CustomPageInitEvent event) async* { | Stream<CustomPageState> _mapInitToState(CustomPageInitEvent event) async* { | ||||
// 获取缓存数据 | // 获取缓存数据 | ||||
var cache = await repository.fetchCacheData(); | var cache = await repository.fetchCacheData(); | ||||
if (!EmptyUtil.isEmpty(cache) && cache is List) { | |||||
yield CustomPageLoadedState(model: cache); | |||||
if (!EmptyUtil.isEmpty(cache) && cache is CustomPageData) { | |||||
yield CustomPageLoadedState(model: cache.modList,backgroundModel: cache.backgroundModel); | |||||
} | } | ||||
// 获取网络数据 | // 获取网络数据 | ||||
var result = await repository.fetchInitData(); | var result = await repository.fetchInitData(); | ||||
List<Map<String, dynamic>> mdata = result; | |||||
List<Map<String, dynamic>> mdata = result.modList; | |||||
for (int i = 0; i < mdata.length; i++) { | for (int i = 0; i < mdata.length; i++) { | ||||
Logger.log("页面数据: " + mdata[i].toString()); | Logger.log("页面数据: " + mdata[i].toString()); | ||||
} | } | ||||
if (!EmptyUtil.isEmpty(result) && result is List) { | |||||
yield CustomPageLoadedState(model: result); | |||||
if (!EmptyUtil.isEmpty(result) && result is CustomPageData) { | |||||
yield CustomPageLoadedState(model: result.modList,backgroundModel: result.backgroundModel); | |||||
} else { | } else { | ||||
if (EmptyUtil.isEmpty(cache)) { | if (EmptyUtil.isEmpty(cache)) { | ||||
yield CustomPageInitErrorState(); | yield CustomPageInitErrorState(); | ||||
@@ -1,3 +1,6 @@ | |||||
import 'dart:convert'; | |||||
import 'package:zhiying_base_widget/pages/main_page/model/background_model.dart'; | |||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
class CustomPageRepository { | class CustomPageRepository { | ||||
@@ -6,7 +9,8 @@ class CustomPageRepository { | |||||
CustomPageRepository({this.data}); | CustomPageRepository({this.data}); | ||||
/// 初始化 | /// 初始化 | ||||
Future<List<Map<String, dynamic>>> fetchInitData() async { | |||||
Future<CustomPageData> fetchInitData() async { | |||||
CustomPageData customPageData=CustomPageData(); | |||||
try { | try { | ||||
String skipIdentifier = | String skipIdentifier = | ||||
!EmptyUtil.isEmpty(data) && data.containsKey(GlobalConfig.SKIP_IDENTIFIER) && !EmptyUtil.isEmpty(data[GlobalConfig.SKIP_IDENTIFIER]) ? data[GlobalConfig.SKIP_IDENTIFIER] : null; | !EmptyUtil.isEmpty(data) && data.containsKey(GlobalConfig.SKIP_IDENTIFIER) && !EmptyUtil.isEmpty(data[GlobalConfig.SKIP_IDENTIFIER]) ? data[GlobalConfig.SKIP_IDENTIFIER] : null; | ||||
@@ -16,7 +20,11 @@ class CustomPageRepository { | |||||
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { | if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { | ||||
List mobList = List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['mod_list']); | List mobList = List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]['mod_list']); | ||||
if (!EmptyUtil.isEmpty(mobList)) { | if (!EmptyUtil.isEmpty(mobList)) { | ||||
return mobList.map((e) => Map<String, dynamic>.from(e)).toList(); | |||||
customPageData.modList= mobList.map((e) => Map<String, dynamic>.from(e)).toList(); | |||||
if(result.containsKey('out_data')){ | |||||
customPageData.backgroundModel=BackgroundModel.fromJson(json.decode(result['out_data'])); | |||||
} | |||||
return customPageData; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -27,17 +35,27 @@ class CustomPageRepository { | |||||
} | } | ||||
/// 缓存数据 | /// 缓存数据 | ||||
Future<List<Map<String, dynamic>>> fetchCacheData() async { | |||||
Future<CustomPageData> fetchCacheData() async { | |||||
CustomPageData customPageData=CustomPageData(); | |||||
try { | try { | ||||
String skipIdentifier = | String skipIdentifier = | ||||
!EmptyUtil.isEmpty(data) && data.containsKey(GlobalConfig.SKIP_IDENTIFIER) && !EmptyUtil.isEmpty(data[GlobalConfig.SKIP_IDENTIFIER]) ? data[GlobalConfig.SKIP_IDENTIFIER] : null; | !EmptyUtil.isEmpty(data) && data.containsKey(GlobalConfig.SKIP_IDENTIFIER) && !EmptyUtil.isEmpty(data[GlobalConfig.SKIP_IDENTIFIER]) ? data[GlobalConfig.SKIP_IDENTIFIER] : null; | ||||
// String skipIdentifier = 'pub.flutter.index.84'; | // String skipIdentifier = 'pub.flutter.index.84'; | ||||
if (!EmptyUtil.isEmpty(skipIdentifier)) { | if (!EmptyUtil.isEmpty(skipIdentifier)) { | ||||
var result = await NetUtil.getRequestCachedData('/api/v1/mod/$skipIdentifier'); | |||||
Map<String,dynamic> result = await NetUtil.getRequestCachedData('/api/v1/mod/$skipIdentifier'); | |||||
if (!EmptyUtil.isEmpty(result)) { | if (!EmptyUtil.isEmpty(result)) { | ||||
List mobList = result['mod_list']; | List mobList = result['mod_list']; | ||||
customPageData.modList=List(); | |||||
if (!EmptyUtil.isEmpty(mobList)) { | if (!EmptyUtil.isEmpty(mobList)) { | ||||
return mobList.map((e) => Map<String, dynamic>.from(e)).toList(); | |||||
for(var item in mobList){ | |||||
customPageData.modList.add(Map<String, dynamic>.from(item)); | |||||
} | |||||
if(result.containsKey('out_data')){ | |||||
var jsonData=json.decode(result['out_data']); | |||||
print(jsonData); | |||||
customPageData.backgroundModel=BackgroundModel.fromJson(jsonData); | |||||
} | |||||
return customPageData; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -47,3 +65,9 @@ class CustomPageRepository { | |||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
class CustomPageData{ | |||||
BackgroundModel backgroundModel; | |||||
List<Map<String, dynamic>> modList; | |||||
} |
@@ -1,5 +1,6 @@ | |||||
import 'package:meta/meta.dart'; | import 'package:meta/meta.dart'; | ||||
import 'package:equatable/equatable.dart'; | import 'package:equatable/equatable.dart'; | ||||
import 'package:zhiying_base_widget/pages/main_page/model/background_model.dart'; | |||||
@immutable | @immutable | ||||
abstract class CustomPageState extends Equatable{ | abstract class CustomPageState extends Equatable{ | ||||
@@ -12,8 +13,9 @@ class CustomPageInitialState extends CustomPageState {} | |||||
/// 数据加载成功 | /// 数据加载成功 | ||||
class CustomPageLoadedState extends CustomPageState { | class CustomPageLoadedState extends CustomPageState { | ||||
BackgroundModel backgroundModel; | |||||
List<Map<String, dynamic>> model; | List<Map<String, dynamic>> model; | ||||
CustomPageLoadedState({this.model}); | |||||
CustomPageLoadedState({this.model,this.backgroundModel}); | |||||
@override | @override | ||||
List<Object> get props => [this.model]; | List<Object> get props => [this.model]; | ||||
} | } | ||||
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart'; | |||||
import 'package:pull_to_refresh/pull_to_refresh.dart'; | import 'package:pull_to_refresh/pull_to_refresh.dart'; | ||||
import 'package:tab_indicator_styler/tab_indicator_styler.dart'; | import 'package:tab_indicator_styler/tab_indicator_styler.dart'; | ||||
import 'package:zhiying_base_widget/pages/custom_page/custom_item_page.dart'; | import 'package:zhiying_base_widget/pages/custom_page/custom_item_page.dart'; | ||||
import 'package:zhiying_base_widget/pages/main_page/model/background_model.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_bg_notifier.dart'; | ||||
import 'package:zhiying_base_widget/widgets/custom/search/custom_search_widget.dart'; | import 'package:zhiying_base_widget/widgets/custom/search/custom_search_widget.dart'; | ||||
import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart'; | import 'package:zhiying_base_widget/widgets/empty/empty_widget.dart'; | ||||
@@ -101,7 +102,7 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single | |||||
/// 有数据 | /// 有数据 | ||||
if (state is CustomPageLoadedState) { | if (state is CustomPageLoadedState) { | ||||
if (EmptyUtil.isEmpty(state.model)) return _buildEmptyWidget(); | if (EmptyUtil.isEmpty(state.model)) return _buildEmptyWidget(); | ||||
return _buildMainWidget(state.model); | |||||
return _buildMainWidget(state.model,state.backgroundModel); | |||||
} | } | ||||
/// 初始化失败 | /// 初始化失败 | ||||
@@ -117,20 +118,22 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single | |||||
} | } | ||||
/// 有数据 | /// 有数据 | ||||
Widget _buildMainWidget(List<Map<String, dynamic>> model) { | |||||
return Stack( | |||||
children: <Widget>[ | |||||
Scaffold( | |||||
appBar: _buildAppbar(model?.first), | |||||
backgroundColor: HexColor.fromHex('#F9F9F9'), | |||||
// floatingActionButton: _buildFloatWidget(), | |||||
floatingActionButtonLocation: _CustomFloatingActionButtonLocation(FloatingActionButtonLocation.endFloat, 0, -100), | |||||
body: Column(children: _buildFirstWidget(model)), | |||||
), | |||||
], | |||||
Widget _buildMainWidget(List<Map<String, dynamic>> model,BackgroundModel backgroundModel) { | |||||
return Scaffold( | |||||
appBar: _buildAppbar(model?.first), | |||||
backgroundColor: HexColor.fromHex(backgroundModel?.bgColor??""), | |||||
// floatingActionButton: _buildFloatWidget(), | |||||
floatingActionButtonLocation: _CustomFloatingActionButtonLocation(FloatingActionButtonLocation.endFloat, 0, -100), | |||||
body: Stack( | |||||
children: <Widget>[ | |||||
_buildBackground(backgroundModel), | |||||
Column(children: _buildFirstWidget(model)), | |||||
], | |||||
), | |||||
); | ); | ||||
} | } | ||||
/// 骨架图 | /// 骨架图 | ||||
Widget _buildSkeletonWidget() { | Widget _buildSkeletonWidget() { | ||||
return Scaffold(); | return Scaffold(); | ||||
@@ -223,8 +226,8 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single | |||||
} | } | ||||
// 没有appbar并且没有tabbar,则给第一个元素加边距 | // 没有appbar并且没有tabbar,则给第一个元素加边距 | ||||
if (!_isHasAppbar && !_isHasTabBar) { | |||||
result.insert(0, SizedBox(height: MediaQueryData.fromWindow(window).padding.top, child: Container(color: HexColor.fromHex('#FF4242'),),)); | |||||
if (!_isHasAppbar) { | |||||
result.insert(0, SizedBox(height: MediaQueryData.fromWindow(window).padding.top, child: Container(color: HexColor.fromHex(''),),)); | |||||
} | } | ||||
return result; | return result; | ||||
@@ -340,6 +343,24 @@ class __CommonPageContainerState extends State<_CommonPageContainer> with Single | |||||
return result; | return result; | ||||
} | } | ||||
_buildBackground(BackgroundModel backgroundModel) { | |||||
if (backgroundModel != null) { | |||||
var headerBg = backgroundModel.headerBg; | |||||
return Container( | |||||
height: double.tryParse(headerBg?.height)?? 0, | |||||
width: double.infinity, | |||||
decoration: BoxDecoration( | |||||
gradient: LinearGradient( | |||||
begin: Alignment.topCenter, | |||||
end: Alignment.bottomCenter, | |||||
colors: [HexColor.fromHex(headerBg?.mainColor ?? ""), HexColor.fromHex(headerBg?.assistColor ?? ""), HexColor.fromHex(headerBg?.minorColor ?? "")])), | |||||
); | |||||
}else{ | |||||
return Container(); | |||||
} | |||||
} | |||||
// /// 悬浮按钮 | // /// 悬浮按钮 | ||||
// Widget _buildFloatWidget() { | // Widget _buildFloatWidget() { | ||||
// return Visibility( | // return Visibility( | ||||
@@ -114,7 +114,7 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
_refreshController.refreshCompleted(); | _refreshController.refreshCompleted(); | ||||
Widget bgWidget = validateBgWidget(context, snapshot.data ?? []); | Widget bgWidget = validateBgWidget(context, snapshot.data ?? []); | ||||
return Scaffold( | return Scaffold( | ||||
backgroundColor: Color(0xfff9f9f9), | |||||
backgroundColor: HexColor.fromHex("#fff9f9f9"), | |||||
floatingActionButton: _floatWidget, | floatingActionButton: _floatWidget, | ||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, | floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, | ||||
body: MediaQuery.removePadding( | body: MediaQuery.removePadding( | ||||
@@ -180,15 +180,16 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
return list; | return list; | ||||
} | } | ||||
///处理特殊背景图 | ///处理特殊背景图 | ||||
Widget validateBgWidget(BuildContext context, List<Map<String, dynamic>> datas) { | Widget validateBgWidget(BuildContext context, List<Map<String, dynamic>> datas) { | ||||
for (int i = 0; i < datas.length; i++) { | for (int i = 0; i < datas.length; i++) { | ||||
WidgetModel item = WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); | WidgetModel item = WidgetModel.fromJson(Map<String, dynamic>.from(datas[i])); | ||||
if (item.modName == "profile_background") { | if (item.modName == "profile_background") { | ||||
final double statusBarHeight = MediaQuery.of(context).padding.top; | final double statusBarHeight = MediaQuery.of(context).padding.top; | ||||
String url=json.decode(item.data)['img']; | |||||
String url = json.decode(item.data)['img']; | |||||
return Container( | return Container( | ||||
width: double.infinity, | width: double.infinity, | ||||
height: statusBarHeight + 250, | height: statusBarHeight + 250, | ||||
@@ -198,21 +199,34 @@ class _MainPageContainerState extends State<_MainPageContainer> { | |||||
), | ), | ||||
); | ); | ||||
} | } | ||||
if (item.modName == "member_info") { | |||||
final double statusBarHeight = MediaQuery.of(context).padding.top; | |||||
String url=json.decode(item.data)['bg_image']; | |||||
String bgColor=json.decode(item.data)['bg_color']; | |||||
return Container( | |||||
width: double.infinity, | |||||
height: statusBarHeight + 250, | |||||
color: HexColor.fromHex(bgColor??""), | |||||
child: CachedNetworkImage( | |||||
imageUrl: url??"", | |||||
fit: BoxFit.fitHeight, | |||||
), | |||||
); | |||||
} | |||||
// if (item.modName == "member_info") { | |||||
// final double statusBarHeight = MediaQuery.of(context).padding.top; | |||||
// String url = json.decode(item.data)['bg_image']; | |||||
// String bgColor = json.decode(item.data)['bg_color']; | |||||
// return Container( | |||||
// width: double.infinity, | |||||
// height: statusBarHeight + 250, | |||||
// color: HexColor.fromHex(bgColor ?? ""), | |||||
// child: CachedNetworkImage( | |||||
// imageUrl: url ?? "", | |||||
// fit: BoxFit.fitHeight, | |||||
// ), | |||||
// ); | |||||
// } | |||||
} | |||||
if (_bloc.backgroundModel != null) { | |||||
var headerBg = _bloc.backgroundModel.headerBg; | |||||
return Container( | |||||
height: double.tryParse(_bloc?.backgroundModel?.headerBg?.height)?? 0, | |||||
decoration: BoxDecoration( | |||||
gradient: LinearGradient( | |||||
begin: Alignment.topCenter, | |||||
end: Alignment.bottomCenter, | |||||
colors: [HexColor.fromHex(headerBg?.mainColor ?? ""), HexColor.fromHex(headerBg?.assistColor ?? ""), HexColor.fromHex(headerBg?.minorColor ?? "")])), | |||||
); | |||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
} | } |
@@ -1,7 +1,9 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'package:zhiying_base_widget/pages/main_page/model/background_model.dart'; | |||||
import 'package:zhiying_comm/util/base_bloc.dart'; | import 'package:zhiying_comm/util/base_bloc.dart'; | ||||
import 'package:zhiying_comm/zhiying_comm.dart'; | import 'package:zhiying_comm/zhiying_comm.dart'; | ||||
import 'dart:convert' as Con; | |||||
class MainPageBloc extends BlocBase { | class MainPageBloc extends BlocBase { | ||||
List<Map<String, dynamic>> _pageData = List(); | List<Map<String, dynamic>> _pageData = List(); | ||||
@@ -11,6 +13,8 @@ class MainPageBloc extends BlocBase { | |||||
Stream<List<Map<String, dynamic>>> get outData => _mainController.stream; | Stream<List<Map<String, dynamic>>> get outData => _mainController.stream; | ||||
BackgroundModel backgroundModel; | |||||
@override | @override | ||||
void dispose() { | void dispose() { | ||||
_mainController.close(); | _mainController.close(); | ||||
@@ -18,6 +22,7 @@ class MainPageBloc extends BlocBase { | |||||
} | } | ||||
void loadData(String skipIdentifier) { | void loadData(String skipIdentifier) { | ||||
print("加载mainPage"+skipIdentifier); | |||||
NetUtil.request('/api/v1/mod/${skipIdentifier}', method: NetMethod.GET, | NetUtil.request('/api/v1/mod/${skipIdentifier}', method: NetMethod.GET, | ||||
onCache: (data) { | onCache: (data) { | ||||
_loadData(data); | _loadData(data); | ||||
@@ -33,7 +38,7 @@ class MainPageBloc extends BlocBase { | |||||
_pageData = list.map((item) { | _pageData = list.map((item) { | ||||
return Map<String, dynamic>.from(item); | return Map<String, dynamic>.from(item); | ||||
}).toList(); | }).toList(); | ||||
backgroundModel=BackgroundModel.fromJson(Con.json.decode(json['out_data'])); | |||||
_mainController.add(_pageData); | _mainController.add(_pageData); | ||||
} | } | ||||
} | } |
@@ -0,0 +1,47 @@ | |||||
class BackgroundModel { | |||||
HeaderBg headerBg; | |||||
String bgColor; | |||||
BackgroundModel({this.headerBg, this.bgColor}); | |||||
BackgroundModel.fromJson(Map<String, dynamic> json) { | |||||
headerBg = json['header_bg'] != null | |||||
? new HeaderBg.fromJson(json['header_bg']) | |||||
: null; | |||||
bgColor = json['bg_color']; | |||||
} | |||||
Map<String, dynamic> toJson() { | |||||
final Map<String, dynamic> data = new Map<String, dynamic>(); | |||||
if (this.headerBg != null) { | |||||
data['header_bg'] = this.headerBg.toJson(); | |||||
} | |||||
data['bg_color'] = this.bgColor; | |||||
return data; | |||||
} | |||||
} | |||||
class HeaderBg { | |||||
String height; | |||||
String mainColor; | |||||
String assistColor; | |||||
String minorColor; | |||||
HeaderBg({this.height, this.mainColor, this.assistColor, this.minorColor}); | |||||
HeaderBg.fromJson(Map<String, dynamic> json) { | |||||
height = json['height']; | |||||
mainColor = json['main_color']; | |||||
assistColor = json['assist_color']; | |||||
minorColor = json['minor_color']; | |||||
} | |||||
Map<String, dynamic> toJson() { | |||||
final Map<String, dynamic> data = new Map<String, dynamic>(); | |||||
data['height'] = this.height; | |||||
data['main_color'] = this.mainColor; | |||||
data['assist_color'] = this.assistColor; | |||||
data['minor_color'] = this.minorColor; | |||||
return data; | |||||
} | |||||
} |
@@ -56,7 +56,7 @@ class CustomGoodsContainer2 extends StatefulWidget { | |||||
class CustomGoodsContainer2State extends State<CustomGoodsContainer2> { | class CustomGoodsContainer2State extends State<CustomGoodsContainer2> { | ||||
HomeGoodsBloc _bloc; | HomeGoodsBloc _bloc; | ||||
String _provider = ''; | |||||
dynamic _provider; | |||||
HomeGoodsStyleModel _style; | HomeGoodsStyleModel _style; | ||||
@override | @override | ||||
@@ -128,7 +128,7 @@ class CustomGoodsContainer2State extends State<CustomGoodsContainer2> { | |||||
} | } | ||||
// Global Key | // Global Key | ||||
void changeProviderOrLoadMore(String provider) { | |||||
void changeProviderOrLoadMore(dynamic provider) { | |||||
Logger.warn('_CustomGoodsContainer2State ======================= provider = $provider'); | Logger.warn('_CustomGoodsContainer2State ======================= provider = $provider'); | ||||
_provider = provider; | _provider = provider; | ||||
_bloc?.loadMore(_bloc.providerss); | _bloc?.loadMore(_bloc.providerss); | ||||
@@ -80,7 +80,7 @@ class _CustomGoodsHeaderContainerState extends State<CustomGoodsHeaderContainer> | |||||
_tabController = TabController(length: _style?.recommendList?.length ?? 0, vsync: this); | _tabController = TabController(length: _style?.recommendList?.length ?? 0, vsync: this); | ||||
if (_style.recommendList.first != null) { | if (_style.recommendList.first != null) { | ||||
// TODO | // TODO | ||||
widget.callBack.onTap(0, _style.recommendList.first.type); | |||||
widget.callBack.onTap(0, _style.recommendList.first.data); | |||||
} | } | ||||
super.initState(); | super.initState(); | ||||
} | } | ||||
@@ -110,7 +110,7 @@ class _CustomGoodsHeaderContainerState extends State<CustomGoodsHeaderContainer> | |||||
tabs: _widgets, | tabs: _widgets, | ||||
onTap: (index) { | onTap: (index) { | ||||
//TODO | //TODO | ||||
widget.callBack.onTap(index, _style.recommendList[index].type); | |||||
widget.callBack.onTap(index, _style.recommendList[index].data); | |||||
setState(() { | setState(() { | ||||
_currentIndex = index; | _currentIndex = index; | ||||
}); | }); | ||||
@@ -84,7 +84,7 @@ class _CustomGoodsHeaderContainer2State extends State<CustomGoodsHeaderContainer | |||||
_tabController = TabController(length: _style?.recommendList?.length ?? 0, vsync: this); | _tabController = TabController(length: _style?.recommendList?.length ?? 0, vsync: this); | ||||
if (_style.recommendList.first != null) { | if (_style.recommendList.first != null) { | ||||
// TODO | // TODO | ||||
widget?.globalKey?.currentState?.changeProviderOrLoadMore(_style.recommendList.first.type); | |||||
widget?.globalKey?.currentState?.changeProviderOrLoadMore(_style.recommendList.first.data); | |||||
} | } | ||||
super.initState(); | super.initState(); | ||||
} | } | ||||
@@ -117,7 +117,7 @@ class _CustomGoodsHeaderContainer2State extends State<CustomGoodsHeaderContainer | |||||
setState(() { | setState(() { | ||||
_currentIndex = index; | _currentIndex = index; | ||||
}); | }); | ||||
widget?.globalKey?.currentState?.changeProviderOrLoadMore(_style.recommendList[index].type); | |||||
widget?.globalKey?.currentState?.changeProviderOrLoadMore(_style.recommendList[index].data); | |||||
}, | }, | ||||
), | ), | ||||
); | ); | ||||
@@ -123,7 +123,7 @@ class _CustomSlideBannerContainerState extends State<CustomSlideBannerContainer> | |||||
child: Container( | child: Container( | ||||
width: double.infinity, | width: double.infinity, | ||||
height: double.infinity, | height: double.infinity, | ||||
color: size > 1 ? HexColor.fromHex(datas?.bgColor2??"#FFFF4242") : Colors.transparent, | |||||
color: size > 1 ? HexColor.fromHex(datas?.bgColor2??"#00000000") : Colors.transparent, | |||||
// color: Colors.yellow, | // color: Colors.yellow, | ||||
), | ), | ||||
), | ), | ||||
@@ -1,4 +1,5 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'dart:convert'; | |||||
import 'package:zhiying_base_widget/widgets/custom/goods/category_goods/category_goods_callback.dart'; | import 'package:zhiying_base_widget/widgets/custom/goods/category_goods/category_goods_callback.dart'; | ||||
import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; | import 'package:zhiying_base_widget/widgets/home/home_goods/models/home_goods_model.dart'; | ||||
@@ -8,7 +9,7 @@ import 'package:zhiying_comm/zhiying_comm.dart'; | |||||
class HomeGoodsBloc extends BlocBase implements CategoryGoodsOnClickCallBack{ | class HomeGoodsBloc extends BlocBase implements CategoryGoodsOnClickCallBack{ | ||||
List<HomeGoodsModel> _goods = List(); | List<HomeGoodsModel> _goods = List(); | ||||
String _provider = ''; | |||||
dynamic _provider ; | |||||
String providerss = ''; | String providerss = ''; | ||||
int _page = 1; | int _page = 1; | ||||
@@ -22,7 +23,7 @@ class HomeGoodsBloc extends BlocBase implements CategoryGoodsOnClickCallBack{ | |||||
_goodsController = null; | _goodsController = null; | ||||
} | } | ||||
void loadMore(String provider) { | |||||
void loadMore(dynamic provider) { | |||||
if (provider != _provider) { | if (provider != _provider) { | ||||
_page = 1; | _page = 1; | ||||
} | } | ||||
@@ -32,7 +33,8 @@ class HomeGoodsBloc extends BlocBase implements CategoryGoodsOnClickCallBack{ | |||||
_goods.clear(); | _goods.clear(); | ||||
} | } | ||||
NetUtil.request('/api/v1/rec/${provider.toString()}?page=${_page.toString()}', | |||||
NetUtil.request('/api/v1/rec?page=${_page.toString()}', | |||||
queryParameters: _provider, | |||||
method: NetMethod.GET, | method: NetMethod.GET, | ||||
onCache: _page == 1 | onCache: _page == 1 | ||||
? (data) { | ? (data) { | ||||
@@ -51,7 +51,7 @@ class _HomeGoodsContainer extends StatefulWidget { | |||||
class _HomeGoodsContainerState extends State<_HomeGoodsContainer> { | class _HomeGoodsContainerState extends State<_HomeGoodsContainer> { | ||||
HomeGoodsBloc _bloc; | HomeGoodsBloc _bloc; | ||||
String _provider = ''; | |||||
dynamic _provider ; | |||||
HomeGoodsStyleModel _style; | HomeGoodsStyleModel _style; | ||||
bool _isFirstLoading = true; | bool _isFirstLoading = true; | ||||
@@ -31,7 +31,7 @@ class GoodsListCreater extends WidgetCreater { | |||||
} | } | ||||
class HomeGoodsHeaderEvent { | class HomeGoodsHeaderEvent { | ||||
String provider; | |||||
dynamic provider; | |||||
HomeGoodsHeaderEvent(this.provider); | HomeGoodsHeaderEvent(this.provider); | ||||
} | } |
@@ -81,7 +81,7 @@ class _HomeGoodsHeaderState extends State<_HomeGoodsHeader> | |||||
TabController(length: _style?.recommendList?.length ?? 0, vsync: this); | TabController(length: _style?.recommendList?.length ?? 0, vsync: this); | ||||
if (_style.recommendList.first != null) { | if (_style.recommendList.first != null) { | ||||
widget.eventBus | widget.eventBus | ||||
.fire(HomeGoodsHeaderEvent(_style.recommendList.first.type)); | |||||
.fire(HomeGoodsHeaderEvent(_style.recommendList.first.data)); | |||||
} | } | ||||
super.initState(); | super.initState(); | ||||
} | } | ||||
@@ -121,7 +121,7 @@ class _HomeGoodsHeaderState extends State<_HomeGoodsHeader> | |||||
tabs: _widgets, | tabs: _widgets, | ||||
onTap: (index) { | onTap: (index) { | ||||
widget.eventBus | widget.eventBus | ||||
.fire(HomeGoodsHeaderEvent(_style.recommendList[index].type)); | |||||
.fire(HomeGoodsHeaderEvent(_style.recommendList[index].data)); | |||||
setState(() { | setState(() { | ||||
_currentIndex = index; | _currentIndex = index; | ||||
}); | }); | ||||
@@ -1,25 +1,49 @@ | |||||
class HomeGoodsHeaderModel { | class HomeGoodsHeaderModel { | ||||
String type; | |||||
// String type; | |||||
String title; | String title; | ||||
String subtitle; | String subtitle; | ||||
int index; | |||||
dynamic data; | |||||
HomeGoodsHeaderModel({ | |||||
this.type, | |||||
this.title, | |||||
this.subtitle, | |||||
}); | |||||
HomeGoodsHeaderModel( | |||||
{ this.title, this.subtitle, this.index, this.data}); | |||||
HomeGoodsHeaderModel.fromJson(Map<String, dynamic> json) { | HomeGoodsHeaderModel.fromJson(Map<String, dynamic> json) { | ||||
type = json['type']; | |||||
/// type = json['type']; | |||||
title = json['title']; | title = json['title']; | ||||
subtitle = json['subtitle']; | subtitle = json['subtitle']; | ||||
index = json['index']; | |||||
data = json['data']; | |||||
} | } | ||||
Map<String, dynamic> toJson() { | Map<String, dynamic> toJson() { | ||||
final Map<String, dynamic> data = new Map<String, dynamic>(); | final Map<String, dynamic> data = new Map<String, dynamic>(); | ||||
data['type'] = this.type; | |||||
//data['type'] = this.type; | |||||
data['title'] = this.title; | data['title'] = this.title; | ||||
data['subtitle'] = this.subtitle; | data['subtitle'] = this.subtitle; | ||||
data['index'] = this.index; | |||||
if (this.data != null) { | |||||
data['data'] = this.data.toJson(); | |||||
} | |||||
return data; | |||||
} | |||||
} | |||||
class Data { | |||||
String pvd; | |||||
String categoryId; | |||||
Data({this.pvd, this.categoryId}); | |||||
Data.fromJson(Map<String, dynamic> json) { | |||||
pvd = json['pvd']; | |||||
categoryId = json['category_id']; | |||||
} | |||||
Map<String, dynamic> toJson() { | |||||
final Map<String, dynamic> data = new Map<String, dynamic>(); | |||||
data['pvd'] = this.pvd; | |||||
data['category_id'] = this.categoryId; | |||||
return data; | return data; | ||||
} | } | ||||
} | } |