@@ -8,7 +8,7 @@ class SearchResultRepository { | |||||
/// 获取网络数据 | /// 获取网络数据 | ||||
Future<List<Map<String, dynamic>>> fetchInit(final Map<String, dynamic> model) async { | Future<List<Map<String, dynamic>>> fetchInit(final Map<String, dynamic> model) async { | ||||
String keywords = model.containsKey('keywords') ? model['keywords'] : ''; | 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); | var result = await NetUtil.post('/api/v1/mod/pub.flutter.search_result', method: NetMethod.GET, cache: true); | ||||
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result)) { | if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result)) { | ||||
try { | try { | ||||
@@ -32,7 +32,7 @@ class SearchResultRepository { | |||||
/// 获取缓存数据 | /// 获取缓存数据 | ||||
Future<List<Map<String, dynamic>>> fetchCachedData(final Map<String, dynamic> model) async { | Future<List<Map<String, dynamic>>> fetchCachedData(final Map<String, dynamic> model) async { | ||||
String keywords = model.containsKey('keywords') ? model['keywords'] : ''; | 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'); | var result = await NetUtil.getRequestCachedData('/api/v1/mod/pub.flutter.search_result'); | ||||
try { | try { | ||||
if (!EmptyUtil.isEmpty(result)) { | if (!EmptyUtil.isEmpty(result)) { | ||||
@@ -5,7 +5,7 @@ class SearchThinkRepository { | |||||
// 商品电商渠道类型,默认为淘宝 | // 商品电商渠道类型,默认为淘宝 | ||||
String type = 'taobao'; | |||||
String type = GlobalConfig.PROVIDER_TB; | |||||
/// 关键字改变 | /// 关键字改变 | ||||
Future<List<SearchThinkModel>> fetchkeyWordsChange(String keywrods) async { | Future<List<SearchThinkModel>> fetchkeyWordsChange(String keywrods) async { | ||||
@@ -4,6 +4,6 @@ import 'package:flutter/material.dart'; | |||||
class TeamPageSkeleton extends StatelessWidget { | class TeamPageSkeleton extends StatelessWidget { | ||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
return Container(); | |||||
return Scaffold(body: Container()); | |||||
} | } | ||||
} | } |
@@ -137,9 +137,32 @@ class BaseWidgetRegister { | |||||
// MOB 秒验 | // MOB 秒验 | ||||
MobUtil.init(); | 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 { | Application.addMethod(() async { | ||||
return Future.delayed(Duration(seconds: 1)); | return Future.delayed(Duration(seconds: 1)); | ||||
}); | }); | ||||
} | } | ||||
// 注册页面 | // 注册页面 | ||||
@@ -241,16 +241,16 @@ class __FavoritesGoodsListWidgetContainerState extends State<_FavoritesGoodsList | |||||
closeOnScroll: false, | closeOnScroll: false, | ||||
secondaryActions: <Widget>[ | secondaryActions: <Widget>[ | ||||
/// 分享 | /// 分享 | ||||
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( | Padding( | ||||
@@ -94,36 +94,6 @@ class _GoodsDetailsFooterContainerState extends State<_GoodsDetailsFooterContain | |||||
/// 分享 | /// 分享 | ||||
void _shareOnClick(GoodsDetailsFooterModel model) async { | 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<String, dynamic> 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<String, dynamic> result = await TurnChainUtil.getShareTurnChain(context, _user, model?.good_id, model.provider, model.convertArgs.toJson()); | Map<String, dynamic> result = await TurnChainUtil.getShareTurnChain(context, _user, model?.good_id, model.provider, model.convertArgs.toJson()); | ||||
if (!EmptyUtil.isEmpty(result)) { | if (!EmptyUtil.isEmpty(result)) { | ||||
model.shareUrlArgs.buyUrl = result['open_app_url']; | model.shareUrlArgs.buyUrl = result['open_app_url']; | ||||
@@ -25,7 +25,7 @@ class GoodsDetailCommendCreater extends WidgetCreater { | |||||
// child: HomeGoodsHeader(model, _eventBus), | // child: HomeGoodsHeader(model, _eventBus), | ||||
// ); | // ); | ||||
String provider = 'taobao'; | |||||
String provider = GlobalConfig.PROVIDER_TB; | |||||
Map<String, dynamic> json = convert.jsonDecode(model['data']); | Map<String, dynamic> json = convert.jsonDecode(model['data']); | ||||
bool haveProvider = false; | bool haveProvider = false; | ||||
try{ | try{ | ||||
@@ -34,17 +34,17 @@ class GoodsDetailCommendCreater extends WidgetCreater { | |||||
provider = json['provider']; | provider = json['provider']; | ||||
} | } | ||||
}catch(e, s){ | }catch(e, s){ | ||||
provider = 'taobao'; | |||||
provider = GlobalConfig.PROVIDER_TB; | |||||
Logger.error(e,s); | Logger.error(e,s); | ||||
} | } | ||||
try { | try { | ||||
if(!haveProvider) { | if(!haveProvider) { | ||||
var listStyle = json['list_style']; | var listStyle = json['list_style']; | ||||
provider = listStyle['product_type']?.toString() ?? 'taobao'; | |||||
provider = listStyle['product_type']?.toString() ?? GlobalConfig.PROVIDER_TB; | |||||
} | } | ||||
} catch (e, s) { | } catch (e, s) { | ||||
provider = 'taobao'; | |||||
provider = GlobalConfig.PROVIDER_TB; | |||||
Logger.error(e, s); | Logger.error(e, s); | ||||
} | } | ||||
Logger.warn(model?.toString()); | Logger.warn(model?.toString()); | ||||
@@ -11,8 +11,7 @@ class HomeGoodsBloc extends BlocBase { | |||||
int _page = 1; | int _page = 1; | ||||
StreamController<List<HomeGoodsModel>> _goodsController = | |||||
StreamController<List<HomeGoodsModel>>(); | |||||
StreamController<List<HomeGoodsModel>> _goodsController = StreamController<List<HomeGoodsModel>>(); | |||||
Stream<List<HomeGoodsModel>> get outData => _goodsController.stream; | Stream<List<HomeGoodsModel>> get outData => _goodsController.stream; | ||||
@@ -32,10 +31,27 @@ class HomeGoodsBloc extends BlocBase { | |||||
_goods.clear(); | _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, | method: NetMethod.GET, | ||||
onCache: (data) {}, onSuccess: (data) { | |||||
onCache: _page == 1 | |||||
? (data) { | |||||
if (!EmptyUtil.isEmpty(data)) { | |||||
if (data.containsKey('good')) { | |||||
try { | |||||
List<dynamic> list = data['good']; | |||||
List<HomeGoodsModel> goods = list.map((item) { | |||||
return HomeGoodsModel.fromJson(Map<String, dynamic>.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<String, dynamic> json = Map<String, dynamic>.from(data); | Map<String, dynamic> json = Map<String, dynamic>.from(data); | ||||
if (json.containsKey('good')) { | if (json.containsKey('good')) { | ||||
List<dynamic> list = json['good']; | List<dynamic> list = json['good']; | ||||
@@ -35,7 +35,7 @@ class SearchTabWidget extends StatefulWidget { | |||||
class _SearchTabWidgetState extends State<SearchTabWidget> { | class _SearchTabWidgetState extends State<SearchTabWidget> { | ||||
TabController _tabController; | TabController _tabController; | ||||
String _type = 'taobao'; | |||||
String _type = GlobalConfig.PROVIDER_TB; | |||||
/// 联想列表的item点击事件 | /// 联想列表的item点击事件 | ||||
_onThinkItemClick(SearchThinkModel model){ | _onThinkItemClick(SearchThinkModel model){ | ||||
@@ -81,7 +81,7 @@ class SearchResultGoodsListRepository { | |||||
/// 查询 | /// 查询 | ||||
Future<List<HomeGoodsModel>> _baseInitData(bool refresh, final Map<String, dynamic> model) async { | Future<List<HomeGoodsModel>> _baseInitData(bool refresh, final Map<String, dynamic> model) async { | ||||
String keyword = model['keywords'] ?? ''; | 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; | if (EmptyUtil.isEmpty(keyword)) return null; | ||||
/// 构造url | /// 构造url | ||||
String url = _buildUrl(type); | String url = _buildUrl(type); | ||||
@@ -37,7 +37,7 @@ class SearchResultTabWidget extends StatefulWidget { | |||||
class _SearchResultTabWidgetState extends State<SearchResultTabWidget> { | class _SearchResultTabWidgetState extends State<SearchResultTabWidget> { | ||||
TabController _tabController; | TabController _tabController; | ||||
String _type = 'taobao'; | |||||
String _type = GlobalConfig.PROVIDER_TB; | |||||
/// 联想点击事件 | /// 联想点击事件 | ||||
_onThinkItemClick(SearchThinkModel model){ | _onThinkItemClick(SearchThinkModel model){ | ||||