Przeglądaj źródła

Merge branch '1.22.0_master' of http://192.168.0.138:3000/FnuoOS_ZhiYing/zhiying_base_widget into 1.22.0_master

tags/0.0.9+9
“yanghuaxuan” 3 lat temu
rodzic
commit
05dfb3d8a6
12 zmienionych plików z 122 dodań i 38 usunięć
  1. +13
    -11
      lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart
  2. +67
    -0
      lib/pages/custom_page/bloc/bottom_nav_repository.dart
  3. +14
    -0
      lib/pages/custom_page/bloc/custom_item_page_bloc.dart
  4. +1
    -6
      lib/pages/custom_page/bloc/custom_item_page_repository.dart
  5. +3
    -0
      lib/pages/custom_page/bloc/custom_item_page_state.dart
  6. +0
    -8
      lib/pages/custom_page/bloc/custom_page_repository.dart
  7. +10
    -0
      lib/pages/custom_page/custom_item_page.dart
  8. +1
    -1
      lib/widgets/goods_details/store/bloc/store_state.dart
  9. +1
    -1
      lib/widgets/home/home_goods/models/home_goods_list_style_model.dart
  10. +2
    -1
      lib/widgets/mine/mine_data/mine_data_widget.dart
  11. +2
    -2
      lib/widgets/mine/mine_header/mine_header_container.dart
  12. +8
    -8
      lib/widgets/restart_widget/restart_widget.dart

+ 13
- 11
lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart Wyświetl plik

@@ -61,11 +61,8 @@ class _IntellectSearchNoGoodsDialogState extends State<IntellectSearchNoGoodsDia
});
}

/// 点击立即搜索,跳转搜索结果页
void openSearchResultPage() {
// RouterUtil.route(SkipModel.fromJson(_styleModel.moduleList.btn.skipInfo.toJson()), {"keywords": searchText, "type": _styleModel.moduleList.btn.skipInfo.pvd}, context).then((_) {
// Navigator.pop(context);
// });
/// 点击立即搜索,跳转默认渠道的搜索结果页
void openDefaultSearchResultPage() {
// 这里直接跳搜索结果页,不能跳搜索页。app端直接写死。需要修改记得修改这个地方
_styleModel.moduleList.btn.skipInfo.skipIdentifier = 'pub.flutter.search_result';
RouterUtil.route(SkipModel.fromJson(_styleModel.moduleList.btn.skipInfo.toJson()), {"keywords": searchText, "type": _styleModel.moduleList.btn.skipInfo.pvd}, context).then((_) {
@@ -73,6 +70,15 @@ class _IntellectSearchNoGoodsDialogState extends State<IntellectSearchNoGoodsDia
});
}

/// 点击跳转指定渠道的搜索页面
void openTargetSearchResultPage(item) {
// 这里直接跳搜索结果页,不能跳搜索页。app端直接写死。需要修改记得修改这个地方
item.skipInfo.skipIdentifier = 'pub.flutter.search_result';
RouterUtil.route(SkipModel.fromJson(item.skipInfo.toJson()), {"keywords": searchText, "type": item.pvd}, context).then((value) {
Navigator.pop(context);
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
@@ -174,7 +180,7 @@ class _IntellectSearchNoGoodsDialogState extends State<IntellectSearchNoGoodsDia
),
)),
),
onTap: () => openSearchResultPage(),
onTap: () => openDefaultSearchResultPage(),
),
)
],
@@ -237,11 +243,7 @@ class _IntellectSearchNoGoodsDialogState extends State<IntellectSearchNoGoodsDia
)
],
),
onTap: () {
RouterUtil.route(SkipModel.fromJson(item.skipInfo.toJson()), {"keywords": searchText, "type": item.pvd}, context).then((value) {
Navigator.pop(context);
});
},
onTap: () => openTargetSearchResultPage(item),
));
}



+ 67
- 0
lib/pages/custom_page/bloc/bottom_nav_repository.dart Wyświetl plik

@@ -0,0 +1,67 @@
import 'dart:async';
import 'package:zhiying_comm/zhiying_comm.dart';

///
/// 底部导航栏数据Repository
///
class BottomNavRepository {

/// 获取网络数据
Future<dynamic> fetchNetData() async {
try {
var result = await NetUtil.post('/api/v1/new/config.json', method: NetMethod.GET, cache: true);
if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) {
return result[GlobalConfig.HTTP_RESPONSE_KEY_DATA];
}
} catch (e, s) {
Logger.error(e, s);
}
return null;
}

/// 获取缓存数据
Future<dynamic> fetchCacheData() async {
try {
var result = await NetUtil.getRequestCachedData('/api/v1/new/config.json');
if (!EmptyUtil.isEmpty(result)) {
return result;
}
} catch (e, s) {
Logger.error(e, s);
}
return null;
}

///
/// 校验底部导航栏是否更新
///
/// 校验的规则:使用 bottom_nav 的 mod_id + mod_pid + template_id + data 进行MD5
/// ⚠️ 由于Register初始化/api/v1/new/config.json没有进行缓存,可以利用这规则,如果Register的init进行了接口缓存则需要修改逻辑
///
/// false: 不更新 true 更新
///
Future<bool> validateBottomNavUpdate() async {
bool rlt = false;
try {
var cacheData = await fetchCacheData();
var netData = await fetchNetData();
if (!EmptyUtil.isEmpty(netData) && !EmptyUtil.isEmpty(cacheData)) {
var netBottomNav = netData['bottom_nav'];
var cacheBottomNav = cacheData['bottom_nav'];
if (!EmptyUtil.isEmpty(netBottomNav) && !EmptyUtil.isEmpty(cacheBottomNav)) {
var netEncodeStr = new StringBuffer();
var cacheEncodeStr = new StringBuffer();
netEncodeStr..write(netBottomNav['mod_id'])..write('-')..write(netBottomNav['mod_pid'])..write('-')..write(netBottomNav['template_id'])..write(netBottomNav['data']);
cacheEncodeStr..write(cacheBottomNav['mod_id'])..write('-')..write(cacheBottomNav['mod_pid'])..write('-')..write(cacheBottomNav['template_id'])..write(cacheBottomNav['data']);
String netMD5 = EncodeUtil.generateMd5(netEncodeStr.toString());
String cacheMD5 = EncodeUtil.generateMd5(cacheEncodeStr.toString());
Logger.log('网络数据的MD5 = ${netMD5}, 本地数据的MD5 = ${cacheMD5}');
rlt = (netMD5 != cacheMD5);
}
}
} catch (e, s) {
Logger.error(e, s);
}
return rlt;
}
}

+ 14
- 0
lib/pages/custom_page/bloc/custom_item_page_bloc.dart Wyświetl plik

@@ -1,6 +1,7 @@
import 'dart:async';

import 'package:bloc/bloc.dart';
import 'package:zhiying_base_widget/pages/custom_page/bloc/bottom_nav_repository.dart';
import 'package:zhiying_base_widget/pages/custom_page/bloc/custom_item_page_repository.dart';
import 'custom_item_page_state.dart';
import 'custom_item_page_event.dart';
@@ -12,6 +13,7 @@ class CustomItemPageBloc extends Bloc<CustomItemPageEvent, CustomItemPageState>
CustomItemPageRepository repository;

CustomItemPageBloc(this.repository) : super(CustomItemPageInitial());
BottomNavRepository _bottomNavRepository = new BottomNavRepository();



@@ -47,6 +49,12 @@ class CustomItemPageBloc extends Bloc<CustomItemPageEvent, CustomItemPageState>
} else {
yield CustomItemPageInitErrorState();
}
// 检查校验是否需要重启App(底部模版问题)
bool needRestart = await _bottomNavRepository.validateBottomNavUpdate();
Logger.log('init 是否重新启动App = ${needRestart}');
if (needRestart) {
yield CustomItemPageAppRestartState();
}
}

/// 下拉刷新
@@ -59,6 +67,12 @@ class CustomItemPageBloc extends Bloc<CustomItemPageEvent, CustomItemPageState>
yield CustomItemPageRefreshErrorState();
yield CustomItemPageErrorState();
}
// 检查校验是否需要重启App(底部模版问题)
bool needRestart = await _bottomNavRepository.validateBottomNavUpdate();
Logger.log('refresh 是否重新启动App = ${needRestart}');
if (needRestart) {
yield CustomItemPageAppRestartState();
}
}

/// 上拉更多


+ 1
- 6
lib/pages/custom_page/bloc/custom_item_page_repository.dart Wyświetl plik

@@ -1,6 +1,6 @@
import 'dart:async';

import 'package:zhiying_base_widget/pages/custom_page/event/reload_event.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class CustomItemPageRepository {
@@ -21,13 +21,8 @@ class CustomItemPageRepository {
List mobList =
!EmptyUtil.isEmpty(data) ? List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA][tabIndex.toString()]) : List.from(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]);
if (!EmptyUtil.isEmpty(mobList)) {
ReloadEvent.com = 0;
return mobList.map((e) => Map<String, dynamic>.from(e)).toList();
}
} else {
Timer(Duration(milliseconds: 1000), () {
EventUtil.instance.fire(ReloadEvent());
});
}
}
} catch (e, s) {


+ 3
- 0
lib/pages/custom_page/bloc/custom_item_page_state.dart Wyświetl plik

@@ -30,3 +30,6 @@ class CustomItemPageLoadErrorState extends CustomItemPageState {}

/// 其他错误
class CustomItemPageErrorState extends CustomItemPageState {}

/// 需要重新渲染App,更新底部导航模版
class CustomItemPageAppRestartState extends CustomItemPageState {}

+ 0
- 8
lib/pages/custom_page/bloc/custom_page_repository.dart Wyświetl plik

@@ -1,8 +1,6 @@
import 'dart:async';
import 'dart:convert';

import 'package:zhiying_base_widget/dialog/loading/loading.dart';
import 'package:zhiying_base_widget/pages/custom_page/event/reload_event.dart';
import 'package:zhiying_base_widget/pages/main_page/model/background_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

@@ -40,12 +38,6 @@ class CustomPageRepository {
}
return customPageData;
}
}else{

Timer(Duration(milliseconds: 1000), (){
EventUtil.instance.fire(ReloadEvent());
});

}
}
} catch (e, s) {


+ 10
- 0
lib/pages/custom_page/custom_item_page.dart Wyświetl plik

@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:event_bus/event_bus.dart';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
@@ -12,6 +14,7 @@ import 'bloc/custom_item_page_bloc.dart';
import 'bloc/custom_item_page_state.dart';
import 'bloc/custom_item_page_event.dart';
import 'bloc/custom_item_page_repository.dart';
import 'package:zhiying_base_widget/pages/custom_page/event/reload_event.dart';

///
/// 通用模块的分类导航下的子模块
@@ -131,9 +134,16 @@ class __CustomItemPageContainerState extends State<_CustomItemPageContainer> wit
if (current is CustomItemPageErrorState) {
return false;
}
if (current is CustomItemPageAppRestartState) {
// 重启App
Logger.log('开始重新启动App CustomItemPageAppRestartState');
EventUtil.instance.fire(ReloadEvent());
return false;
}
return true;
},
builder: (context, state) {
Logger.log('Custom item page builder 刷新了');
if (state is CustomItemPageLoadedState) {
Logger.log('custom item page current state = ' + state?.toString());
if (EmptyUtil.isEmpty(state.model))


+ 1
- 1
lib/widgets/goods_details/store/bloc/store_state.dart Wyświetl plik

@@ -17,7 +17,7 @@ class StoreLoadedState extends StoreState {
const StoreLoadedState({this.model});

@override
List<Object> get props => [];
List<Object> get props => [this.model];
}

/// 数据加载出错


+ 1
- 1
lib/widgets/home/home_goods/models/home_goods_list_style_model.dart Wyświetl plik

@@ -33,7 +33,7 @@ class HomeGoodsListStyleModel {
});

HomeGoodsListStyleModel.fromJson(Map<String, dynamic> json) {
hotRankIconList = json['hot_rank_icon_list']. cast<String>();
hotRankIconList = json['hot_rank_icon_list'].cast<String>();
topMargin = json['top_margin'];
listColumn = json['list_column'];
leftRighMargin = json['left_righ_margin'];


+ 2
- 1
lib/widgets/mine/mine_data/mine_data_widget.dart Wyświetl plik

@@ -7,6 +7,7 @@ import 'package:zhiying_base_widget/widgets/mine/mine_data/model/mine_data_model
import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:zhiying_comm/util/shared_prefe_util.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class MineDataWidget extends StatefulWidget {
final Map<String, dynamic> data;
@@ -118,7 +119,7 @@ class _MineDataWidgetState extends State<MineDataWidget> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
_isiOSReview ? '' : widget?.profile?.gridViews[0]?.name ?? "累计收益",
_isiOSReview ? '' : EmptyUtil.isEmpty(widget?.profile?.gridViews) ? "累计收益" : widget?.profile?.gridViews[0]?.name ?? '累计收益',
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w600,


+ 2
- 2
lib/widgets/mine/mine_header/mine_header_container.dart Wyświetl plik

@@ -147,11 +147,11 @@ class _MineHeaderContainerState extends State<MineHeaderContainer> {
child: Row(
children: <Widget>[
Text(
'邀请码:${profile.inviteCode}',
'邀请码:${profile?.inviteCode ?? ''}',
maxLines: 1,
style: TextStyle(
fontSize: 13,
color: HexColor.fromHex(widget.staticModel.userNameColor),
color: HexColor.fromHex(widget?.staticModel?.userNameColor),
fontFamily: 'Din',
package: 'zhiying_comm',
),


+ 8
- 8
lib/widgets/restart_widget/restart_widget.dart Wyświetl plik

@@ -21,7 +21,7 @@ class RestartWidget extends StatefulWidget {
class _RestartWidgetState extends State<RestartWidget> {
bool reStart = false;

int com = 0;
// int com = 0;
Timer timer1;
Timer timer2;

@@ -37,15 +37,15 @@ class _RestartWidgetState extends State<RestartWidget> {
return;
}

com++;
// com++;

///刷新3次后不再刷新
if (com > 3) {
if (com < 7) {
Fluttertoast.showToast(msg: "网络服务不可用");
}
return;
}
// if (com > 3) {
// if (com < 7) {
// Fluttertoast.showToast(msg: "网络服务不可用");
// }
// return;
// }

Loading.show(context, msg: "更新数据中...");



Ładowanie…
Anuluj
Zapisz