diff --git a/lib/pages/search_result_page/bloc/search_result_repository.dart b/lib/pages/search_result_page/bloc/search_result_repository.dart index 6bb3002..b4d743b 100644 --- a/lib/pages/search_result_page/bloc/search_result_repository.dart +++ b/lib/pages/search_result_page/bloc/search_result_repository.dart @@ -8,7 +8,7 @@ class SearchResultRepository { /// 获取网络数据 Future>> fetchInit(final Map model) async { String keywords = model.containsKey('keywords') ? model['keywords'] : ''; - String type = model.containsKey('type') ? model['type'] : 'taobao'; + String type = model.containsKey('type') ? model['type'] : GlobalConfig.PROVIDER_TB; var result = await NetUtil.post('/api/v1/mod/pub.flutter.search_result', method: NetMethod.GET, cache: true); if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result)) { try { @@ -32,7 +32,7 @@ class SearchResultRepository { /// 获取缓存数据 Future>> fetchCachedData(final Map model) async { String keywords = model.containsKey('keywords') ? model['keywords'] : ''; - String type = model.containsKey('type') ? model['type'] : 'taobao'; + String type = model.containsKey('type') ? model['type'] : GlobalConfig.PROVIDER_TB; var result = await NetUtil.getRequestCachedData('/api/v1/mod/pub.flutter.search_result'); try { if (!EmptyUtil.isEmpty(result)) { diff --git a/lib/pages/search_think_page/bloc/search_think_repository.dart b/lib/pages/search_think_page/bloc/search_think_repository.dart index 67668cc..c3d1d11 100644 --- a/lib/pages/search_think_page/bloc/search_think_repository.dart +++ b/lib/pages/search_think_page/bloc/search_think_repository.dart @@ -5,7 +5,7 @@ class SearchThinkRepository { // 商品电商渠道类型,默认为淘宝 - String type = 'taobao'; + String type = GlobalConfig.PROVIDER_TB; /// 关键字改变 Future> fetchkeyWordsChange(String keywrods) async { diff --git a/lib/pages/team_page/team_page_sk.dart b/lib/pages/team_page/team_page_sk.dart index d7e636c..5438dcc 100644 --- a/lib/pages/team_page/team_page_sk.dart +++ b/lib/pages/team_page/team_page_sk.dart @@ -4,6 +4,6 @@ import 'package:flutter/material.dart'; class TeamPageSkeleton extends StatelessWidget { @override Widget build(BuildContext context) { - return Container(); + return Scaffold(body: Container()); } } diff --git a/lib/register.dart b/lib/register.dart index c5a118f..341b959 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -137,9 +137,32 @@ class BaseWidgetRegister { // MOB 秒验 MobUtil.init(); + // 缓存可能用到的数据,预加载 + Application.addMethod(() { + // 精选的数据 + NetUtil.post('/api/v1/rec/featured?page=1', method: NetMethod.GET, cache: true); + // 淘宝的数据 + NetUtil.post('/api/v1/rec/taobao?page=1', method: NetMethod.GET, cache: true); + // 京东 + NetUtil.post('/api/v1/rec/jd?page=1', method: NetMethod.GET, cache: true); + // 唯品会 + NetUtil.post('/api/v1/rec/vip?page=1', method: NetMethod.GET, cache: true); + // 拼多多 + NetUtil.post('/api/v1/rec/pdd?page=1', method: NetMethod.GET, cache: true); + // 苏宁 + NetUtil.post('/api/v1/rec/suning?page=1', method: NetMethod.GET, cache: true); + // 考拉 + NetUtil.post('/api/v1/rec/kaola?page=1', method: NetMethod.GET, cache: true); + + return null; + }); + + // 延迟一秒 Application.addMethod(() async { return Future.delayed(Duration(seconds: 1)); }); + + } // 注册页面 diff --git a/lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart b/lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart index 8b879a5..ed16f10 100644 --- a/lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart +++ b/lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart @@ -241,16 +241,16 @@ class __FavoritesGoodsListWidgetContainerState extends State<_FavoritesGoodsList closeOnScroll: false, secondaryActions: [ /// 分享 - Padding( - padding: const EdgeInsets.only(bottom: 8), - child: IconSlideAction( - caption: '分享', - color: Colors.deepOrange, - icon: Icons.share, - onTap: () => _onSlideShare(), - closeOnTap: true, - ), - ), + // Padding( + // padding: const EdgeInsets.only(bottom: 8), + // child: IconSlideAction( + // caption: '分享', + // color: Colors.deepOrange, + // icon: Icons.share, + // onTap: () => _onSlideShare(), + // closeOnTap: true, + // ), + // ), /// 删除 Padding( diff --git a/lib/widgets/goods_details/footer/goods_details_footer_widget.dart b/lib/widgets/goods_details/footer/goods_details_footer_widget.dart index e394335..37462bd 100644 --- a/lib/widgets/goods_details/footer/goods_details_footer_widget.dart +++ b/lib/widgets/goods_details/footer/goods_details_footer_widget.dart @@ -94,36 +94,6 @@ class _GoodsDetailsFooterContainerState extends State<_GoodsDetailsFooterContain /// 分享 void _shareOnClick(GoodsDetailsFooterModel model) async { - // print(_user?.toString()); - // if (_user?.token == null || _user.token == '') { - // print('need login...'); - // RouterUtil.goLogin(context); - // return; - // } - // - // String d = widget.model['data']; - // Map data = jsonDecode(d); - // - // Map shareArgs = data['share_url_args'] ?? {}; - // String shopType = shareArgs['type']; - // - // if (data.containsKey('buy_url')) { - // String url = data['buy_url']; - // if (url == null || url == '') { - // Fluttertoast.showToast(msg: '购买链接不存在'); - // return; - // } - // if (shopType == 'taobao') { - // // bool isAuth = await TaobaoAuth.isAuth(); - // if (!_user.isTBAuth) { - // TaobaoAuth.auth(context); - // return; - // } - // } - // Navigator.of(context).push(CupertinoPageRoute( - // builder: (context) => GoodsSharePage(widget.model))); - // } - Map result = await TurnChainUtil.getShareTurnChain(context, _user, model?.good_id, model.provider, model.convertArgs.toJson()); if (!EmptyUtil.isEmpty(result)) { model.shareUrlArgs.buyUrl = result['open_app_url']; diff --git a/lib/widgets/goods_details/recommend/goods_detail_commend_creater.dart b/lib/widgets/goods_details/recommend/goods_detail_commend_creater.dart index 88ea5d7..bbf7a6f 100644 --- a/lib/widgets/goods_details/recommend/goods_detail_commend_creater.dart +++ b/lib/widgets/goods_details/recommend/goods_detail_commend_creater.dart @@ -25,7 +25,7 @@ class GoodsDetailCommendCreater extends WidgetCreater { // child: HomeGoodsHeader(model, _eventBus), // ); - String provider = 'taobao'; + String provider = GlobalConfig.PROVIDER_TB; Map json = convert.jsonDecode(model['data']); bool haveProvider = false; try{ @@ -34,17 +34,17 @@ class GoodsDetailCommendCreater extends WidgetCreater { provider = json['provider']; } }catch(e, s){ - provider = 'taobao'; + provider = GlobalConfig.PROVIDER_TB; Logger.error(e,s); } try { if(!haveProvider) { var listStyle = json['list_style']; - provider = listStyle['product_type']?.toString() ?? 'taobao'; + provider = listStyle['product_type']?.toString() ?? GlobalConfig.PROVIDER_TB; } } catch (e, s) { - provider = 'taobao'; + provider = GlobalConfig.PROVIDER_TB; Logger.error(e, s); } Logger.warn(model?.toString()); diff --git a/lib/widgets/home/home_goods/bloc/home_goods_bloc.dart b/lib/widgets/home/home_goods/bloc/home_goods_bloc.dart index d3b5ca9..4f53169 100644 --- a/lib/widgets/home/home_goods/bloc/home_goods_bloc.dart +++ b/lib/widgets/home/home_goods/bloc/home_goods_bloc.dart @@ -11,8 +11,7 @@ class HomeGoodsBloc extends BlocBase { int _page = 1; - StreamController> _goodsController = - StreamController>(); + StreamController> _goodsController = StreamController>(); Stream> get outData => _goodsController.stream; @@ -32,10 +31,27 @@ class HomeGoodsBloc extends BlocBase { _goods.clear(); } - NetUtil.request( - '/api/v1/rec/${provider.toString()}?page=${_page.toString()}', + NetUtil.request('/api/v1/rec/${provider.toString()}?page=${_page.toString()}', method: NetMethod.GET, - onCache: (data) {}, onSuccess: (data) { + onCache: _page == 1 + ? (data) { + if (!EmptyUtil.isEmpty(data)) { + + if (data.containsKey('good')) { + try { + List list = data['good']; + List goods = list.map((item) { + return HomeGoodsModel.fromJson(Map.from(item)); + }).toList(); + Logger.warn('goods list cache data = ${data?.toString()}'); + _goodsController.add(goods); + } catch (e, s) { + Logger.warn(e,s); + } + } + } + } + : null, onSuccess: (data) { Map json = Map.from(data); if (json.containsKey('good')) { List list = json['good']; diff --git a/lib/widgets/search/tabbar/search_tab_widget.dart b/lib/widgets/search/tabbar/search_tab_widget.dart index ff1ddca..a031040 100644 --- a/lib/widgets/search/tabbar/search_tab_widget.dart +++ b/lib/widgets/search/tabbar/search_tab_widget.dart @@ -35,7 +35,7 @@ class SearchTabWidget extends StatefulWidget { class _SearchTabWidgetState extends State { TabController _tabController; - String _type = 'taobao'; + String _type = GlobalConfig.PROVIDER_TB; /// 联想列表的item点击事件 _onThinkItemClick(SearchThinkModel model){ diff --git a/lib/widgets/search_result/goods_list/bloc/search_result_goods_list_repository.dart b/lib/widgets/search_result/goods_list/bloc/search_result_goods_list_repository.dart index 0b01b1a..2be40de 100644 --- a/lib/widgets/search_result/goods_list/bloc/search_result_goods_list_repository.dart +++ b/lib/widgets/search_result/goods_list/bloc/search_result_goods_list_repository.dart @@ -81,7 +81,7 @@ class SearchResultGoodsListRepository { /// 查询 Future> _baseInitData(bool refresh, final Map model) async { String keyword = model['keywords'] ?? ''; - String type = model.containsKey('type') ? model['type'] : 'taobao'; + String type = model.containsKey('type') ? model['type'] : GlobalConfig.PROVIDER_TB; if (EmptyUtil.isEmpty(keyword)) return null; /// 构造url String url = _buildUrl(type); diff --git a/lib/widgets/search_result/tarbar/search_result_tab_widget.dart b/lib/widgets/search_result/tarbar/search_result_tab_widget.dart index 3e16037..f820fdf 100644 --- a/lib/widgets/search_result/tarbar/search_result_tab_widget.dart +++ b/lib/widgets/search_result/tarbar/search_result_tab_widget.dart @@ -37,7 +37,7 @@ class SearchResultTabWidget extends StatefulWidget { class _SearchResultTabWidgetState extends State { TabController _tabController; - String _type = 'taobao'; + String _type = GlobalConfig.PROVIDER_TB; /// 联想点击事件 _onThinkItemClick(SearchThinkModel model){