package com.dayu.general.activity
|
|
import android.content.Context
|
import com.dayu.baselibrary.net.subscribers.SubscriberListener
|
import com.dayu.baselibrary.utils.ToastUtil
|
import com.dayu.general.bean.net.SearchUserResult
|
import com.dayu.general.net.ApiManager
|
import com.dayu.general.net.BaseResponse
|
|
/**
|
* Description:
|
* Author: zuo
|
* Date: 2025/3/13
|
*/
|
class LoginActivity {
|
|
companion object {
|
@JvmStatic
|
fun login(phone: String, password: String, myContext: Context) {
|
val map = mutableMapOf<String, Any>()
|
|
if (phone.isNotEmpty()) {
|
map["phone"] = phone
|
}
|
|
if (password.isNotEmpty()) {
|
map["password"] = password
|
}
|
|
map["orgTag"] = "ym"
|
|
// 使用正确的类型参数
|
ApiManager.getInstance().requestPostLoading(
|
myContext,
|
"sso/sso/loginJson",
|
SearchUserResult::class.java,
|
map,
|
object : SubscriberListener<BaseResponse<SearchUserResult>>() {
|
override fun onNext(t: BaseResponse<SearchUserResult>) {
|
if (t.success) {
|
|
} else {
|
// 处理搜索失败的情况
|
ToastUtil.show(t.msg)
|
}
|
}
|
|
override fun onError(e: Throwable?) {
|
super.onError(e)
|
ToastUtil.show("搜索失败: ${e?.message ?: "未知错误"}")
|
}
|
}
|
)
|
}
|
}
|
|
|
}
|