Explorar el Código

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.17+7
“yanghuaxuan” hace 3 años
padre
commit
0ce784b5ca
Se han modificado 7 ficheros con 170 adiciones y 93 borrados
  1. +87
    -85
      lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart
  2. +52
    -3
      lib/dialog/global_dialog/policy_dialog/policy_dialog.dart
  3. +5
    -0
      lib/pages/custom_page/bloc/custom_item_page_bloc.dart
  4. +3
    -0
      lib/pages/custom_page/bloc/custom_item_page_state.dart
  5. +22
    -3
      lib/pages/custom_page/custom_item_page.dart
  6. +0
    -1
      lib/widgets/custom/multi_nav/custom_quick_entry.dart
  7. +1
    -1
      lib/widgets/custom/ordedr_class/order_class_nav/order_class_style.dart

+ 87
- 85
lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart Ver fichero

@@ -21,6 +21,93 @@ class IntellectSearchGoodsDialog extends StatefulWidget {
class _IntellectSearchGoodsDialogState extends State<IntellectSearchGoodsDialog> {
HasGoodsDialogStyleModel _styleModel;

///打开详情
void openGoodsDetails() {
Clipboard.setData(ClipboardData(text: ""));
String provider = widget.model.provider;
String goodId = widget.model.itemId;
RouterUtil.route(SkipModel(skipIdentifier: "goods_details"), {"provider": provider, "good_id": goodId}, context).then((data) {
Navigator.pop(context);
});
}

/// 跳转购买
void openUrl() async {
///跳转购买
UserInfoModel userInfo = UserInfoNotifier.staitcUserInfo;

/// 登录
if (userInfo?.token == null || userInfo.token == '') {
print('need login...');
RouterUtil.goLogin(context);
return;
} else {
print("平台" + widget?.model?.provider ?? "");
// if(!widget?.model?.couponUrl.contains("http")){
// widget?.model?.couponUrl="https:"+widget?.model?.couponUrl;
// }
// widget?.model?.couponUrl=widget?.model?.couponUrl.replaceAll("\\", "");
print("链接" + widget?.model?.couponUrl ?? "");
Logger.log('智能弹窗有商品情况跳转数据 = ${widget?.model?.toJson()}');

String tempProvider = widget?.model?.provider ?? 'taobao';

/// 判断淘宝渠道是否授权
if (tempProvider == GlobalConfig.PROVIDER_TB || tempProvider == GlobalConfig.PROVIDER_TM) {
bool isAuth = await TaobaoAuth.auth(context);

///关闭弹窗
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
if (!isAuth) return;
} else if (tempProvider == GlobalConfig.PROVIDER_PDD) {
/// 拼多多
bool isNeedAuth = await PddAuth.auth(context, isShare: '0');

///关闭弹窗
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
if (isNeedAuth) return;
} else {
///关闭弹窗
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
}

/// 改成统一跳转
await TurnChainUtil.jumpNative(
context,
provider: widget?.model?.provider ?? 'taobao',
openAppUrl: widget?.model?.couponUrl,
appUrl: widget?.model?.appUrl,
webUrl: widget?.model?.couponUrl,
);
// if (widget?.model?.provider == GlobalConfig.PROVIDER_TB || widget?.model?.provider == GlobalConfig.PROVIDER_TM) {
// TradeResult result;
// if (Platform.isAndroid) {
// result = await FlutterAlibc.openByUrl(url: widget?.model?.couponUrl ?? "", backUrl: "alisdk://");
// } else if (Platform.isIOS) {
// result = await FlutterAlibc.openByUrl(url: widget?.model?.couponUrl ?? "");
// }
// Logger.debug('${result.errorCode} ${result.errorMessage} ');
// print("链接" + widget?.model?.couponUrl ?? "");
// print("错误码" + result.errorCode);
// print("原因" + result.errorMessage);
// } else if (widget?.model?.provider == GlobalConfig.PROVIDER_JD) {
// /// 京东
// // Jdsdk.openUrl(url: openAppUrl);
// Logger.log('走了京东打开');
// } else {
// /// 其它
// Logger.log('走了其它打开方式');
// // await FlutterAlibc.openByUrl(url: widget?.model?.couponUrl, openType: AlibcOpenType.AlibcOpenTypeNative);
// }
}
}

@override
void initState() {
requestStyle();
@@ -291,91 +378,6 @@ class _IntellectSearchGoodsDialogState extends State<IntellectSearchGoodsDialog>
});
}

void openUrl() async {
///跳转购买
UserInfoModel userInfo = UserInfoNotifier.staitcUserInfo;

/// 登录
if (userInfo?.token == null || userInfo.token == '') {
print('need login...');
RouterUtil.goLogin(context);
return;
} else {
print("平台" + widget?.model?.provider ?? "");
// if(!widget?.model?.couponUrl.contains("http")){
// widget?.model?.couponUrl="https:"+widget?.model?.couponUrl;
// }
// widget?.model?.couponUrl=widget?.model?.couponUrl.replaceAll("\\", "");
print("链接" + widget?.model?.couponUrl ?? "");
Logger.log('智能弹窗有商品情况跳转数据 = ${widget?.model?.toJson()}');

String tempProvider = widget?.model?.provider ?? 'taobao';

/// 判断淘宝渠道是否授权
if (tempProvider == GlobalConfig.PROVIDER_TB || tempProvider == GlobalConfig.PROVIDER_TM) {
bool isAuth = await TaobaoAuth.auth(context);

///关闭弹窗
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
if (!isAuth) return;
} else if (tempProvider == GlobalConfig.PROVIDER_PDD) {
/// 拼多多
bool isNeedAuth = await PddAuth.auth(context, isShare: '0');

///关闭弹窗
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
if (isNeedAuth) return;
} else {
///关闭弹窗
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
}

/// 改成统一跳转
await TurnChainUtil.jumpNative(
context,
provider: widget?.model?.provider ?? 'taobao',
openAppUrl: widget?.model?.couponUrl,
appUrl: widget?.model?.appUrl,
webUrl: widget?.model?.couponUrl,
);
// if (widget?.model?.provider == GlobalConfig.PROVIDER_TB || widget?.model?.provider == GlobalConfig.PROVIDER_TM) {
// TradeResult result;
// if (Platform.isAndroid) {
// result = await FlutterAlibc.openByUrl(url: widget?.model?.couponUrl ?? "", backUrl: "alisdk://");
// } else if (Platform.isIOS) {
// result = await FlutterAlibc.openByUrl(url: widget?.model?.couponUrl ?? "");
// }
// Logger.debug('${result.errorCode} ${result.errorMessage} ');
// print("链接" + widget?.model?.couponUrl ?? "");
// print("错误码" + result.errorCode);
// print("原因" + result.errorMessage);
// } else if (widget?.model?.provider == GlobalConfig.PROVIDER_JD) {
// /// 京东
// // Jdsdk.openUrl(url: openAppUrl);
// Logger.log('走了京东打开');
// } else {
// /// 其它
// Logger.log('走了其它打开方式');
// // await FlutterAlibc.openByUrl(url: widget?.model?.couponUrl, openType: AlibcOpenType.AlibcOpenTypeNative);
// }
}
}

///打开详情
void openGoodsDetails() {
String provider = widget.model.provider;
String goodId = widget.model.itemId;
RouterUtil.route(SkipModel(skipIdentifier: "goods_details"), {"provider": provider, "good_id": goodId}, context).then((data) {
Navigator.pop(context);
});
}

@override
void dispose() {
Clipboard.setData(ClipboardData(text: ""));


+ 52
- 3
lib/dialog/global_dialog/policy_dialog/policy_dialog.dart Ver fichero

@@ -11,8 +11,8 @@ class PolicyDialog extends StatefulWidget {
const PolicyDialog(this.model, {Key key}) : super(key: key);

static Future<bool> show(BuildContext context) async {
Map json =
await NetUtil.post('/api/v1/app/permissions', method: NetMethod.GET);
// 旧接口:/api/v1/app/permissions
Map json = await NetUtil.post('/api/v1/app/new_permissions', method: NetMethod.GET);
PolicyDialogModel model =
PolicyDialogModel.fromJson(Map<String, dynamic>.from(json['data']));
bool agree = null;
@@ -58,7 +58,7 @@ class _PolicyDialogState extends State<PolicyDialog> {
child: Padding(
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0),
child: SingleChildScrollView(
child: _createText(),
child: _createNewText(),
),
),
),
@@ -123,6 +123,55 @@ class _PolicyDialogState extends State<PolicyDialog> {
);
}

/// 新的替换方法
Widget _createNewText() {
String content = widget.model?.content ?? '';
List<TextSpan> texts = List();
if (!EmptyUtil.isEmpty(content)) {
// 需要替换
if (!EmptyUtil.isEmpty(widget?.model?.selectedText)) {
widget.model.selectedText.forEach((item) {
// 切割关键字不等于null,并且content内有找到切割关键字才进行操作
if (!EmptyUtil.isEmpty(item?.key) && content.indexOf(item.key) != -1) {
List<String> tempArr = content.split(item.key);
if (!EmptyUtil.isEmpty(tempArr) && tempArr.length == 2) {
// step1、普通文字
texts.add(TextSpan(text: tempArr[0]));
// step2、点击链接
texts.add(TextSpan(
text: item?.text ?? '',
recognizer: TapGestureRecognizer()
..onTap = () {
NativeUtil.openUrl(context, item?.url ?? '');
},
style: TextStyle(color: HexColor.fromHex(widget.model?.selectedColor ?? '#FF4242')),
));
// step3、更新切割后的数据
content = tempArr[1];
}
}
});
} else {
// 无需替换
texts.add(TextSpan(
text: content
));
}
}
return EmptyUtil.isEmpty(texts) ? Container() : RichText(
textAlign: TextAlign.left,
text: TextSpan(
text: '',
style: TextStyle(
height: 1.2,
fontSize: 14,
color: HexColor.fromHex('#555555'),
),
children: texts),
);
}

// 弃用
Widget _createText() {
String content = widget.model?.content ?? '';
Map<int, PolicyItemModel> replaces = Map();


+ 5
- 0
lib/pages/custom_page/bloc/custom_item_page_bloc.dart Ver fichero

@@ -35,6 +35,7 @@ class CustomItemPageBloc extends Bloc<CustomItemPageEvent, CustomItemPageState>
if (event is CustomItemPageLoadEvent) {
yield* _mapLoadEventToState(event);
}

}

/// 初始化
@@ -71,7 +72,11 @@ class CustomItemPageBloc extends Bloc<CustomItemPageEvent, CustomItemPageState>
bool needRestart = await _bottomNavRepository.validateBottomNavUpdate();
Logger.log('refresh 是否重新启动App = ${needRestart}');
if (needRestart) {
// App重启,不需要进行子Widget刷新
yield CustomItemPageAppRestartState();
} else {
// 子Widget刷新,写在后面是为了等渲染完成
yield CustomItemPageItemWidgetRefreshState();
}
}



+ 3
- 0
lib/pages/custom_page/bloc/custom_item_page_state.dart Ver fichero

@@ -36,3 +36,6 @@ class CustomItemPageErrorState extends CustomItemPageState {}

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

/// 子Widget刷新状态
class CustomItemPageItemWidgetRefreshState extends CustomItemPageState {}

+ 22
- 3
lib/pages/custom_page/custom_item_page.dart Ver fichero

@@ -125,11 +125,15 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai
return BlocConsumer<CustomItemPageBloc, CustomItemPageState>(
listener: (context, state) {},
buildWhen: (prev, current) {
/// 子Item刷新
if (current is CustomItemPageItemWidgetRefreshState) {
/// 子Widget刷新
refreshPage();
return false;
}
/// 下拉刷新成功
if (current is CustomItemPageRefreshSuccessState) {
_refreshController?.refreshCompleted(resetFooterState: true);
///刷新页面
refreshPage();
return false;
}
/// 下拉刷新出错
@@ -191,7 +195,7 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai
SmartRefresher(
controller: _refreshController,
enablePullDown: true,
enablePullUp: true,
enablePullUp: _hasProductList(model),
onRefresh: _refreshEvent,
onLoading: _loadEvent,
header: RefreshGifHeader(),
@@ -258,6 +262,21 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai
return result;
}

/// 判断是否有商品列表,如果没有不进行,上拉更多
bool _hasProductList(final List<Map<String, dynamic>> datas) {
var rlt = false;
if (!EmptyUtil.isEmpty(datas)) {
for (int i = 0; i < datas.length; i++) {
WidgetModel item = WidgetModel.fromJson(Map<String, dynamic>.from(datas[i]));
if (item.modName == 'product') {
rlt = true;
break;
}
}
}
return rlt;
}

/// 空数据
Widget _buildEmptyWidget() {
return SmartRefresher(


+ 0
- 1
lib/widgets/custom/multi_nav/custom_quick_entry.dart Ver fichero

@@ -31,7 +31,6 @@ class _CustomQuickEntryState extends BaseWidgetState<CustomQuickEntry> with Tick
@override
void refreshWidget(String value) {
setState(() {
Logger.log('多言导航 ===== ' + widget?.model?.toString());
model = _repository.fetchParentData(model: widget?.model);
});
}


+ 1
- 1
lib/widgets/custom/ordedr_class/order_class_nav/order_class_style.dart Ver fichero

@@ -129,7 +129,7 @@ class ListStyle {
this.skipName});

ListStyle.fromJson(Map<String, dynamic> json) {
idx = json['idx'];
idx = json['idx']?.toString();
title = json['title'];
img = json['img'];
data = json['data'] != null ? new Data.fromJson(json['data']) : null;


Cargando…
Cancelar
Guardar