用户详情
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.example.defenseapplication.bean
|
||||
|
||||
data class ObtainInviterInformationBean(
|
||||
val nickName: String? = null,
|
||||
val idCard: String? = null,
|
||||
val phonenumber: String? = null,
|
||||
val userId: String? = null,
|
||||
val id: String? = null,
|
||||
val status: String? = null,
|
||||
val mac: String? = null
|
||||
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.example.defenseapplication.bean
|
||||
|
||||
data class ObtainInviterInformationRequest(
|
||||
val childId: String
|
||||
)
|
||||
@@ -82,10 +82,7 @@ class LinkedUserActivity : AppCompatActivity() {
|
||||
isUnlinkMode = isUnlinkMode,
|
||||
onItemClick = { user, position ->
|
||||
val intent = Intent(this, UserDetailsActivity::class.java).apply {
|
||||
putExtra("name", user.name)
|
||||
putExtra("phone", user.phone)
|
||||
putExtra("idCard", user.idCard)
|
||||
putExtra("time", user.time)
|
||||
putExtra("userId", user.userId)
|
||||
}
|
||||
startActivity(intent)
|
||||
},
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
package com.example.defenseapplication.liveVideo
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.example.defenseapplication.R
|
||||
import com.example.defenseapplication.bean.DeleteDeviceUserRequest
|
||||
import com.example.defenseapplication.bean.ObtainInviterInformationRequest
|
||||
import com.example.defenseapplication.utils.DeviceIdEvent
|
||||
import com.example.defenseapplication.utils.DeviceUserUpdateEvent
|
||||
import com.example.defenseapplication.databinding.UserDetailsActivityBinding
|
||||
import com.example.defenseapplication.utils.RetrofitNetwork
|
||||
import com.example.defenseapplication.view.CustomDialogFragmentText
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
//用户详情页面
|
||||
class UserDetailsActivity : AppCompatActivity() {
|
||||
private lateinit var binding: UserDetailsActivityBinding
|
||||
|
||||
private lateinit var userName: String
|
||||
private lateinit var phone: String
|
||||
private lateinit var idCard: String
|
||||
private lateinit var time: String
|
||||
private var userId: String = ""
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -27,22 +35,45 @@ class UserDetailsActivity : AppCompatActivity() {
|
||||
.init()
|
||||
|
||||
initData()
|
||||
initView()
|
||||
initListener()
|
||||
fetchInviterInformation()
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
userName = intent.getStringExtra("name") ?: ""
|
||||
phone = intent.getStringExtra("phone") ?: ""
|
||||
idCard = intent.getStringExtra("idCard") ?: ""
|
||||
time = intent.getStringExtra("time") ?: ""
|
||||
userId = intent.getStringExtra("userId") ?: ""
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
binding.tvContactName.text = userName
|
||||
binding.tvPhone.text = phone
|
||||
binding.tvIdCard.text = idCard
|
||||
binding.tvMacAddress.text = "AA:BB:CC:DD:EE:FF"
|
||||
private fun fetchInviterInformation() {
|
||||
if (userId.isEmpty()) {
|
||||
Toast.makeText(this, "用户ID为空", Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
val request = ObtainInviterInformationRequest(childId = userId)
|
||||
val response = RetrofitNetwork.getNetworkService().obtainInviterInformation(request)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (response.code == 200 && response.data != null) {
|
||||
updateUI(response.data!!)
|
||||
} else {
|
||||
Toast.makeText(this@UserDetailsActivity, response.msg ?: "获取信息失败", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(this@UserDetailsActivity, "网络请求失败", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateUI(data: com.example.defenseapplication.bean.ObtainInviterInformationBean) {
|
||||
binding.tvContactName.text = data.nickName ?: "未知用户"
|
||||
binding.tvPhone.text = data.phonenumber ?: ""
|
||||
binding.tvIdCard.text = data.idCard ?: ""
|
||||
binding.tvMacAddress.text = data.mac ?: ""
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
@@ -75,13 +106,40 @@ class UserDetailsActivity : AppCompatActivity() {
|
||||
dialog.setPositiveText(getString(R.string.confirm))
|
||||
dialog.setNegativeText(getString(R.string.cancel))
|
||||
dialog.setOnConfirmListener {
|
||||
finish()
|
||||
// if(){
|
||||
// ToastUtils.showSuccess(this, getString(R.string.wifi_connection_success)
|
||||
// }else{
|
||||
// ToastUtils.showError(this, getString(R.string.wifi_connection_failed))
|
||||
// }
|
||||
deleteDeviceUser()
|
||||
}
|
||||
dialog.show(supportFragmentManager, "DeleteUserDialog")
|
||||
}
|
||||
}
|
||||
|
||||
private fun deleteDeviceUser() {
|
||||
val deviceId = DeviceIdEvent.getDeviceId()
|
||||
if (deviceId.isNullOrEmpty() || userId.isEmpty()) {
|
||||
Toast.makeText(this, "参数错误", Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
|
||||
lifecycleScope.launch {
|
||||
try {
|
||||
val request = DeleteDeviceUserRequest(
|
||||
userId = userId,
|
||||
deviceId = deviceId
|
||||
)
|
||||
val response = RetrofitNetwork.getNetworkService().deleteDeviceUser(request)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (response.code == 200) {
|
||||
Toast.makeText(this@UserDetailsActivity, "删除成功", Toast.LENGTH_SHORT).show()
|
||||
DeviceUserUpdateEvent.notifyUpdate()
|
||||
finish()
|
||||
} else {
|
||||
Toast.makeText(this@UserDetailsActivity, response.msg ?: "删除失败", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(this@UserDetailsActivity, "网络请求失败", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import com.example.defenseapplication.bean.DeleteBean
|
||||
import com.example.defenseapplication.bean.DeleteDeviceUserRequest
|
||||
import com.example.defenseapplication.bean.FamilyMembersBean
|
||||
import com.example.defenseapplication.bean.MessageGroup
|
||||
import com.example.defenseapplication.bean.ObtainInviterInformationBean
|
||||
import com.example.defenseapplication.bean.ObtainInviterInformationRequest
|
||||
import com.example.defenseapplication.bean.SwitchFamilyRequest
|
||||
import com.example.defenseapplication.bean.UpdatePassword
|
||||
import com.example.defenseapplication.bean.UpdateUserInfo
|
||||
@@ -171,6 +173,18 @@ interface ApiService {
|
||||
suspend fun logout(): GetCodeBean<Any>
|
||||
|
||||
|
||||
/**
|
||||
* 获取邀请人信息
|
||||
*/
|
||||
@POST("/app/obtainInviterInformation")
|
||||
suspend fun obtainInviterInformation(@Body request: ObtainInviterInformationRequest): GetCodeBean<ObtainInviterInformationBean>
|
||||
|
||||
|
||||
/**
|
||||
* 修改家庭用户状态
|
||||
*/
|
||||
//@POST("/app/updateFamilyUser")
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user