|
|
@@ -78,28 +78,58 @@ class MobUtil { |
|
|
|
static Future<bool> 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<bool> _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; |
|
|
|
} |
|
|
|
|
|
|
|
/// 询问验证码是否可以下发 |
|
|
|