@@ -22,7 +22,12 @@ class IntellectCreate { | |||
static checkAndCreate(AppLifecycleState state, BuildContext context) async { | |||
if (state == AppLifecycleState.resumed && !isRequest) { | |||
isRequest = true; | |||
_requestSetData(context); | |||
try { | |||
_requestSetData(context); | |||
} catch (e, s) { | |||
print(e); | |||
print(s); | |||
} | |||
} | |||
// Timer(Duration(milliseconds: 500), () async { | |||
// if (!Constants.isShowIntellectDialog) { | |||
@@ -49,7 +54,7 @@ class IntellectCreate { | |||
Constants.spIsCacheSetModel); | |||
_setModel = IntellectSearchSetModel.fromJson( | |||
json.decode(data['clipboard_base'])); | |||
if (result.isEmpty) { | |||
if (result == null || result.isEmpty) { | |||
validate(context, _setModel); | |||
} | |||
SharedPreferencesUtil.setNetCacheResult( | |||
@@ -80,11 +85,12 @@ class IntellectCreate { | |||
///请求数据打开弹窗 | |||
static requestDialog(BuildContext context, String content) async { | |||
content = | |||
"6緮置内容 Http:/T¢ZKkjceixTjW¢转移至ta0寶【URBANISTA/爱班Stockholm斯德哥尔摩 真无线蓝牙运动耳机半入耳式】"; | |||
// content = | |||
// "6緮置内容 Http:/T¢ZKkjceixTjW¢转移至ta0寶【URBANISTA/爱班Stockholm斯德哥尔摩 真无线蓝牙运动耳机半入耳式】"; | |||
var params = {"content": content}; | |||
NetUtil.request("/api/v1/clipboard/parse", | |||
NetUtil.request("/api/v1/clipboard/parse", | |||
params: params, method: NetMethod.POST, onSuccess: (data) async { | |||
print(data); | |||
isRequest = false; | |||
if (data == null || data.toString().length == 0) { | |||
if (!Constants.isShowIntellectDialog) { | |||
@@ -113,36 +119,37 @@ class IntellectCreate { | |||
static void validate( | |||
BuildContext context, IntellectSearchSetModel setModel) async { | |||
ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); | |||
String content = data?.text ?? ""; | |||
// //是否监听 | |||
// if (setModel.isListen != "1") { | |||
// return; | |||
// } | |||
// | |||
// if(content==null||content.length==0){ | |||
// return; | |||
// } | |||
// ///长度大小限制 | |||
// if (setModel.isKeyLength == "1" && | |||
// (int.tryParse(setModel.keyLengthMin) > content.length) || | |||
// (int.tryParse(setModel.keyLengthMax) < content.length)) { | |||
// return; | |||
// } | |||
// | |||
// //是否纯数字 | |||
// if (setModel.isNumber == "1" && isNumeric(content)) { | |||
// return; | |||
// } | |||
// | |||
// ///是否纯字母 | |||
// if (setModel.isLetter == "1" && isAlpha(content)) { | |||
// return; | |||
// } | |||
// | |||
// ///是否仅包含数字和字母 | |||
// if (setModel.isNumAndLet == "1" && isAlphanumeric(content)) { | |||
// return; | |||
// } | |||
String content = data?.text?.trim() ?? ""; | |||
//是否监听 | |||
if (setModel.isListen != "1") { | |||
return; | |||
} | |||
if (content == null || content.length == 0) { | |||
return; | |||
} | |||
///长度大小限制 | |||
if (setModel.isKeyLength == "1" && | |||
(int.tryParse(setModel.keyLengthMin) > content.length) || | |||
(int.tryParse(setModel.keyLengthMax) < content.length)) { | |||
return; | |||
} | |||
//是否纯数字 | |||
if (setModel.isNumber == "1" && isNumeric(content)) { | |||
return; | |||
} | |||
///是否纯字母 | |||
if (setModel.isLetter == "1" && isAlpha(content)) { | |||
return; | |||
} | |||
///是否仅包含数字和字母 | |||
if (setModel.isNumAndLet == "1" && isAlphanumeric(content)) { | |||
return; | |||
} | |||
///是否包含某个排除词 | |||
if (setModel.banWords != null && setModel.banWords.length > 0) { | |||
@@ -31,7 +31,7 @@ class _IntellectSearchGoodsDialogState | |||
@override | |||
void initState() { | |||
//Clipboard.setData(ClipboardData(text: "")); | |||
requestStyle(); | |||
super.initState(); | |||
} | |||
@@ -125,49 +125,55 @@ class _IntellectSearchGoodsDialogState | |||
), | |||
Row( | |||
children: <Widget>[ | |||
Container( | |||
decoration: BoxDecoration( | |||
color: Colors.red, | |||
borderRadius: BorderRadius.circular(2)), | |||
padding: EdgeInsets.all(2), | |||
child: Row( | |||
mainAxisSize: MainAxisSize.min, | |||
children: <Widget>[ | |||
Container( | |||
width: 30.w, | |||
height: 30.w, | |||
(widget.model?.couponPrice ?? "0") == "0" | |||
? Container() | |||
: Container( | |||
margin: EdgeInsets.only(right: 16), | |||
decoration: BoxDecoration( | |||
color: HexColor.fromHex(_styleModel | |||
?.moduleList?.coupon?.bgColor ?? | |||
"")), | |||
child: Center( | |||
child: Text( | |||
_styleModel?.moduleList?.coupon?.content ?? | |||
"", | |||
style: TextStyle( | |||
color: HexColor.fromHex(_styleModel | |||
?.moduleList?.coupon?.fontColor ?? | |||
""), | |||
fontSize: 20.sp), | |||
), | |||
color: Colors.red, | |||
borderRadius: BorderRadius.circular(2)), | |||
padding: EdgeInsets.all(2), | |||
child: Row( | |||
mainAxisSize: MainAxisSize.min, | |||
children: <Widget>[ | |||
Container( | |||
width: 30.w, | |||
height: 30.w, | |||
decoration: BoxDecoration( | |||
color: HexColor.fromHex(_styleModel | |||
?.moduleList?.coupon?.bgColor ?? | |||
"")), | |||
child: Center( | |||
child: Text( | |||
_styleModel | |||
?.moduleList?.coupon?.content ?? | |||
"", | |||
style: TextStyle( | |||
color: HexColor.fromHex(_styleModel | |||
?.moduleList | |||
?.coupon | |||
?.fontColor ?? | |||
""), | |||
fontSize: 20.sp), | |||
), | |||
), | |||
), | |||
Padding( | |||
padding: const EdgeInsets.only( | |||
left: 4, right: 4), | |||
child: Text( | |||
"¥" + (widget.model?.couponPrice ?? ""), | |||
style: TextStyle( | |||
color: HexColor.fromHex(_styleModel | |||
?.moduleList | |||
?.couponPrice | |||
?.fontColor), | |||
fontSize: 20.sp), | |||
), | |||
) | |||
], | |||
), | |||
), | |||
Padding( | |||
padding: const EdgeInsets.only(left: 4, right: 4), | |||
child: Text( | |||
"¥" + (widget.model?.couponPrice ?? ""), | |||
style: TextStyle( | |||
color: HexColor.fromHex(_styleModel | |||
?.moduleList?.couponPrice?.fontColor), | |||
fontSize: 20.sp), | |||
), | |||
) | |||
], | |||
), | |||
), | |||
SizedBox( | |||
width: 12.w, | |||
), | |||
Container( | |||
decoration: BoxDecoration( | |||
color: HexColor.fromHex( | |||
@@ -275,7 +281,9 @@ class _IntellectSearchGoodsDialogState | |||
child: Text( | |||
(_styleModel?.moduleList?.saveBtn?.content ?? "") + | |||
" ¥" + | |||
((double.tryParse(widget?.model?.couponPrice??"0.0")??0) + | |||
((double.tryParse( | |||
widget?.model?.couponPrice ?? "0.0") ?? | |||
0) + | |||
double.tryParse( | |||
widget?.model?.commission ?? '0')) | |||
.toString() | |||
@@ -331,6 +339,7 @@ class _IntellectSearchGoodsDialogState | |||
void requestStyle() { | |||
NetUtil.request("/api/v1/cfg/clipboard_identified", onSuccess: (data) { | |||
print(data); | |||
_styleModel = HasGoodsDialogStyleModel.fromJson( | |||
json.decode(data['clipboard_identified'])); | |||
setState(() {}); | |||
@@ -344,10 +353,15 @@ class _IntellectSearchGoodsDialogState | |||
RouterUtil.goLogin(context); | |||
return; | |||
} else { | |||
print("平台"+widget?.model?.provider??""); | |||
if (widget?.model?.provider == 'taobao') { | |||
TradeResult result = | |||
await FlutterAlibc.openByUrl(url: widget?.model?.couponUrl); | |||
await FlutterAlibc.openByUrl(url: widget?.model?.couponUrl??""); | |||
Logger.debug('${result.errorCode} ${result.errorMessage} '); | |||
print("链接"+widget?.model?.couponUrl??""); | |||
print("错误码"+result.errorCode); | |||
print("原因"+result.errorMessage); | |||
} else { | |||
RouterUtil.openWebview(widget?.model?.couponUrl, context); | |||
} | |||
@@ -359,8 +373,15 @@ class _IntellectSearchGoodsDialogState | |||
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); | |||
{"provider": provider, "good_id": goodId}, context) | |||
.then((data) { | |||
Navigator.pop(context); | |||
}); | |||
} | |||
@override | |||
void dispose() { | |||
Clipboard.setData(ClipboardData(text: "")); | |||
super.dispose(); | |||
} | |||
} |
@@ -1,5 +1,4 @@ | |||
import 'dart:convert'; | |||
import 'package:flutter/material.dart'; | |||
import 'package:flutter/services.dart'; | |||
import 'package:flutter_screenutil/flutter_screenutil.dart'; | |||
@@ -25,18 +24,20 @@ class _IntellectSearchNoGoodsDialogState | |||
NoGoodsDialogStyleModel _styleModel; | |||
var searchText; | |||
@override | |||
void initState() { | |||
_textEditingController = TextEditingController(); | |||
_getClipBoardData(); | |||
super.initState(); | |||
} | |||
///获取粘贴板内容 | |||
_getClipBoardData() async { | |||
ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); | |||
_textEditingController.text = data.text; | |||
_textEditingController.text = data.text.trim(); | |||
searchText = data.text.trim(); | |||
requestStyle(); | |||
setState(() {}); | |||
} | |||
@@ -141,23 +142,38 @@ class _IntellectSearchNoGoodsDialogState | |||
Row( | |||
children: <Widget>[ | |||
Expanded( | |||
child: InkWell( | |||
child: Container( | |||
decoration: BoxDecoration( | |||
color: HexColor.fromHex( | |||
_styleModel?.moduleList?.btn?.bgColor ?? ""), | |||
borderRadius: BorderRadius.circular(50)), | |||
child: Center( | |||
child: Padding( | |||
padding: const EdgeInsets.all(12.0), | |||
child: Text( | |||
_styleModel?.moduleList?.btn?.content ?? "", | |||
style: TextStyle( | |||
decoration: BoxDecoration( | |||
color: HexColor.fromHex( | |||
_styleModel?.moduleList?.btn?.textColor), | |||
fontSize: 24.sp), | |||
_styleModel?.moduleList?.btn?.bgColor ?? ""), | |||
borderRadius: BorderRadius.circular(50)), | |||
child: Center( | |||
child: Padding( | |||
padding: const EdgeInsets.all(12.0), | |||
child: Text( | |||
_styleModel?.moduleList?.btn?.content ?? "", | |||
style: TextStyle( | |||
color: HexColor.fromHex( | |||
_styleModel?.moduleList?.btn?.textColor), | |||
fontSize: 24.sp), | |||
), | |||
)), | |||
), | |||
)), | |||
)) | |||
onTap: () { | |||
RouterUtil.route( | |||
SkipModel.fromJson( | |||
_styleModel.moduleList.btn.skipInfo.toJson()), | |||
{ | |||
"keywords": searchText, | |||
"type": _styleModel.moduleList.btn.skipInfo.pvd | |||
}, | |||
context).then((_){ | |||
Navigator.pop(context); | |||
}); | |||
}, | |||
), | |||
) | |||
], | |||
), | |||
SizedBox( | |||
@@ -210,9 +226,8 @@ class _IntellectSearchNoGoodsDialogState | |||
child: Column( | |||
children: <Widget>[ | |||
Container( | |||
color: Colors.deepOrange, | |||
child: Image.network( | |||
"", | |||
item.image ?? "", | |||
width: 60.w, | |||
height: 60.w, | |||
fit: BoxFit.fill, | |||
@@ -229,7 +244,16 @@ class _IntellectSearchNoGoodsDialogState | |||
) | |||
], | |||
), | |||
onTap: () {}, | |||
onTap: () { | |||
RouterUtil.route(SkipModel.fromJson(item.skipInfo.toJson()), | |||
{"keywords": searchText, "type": item.pvd}, context); | |||
}, | |||
)); | |||
} | |||
@override | |||
void dispose() { | |||
Clipboard.setData(ClipboardData(text: "")); | |||
super.dispose(); | |||
} | |||
} |
@@ -38,13 +38,19 @@ class NoGoodsDialogStyleModel { | |||
class IconList { | |||
String image; | |||
String title; | |||
String pvd; | |||
SkipInfo skipInfo; | |||
String textColor; | |||
IconList({this.image, this.title, this.textColor}); | |||
IconList({this.image, this.title, this.pvd, this.skipInfo, this.textColor}); | |||
IconList.fromJson(Map<String, dynamic> json) { | |||
image = json['image']; | |||
title = json['title']; | |||
pvd = json['pvd']; | |||
skipInfo = json['skip_info'] != null | |||
? new SkipInfo.fromJson(json['skip_info']) | |||
: null; | |||
textColor = json['text_color']; | |||
} | |||
@@ -52,11 +58,48 @@ class IconList { | |||
final Map<String, dynamic> data = new Map<String, dynamic>(); | |||
data['image'] = this.image; | |||
data['title'] = this.title; | |||
data['pvd'] = this.pvd; | |||
if (this.skipInfo != null) { | |||
data['skip_info'] = this.skipInfo.toJson(); | |||
} | |||
data['text_color'] = this.textColor; | |||
return data; | |||
} | |||
} | |||
class SkipInfo { | |||
String pvd; | |||
String requiredLogin; | |||
String requiredTaobaoAuth; | |||
String skipIdentifier; | |||
int isDefault; | |||
SkipInfo( | |||
{this.pvd, | |||
this.requiredLogin, | |||
this.requiredTaobaoAuth, | |||
this.skipIdentifier, | |||
this.isDefault}); | |||
SkipInfo.fromJson(Map<String, dynamic> json) { | |||
pvd = json['pvd']; | |||
requiredLogin = json['required_login']; | |||
requiredTaobaoAuth = json['required_taobao_auth']; | |||
skipIdentifier = json['skip_identifier']; | |||
isDefault = json['is_default']; | |||
} | |||
Map<String, dynamic> toJson() { | |||
final Map<String, dynamic> data = new Map<String, dynamic>(); | |||
data['pvd'] = this.pvd; | |||
data['required_login'] = this.requiredLogin; | |||
data['required_taobao_auth'] = this.requiredTaobaoAuth; | |||
data['skip_identifier'] = this.skipIdentifier; | |||
data['is_default'] = this.isDefault; | |||
return data; | |||
} | |||
} | |||
class ModuleList { | |||
Title title; | |||
Title segment; | |||
@@ -140,6 +183,8 @@ class Btn { | |||
String name; | |||
String content; | |||
String type; | |||
String pvd; | |||
SkipInfo skipInfo; | |||
String textColor; | |||
String bgColor; | |||
String bgImage; | |||
@@ -148,6 +193,8 @@ class Btn { | |||
{this.name, | |||
this.content, | |||
this.type, | |||
this.pvd, | |||
this.skipInfo, | |||
this.textColor, | |||
this.bgColor, | |||
this.bgImage}); | |||
@@ -156,6 +203,10 @@ class Btn { | |||
name = json['name']; | |||
content = json['content']; | |||
type = json['type']; | |||
pvd = json['pvd']; | |||
skipInfo = json['skip_info'] != null | |||
? new SkipInfo.fromJson(json['skip_info']) | |||
: null; | |||
textColor = json['text_color']; | |||
bgColor = json['bg_color']; | |||
bgImage = json['bg_image']; | |||
@@ -166,6 +217,10 @@ class Btn { | |||
data['name'] = this.name; | |||
data['content'] = this.content; | |||
data['type'] = this.type; | |||
data['pvd'] = this.pvd; | |||
if (this.skipInfo != null) { | |||
data['skip_info'] = this.skipInfo.toJson(); | |||
} | |||
data['text_color'] = this.textColor; | |||
data['bg_color'] = this.bgColor; | |||
data['bg_image'] = this.bgImage; | |||
@@ -3,6 +3,7 @@ import 'dart:convert' as convert; | |||
import 'package:cached_network_image/cached_network_image.dart'; | |||
import 'package:flutter/cupertino.dart'; | |||
import 'package:flutter/material.dart'; | |||
import 'package:zhiying_base_widget/utils/contants.dart'; | |||
import 'package:zhiying_comm/models/base/base_tab_model.dart'; | |||
import 'package:zhiying_comm/util/image_util.dart'; | |||
import 'package:zhiying_comm/zhiying_comm.dart'; | |||
@@ -30,7 +31,7 @@ class _HomePageState extends State<HomePage> { | |||
} catch (error) { | |||
Logger.error(error); | |||
} | |||
Constants.isShowIntellectDialog = false; | |||
super.initState(); | |||
} | |||
@@ -105,7 +105,7 @@ class BaseWidgetRegister { | |||
PageFactory.regist('goods_details', (model) => GoodsDetailsPage(model)); | |||
PageFactory.regist('search', (model) => SearchPage(model)); | |||
PageFactory.regist('search_item_page', (model) => SearchItemPage(model)); | |||
PageFactory.regist('search_result', (model) => SearchResultPage(model)); | |||
PageFactory.regist('pub.flutter.search_index', (model) => SearchResultPage(model)); | |||
PageFactory.regist( | |||
'search_result_item', (model) => SearchResultItemPage(model)); | |||
// PageFactory.regist('search_think_page', (model) => SearchThinkPage(model)); | |||
@@ -152,9 +152,10 @@ class _SearchResultInputWidgetState extends State<SearchResultInputWidget> { | |||
focusNode: _focusNode, | |||
style: TextStyle(fontSize: 14, color: HexColor.fromHex('#333333')), | |||
decoration: InputDecoration( | |||
filled: false, | |||
// filled: true, | |||
contentPadding: const EdgeInsets.only(left: 0, right: 0,top: 0 ,bottom: 12), | |||
// focusColor: Colors.transparent, | |||
// fillColor: Colors.transparent, | |||
// fillColor: Colors.transparent, | |||
border: InputBorder.none, | |||
focusedBorder: InputBorder.none, | |||
focusedErrorBorder: InputBorder.none, | |||