用户详情
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,
|
isUnlinkMode = isUnlinkMode,
|
||||||
onItemClick = { user, position ->
|
onItemClick = { user, position ->
|
||||||
val intent = Intent(this, UserDetailsActivity::class.java).apply {
|
val intent = Intent(this, UserDetailsActivity::class.java).apply {
|
||||||
putExtra("name", user.name)
|
putExtra("userId", user.userId)
|
||||||
putExtra("phone", user.phone)
|
|
||||||
putExtra("idCard", user.idCard)
|
|
||||||
putExtra("time", user.time)
|
|
||||||
}
|
}
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,20 +1,28 @@
|
|||||||
package com.example.defenseapplication.liveVideo
|
package com.example.defenseapplication.liveVideo
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.example.defenseapplication.R
|
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.databinding.UserDetailsActivityBinding
|
||||||
|
import com.example.defenseapplication.utils.RetrofitNetwork
|
||||||
import com.example.defenseapplication.view.CustomDialogFragmentText
|
import com.example.defenseapplication.view.CustomDialogFragmentText
|
||||||
import com.gyf.immersionbar.ImmersionBar
|
import com.gyf.immersionbar.ImmersionBar
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
//用户详情页面
|
//用户详情页面
|
||||||
class UserDetailsActivity : AppCompatActivity() {
|
class UserDetailsActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: UserDetailsActivityBinding
|
private lateinit var binding: UserDetailsActivityBinding
|
||||||
|
|
||||||
private lateinit var userName: String
|
private var userId: String = ""
|
||||||
private lateinit var phone: String
|
|
||||||
private lateinit var idCard: String
|
|
||||||
private lateinit var time: String
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -27,22 +35,45 @@ class UserDetailsActivity : AppCompatActivity() {
|
|||||||
.init()
|
.init()
|
||||||
|
|
||||||
initData()
|
initData()
|
||||||
initView()
|
|
||||||
initListener()
|
initListener()
|
||||||
|
fetchInviterInformation()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initData() {
|
private fun initData() {
|
||||||
userName = intent.getStringExtra("name") ?: ""
|
userId = intent.getStringExtra("userId") ?: ""
|
||||||
phone = intent.getStringExtra("phone") ?: ""
|
|
||||||
idCard = intent.getStringExtra("idCard") ?: ""
|
|
||||||
time = intent.getStringExtra("time") ?: ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initView() {
|
private fun fetchInviterInformation() {
|
||||||
binding.tvContactName.text = userName
|
if (userId.isEmpty()) {
|
||||||
binding.tvPhone.text = phone
|
Toast.makeText(this, "用户ID为空", Toast.LENGTH_SHORT).show()
|
||||||
binding.tvIdCard.text = idCard
|
return
|
||||||
binding.tvMacAddress.text = "AA:BB:CC:DD:EE:FF"
|
}
|
||||||
|
|
||||||
|
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() {
|
private fun initListener() {
|
||||||
@@ -75,13 +106,40 @@ class UserDetailsActivity : AppCompatActivity() {
|
|||||||
dialog.setPositiveText(getString(R.string.confirm))
|
dialog.setPositiveText(getString(R.string.confirm))
|
||||||
dialog.setNegativeText(getString(R.string.cancel))
|
dialog.setNegativeText(getString(R.string.cancel))
|
||||||
dialog.setOnConfirmListener {
|
dialog.setOnConfirmListener {
|
||||||
finish()
|
deleteDeviceUser()
|
||||||
// if(){
|
|
||||||
// ToastUtils.showSuccess(this, getString(R.string.wifi_connection_success)
|
|
||||||
// }else{
|
|
||||||
// ToastUtils.showError(this, getString(R.string.wifi_connection_failed))
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
dialog.show(supportFragmentManager, "DeleteUserDialog")
|
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.DeleteDeviceUserRequest
|
||||||
import com.example.defenseapplication.bean.FamilyMembersBean
|
import com.example.defenseapplication.bean.FamilyMembersBean
|
||||||
import com.example.defenseapplication.bean.MessageGroup
|
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.SwitchFamilyRequest
|
||||||
import com.example.defenseapplication.bean.UpdatePassword
|
import com.example.defenseapplication.bean.UpdatePassword
|
||||||
import com.example.defenseapplication.bean.UpdateUserInfo
|
import com.example.defenseapplication.bean.UpdateUserInfo
|
||||||
@@ -171,6 +173,18 @@ interface ApiService {
|
|||||||
suspend fun logout(): GetCodeBean<Any>
|
suspend fun logout(): GetCodeBean<Any>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取邀请人信息
|
||||||
|
*/
|
||||||
|
@POST("/app/obtainInviterInformation")
|
||||||
|
suspend fun obtainInviterInformation(@Body request: ObtainInviterInformationRequest): GetCodeBean<ObtainInviterInformationBean>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改家庭用户状态
|
||||||
|
*/
|
||||||
|
//@POST("/app/updateFamilyUser")
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@
|
|||||||
android:layout_height="1px"
|
android:layout_height="1px"
|
||||||
android:background="@color/gray_divider"/>
|
android:background="@color/gray_divider"/>
|
||||||
|
|
||||||
<!-- 打击距离(电话) -->
|
<!--手机号 -->
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/strike_distance"
|
android:text="@string/phone_number"
|
||||||
android:textSize="14dp"/>
|
android:textSize="14dp"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
Reference in New Issue
Block a user