@@ -21,6 +21,93 @@ class IntellectSearchGoodsDialog extends StatefulWidget { | |||||
class _IntellectSearchGoodsDialogState extends State<IntellectSearchGoodsDialog> { | class _IntellectSearchGoodsDialogState extends State<IntellectSearchGoodsDialog> { | ||||
HasGoodsDialogStyleModel _styleModel; | 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 | @override | ||||
void initState() { | void initState() { | ||||
requestStyle(); | 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 | @override | ||||
void dispose() { | void dispose() { | ||||
Clipboard.setData(ClipboardData(text: "")); | Clipboard.setData(ClipboardData(text: "")); | ||||
@@ -11,8 +11,8 @@ class PolicyDialog extends StatefulWidget { | |||||
const PolicyDialog(this.model, {Key key}) : super(key: key); | const PolicyDialog(this.model, {Key key}) : super(key: key); | ||||
static Future<bool> show(BuildContext context) async { | 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 model = | ||||
PolicyDialogModel.fromJson(Map<String, dynamic>.from(json['data'])); | PolicyDialogModel.fromJson(Map<String, dynamic>.from(json['data'])); | ||||
bool agree = null; | bool agree = null; | ||||
@@ -58,7 +58,7 @@ class _PolicyDialogState extends State<PolicyDialog> { | |||||
child: Padding( | child: Padding( | ||||
padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), | padding: const EdgeInsets.only(top: 8.0, bottom: 8.0), | ||||
child: SingleChildScrollView( | 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() { | Widget _createText() { | ||||
String content = widget.model?.content ?? ''; | String content = widget.model?.content ?? ''; | ||||
Map<int, PolicyItemModel> replaces = Map(); | Map<int, PolicyItemModel> replaces = Map(); | ||||
@@ -35,6 +35,7 @@ class CustomItemPageBloc extends Bloc<CustomItemPageEvent, CustomItemPageState> | |||||
if (event is CustomItemPageLoadEvent) { | if (event is CustomItemPageLoadEvent) { | ||||
yield* _mapLoadEventToState(event); | yield* _mapLoadEventToState(event); | ||||
} | } | ||||
} | } | ||||
/// 初始化 | /// 初始化 | ||||
@@ -71,7 +72,11 @@ class CustomItemPageBloc extends Bloc<CustomItemPageEvent, CustomItemPageState> | |||||
bool needRestart = await _bottomNavRepository.validateBottomNavUpdate(); | bool needRestart = await _bottomNavRepository.validateBottomNavUpdate(); | ||||
Logger.log('refresh 是否重新启动App = ${needRestart}'); | Logger.log('refresh 是否重新启动App = ${needRestart}'); | ||||
if (needRestart) { | if (needRestart) { | ||||
// App重启,不需要进行子Widget刷新 | |||||
yield CustomItemPageAppRestartState(); | yield CustomItemPageAppRestartState(); | ||||
} else { | |||||
// 子Widget刷新,写在后面是为了等渲染完成 | |||||
yield CustomItemPageItemWidgetRefreshState(); | |||||
} | } | ||||
} | } | ||||
@@ -36,3 +36,6 @@ class CustomItemPageErrorState extends CustomItemPageState {} | |||||
/// 需要重新渲染App,更新底部导航模版 | /// 需要重新渲染App,更新底部导航模版 | ||||
class CustomItemPageAppRestartState extends CustomItemPageState {} | class CustomItemPageAppRestartState extends CustomItemPageState {} | ||||
/// 子Widget刷新状态 | |||||
class CustomItemPageItemWidgetRefreshState extends CustomItemPageState {} |
@@ -125,11 +125,15 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai | |||||
return BlocConsumer<CustomItemPageBloc, CustomItemPageState>( | return BlocConsumer<CustomItemPageBloc, CustomItemPageState>( | ||||
listener: (context, state) {}, | listener: (context, state) {}, | ||||
buildWhen: (prev, current) { | buildWhen: (prev, current) { | ||||
/// 子Item刷新 | |||||
if (current is CustomItemPageItemWidgetRefreshState) { | |||||
/// 子Widget刷新 | |||||
refreshPage(); | |||||
return false; | |||||
} | |||||
/// 下拉刷新成功 | /// 下拉刷新成功 | ||||
if (current is CustomItemPageRefreshSuccessState) { | if (current is CustomItemPageRefreshSuccessState) { | ||||
_refreshController?.refreshCompleted(resetFooterState: true); | _refreshController?.refreshCompleted(resetFooterState: true); | ||||
///刷新页面 | |||||
refreshPage(); | |||||
return false; | return false; | ||||
} | } | ||||
/// 下拉刷新出错 | /// 下拉刷新出错 | ||||
@@ -191,7 +195,7 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai | |||||
SmartRefresher( | SmartRefresher( | ||||
controller: _refreshController, | controller: _refreshController, | ||||
enablePullDown: true, | enablePullDown: true, | ||||
enablePullUp: true, | |||||
enablePullUp: _hasProductList(model), | |||||
onRefresh: _refreshEvent, | onRefresh: _refreshEvent, | ||||
onLoading: _loadEvent, | onLoading: _loadEvent, | ||||
header: RefreshGifHeader(), | header: RefreshGifHeader(), | ||||
@@ -258,6 +262,21 @@ class __CustomItemPageContainerState extends BasePageState<_CustomItemPageContai | |||||
return result; | 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() { | Widget _buildEmptyWidget() { | ||||
return SmartRefresher( | return SmartRefresher( | ||||
@@ -31,7 +31,6 @@ class _CustomQuickEntryState extends BaseWidgetState<CustomQuickEntry> with Tick | |||||
@override | @override | ||||
void refreshWidget(String value) { | void refreshWidget(String value) { | ||||
setState(() { | setState(() { | ||||
Logger.log('多言导航 ===== ' + widget?.model?.toString()); | |||||
model = _repository.fetchParentData(model: widget?.model); | model = _repository.fetchParentData(model: widget?.model); | ||||
}); | }); | ||||
} | } | ||||
@@ -129,7 +129,7 @@ class ListStyle { | |||||
this.skipName}); | this.skipName}); | ||||
ListStyle.fromJson(Map<String, dynamic> json) { | ListStyle.fromJson(Map<String, dynamic> json) { | ||||
idx = json['idx']; | |||||
idx = json['idx']?.toString(); | |||||
title = json['title']; | title = json['title']; | ||||
img = json['img']; | img = json['img']; | ||||
data = json['data'] != null ? new Data.fromJson(json['data']) : null; | data = json['data'] != null ? new Data.fromJson(json['data']) : null; | ||||