| | |
| | | |
| | | typedef OnHttpRequestStart = void Function(); |
| | | |
| | | _showLoading(BuildContext context) { |
| | | showLoading(BuildContext context) { |
| | | //先丢失焦点 |
| | | FocusScope.of(context).unfocus(); |
| | | //开启加载框 |
| | |
| | | return EncryptUtil.MD5(signStr); |
| | | } |
| | | |
| | | static Future<HttpRequestResult> baseRequest( |
| | | String api, Map<String, dynamic> params, OnHttpRequestStart? onStart, |
| | | {bool notifyError = false}) async { |
| | | // params ??= {}; |
| | | static Future<Map<String, dynamic>> getBaseParams( |
| | | Map<String, dynamic>? params) async { |
| | | params ??= {}; |
| | | |
| | | if (Platform.isAndroid) { |
| | | if (_androidInfo == null) { |
| | |
| | | } |
| | | |
| | | params["sign"] = _getSign(params); |
| | | |
| | | return params; |
| | | } |
| | | |
| | | static Future<HttpRequestResult> baseRequest( |
| | | String api, Map<String, dynamic> params, OnHttpRequestStart? onStart, |
| | | {bool notifyError = false}) async { |
| | | // params ??= {}; |
| | | params = await getBaseParams(params); |
| | | |
| | | var httpClient = HttpClient(); |
| | | httpClient.connectionTimeout = const Duration(seconds: 20); |
| | |
| | | BuildContext context, String phone) async { |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/sms/sendSMS", {"phone": phone}, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | params["uid"] = uid.toString(); |
| | | } |
| | | |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/user/uploadPushRegId", params, () { |
| | | }); |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/user/uploadPushRegId", params, () {}); |
| | | if (result.success) { |
| | | return result.data; |
| | | } |
| | |
| | | |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/user/loginPhone", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }, notifyError: true); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | type.toString().substring(type.toString().indexOf(".") + 1); |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/location/addLocationUser", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | |
| | | _dismissDialog(context); |
| | |
| | | |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/location/updateLocationUser", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | var params = {"uid": uid.toString(), "id": id}; |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/location/deleteLocationUser", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/sos/addEmergencyContacts", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/sos/deleteEmergencyContacts", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/sos/updateEmergencyContacts", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/sos/addSOSRecord", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/sos/clearSOSRecord", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | params["content"] = content; |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/feedback/advice", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }, notifyError: true); |
| | | |
| | | _dismissDialog(context); |