From 3b871f7e24b4a31c0ec697daf5a7ac7d6bd5f0f9 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Wed, 19 May 2021 16:05:48 +0800 Subject: [PATCH 1/4] =?UTF-8?q?1=E3=80=81CustomPage=E7=9A=84=E5=AD=90Widge?= =?UTF-8?q?t=E5=88=B7=E6=96=B0=E9=97=AE=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bloc/custom_item_page_bloc.dart | 5 ++++ .../bloc/custom_item_page_state.dart | 3 +++ lib/pages/custom_page/custom_item_page.dart | 25 ++++++++++++++++--- .../custom/multi_nav/custom_quick_entry.dart | 1 - 4 files changed, 30 insertions(+), 4 deletions(-) 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); }); } From ce9b2dd9b989fddaff4aee72ad3743fe9db526da Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Wed, 19 May 2021 18:35:09 +0800 Subject: [PATCH 2/4] =?UTF-8?q?1=E3=80=81=E5=8A=9F=E8=83=BD=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=AF=BC=E8=88=AA=E6=95=B0=E6=8D=AE=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E5=87=BA=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom/ordedr_class/order_class_nav/order_class_style.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 4fc5fb56c312f4151769bc08aa0306bd4fed9904 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Sat, 22 May 2021 10:43:13 +0800 Subject: [PATCH 3/4] =?UTF-8?q?1=E3=80=81=E9=9A=90=E7=A7=81=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E7=9A=84=E6=9B=BF=E6=8D=A2=E6=96=B9=E6=B3=95=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../policy_dialog/policy_dialog.dart | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) 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(); From d58e40da5860395588dc2e55c34a963da750ddef Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Mon, 24 May 2021 10:17:30 +0800 Subject: [PATCH 4/4] =?UTF-8?q?1=E3=80=81=E6=99=BA=E8=83=BD=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E7=9A=84=E8=B7=B3=E8=BD=AC=E5=95=86=E5=93=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=B8=85=E9=99=A4=E5=89=AA=E5=88=87=E6=9D=BF=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../intellect_search_goods_dialog.dart | 172 +++++++++--------- 1 file changed, 87 insertions(+), 85 deletions(-) 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: ""));