修改密码;获取项目列表接口修改

main
chenglifeng 1 month ago
parent b407c73ae4
commit 1d80f1be86
  1. 6
      app/src/main/AndroidManifest.xml
  2. 19
      app/src/main/java/com/project/survey/logic/viewmodel/LoginViewModel.kt
  3. 45
      app/src/main/java/com/project/survey/logic/viewmodel/ProjectViewModel.kt
  4. 6
      app/src/main/java/com/project/survey/model/ProjectBean.kt
  5. 23
      app/src/main/java/com/project/survey/network/Api.kt
  6. 10
      app/src/main/java/com/project/survey/ui/home/MeFragment.kt
  7. 67
      app/src/main/java/com/project/survey/ui/login/UpdatePwdActivity.kt
  8. 4
      app/src/main/java/com/project/survey/ui/mine/AboutActivity.kt
  9. 8
      app/src/main/java/com/project/survey/ui/project/ProjectListActivity.kt
  10. 23
      app/src/main/res/layout/activity_about.xml
  11. 96
      app/src/main/res/layout/activity_update_pwd.xml

@ -455,7 +455,11 @@
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name=".ui.home.AboutActivity"
android:name=".ui.mine.AboutActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name=".ui.login.UpdatePwdActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize|stateHidden" />
</application>

@ -18,6 +18,7 @@ import com.project.survey.ui.login.LoginActivity
import com.project.survey.ui.login.LoginInputCodeActivity
import com.project.survey.ui.project.ProjectListActivity
import com.project.survey.util.SPUtils
import kotlinx.coroutines.delay
class LoginViewModel : BaseViewModel() {
@ -150,4 +151,22 @@ class LoginViewModel : BaseViewModel() {
// }
// }
// }
val updatePasswordResponse: LiveData<String>
get() = _updatePasswordResponse
private val _updatePasswordResponse = MutableLiveData<String>()
/**
* 修改密码
*/
fun updatePassword(oldPassword: String, newPassword: String) {
launch {
val res = api.updatePassword(oldPassword, newPassword)
if (res.success) {
_updatePasswordResponse.postValue(res.message)
} else {
toast(res.message)
}
}
}
}

@ -31,18 +31,44 @@ class ProjectViewModel : BaseViewModel() {
val api = RetrofitClient.createApiService()
val projectResponse: LiveData<List<ProjectBean>>
get() = _projectResponse
private val _projectResponse = MutableLiveData<List<ProjectBean>>()
// val projectResponse: LiveData<List<ProjectBean>>
// get() = _projectResponse
// private val _projectResponse = MutableLiveData<List<ProjectBean>>()
//
// /**
// * 获取用户在工作的所以项目的信息
// */
// fun fetchProjectList() {
// launch {
// val res = api.fetchProjectList(SPUtils.getString(SPConstants.PERSON_ID))
// if (res.success) {
// _projectResponse.postValue(res.data.map { it.values })
// } else {
// errorResponse.postValue(res.message)
// }
// }
// }
val projectListResponse: LiveData<List<ProjectBean>>
get() = _projectListResponse
private val _projectListResponse = MutableLiveData<List<ProjectBean>>()
/**
* 获取用户在工作的所以项目的信息
* 获取项目的信息
* @param name 项目名称
* @param code 项目编码
*/
fun fetchProjectList() {
// fun fetchProjectList(name: String? = null, code: String? = null) {
fun fetchProjectList(searchContent: String? = null) {
launch {
val res = api.fetchProjectList(SPUtils.getString(SPConstants.PERSON_ID))
val res =
api.fetchProjectListByProperty(
SPUtils.getString(SPConstants.PERSON_ID),
searchContent,
searchContent
)
if (res.success) {
_projectResponse.postValue(res.data.map { it.values })
_projectListResponse.postValue(res.data.records.map { it.values })
} else {
errorResponse.postValue(res.message)
}
@ -308,7 +334,10 @@ class ProjectViewModel : BaseViewModel() {
/**
* 拉取坐标
*/
fun fetchCoordinateSystem(onSuccess: (CoordinateSystemValue) -> Unit, onFailure: (String) -> Unit) {
fun fetchCoordinateSystem(
onSuccess: (CoordinateSystemValue) -> Unit,
onFailure: (String) -> Unit
) {
launch {
val res = api.downloadCoordinateSystem()
if (res.success) {

@ -64,4 +64,10 @@ data class ProjectData(
val tenantIdField: String,
val tenantNameField: String,
val values: ProjectBean
): Parcelable
@Keep
@Parcelize
data class ProjectListData(
val records: List<ProjectData>
): Parcelable

@ -18,6 +18,7 @@ import com.project.survey.model.MeasureBean
import com.project.survey.model.PointEntry
import com.project.survey.model.ProjectBean
import com.project.survey.model.ProjectData
import com.project.survey.model.ProjectListData
import com.project.survey.model.SpecialControlNetworkVersionBean
import com.project.survey.util.SPUtils
import okhttp3.RequestBody
@ -79,6 +80,18 @@ interface Api {
@Query("personId") personId: String
): HttpResult<List<ProjectData>>
/**
* 获取项目的信息
*/
@GET("je/project/getProjectInfoByProperty")
suspend fun fetchProjectListByProperty(
@Query("personId") personId: String,
@Query("name") name: String?,
@Query("code") code: String?,
@Query("current") current: String = "1",
@Query("pageSize") pageSize: String = "100"
): HttpResult<ProjectListData>
/**
* 获取流程审批列表
*/
@ -292,4 +305,14 @@ interface Api {
@Field("coordinateParameter") coordinateParameter: String,
@Field("name") name: String
): HttpResult<Any>
/**
* 修改密码
*/
@FormUrlEncoded
@POST("/je/personInfo/updatePassword")
suspend fun updatePassword(
@Field("oldPassword") oldPassword: String,
@Field("newPassword") newPassword: String
): HttpResult<Any>
}

@ -3,22 +3,18 @@ package com.project.survey.ui.home
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import blankj.utilcode.util.ActivityUtils
import com.afollestad.materialdialogs.MaterialDialog
import com.project.survey.BuildConfig
import com.project.survey.R
import com.project.survey.constants.EventConstants
import com.project.survey.constants.SPConstants
import com.project.survey.databinding.FragmentMeBinding
import com.project.survey.extend.setOnClickNoRepeatListener
import com.project.survey.logic.event.Message
import com.project.survey.logic.viewmodel.LoginViewModel
import com.project.survey.logic.viewmodel.MainViewModel
import com.project.survey.model.ProjectBean
import com.project.survey.ui.MainActivity
import com.project.survey.ui.base.BaseBindingFragment
import com.project.survey.ui.login.ForgetPwdInputCodeActivity
import com.project.survey.ui.login.LoginActivity
import com.project.survey.ui.login.UpdatePwdActivity
import com.project.survey.ui.mine.AboutActivity
import com.project.survey.ui.project.ProjectListActivity
import com.project.survey.util.ActivityNavUtil
import com.project.survey.util.LogoutUtil
@ -81,7 +77,7 @@ class MeFragment : BaseBindingFragment<FragmentMeBinding>() {
ProjectListActivity.start()
}
mBinding.llChangePwd.setOnClickNoRepeatListener {
ForgetPwdInputCodeActivity.start()
UpdatePwdActivity.start()
}
// 关于
mBinding.llAbout.setOnClickNoRepeatListener {

@ -0,0 +1,67 @@
package com.project.survey.ui.login
import androidx.activity.viewModels
import com.project.survey.databinding.ActivityUpdatePwdBinding
import com.project.survey.extend.setOnClickNoRepeatListener
import com.project.survey.extend.smartDismiss
import com.project.survey.extend.toast
import com.project.survey.logic.viewmodel.LoginViewModel
import com.project.survey.ui.base.BaseBindingActivity
import com.project.survey.util.ActivityNavUtil
/**
* 更新密码
*/
class UpdatePwdActivity : BaseBindingActivity<ActivityUpdatePwdBinding>() {
companion object {
fun start() {
ActivityNavUtil.startActivity<UpdatePwdActivity> {}
}
}
private val viewModel: LoginViewModel by viewModels()
override fun getBinding(): ActivityUpdatePwdBinding =
ActivityUpdatePwdBinding.inflate(layoutInflater)
override fun initView() {
immersionToolbar(mBinding.toolbar)
viewModel.errorResponse.observe(this) {
toast(it)
}
viewModel.updatePasswordResponse.observe(this) {
finish()
toast(it)
}
}
override fun initData() {
}
override fun initListener() {
mBinding.btnConfirm.setOnClickNoRepeatListener {
val oldPassword = mBinding.passwordViewOld.text.takeIf { it.isNotEmpty() } ?: run {
toast("请输入旧密码")
return@setOnClickNoRepeatListener
}
val newPassword = mBinding.passwordViewOne.text.takeIf { it.isNotEmpty() } ?: run {
toast("请输入新密码")
return@setOnClickNoRepeatListener
}
val newPassword2 = mBinding.passwordViewTwo.text.takeIf { it.isNotEmpty() } ?: run {
toast("请输入确认密码")
return@setOnClickNoRepeatListener
}
if (newPassword != newPassword2) {
toast("新密码输入不一致")
return@setOnClickNoRepeatListener
}
viewModel.updatePassword(oldPassword, newPassword)
}
}
}

@ -1,4 +1,4 @@
package com.project.survey.ui.home
package com.project.survey.ui.mine
import blankj.utilcode.util.AppUtils
import com.project.survey.R
@ -24,7 +24,7 @@ class AboutActivity : BaseBindingActivity<ActivityAboutBinding>() {
}
override fun initData() {
mBinding.tvVersion.text = "工程测量综合管理系统 V${AppUtils.getAppVersionName()}"
mBinding.tvVersion.text = "工程测量综合管理系统\nV${AppUtils.getAppVersionName()}"
}
override fun initListener() {

@ -47,6 +47,7 @@ class ProjectListActivity : BaseBindingActivity<ActivityProjectListBinding>(), O
private val viewModel: ProjectViewModel by viewModels()
private val adapter by lazy { ProjectListAdapter() }
private var searchContent: String? = null
override fun initView() {
immersionToolbar(mBinding.toolbar, "项目列表")
@ -62,7 +63,8 @@ class ProjectListActivity : BaseBindingActivity<ActivityProjectListBinding>(), O
// initTabLayout()
// 搜索
mBinding.searchWidget.setOnEditorSearchListener {
// 搜索 it
searchContent = it.ifBlank { null }
fetchData()
}
mBinding.smartRefreshLayout.setOnRefreshListener(this)
@ -76,7 +78,7 @@ class ProjectListActivity : BaseBindingActivity<ActivityProjectListBinding>(), O
toast(it)
mBinding.smartRefreshLayout.smartDismiss()
}
viewModel.projectResponse.observe(this) {
viewModel.projectListResponse.observe(this) {
mBinding.smartRefreshLayout.smartDismiss()
if (it.isNotEmpty()) {
adapter.submitList(it)
@ -88,7 +90,7 @@ class ProjectListActivity : BaseBindingActivity<ActivityProjectListBinding>(), O
}
private fun fetchData() {
viewModel.fetchProjectList()
viewModel.fetchProjectList(searchContent)
}
override fun onRefresh(refreshLayout: RefreshLayout) {

@ -23,9 +23,9 @@
<ImageView
android:id="@+id/ic_launcher"
android:layout_width="@dimen/sw_60dp"
android:layout_height="@dimen/sw_60dp"
android:layout_marginTop="@dimen/sw_30dp"
android:layout_width="@dimen/sw_80dp"
android:layout_height="@dimen/sw_80dp"
android:layout_marginTop="@dimen/sw_50dp"
android:src="@mipmap/icon_launcher"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@ -36,12 +36,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/sw_20dp"
android:textColor="@color/text_color_666"
android:textSize="@dimen/sw_14sp"
android:gravity="center"
android:textColor="@color/text_color_33"
android:textSize="@dimen/sw_15sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ic_launcher"
tools:text="工程测量综合管理系统 V1.0.0" />
tools:text="工程测量综合管理系统\nV1.0.0" />
<TextView
android:id="@+id/tv_support"
@ -50,7 +51,7 @@
android:layout_marginTop="@dimen/sw_5dp"
android:text="上海院提供产品与技术支持"
android:textColor="@color/text_color_666"
android:textSize="@dimen/sw_14sp"
android:textSize="@dimen/sw_12sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_version" />
@ -60,8 +61,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Copyright© 2023-2025"
android:textColor="@color/text_color_666"
android:textSize="@dimen/sw_14sp"
android:textColor="@color/text_color_999"
android:textSize="@dimen/sw_12sp"
app:layout_constraintBottom_toTopOf="@id/tv_company"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
@ -72,8 +73,8 @@
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/sw_50dp"
android:text="上海勘测设计研究院有限公司"
android:textColor="@color/text_color_666"
android:textSize="@dimen/sw_14sp"
android:textColor="@color/text_color_999"
android:textSize="@dimen/sw_12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- <include layout="@layout/sh_toolbar" />-->
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="@color/transparent"
app:navigationIcon="@drawable/icon_toolbar_back"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:titleCentered="true"
app:titleTextAppearance="@style/ToolbarTextAppearance" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/sw_12dp"
android:orientation="vertical"
android:paddingHorizontal="@dimen/sw_22dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/change_pwd"
android:textColor="@color/text_color_20"
android:textSize="@dimen/sw_20sp"
android:textStyle="bold" />
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="@dimen/sw_6dp"-->
<!-- android:text="@string/please_enter_new_password"-->
<!-- android:textColor="@color/text_color_727778"-->
<!-- android:textSize="@dimen/sw_14sp" />-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/sw_40dp"
android:text="旧密码"
android:textColor="@color/text_color_727778"
android:textSize="@dimen/sw_11sp" />
<com.project.survey.widget.edittext.PasswordView
android:id="@+id/passwordViewOld"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/sw_24dp"
android:text="新密码"
android:textColor="@color/text_color_727778"
android:textSize="@dimen/sw_11sp" />
<com.project.survey.widget.edittext.PasswordView
android:id="@+id/passwordViewOne"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/sw_24dp"
android:text="@string/confirm_password"
android:textColor="@color/text_color_727778"
android:textSize="@dimen/sw_11sp" />
<com.project.survey.widget.edittext.PasswordView
android:id="@+id/passwordViewTwo"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btnConfirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/sw_60dp"
android:background="@drawable/bg_btn_login"
android:text="确认"
android:textColor="@color/white"
android:textSize="@dimen/sw_16sp" />
</LinearLayout>
</LinearLayout>
Loading…
Cancel
Save