Commit e4f090c2 authored by 张释方's avatar 张释方

提交代码

parent be03d715
...@@ -23,7 +23,7 @@ interface MainApi { ...@@ -23,7 +23,7 @@ interface MainApi {
* @return * @return
*/ */
@POST("api/sendMobileCode") @POST("api/sendMobileCode")
fun sendMobileCode(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>> fun sendMobileCode(@Body vo: Map<String, String>): Observable<Response<BaseResponse<Any>>>
/** /**
* 登录 * 登录
......
...@@ -12,7 +12,8 @@ import java.io.Serializable; ...@@ -12,7 +12,8 @@ import java.io.Serializable;
*/ */
public class BaseResponse<T> implements Serializable { public class BaseResponse<T> implements Serializable {
private int status; private int status;
private String message;
private String message="";
// @JsonAdapter(value = JsonAdapterGsonDeserializer.class) // @JsonAdapter(value = JsonAdapterGsonDeserializer.class)
@SerializedName("data") @SerializedName("data")
...@@ -27,6 +28,11 @@ public class BaseResponse<T> implements Serializable { ...@@ -27,6 +28,11 @@ public class BaseResponse<T> implements Serializable {
this.result = result; this.result = result;
} }
public BaseResponse(int status) {
this.status = status;
}
public int getstatus() { public int getstatus() {
return status; return status;
} }
......
...@@ -32,15 +32,15 @@ class LoginViewModel(application: Application) : BaseViewModel(application) { ...@@ -32,15 +32,15 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
* @param mobile * @param mobile
*/ */
fun sendMobileCode(mobile: String) { fun sendMobileCode(mobile: String) {
val vo = HashMap<String, Any>() val vo = HashMap<String, String>()
vo["mobile"] = mobile vo["mobile"] = mobile
vo["type"] = 1 // vo["type"] = 1
ApiModel.sendMobileCode(lifecycleProvider,vo).safeSubscribe( ApiModel.sendMobileCode(lifecycleProvider,vo).subscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>( object : HttpSubscribeImpl<BaseResponse<Any>>(
this@LoginViewModel, true) { this@LoginViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) { override fun onBusinessSuccess(response: BaseResponse<Any>) {
KLog.e("sendMobileCode", response.result.toString()) // KLog.e("sendMobileCode", response.result.toString())
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) {
data.value = "失败" data.value = "失败"
......
...@@ -16,7 +16,7 @@ object ApiModel { ...@@ -16,7 +16,7 @@ object ApiModel {
/** /**
* 发送验证码 * 发送验证码
*/ */
fun sendMobileCode(lifecycleProvider: LifecycleProvider<Any>?, map: Map<String, Any>): Observable<Response<BaseResponse<Any>>> { fun sendMobileCode(lifecycleProvider: LifecycleProvider<Any>?, map: Map<String, String>): Observable<Response<BaseResponse<Any>>> {
return HttpManager.getInstance() return HttpManager.getInstance()
.execute(lifecycleProvider, MainApi.newInstance().sendMobileCode(map)) .execute(lifecycleProvider, MainApi.newInstance().sendMobileCode(map))
} }
......
...@@ -6,7 +6,7 @@ package me.goldze.mvvmhabit.http; ...@@ -6,7 +6,7 @@ package me.goldze.mvvmhabit.http;
public class ResponseThrowable extends Exception { public class ResponseThrowable extends Exception {
public int code; public int code;
public String message; public String message = "";
public ResponseThrowable(Throwable throwable, int code) { public ResponseThrowable(Throwable throwable, int code) {
super(throwable); super(throwable);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment