diff --git a/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart index 097e731..ab1c3ec 100644 --- a/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart +++ b/lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart @@ -21,6 +21,93 @@ class IntellectSearchGoodsDialog extends StatefulWidget { class _IntellectSearchGoodsDialogState extends State { 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 }); } - 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: "")); diff --git a/lib/dialog/global_dialog/policy_dialog/policy_dialog.dart b/lib/dialog/global_dialog/policy_dialog/policy_dialog.dart index 4c9413a..b9c03a4 100644 --- a/lib/dialog/global_dialog/policy_dialog/policy_dialog.dart +++ b/lib/dialog/global_dialog/policy_dialog/policy_dialog.dart @@ -11,8 +11,8 @@ class PolicyDialog extends StatefulWidget { const PolicyDialog(this.model, {Key key}) : super(key: key); static Future 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.from(json['data'])); bool agree = null; @@ -58,7 +58,7 @@ class _PolicyDialogState extends State { 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 { ); } + /// 新的替换方法 + Widget _createNewText() { + String content = widget.model?.content ?? ''; + List 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 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 replaces = Map(); diff --git a/lib/pages/custom_page/bloc/custom_item_page_bloc.dart b/lib/pages/custom_page/bloc/custom_item_page_bloc.dart index 661aa28..ffc83ab 100644 --- a/lib/pages/custom_page/bloc/custom_item_page_bloc.dart +++ b/lib/pages/custom_page/bloc/custom_item_page_bloc.dart @@ -35,6 +35,7 @@ class CustomItemPageBloc extends Bloc if (event is CustomItemPageLoadEvent) { yield* _mapLoadEventToState(event); } + } /// 初始化 @@ -71,7 +72,11 @@ class CustomItemPageBloc extends Bloc bool needRestart = await _bottomNavRepository.validateBottomNavUpdate(); Logger.log('refresh 是否重新启动App = ${needRestart}'); if (needRestart) { + // App重启,不需要进行子Widget刷新 yield CustomItemPageAppRestartState(); + } else { + // 子Widget刷新,写在后面是为了等渲染完成 + yield CustomItemPageItemWidgetRefreshState(); } } diff --git a/lib/pages/custom_page/bloc/custom_item_page_state.dart b/lib/pages/custom_page/bloc/custom_item_page_state.dart index f46caa3..2bc3376 100644 --- a/lib/pages/custom_page/bloc/custom_item_page_state.dart +++ b/lib/pages/custom_page/bloc/custom_item_page_state.dart @@ -36,3 +36,6 @@ class CustomItemPageErrorState extends CustomItemPageState {} /// 需要重新渲染App,更新底部导航模版 class CustomItemPageAppRestartState extends CustomItemPageState {} + +/// 子Widget刷新状态 +class CustomItemPageItemWidgetRefreshState extends CustomItemPageState {} \ No newline at end of file diff --git a/lib/pages/custom_page/custom_item_page.dart b/lib/pages/custom_page/custom_item_page.dart index cd2a6f5..5841f90 100644 --- a/lib/pages/custom_page/custom_item_page.dart +++ b/lib/pages/custom_page/custom_item_page.dart @@ -125,11 +125,15 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai return BlocConsumer( 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> datas) { + var rlt = false; + if (!EmptyUtil.isEmpty(datas)) { + for (int i = 0; i < datas.length; i++) { + WidgetModel item = WidgetModel.fromJson(Map.from(datas[i])); + if (item.modName == 'product') { + rlt = true; + break; + } + } + } + return rlt; + } + /// 空数据 Widget _buildEmptyWidget() { return SmartRefresher( diff --git a/lib/widgets/custom/multi_nav/custom_quick_entry.dart b/lib/widgets/custom/multi_nav/custom_quick_entry.dart index a8e1469..1874a6b 100644 --- a/lib/widgets/custom/multi_nav/custom_quick_entry.dart +++ b/lib/widgets/custom/multi_nav/custom_quick_entry.dart @@ -31,7 +31,6 @@ class _CustomQuickEntryState extends BaseWidgetState with Tick @override void refreshWidget(String value) { setState(() { - Logger.log('多言导航 ===== ' + widget?.model?.toString()); model = _repository.fetchParentData(model: widget?.model); }); } diff --git a/lib/widgets/custom/ordedr_class/order_class_nav/order_class_style.dart b/lib/widgets/custom/ordedr_class/order_class_nav/order_class_style.dart index cbb02bc..8e0afa6 100644 --- a/lib/widgets/custom/ordedr_class/order_class_nav/order_class_style.dart +++ b/lib/widgets/custom/ordedr_class/order_class_nav/order_class_style.dart @@ -129,7 +129,7 @@ class ListStyle { this.skipName}); ListStyle.fromJson(Map json) { - idx = json['idx']; + idx = json['idx']?.toString(); title = json['title']; img = json['img']; data = json['data'] != null ? new Data.fromJson(json['data']) : null;