| | |
| | | package com.dayu.general.activity |
| | | |
| | | import android.app.Activity |
| | | import android.content.Context |
| | | import android.content.Intent |
| | | import com.dayu.baselibrary.net.subscribers.SubscriberListener |
| | | import com.dayu.baselibrary.utils.ToastUtil |
| | | import com.dayu.general.BaseApplication |
| | | import com.dayu.general.bean.net.LoginResult |
| | | import com.dayu.general.bean.net.SearchUserResult |
| | | import com.dayu.general.net.ApiManager |
| | | import com.dayu.general.net.BaseResponse |
| | |
| | | |
| | | companion object { |
| | | @JvmStatic |
| | | fun login(phone: String, password: String, myContext: Context) { |
| | | fun login(phone: String, password: String, myContext: Activity) { |
| | | val map = mutableMapOf<String, Any>() |
| | | |
| | | if (phone.isNotEmpty()) { |
| | |
| | | map["password"] = password |
| | | } |
| | | |
| | | map["orgTag"] = "ym" |
| | | map["orgTag"] = BaseApplication.tag |
| | | |
| | | // 使用正确的类型参数 |
| | | ApiManager.getInstance().requestPostLoading( |
| | | myContext, |
| | | "sso/sso/loginJson", |
| | | SearchUserResult::class.java, |
| | | LoginResult::class.java, |
| | | map, |
| | | object : SubscriberListener<BaseResponse<SearchUserResult>>() { |
| | | override fun onNext(t: BaseResponse<SearchUserResult>) { |
| | | object : SubscriberListener<BaseResponse<LoginResult>>() { |
| | | override fun onNext(t: BaseResponse<LoginResult>) { |
| | | if (t.success) { |
| | | |
| | | BaseApplication.token = t.content?.token ?: "" |
| | | BaseApplication.userId = t.content?.id ?: "" |
| | | val intent = Intent(myContext, MainActivity::class.java) |
| | | myContext.startActivity(intent) |
| | | } else { |
| | | // 处理搜索失败的情况 |
| | | ToastUtil.show(t.msg) |