Browse Source

1.关闭弹窗问题

tags/0.0.1
杨华轩 4 years ago
parent
commit
1e11cd5778
7 changed files with 214 additions and 105 deletions
  1. +42
    -35
      lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart
  2. +66
    -45
      lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart
  3. +44
    -20
      lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart
  4. +56
    -1
      lib/dialog/global_dialog/intellect_search_goods_dialog/model/no_goods_dialog_style_model.dart
  5. +2
    -1
      lib/pages/home_page/home_page.dart
  6. +1
    -1
      lib/register.dart
  7. +3
    -2
      lib/widgets/search_result/search_input/search_result_input.dart

+ 42
- 35
lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_create.dart View File

@@ -22,7 +22,12 @@ class IntellectCreate {
static checkAndCreate(AppLifecycleState state, BuildContext context) async { static checkAndCreate(AppLifecycleState state, BuildContext context) async {
if (state == AppLifecycleState.resumed && !isRequest) { if (state == AppLifecycleState.resumed && !isRequest) {
isRequest = true; isRequest = true;
_requestSetData(context);
try {
_requestSetData(context);
} catch (e, s) {
print(e);
print(s);
}
} }
// Timer(Duration(milliseconds: 500), () async { // Timer(Duration(milliseconds: 500), () async {
// if (!Constants.isShowIntellectDialog) { // if (!Constants.isShowIntellectDialog) {
@@ -49,7 +54,7 @@ class IntellectCreate {
Constants.spIsCacheSetModel); Constants.spIsCacheSetModel);
_setModel = IntellectSearchSetModel.fromJson( _setModel = IntellectSearchSetModel.fromJson(
json.decode(data['clipboard_base'])); json.decode(data['clipboard_base']));
if (result.isEmpty) {
if (result == null || result.isEmpty) {
validate(context, _setModel); validate(context, _setModel);
} }
SharedPreferencesUtil.setNetCacheResult( SharedPreferencesUtil.setNetCacheResult(
@@ -80,11 +85,12 @@ class IntellectCreate {


///请求数据打开弹窗 ///请求数据打开弹窗
static requestDialog(BuildContext context, String content) async { 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}; var params = {"content": content};
NetUtil.request("/api/v1/clipboard/parse",
NetUtil.request("/api/v1/clipboard/parse",
params: params, method: NetMethod.POST, onSuccess: (data) async { params: params, method: NetMethod.POST, onSuccess: (data) async {
print(data);
isRequest = false; isRequest = false;
if (data == null || data.toString().length == 0) { if (data == null || data.toString().length == 0) {
if (!Constants.isShowIntellectDialog) { if (!Constants.isShowIntellectDialog) {
@@ -113,36 +119,37 @@ class IntellectCreate {
static void validate( static void validate(
BuildContext context, IntellectSearchSetModel setModel) async { BuildContext context, IntellectSearchSetModel setModel) async {
ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); 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) { if (setModel.banWords != null && setModel.banWords.length > 0) {


+ 66
- 45
lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_goods_dialog.dart View File

@@ -31,7 +31,7 @@ class _IntellectSearchGoodsDialogState


@override @override
void initState() { void initState() {
//Clipboard.setData(ClipboardData(text: ""));
requestStyle(); requestStyle();
super.initState(); super.initState();
} }
@@ -125,49 +125,55 @@ class _IntellectSearchGoodsDialogState
), ),
Row( Row(
children: <Widget>[ 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( 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( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: HexColor.fromHex( color: HexColor.fromHex(
@@ -275,7 +281,9 @@ class _IntellectSearchGoodsDialogState
child: Text( child: Text(
(_styleModel?.moduleList?.saveBtn?.content ?? "") + (_styleModel?.moduleList?.saveBtn?.content ?? "") +
" ¥" + " ¥" +
((double.tryParse(widget?.model?.couponPrice??"0.0")??0) +
((double.tryParse(
widget?.model?.couponPrice ?? "0.0") ??
0) +
double.tryParse( double.tryParse(
widget?.model?.commission ?? '0')) widget?.model?.commission ?? '0'))
.toString() .toString()
@@ -331,6 +339,7 @@ class _IntellectSearchGoodsDialogState


void requestStyle() { void requestStyle() {
NetUtil.request("/api/v1/cfg/clipboard_identified", onSuccess: (data) { NetUtil.request("/api/v1/cfg/clipboard_identified", onSuccess: (data) {
print(data);
_styleModel = HasGoodsDialogStyleModel.fromJson( _styleModel = HasGoodsDialogStyleModel.fromJson(
json.decode(data['clipboard_identified'])); json.decode(data['clipboard_identified']));
setState(() {}); setState(() {});
@@ -344,10 +353,15 @@ class _IntellectSearchGoodsDialogState
RouterUtil.goLogin(context); RouterUtil.goLogin(context);
return; return;
} else { } else {
print("平台"+widget?.model?.provider??"");
if (widget?.model?.provider == 'taobao') { if (widget?.model?.provider == 'taobao') {
TradeResult result = TradeResult result =
await FlutterAlibc.openByUrl(url: widget?.model?.couponUrl);
await FlutterAlibc.openByUrl(url: widget?.model?.couponUrl??"");
Logger.debug('${result.errorCode} ${result.errorMessage} '); Logger.debug('${result.errorCode} ${result.errorMessage} ');
print("链接"+widget?.model?.couponUrl??"");
print("错误码"+result.errorCode);
print("原因"+result.errorMessage);

} else { } else {
RouterUtil.openWebview(widget?.model?.couponUrl, context); RouterUtil.openWebview(widget?.model?.couponUrl, context);
} }
@@ -359,8 +373,15 @@ class _IntellectSearchGoodsDialogState
String provider = widget.model.provider; String provider = widget.model.provider;
String goodId = widget.model.itemId; String goodId = widget.model.itemId;
RouterUtil.route(SkipModel(skipIdentifier: "goods_details"), 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();
}
} }

+ 44
- 20
lib/dialog/global_dialog/intellect_search_goods_dialog/intellect_search_no_goods_dialog.dart View File

@@ -1,5 +1,4 @@
import 'dart:convert'; import 'dart:convert';

import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -25,18 +24,20 @@ class _IntellectSearchNoGoodsDialogState


NoGoodsDialogStyleModel _styleModel; NoGoodsDialogStyleModel _styleModel;


var searchText;

@override @override
void initState() { void initState() {
_textEditingController = TextEditingController(); _textEditingController = TextEditingController();
_getClipBoardData(); _getClipBoardData();

super.initState(); super.initState();
} }


///获取粘贴板内容 ///获取粘贴板内容
_getClipBoardData() async { _getClipBoardData() async {
ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain);
_textEditingController.text = data.text;
_textEditingController.text = data.text.trim();
searchText = data.text.trim();
requestStyle(); requestStyle();
setState(() {}); setState(() {});
} }
@@ -141,23 +142,38 @@ class _IntellectSearchNoGoodsDialogState
Row( Row(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: InkWell(
child: Container( 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( 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( SizedBox(
@@ -210,9 +226,8 @@ class _IntellectSearchNoGoodsDialogState
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Container( Container(
color: Colors.deepOrange,
child: Image.network( child: Image.network(
"",
item.image ?? "",
width: 60.w, width: 60.w,
height: 60.w, height: 60.w,
fit: BoxFit.fill, 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();
}
} }

+ 56
- 1
lib/dialog/global_dialog/intellect_search_goods_dialog/model/no_goods_dialog_style_model.dart View File

@@ -38,13 +38,19 @@ class NoGoodsDialogStyleModel {
class IconList { class IconList {
String image; String image;
String title; String title;
String pvd;
SkipInfo skipInfo;
String textColor; 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) { IconList.fromJson(Map<String, dynamic> json) {
image = json['image']; image = json['image'];
title = json['title']; title = json['title'];
pvd = json['pvd'];
skipInfo = json['skip_info'] != null
? new SkipInfo.fromJson(json['skip_info'])
: null;
textColor = json['text_color']; textColor = json['text_color'];
} }


@@ -52,11 +58,48 @@ class IconList {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = new Map<String, dynamic>();
data['image'] = this.image; data['image'] = this.image;
data['title'] = this.title; data['title'] = this.title;
data['pvd'] = this.pvd;
if (this.skipInfo != null) {
data['skip_info'] = this.skipInfo.toJson();
}
data['text_color'] = this.textColor; data['text_color'] = this.textColor;
return data; 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 { class ModuleList {
Title title; Title title;
Title segment; Title segment;
@@ -140,6 +183,8 @@ class Btn {
String name; String name;
String content; String content;
String type; String type;
String pvd;
SkipInfo skipInfo;
String textColor; String textColor;
String bgColor; String bgColor;
String bgImage; String bgImage;
@@ -148,6 +193,8 @@ class Btn {
{this.name, {this.name,
this.content, this.content,
this.type, this.type,
this.pvd,
this.skipInfo,
this.textColor, this.textColor,
this.bgColor, this.bgColor,
this.bgImage}); this.bgImage});
@@ -156,6 +203,10 @@ class Btn {
name = json['name']; name = json['name'];
content = json['content']; content = json['content'];
type = json['type']; type = json['type'];
pvd = json['pvd'];
skipInfo = json['skip_info'] != null
? new SkipInfo.fromJson(json['skip_info'])
: null;
textColor = json['text_color']; textColor = json['text_color'];
bgColor = json['bg_color']; bgColor = json['bg_color'];
bgImage = json['bg_image']; bgImage = json['bg_image'];
@@ -166,6 +217,10 @@ class Btn {
data['name'] = this.name; data['name'] = this.name;
data['content'] = this.content; data['content'] = this.content;
data['type'] = this.type; data['type'] = this.type;
data['pvd'] = this.pvd;
if (this.skipInfo != null) {
data['skip_info'] = this.skipInfo.toJson();
}
data['text_color'] = this.textColor; data['text_color'] = this.textColor;
data['bg_color'] = this.bgColor; data['bg_color'] = this.bgColor;
data['bg_image'] = this.bgImage; data['bg_image'] = this.bgImage;


+ 2
- 1
lib/pages/home_page/home_page.dart View File

@@ -3,6 +3,7 @@ import 'dart:convert' as convert;
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.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/models/base/base_tab_model.dart';
import 'package:zhiying_comm/util/image_util.dart'; import 'package:zhiying_comm/util/image_util.dart';
import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:zhiying_comm/zhiying_comm.dart';
@@ -30,7 +31,7 @@ class _HomePageState extends State<HomePage> {
} catch (error) { } catch (error) {
Logger.error(error); Logger.error(error);
} }
Constants.isShowIntellectDialog = false;
super.initState(); super.initState();
} }




+ 1
- 1
lib/register.dart View File

@@ -105,7 +105,7 @@ class BaseWidgetRegister {
PageFactory.regist('goods_details', (model) => GoodsDetailsPage(model)); PageFactory.regist('goods_details', (model) => GoodsDetailsPage(model));
PageFactory.regist('search', (model) => SearchPage(model)); PageFactory.regist('search', (model) => SearchPage(model));
PageFactory.regist('search_item_page', (model) => SearchItemPage(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( PageFactory.regist(
'search_result_item', (model) => SearchResultItemPage(model)); 'search_result_item', (model) => SearchResultItemPage(model));
// PageFactory.regist('search_think_page', (model) => SearchThinkPage(model)); // PageFactory.regist('search_think_page', (model) => SearchThinkPage(model));


+ 3
- 2
lib/widgets/search_result/search_input/search_result_input.dart View File

@@ -152,9 +152,10 @@ class _SearchResultInputWidgetState extends State<SearchResultInputWidget> {
focusNode: _focusNode, focusNode: _focusNode,
style: TextStyle(fontSize: 14, color: HexColor.fromHex('#333333')), style: TextStyle(fontSize: 14, color: HexColor.fromHex('#333333')),
decoration: InputDecoration( decoration: InputDecoration(
filled: false,
// filled: true,
contentPadding: const EdgeInsets.only(left: 0, right: 0,top: 0 ,bottom: 12),
// focusColor: Colors.transparent, // focusColor: Colors.transparent,
// fillColor: Colors.transparent,
// fillColor: Colors.transparent,
border: InputBorder.none, border: InputBorder.none,
focusedBorder: InputBorder.none, focusedBorder: InputBorder.none,
focusedErrorBorder: InputBorder.none, focusedErrorBorder: InputBorder.none,


Loading…
Cancel
Save