diff --git a/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java b/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java index 59220d7..65232b5 100644 --- a/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java +++ b/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java @@ -158,9 +158,9 @@ public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommN public Map getSetting() { Map map = new HashMap(); ///测试 -// map.put("domain", "http://inapi.izhyin.cn/");//"http://120.76.175.204:8989");http://47.114.51.254:80 http://inapi.izhyin.cn/ -// map.put("master_id", "22255132"); -// map.put("secret_key", "123456"); + map.put("domain", "http://inapi.izhyin.cn/");//"http://120.76.175.204:8989");http://47.114.51.254:80 http://inapi.izhyin.cn/ + map.put("master_id", "123456"); + map.put("secret_key", "123456"); ///正式 // map.put("domain", "http://api.zhios.cn/");//45678910,api.zhios.cn84198689 @@ -174,9 +174,9 @@ public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommN // map.put("token", "123465"); - map.put("domain", "http://api.quanslm.com/");//"http://120.76.175.204:8989");http://47.114.51.254:80 http://inapi.izhyin.cn/ - map.put("master_id", "22655501"); - map.put("secret_key", "123456"); +// map.put("domain", "http://api.quanslm.com/");//"http://120.76.175.204:8989");http://47.114.51.254:80 http://inapi.izhyin.cn/ +// map.put("master_id", "22655501"); +// map.put("secret_key", "123456"); return map; } 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 aa23b60..003abb6 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 @@ -15,12 +15,10 @@ class IntellectSearchGoodsDialog extends StatefulWidget { const IntellectSearchGoodsDialog({Key key, this.model}) : super(key: key); @override - _IntellectSearchGoodsDialogState createState() => - _IntellectSearchGoodsDialogState(); + _IntellectSearchGoodsDialogState createState() => _IntellectSearchGoodsDialogState(); } -class _IntellectSearchGoodsDialogState - extends State { +class _IntellectSearchGoodsDialogState extends State { HasGoodsDialogStyleModel _styleModel; @override @@ -46,15 +44,8 @@ class _IntellectSearchGoodsDialogState children: [ Container( margin: EdgeInsets.only(top: 19, left: 48, right: 48), - padding: EdgeInsets.only( - top: 38, - left: 15, - right: 15, - bottom: 24), - decoration: BoxDecoration( - color: - HexColor.fromHex(_styleModel?.bgColor ?? "#FFFFFF"), - borderRadius: BorderRadius.circular(16)), + padding: EdgeInsets.only(top: 38, left: 15, right: 15, bottom: 24), + decoration: BoxDecoration(color: HexColor.fromHex(_styleModel?.bgColor ?? "#FFFFFF"), borderRadius: BorderRadius.circular(16)), width: double.infinity, child: Column( children: [_buildTopItem(), _buildBottomItem()], @@ -100,12 +91,8 @@ class _IntellectSearchGoodsDialogState Container( width: 80, height: 80, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(6), - image: DecorationImage( - image: - CachedNetworkImageProvider(widget.model?.thumbnail ?? ""), - fit: BoxFit.fill)), + decoration: + BoxDecoration(borderRadius: BorderRadius.circular(6), image: DecorationImage(image: CachedNetworkImageProvider(widget.model?.thumbnail ?? ""), fit: BoxFit.fill)), ), SizedBox( width: 9.5, @@ -133,9 +120,7 @@ class _IntellectSearchGoodsDialogState ? Container() : Container( margin: EdgeInsets.only(right: 16), - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(2)), + decoration: BoxDecoration(color: Colors.red, borderRadius: BorderRadius.circular(2)), padding: EdgeInsets.all(2), child: Row( mainAxisSize: MainAxisSize.min, @@ -143,46 +128,26 @@ class _IntellectSearchGoodsDialogState Container( width: 15, height: 15, - decoration: BoxDecoration( - color: HexColor.fromHex(_styleModel - ?.moduleList?.coupon?.bgColor ?? - "")), + 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: 10), + _styleModel?.moduleList?.coupon?.content ?? "", + style: TextStyle(color: HexColor.fromHex(_styleModel?.moduleList?.coupon?.fontColor ?? ""), fontSize: 10), ), ), ), Padding( - padding: const EdgeInsets.only( - left: 4, right: 4), + padding: const EdgeInsets.only(left: 4, right: 4), child: Text( "¥" + (widget.model?.couponPrice ?? ""), - style: TextStyle( - color: HexColor.fromHex(_styleModel - ?.moduleList - ?.couponPrice - ?.fontColor), - fontSize: 10), + style: TextStyle(color: HexColor.fromHex(_styleModel?.moduleList?.couponPrice?.fontColor), fontSize: 10), ), ) ], ), ), Container( - decoration: BoxDecoration( - color: HexColor.fromHex( - _styleModel?.moduleList?.commission?.bgColor), - borderRadius: BorderRadius.circular(2)), + decoration: BoxDecoration(color: HexColor.fromHex(_styleModel?.moduleList?.commission?.bgColor), borderRadius: BorderRadius.circular(2)), padding: EdgeInsets.all(2), child: Row( mainAxisSize: MainAxisSize.min, @@ -192,21 +157,10 @@ class _IntellectSearchGoodsDialogState ), Center( child: Padding( - padding: - const EdgeInsets.only(left: 4, right: 4), + padding: const EdgeInsets.only(left: 4, right: 4), child: Text( - (_styleModel?.moduleList?.commission - ?.content ?? - "") + - " ¥" + - (widget.model?.commission ?? ""), - style: TextStyle( - color: HexColor.fromHex(_styleModel - ?.moduleList - ?.commission - ?.fontColor ?? - ""), - fontSize: 10), + (_styleModel?.moduleList?.commission?.content ?? "") + " ¥" + (widget.model?.commission ?? ""), + style: TextStyle(color: HexColor.fromHex(_styleModel?.moduleList?.commission?.fontColor ?? ""), fontSize: 10), ), ), ) @@ -227,23 +181,14 @@ class _IntellectSearchGoodsDialogState padding: const EdgeInsets.only(bottom: 2), child: Text( _styleModel?.moduleList?.couponAfter?.content ?? "", - style: TextStyle( - fontSize: 10, - color: HexColor.fromHex(_styleModel - ?.moduleList?.couponAfterPrice?.fontColor ?? - "")), + style: TextStyle(fontSize: 10, color: HexColor.fromHex(_styleModel?.moduleList?.couponAfterPrice?.fontColor ?? "")), ), ), Padding( - padding: - const EdgeInsets.only(bottom: 2, left: 4, right: 4), + padding: const EdgeInsets.only(bottom: 2, left: 4, right: 4), child: Text( "¥", - style: TextStyle( - fontSize: 10, - color: HexColor.fromHex(_styleModel - ?.moduleList?.couponAfterPrice?.fontColor ?? - "")), + style: TextStyle(fontSize: 10, color: HexColor.fromHex(_styleModel?.moduleList?.couponAfterPrice?.fontColor ?? "")), ), ), Expanded( @@ -253,8 +198,7 @@ class _IntellectSearchGoodsDialogState maxLines: 1, style: TextStyle( fontSize: 16, - color: HexColor.fromHex(_styleModel - ?.moduleList?.couponAfterPrice?.fontColor), + color: HexColor.fromHex(_styleModel?.moduleList?.couponAfterPrice?.fontColor), ), ), ) @@ -291,10 +235,7 @@ class _IntellectSearchGoodsDialogState Expanded( child: Container( margin: EdgeInsets.only(left: 10, right: 10), - decoration: BoxDecoration( - color: HexColor.fromHex( - _styleModel?.moduleList?.saveBtn?.bgColor ?? ""), - borderRadius: BorderRadius.circular(50)), + decoration: BoxDecoration(color: HexColor.fromHex(_styleModel?.moduleList?.saveBtn?.bgColor ?? ""), borderRadius: BorderRadius.circular(50)), child: Center( child: Padding( padding: const EdgeInsets.all(12.0), @@ -302,10 +243,7 @@ class _IntellectSearchGoodsDialogState (_styleModel?.moduleList?.saveBtn?.content ?? "") + " ¥" + formatNum((num.tryParse(widget?.model?.couponPrice ?? "0") ?? 0) + num.tryParse(widget?.model?.commission ?? '0'), 2), - style: TextStyle( - color: HexColor.fromHex( - _styleModel?.moduleList?.saveBtn?.fontColor), - fontSize: 12), + style: TextStyle(color: HexColor.fromHex(_styleModel?.moduleList?.saveBtn?.fontColor), fontSize: 12), ), )), )) @@ -323,21 +261,14 @@ class _IntellectSearchGoodsDialogState children: [ Expanded( child: Container( - margin: EdgeInsets.only(left: 10, right:10), - decoration: BoxDecoration( - color: HexColor.fromHex( - _styleModel?.moduleList?.viewGoodsBtn?.bgColor ?? ""), - borderRadius: BorderRadius.circular(50)), + margin: EdgeInsets.only(left: 10, right: 10), + decoration: BoxDecoration(color: HexColor.fromHex(_styleModel?.moduleList?.viewGoodsBtn?.bgColor ?? ""), borderRadius: BorderRadius.circular(50)), child: Center( child: Padding( padding: const EdgeInsets.all(12.0), child: Text( _styleModel?.moduleList?.viewGoodsBtn?.content ?? "", - style: TextStyle( - color: HexColor.fromHex( - _styleModel?.moduleList?.viewGoodsBtn?.fontColor ?? - ""), - fontSize: 12), + style: TextStyle(color: HexColor.fromHex(_styleModel?.moduleList?.viewGoodsBtn?.fontColor ?? ""), fontSize: 12), ), )), )) @@ -354,8 +285,7 @@ class _IntellectSearchGoodsDialogState void requestStyle() { NetUtil.request("/api/v1/cfg/clipboard_identified", onSuccess: (data) { print(data); - _styleModel = HasGoodsDialogStyleModel.fromJson( - json.decode(data['clipboard_identified'])); + _styleModel = HasGoodsDialogStyleModel.fromJson(json.decode(data['clipboard_identified'])); setState(() {}); }); } @@ -363,6 +293,7 @@ class _IntellectSearchGoodsDialogState void openUrl() async { ///跳转购买 UserInfoModel userInfo = UserInfoNotifier.staitcUserInfo; + /// 登录 if (userInfo?.token == null || userInfo.token == '') { print('need login...'); @@ -370,32 +301,34 @@ class _IntellectSearchGoodsDialogState 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("\\", ""); + // 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 ) { + 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) { /// 拼多多 + } 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{ + } else { ///关闭弹窗 if (Navigator.canPop(context)) { Navigator.pop(context); @@ -407,7 +340,7 @@ class _IntellectSearchGoodsDialogState context, provider: widget?.model?.provider ?? 'taobao', openAppUrl: widget?.model?.couponUrl, - appUrl: widget?.model?.couponUrl, + appUrl: widget?.model?.appUrl, webUrl: widget?.model?.couponUrl, ); // if (widget?.model?.provider == GlobalConfig.PROVIDER_TB || widget?.model?.provider == GlobalConfig.PROVIDER_TM) { @@ -437,9 +370,7 @@ class _IntellectSearchGoodsDialogState 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) { + RouterUtil.route(SkipModel(skipIdentifier: "goods_details"), {"provider": provider, "good_id": goodId}, context).then((data) { Navigator.pop(context); }); } diff --git a/lib/dialog/global_dialog/intellect_search_goods_dialog/model/intellect_dialog_data_model.dart b/lib/dialog/global_dialog/intellect_search_goods_dialog/model/intellect_dialog_data_model.dart index 5c83878..623b6d9 100644 --- a/lib/dialog/global_dialog/intellect_search_goods_dialog/model/intellect_dialog_data_model.dart +++ b/lib/dialog/global_dialog/intellect_search_goods_dialog/model/intellect_dialog_data_model.dart @@ -9,19 +9,20 @@ class IntellectDialogDataModel { String provider; String couponUrl; String couponPrice; - + String appUrl; IntellectDialogDataModel( {this.itemId, - this.title, - this.price, - this.priceOriginal, - this.commission, - this.commissionRate, - this.thumbnail, - this.provider, - this.couponUrl, - this.couponPrice}); + this.title, + this.price, + this.priceOriginal, + this.commission, + this.commissionRate, + this.thumbnail, + this.provider, + this.couponUrl, + this.couponPrice, + this.appUrl}); IntellectDialogDataModel.fromJson(Map json) { itemId = json['item_id'].toString(); @@ -34,6 +35,7 @@ class IntellectDialogDataModel { provider = json['provider'].toString(); couponUrl = json['coupon_url'].toString(); couponPrice = json['coupon_price'].toString(); + appUrl = json['app_url']; } Map toJson() { @@ -48,6 +50,7 @@ class IntellectDialogDataModel { data['provider'] = this.provider; data['coupon_url'] = this.couponUrl; data['coupon_price'] = this.couponPrice; + data['app_url']=this.appUrl; return data; } }