From c2e4c7d4b151a00c8435f3a7ddbf20ba464fe1d2 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Wed, 31 Mar 2021 18:26:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E6=99=BA?= =?UTF-8?q?=E7=9B=9F=E7=9F=AD=E4=BF=A1=E6=94=AF=E6=8C=81=202=E3=80=81?= =?UTF-8?q?=E5=8E=BB=E9=99=A4net=5Futil=20=E6=B5=8B=E8=AF=95=E7=9A=84head?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/util/mob_util/mob_util.dart | 66 ++++++++++++++++++++++++--------- lib/util/net_util.dart | 2 +- 2 files changed, 49 insertions(+), 19 deletions(-) diff --git a/lib/util/mob_util/mob_util.dart b/lib/util/mob_util/mob_util.dart index 5c32e5d..02e473d 100644 --- a/lib/util/mob_util/mob_util.dart +++ b/lib/util/mob_util/mob_util.dart @@ -78,28 +78,58 @@ class MobUtil { static Future getTextCode(final String phone, {String zoneCode = '86', SMSCodeType smsCodeType = SMSCodeType.NORMAL}) async { bool result = false; String vCodeType = await _getSMSStrategy(phone, type: smsCodeType); - if (EmptyUtil.isEmpty(vCodeType)) return result; - Logger.debug('phone = $phone, zoneCode = $zoneCode, vCodeType = $vCodeType'); - await Smssdk.getTextCode(phone, zoneCode, vCodeType, (ret, err) { - if (err != null) { - result = false; - Logger.debug('get vcode fail err = ${err?.toString()}, ret = ${ret?.toString()}' ); - if(!EmptyUtil.isEmpty(err)){ - Fluttertoast.showToast(msg: '获取验证码失败:${err['msg']}'); - }else { - Fluttertoast.showToast(msg: '获取验证码失败~'); + if (EmptyUtil.isEmpty(vCodeType)) { + result = await _getSMSDefault(phone, type: smsCodeType); + return Future.value(result); + } else { + Logger.debug('phone = $phone, zoneCode = $zoneCode, vCodeType = $vCodeType'); + await Smssdk.getTextCode(phone, zoneCode, vCodeType, (ret, err) { + if (err != null) { + result = false; + Logger.debug('get vcode fail err = ${err?.toString()}, ret = ${ret?.toString()}'); + if (!EmptyUtil.isEmpty(err)) { + Fluttertoast.showToast(msg: '获取验证码失败:${err['msg']}'); + } else { + Fluttertoast.showToast(msg: '获取验证码失败~'); + } + } else { + String rst = ret.toString(); + if (rst == null || rst == "") { + rst = '获取验证码成功! ret = ${ret?.toString()}, err = ${err?.toString()} '; + } + Logger.debug(rst); + result = true; } + }); + } + return Future.value(result); + } + /// + /// 获取智联盟的短信验证码 + /// + static Future _getSMSDefault(final String phone, {SMSCodeType type = SMSCodeType.NORMAL}) async { + bool rlt = false; + try { + String vCodeType = enumToString(type)?.toLowerCase(); + if (EmptyUtil.isEmpty(vCodeType)) { + vCodeType = enumToString(SMSCodeType.NORMAL).toLowerCase(); + } + var result = await NetUtil.post('/api/v1/sign/more_sms/captcha', method: NetMethod.POST, params: { + 'mobile': phone, + 'type': vCodeType + }); + if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { + // Fluttertoast.showToast(msg: result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); + Logger.debug(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); + rlt = true; } else { - String rst = ret.toString(); - if (rst == null || rst == "") { - rst = '获取验证码成功! ret = ${ret?.toString()}, err = ${err?.toString()} '; - } - Logger.debug(rst); - result = true; + Fluttertoast.showToast(msg: result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); } - }); - return Future.value(result); + } catch (e, s) { + Logger.error(e, s); + } + return rlt; } /// 询问验证码是否可以下发 diff --git a/lib/util/net_util.dart b/lib/util/net_util.dart index ad140bc..e3e3a5f 100644 --- a/lib/util/net_util.dart +++ b/lib/util/net_util.dart @@ -69,7 +69,7 @@ class NetUtil { receiveTimeout: 15000, contentType: Headers.jsonContentType, followRedirects: true, - headers: {'device': 'wx_applet', 'Platform': 'wx_applet'}, + // headers: {'device': 'wx_applet', 'Platform': 'wx_applet'}, validateStatus: (_) { return true; })); From ed329c639027ad749f2e11787a841bcc403b36f0 Mon Sep 17 00:00:00 2001 From: PH2 <1293456824@qq.com> Date: Wed, 31 Mar 2021 19:44:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=E3=80=81=E6=B7=BB=E5=8A=A0=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=B8=A0=E9=81=93=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/util/turn_chain/turn_chain_util.dart | 64 ++++++++++++++++-------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/lib/util/turn_chain/turn_chain_util.dart b/lib/util/turn_chain/turn_chain_util.dart index bdba4fa..6a5045c 100644 --- a/lib/util/turn_chain/turn_chain_util.dart +++ b/lib/util/turn_chain/turn_chain_util.dart @@ -55,7 +55,7 @@ class TurnChainUtil { /// 微盘: sinavdisk:// /// 名片全能王: camcard:// /// - static Future openReceiveCoupon(BuildContext context, UserInfoModel userInfoModel, String goodsId, String provider, Map data, {bool isFree=false}) async { + static Future openReceiveCoupon(BuildContext context, UserInfoModel userInfoModel, String goodsId, String provider, Map data, {bool isFree = false}) async { ///iOS 审核状态 String is_ios_review = await SharedPreferencesUtil.getStringValue(GlobalConfig.IS_IOS_REVIEW, defaultVal: '0'); @@ -119,25 +119,25 @@ class TurnChainUtil { case GlobalConfig.PROVIDER_KL: case GlobalConfig.PROVIDER_PDD: case GlobalConfig.PROVIDER_SN: - bool launchable = await canLaunch(appUrl); - if (Platform.isIOS) { - launchable = await launch(appUrl); - } - if (launchable) { - if (!Platform.isIOS) { - if(appUrl.startsWith("suning")){ - RouterUtil.openWebview(webUrl, context); - }else{ - RouterUtil.openWebview(webUrl, context); + bool launchable = await canLaunch(appUrl); + if (Platform.isIOS) { + launchable = await launch(appUrl); + } + if (launchable) { + if (!Platform.isIOS) { + if (appUrl.startsWith("suning")) { + RouterUtil.openWebview(webUrl, context); + } else { + RouterUtil.openWebview(webUrl, context); + } } + } else if (!EmptyUtil.isEmpty(webUrl)) { + Logger.log('打开${provider} webUrl, url = ${webUrl}'); + RouterUtil.openWebview(webUrl, context); + } else { + Fluttertoast.cancel(); + Fluttertoast.showToast(msg: '购买链接不存在'); } - } else if (!EmptyUtil.isEmpty(webUrl)) { - Logger.log('打开${provider} webUrl, url = ${webUrl}'); - RouterUtil.openWebview(webUrl, context); - } else { - Fluttertoast.cancel(); - Fluttertoast.showToast(msg: '购买链接不存在'); - } break; case GlobalConfig.PROVIDER_VIP: bool launchable = await canLaunch(appUrl); @@ -156,6 +156,28 @@ class TurnChainUtil { Fluttertoast.showToast(msg: '购买链接不存在'); } break; + default: + if (!EmptyUtil.isEmpty(openAppUrl)) { + bool launchable = await canLaunch(appUrl); + if (launchable) { + launchable = await launch(appUrl); + } + if (launchable) { + if (!Platform.isIOS) { + RouterUtil.openWebview(webUrl, context); + } + } else if (!EmptyUtil.isEmpty(webUrl)) { + Logger.log('打开${provider} webUrl, url = ${webUrl}'); + RouterUtil.openWebview(webUrl, context); + } else { + Fluttertoast.cancel(); + Fluttertoast.showToast(msg: '购买链接不存在'); + } + } else { + Fluttertoast.cancel(); + Fluttertoast.showToast(msg: '购买链接不存在'); + } + break; } } else { Fluttertoast.cancel(); @@ -187,7 +209,7 @@ class TurnChainUtil { } /// 3、获取转链的结果 - Map result = await getTurnChainResult(context, goodsId, provider, data, isShare: true ); + Map result = await getTurnChainResult(context, goodsId, provider, data, isShare: true); if (!EmptyUtil.isEmpty(result) && !EmptyUtil.isEmpty(result['open_app_url'])) { return result; } @@ -232,8 +254,8 @@ class TurnChainUtil { data['is_share'] = isShare ? '1' : '0'; ///1为免单,0为普通 - data['is_free'] = (isFree??false) ? "1" : "0"; - (isFree??false) ? print("免单") : print("普通"); + data['is_free'] = (isFree ?? false) ? "1" : "0"; + (isFree ?? false) ? print("免单") : print("普通"); if (EmptyUtil.isEmpty(model)) { // 开启loading