Procházet zdrojové kódy

1、缓存部分列表的数据

2、删除收藏商品的分享功能
3、把 'taobao' 的改成常量
4、商品列表第一页进行缓存
tags/0.0.2+11
PH2 před 4 roky
rodič
revize
217cd938c2
11 změnil soubory, kde provedl 65 přidání a 56 odebrání
  1. +2
    -2
      lib/pages/search_result_page/bloc/search_result_repository.dart
  2. +1
    -1
      lib/pages/search_think_page/bloc/search_think_repository.dart
  3. +1
    -1
      lib/pages/team_page/team_page_sk.dart
  4. +23
    -0
      lib/register.dart
  5. +10
    -10
      lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart
  6. +0
    -30
      lib/widgets/goods_details/footer/goods_details_footer_widget.dart
  7. +4
    -4
      lib/widgets/goods_details/recommend/goods_detail_commend_creater.dart
  8. +21
    -5
      lib/widgets/home/home_goods/bloc/home_goods_bloc.dart
  9. +1
    -1
      lib/widgets/search/tabbar/search_tab_widget.dart
  10. +1
    -1
      lib/widgets/search_result/goods_list/bloc/search_result_goods_list_repository.dart
  11. +1
    -1
      lib/widgets/search_result/tarbar/search_result_tab_widget.dart

+ 2
- 2
lib/pages/search_result_page/bloc/search_result_repository.dart Zobrazit soubor

@@ -8,7 +8,7 @@ class SearchResultRepository {
/// 获取网络数据
Future<List<Map<String, dynamic>>> fetchInit(final Map<String, dynamic> 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<List<Map<String, dynamic>>> fetchCachedData(final Map<String, dynamic> 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)) {


+ 1
- 1
lib/pages/search_think_page/bloc/search_think_repository.dart Zobrazit soubor

@@ -5,7 +5,7 @@ class SearchThinkRepository {


// 商品电商渠道类型,默认为淘宝
String type = 'taobao';
String type = GlobalConfig.PROVIDER_TB;

/// 关键字改变
Future<List<SearchThinkModel>> fetchkeyWordsChange(String keywrods) async {


+ 1
- 1
lib/pages/team_page/team_page_sk.dart Zobrazit soubor

@@ -4,6 +4,6 @@ import 'package:flutter/material.dart';
class TeamPageSkeleton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container();
return Scaffold(body: Container());
}
}

+ 23
- 0
lib/register.dart Zobrazit soubor

@@ -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));
});


}

// 注册页面


+ 10
- 10
lib/widgets/favorites/goods_list/favorites_goods_list_widget.dart Zobrazit soubor

@@ -241,16 +241,16 @@ class __FavoritesGoodsListWidgetContainerState extends State<_FavoritesGoodsList
closeOnScroll: false,
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(


+ 0
- 30
lib/widgets/goods_details/footer/goods_details_footer_widget.dart Zobrazit soubor

@@ -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<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());
if (!EmptyUtil.isEmpty(result)) {
model.shareUrlArgs.buyUrl = result['open_app_url'];


+ 4
- 4
lib/widgets/goods_details/recommend/goods_detail_commend_creater.dart Zobrazit soubor

@@ -25,7 +25,7 @@ class GoodsDetailCommendCreater extends WidgetCreater {
// child: HomeGoodsHeader(model, _eventBus),
// );

String provider = 'taobao';
String provider = GlobalConfig.PROVIDER_TB;
Map<String, dynamic> 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());


+ 21
- 5
lib/widgets/home/home_goods/bloc/home_goods_bloc.dart Zobrazit soubor

@@ -11,8 +11,7 @@ class HomeGoodsBloc extends BlocBase {

int _page = 1;

StreamController<List<HomeGoodsModel>> _goodsController =
StreamController<List<HomeGoodsModel>>();
StreamController<List<HomeGoodsModel>> _goodsController = StreamController<List<HomeGoodsModel>>();

Stream<List<HomeGoodsModel>> 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<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);
if (json.containsKey('good')) {
List<dynamic> list = json['good'];


+ 1
- 1
lib/widgets/search/tabbar/search_tab_widget.dart Zobrazit soubor

@@ -35,7 +35,7 @@ class SearchTabWidget extends StatefulWidget {

class _SearchTabWidgetState extends State<SearchTabWidget> {
TabController _tabController;
String _type = 'taobao';
String _type = GlobalConfig.PROVIDER_TB;

/// 联想列表的item点击事件
_onThinkItemClick(SearchThinkModel model){


+ 1
- 1
lib/widgets/search_result/goods_list/bloc/search_result_goods_list_repository.dart Zobrazit soubor

@@ -81,7 +81,7 @@ class SearchResultGoodsListRepository {
/// 查询
Future<List<HomeGoodsModel>> _baseInitData(bool refresh, final Map<String, dynamic> 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);


+ 1
- 1
lib/widgets/search_result/tarbar/search_result_tab_widget.dart Zobrazit soubor

@@ -37,7 +37,7 @@ class SearchResultTabWidget extends StatefulWidget {

class _SearchResultTabWidgetState extends State<SearchResultTabWidget> {
TabController _tabController;
String _type = 'taobao';
String _type = GlobalConfig.PROVIDER_TB;

/// 联想点击事件
_onThinkItemClick(SearchThinkModel model){


Načítá se…
Zrušit
Uložit