Explorar el Código

1.添加评价记录功能

王鹏鹏 hace 2 años
padre
commit
655784618a

+ 3 - 0
.idea/misc.xml

@@ -59,11 +59,14 @@
         <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/activity_consultation_request.xml" value="0.4421768707482993" />
         <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/activity_consultation_sheet.xml" value="0.72" />
         <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/activity_doctor_details.xml" value="0.42051756007393715" />
+        <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/activity_evaluate.xml" value="0.264" />
         <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/activity_health_consultation.xml" value="0.4" />
         <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/activity_main.xml" value="0.23697916666666666" />
         <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/dialog_select_pic.xml" value="0.4421768707482993" />
+        <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/fragment_evaluate.xml" value="0.22239583333333332" />
         <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/item_consultation.xml" value="0.3953084274543875" />
         <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/item_consultation_record.xml" value="0.536" />
+        <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/item_evaluate.xml" value="1.0" />
         <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/item_image.xml" value="0.536" />
         <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/item_recommend_doctor.xml" value="0.6" />
         <entry key="..\:/workspace/hcp-pad/healthconsultation/src/main/res/layout/item_sick_time.xml" value="0.8800000000000001" />

+ 5 - 0
baselib/src/main/java/com/yingyangfly/baselib/router/RouterUrlCommon.kt

@@ -150,4 +150,9 @@ object RouterUrlCommon {
      */
     const val consultationRecord = "/consultation/record"
 
+    /**
+     * 评价记录
+     */
+    const val evaluate = "/evaluate/evaluate"
+
 }

+ 6 - 0
healthconsultation/src/main/AndroidManifest.xml

@@ -32,5 +32,11 @@
             android:configChanges="keyboardHidden|orientation|screenSize"
             android:screenOrientation="landscape"
             android:windowSoftInputMode="adjustResize|adjustPan" />
+
+        <activity
+            android:name="com.yingyang.healthconsultation.evaluate.EvaluateActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:screenOrientation="landscape"
+            android:windowSoftInputMode="adjustResize|adjustPan" />
     </application>
 </manifest>

+ 26 - 0
healthconsultation/src/main/java/com/yingyang/healthconsultation/adapter/EvaluateAdapter.kt

@@ -0,0 +1,26 @@
+package com.yingyang.healthconsultation.adapter
+
+import android.annotation.SuppressLint
+import com.yingyang.healthconsultation.R
+import com.yingyang.healthconsultation.databinding.ItemEvaluateBinding
+import com.yingyang.healthconsultation.entity.EvaluateRecordsBean
+import com.yingyangfly.baselib.adapter.BaseDataBindingAdapter
+
+/**
+ * 评价列表
+ */
+class EvaluateAdapter(override val layoutId: Int = R.layout.item_evaluate) :
+    BaseDataBindingAdapter<EvaluateRecordsBean, ItemEvaluateBinding>() {
+
+    @SuppressLint("SetTextI18n")
+    override fun onBindViewHolder(
+        binding: ItemEvaluateBinding,
+        item: EvaluateRecordsBean,
+        position: Int
+    ) {
+        binding.data = item
+        val index = position + 1
+        binding.tvTitle.text = "匿名者$index"
+    }
+
+}

+ 24 - 0
healthconsultation/src/main/java/com/yingyang/healthconsultation/entity/EvaluateRecordListBean.kt

@@ -0,0 +1,24 @@
+package com.yingyang.healthconsultation.entity
+
+/**
+ * 患者评价bean
+ */
+class EvaluateRecordListBean(
+    val current: Int,
+    val pages: Int,
+    val records: List<EvaluateRecordsBean>,
+    val size: Int,
+    val total: Int
+)
+
+data class EvaluateRecordsBean(
+    val appUserId: Int,
+    val createTime: String,
+    val id: Int,
+    val mid: Int,
+    val orgCode: String,
+    val orgName: String,
+    val remark: String,
+    val sysUserId: Int,
+    val value: Int
+)

+ 5 - 0
healthconsultation/src/main/java/com/yingyang/healthconsultation/entity/GetPatientReviewBean.kt

@@ -0,0 +1,5 @@
+package com.yingyang.healthconsultation.entity
+
+class GetPatientReviewBean {
+    var page: Int = 0
+}

+ 91 - 0
healthconsultation/src/main/java/com/yingyang/healthconsultation/evaluate/EvaluateActivity.kt

@@ -0,0 +1,91 @@
+package com.yingyang.healthconsultation.evaluate
+
+import com.alibaba.android.arouter.facade.annotation.Route
+import com.yingyang.healthconsultation.adapter.EvaluateAdapter
+import com.yingyang.healthconsultation.databinding.ActivityEvaluateBinding
+import com.yingyang.healthconsultation.entity.EvaluateRecordsBean
+import com.yingyangfly.baselib.ext.show
+import com.yingyangfly.baselib.mvvm.BaseMVVMActivity
+import com.yingyangfly.baselib.router.RouterUrlCommon
+
+/**
+ * 患者评价
+ */
+@Route(path = RouterUrlCommon.evaluate)
+class EvaluateActivity : BaseMVVMActivity<ActivityEvaluateBinding, EvaluateViewModel>() {
+
+    private var page = 1
+    private val adapter by lazy { EvaluateAdapter() }
+    private var evaluateRecordsBeans = mutableListOf<EvaluateRecordsBean>()
+
+    override fun initViews() {
+        binding {
+            evaluationRefresh.setEnableRefresh(true)
+            evaluationRefresh.setEnableLoadMore(true)
+            rvEvaluation.adapter = adapter
+            adapter.setData(evaluateRecordsBeans)
+        }
+    }
+
+    override fun initListener() {
+        binding {
+            evaluationRefresh.setOnRefreshListener {
+                loadData(true, false)
+            }
+
+            evaluationRefresh.setOnLoadMoreListener {
+                loadData(false, false)
+            }
+        }
+    }
+
+    override fun initData() {
+
+    }
+
+    override fun onResume() {
+        super.onResume()
+        loadData(true, true)
+    }
+
+    /**
+     * 加载数据
+     */
+    private fun loadData(isRefresh: Boolean, isShowLoading: Boolean) {
+        if (isRefresh) {
+            page = 1
+            binding.evaluationRefresh.resetNoMoreData()
+        } else {
+            page++
+        }
+        viewModel.getPatientReview(page, isShowLoading, fail = {
+            endRefresh()
+            it.show()
+        }, success = {
+            endRefresh()
+            if (isRefresh) {
+                evaluateRecordsBeans.clear()
+            }
+            if (it != null) {
+                if (it.records.isNullOrEmpty().not()) {
+                    evaluateRecordsBeans.addAll(it.records)
+                }
+            }
+            if (evaluateRecordsBeans.isEmpty()) {
+                binding.evaluationRefresh.finishLoadMoreWithNoMoreData()
+            }
+            adapter.showEmptyView = evaluateRecordsBeans.isEmpty()
+            adapter.setData(evaluateRecordsBeans)
+        })
+    }
+
+    /**
+     * 结束刷新
+     */
+    private fun endRefresh() {
+        binding {
+            evaluationRefresh.finishRefresh()
+            evaluationRefresh.finishLoadMore()
+        }
+    }
+}

+ 31 - 0
healthconsultation/src/main/java/com/yingyang/healthconsultation/evaluate/EvaluateViewModel.kt

@@ -0,0 +1,31 @@
+package com.yingyang.healthconsultation.evaluate
+
+import com.yingyang.healthconsultation.entity.EvaluateRecordListBean
+import com.yingyang.healthconsultation.entity.EvaluateRecordsBean
+import com.yingyang.healthconsultation.entity.GetPatientReviewBean
+import com.yingyang.healthconsultation.net.HEALTHCONSULTATION_API
+import com.yingyangfly.baselib.mvvm.BaseViewModel
+import com.yingyangfly.baselib.net.XUtils
+import com.yingyangfly.baselib.utils.GsonUtil
+
+/**
+ * @author 王鹏鹏
+ */
+class EvaluateViewModel : BaseViewModel() {
+
+    fun getPatientReview(
+        index: Int,
+        isShowLoading: Boolean,
+        fail: ((msg: String) -> Unit)? = null,
+        success: ((success: EvaluateRecordListBean?) -> Unit)? = null,
+    ) = launchFlow(isShowLoading) {
+        val requestBean = GetPatientReviewBean().apply {
+            page = index
+        }
+        val body = XUtils.createJson(GsonUtil.GsonString(requestBean))
+        HEALTHCONSULTATION_API.getPatientReview(body)
+    }.runUI(
+        success,
+        fail
+    )
+}

+ 9 - 1
healthconsultation/src/main/java/com/yingyang/healthconsultation/net/HealthConsultationApiService.kt

@@ -1,9 +1,12 @@
 package com.yingyang.healthconsultation.net
 
+import com.yingyang.healthconsultation.entity.EvaluateRecordListBean
+import com.yingyang.healthconsultation.entity.EvaluateRecordsBean
 import com.yingyang.healthconsultation.entity.UserInfoBean
 import com.yingyangfly.baselib.db.DoctorBean
 import com.yingyangfly.baselib.net.BaseResp
 import okhttp3.MultipartBody
+import okhttp3.RequestBody
 import retrofit2.http.Body
 import retrofit2.http.POST
 
@@ -15,7 +18,6 @@ interface HealthConsultationApiService {
     @POST("medical_consultation/recommend_doctor")
     suspend fun getRecommendDoctorList(): BaseResp<List<DoctorBean>>
 
-
     /**
      * 正在进行的咨询列表
      */
@@ -34,4 +36,10 @@ interface HealthConsultationApiService {
     @POST("common/upload")
     suspend fun uploadFile(@Body multipartBody: MultipartBody): BaseResp<Unit>
 
+    /**
+     * 评价列表
+     */
+    @POST("patient_review/list")
+    suspend fun getPatientReview(@Body requestBody: RequestBody): BaseResp<EvaluateRecordListBean>
+
 }

+ 6 - 0
healthconsultation/src/main/manifest/AndroidManifest.xml

@@ -31,5 +31,11 @@
             android:configChanges="keyboardHidden|orientation|screenSize"
             android:screenOrientation="landscape"
             android:windowSoftInputMode="adjustResize|adjustPan" />
+
+        <activity
+            android:name="com.yingyang.healthconsultation.evaluate.EvaluateActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:screenOrientation="landscape"
+            android:windowSoftInputMode="adjustResize|adjustPan" />
     </application>
 </manifest>

+ 83 - 0
healthconsultation/src/main/res/layout/activity_evaluate.xml

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:ignore="ResourceName">
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@mipmap/icon_uniform_background">
+
+        <LinearLayout
+            android:id="@+id/backLayout"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginStart="@dimen/divider_65px"
+            android:layout_marginTop="@dimen/divider_35px"
+            android:gravity="center"
+            android:orientation="horizontal"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent">
+
+            <androidx.appcompat.widget.AppCompatImageView
+                android:layout_width="@dimen/divider_48px"
+                android:layout_height="@dimen/divider_48px"
+                android:background="@mipmap/icon_back" />
+
+            <androidx.appcompat.widget.AppCompatTextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="@dimen/divider_14px"
+                android:text="@string/back_pager"
+                android:textColor="@android:color/white"
+                android:textSize="@dimen/divider_28px"
+                android:textStyle="bold" />
+
+        </LinearLayout>
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvTitle"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/divider_32px"
+            android:text="@string/patient_evaluate"
+            android:textColor="@android:color/white"
+            android:textSize="@dimen/divider_38px"
+            android:textStyle="bold"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <com.google.android.material.card.MaterialCardView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_marginStart="@dimen/divider_21px"
+            android:layout_marginTop="@dimen/divider_24px"
+            android:layout_marginEnd="@dimen/divider_22px"
+            android:layout_marginBottom="@dimen/divider_21px"
+            android:theme="@style/Theme.MaterialComponents.NoActionBar"
+            app:cardBackgroundColor="@android:color/white"
+            app:cardCornerRadius="@dimen/divider_28px"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/tvTitle">
+
+            <com.scwang.smartrefresh.layout.SmartRefreshLayout
+                android:id="@+id/evaluationRefresh"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent">
+
+                <androidx.recyclerview.widget.RecyclerView
+                    android:id="@+id/rvEvaluation"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:layout_marginStart="@dimen/divider_47px"
+                    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
+
+            </com.scwang.smartrefresh.layout.SmartRefreshLayout>
+        </com.google.android.material.card.MaterialCardView>
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+</layout>

+ 95 - 0
healthconsultation/src/main/res/layout/item_evaluate.xml

@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:ignore="ResourceName">
+
+    <data>
+
+        <variable
+            name="data"
+            type="com.yingyang.healthconsultation.entity.EvaluateRecordsBean" />
+    </data>
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvTitle"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/divider_23px"
+            android:text="@string/anonymous_user"
+            android:textColor="@color/color_FF000000"
+            android:textSize="@dimen/divider_28px"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <androidx.appcompat.widget.AppCompatImageView
+            android:id="@+id/starOne"
+            android:layout_width="@dimen/divider_32px"
+            android:layout_height="@dimen/divider_32px"
+            android:layout_marginStart="@dimen/divider_31px"
+            android:layout_marginTop="@dimen/divider_28px"
+            app:layout_constraintStart_toEndOf="@+id/tvTitle"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <androidx.appcompat.widget.AppCompatImageView
+            android:id="@+id/starTwo"
+            android:layout_width="@dimen/divider_32px"
+            android:layout_height="@dimen/divider_32px"
+            android:layout_marginStart="@dimen/divider_6px"
+            android:layout_marginTop="@dimen/divider_28px"
+            app:layout_constraintStart_toEndOf="@+id/starOne"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <androidx.appcompat.widget.AppCompatImageView
+            android:id="@+id/starThree"
+            android:layout_width="@dimen/divider_32px"
+            android:layout_height="@dimen/divider_32px"
+            android:layout_marginStart="@dimen/divider_6px"
+            android:layout_marginTop="@dimen/divider_28px"
+            app:layout_constraintStart_toEndOf="@+id/starTwo"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <androidx.appcompat.widget.AppCompatImageView
+            android:id="@+id/starFour"
+            android:layout_width="@dimen/divider_32px"
+            android:layout_height="@dimen/divider_32px"
+            android:layout_marginStart="@dimen/divider_6px"
+            android:layout_marginTop="@dimen/divider_28px"
+            app:layout_constraintStart_toEndOf="@+id/starThree"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <androidx.appcompat.widget.AppCompatImageView
+            android:id="@+id/starFive"
+            android:layout_width="@dimen/divider_32px"
+            android:layout_height="@dimen/divider_32px"
+            android:layout_marginStart="@dimen/divider_6px"
+            android:layout_marginTop="@dimen/divider_28px"
+            app:layout_constraintStart_toEndOf="@+id/starFour"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <androidx.appcompat.widget.AppCompatTextView
+            android:id="@+id/tvTime"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="@dimen/divider_20px"
+            android:layout_marginEnd="@dimen/divider_34px"
+            android:text="@{data.createTime}"
+            android:textColor="@color/color_FF000000"
+            android:textSize="@dimen/divider_28px"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="parent" />
+
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="@dimen/divider_1px"
+            android:background="@color/color_FFE2E2E2"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent" />
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+</layout>

+ 1 - 0
healthconsultation/src/main/res/values/colors.xml

@@ -19,4 +19,5 @@
     <color name="color_FF666666" tools:ignore="ResourceName">#FF666666</color>
     <color name="color_B3000000" tools:ignore="ResourceName">#B3000000</color>
     <color name="transparent" tools:ignore="ResourceName">#00000000</color><!-- 透明   -->
+    <color name="color_FFE2E2E2" tools:ignore="ResourceName">#FFE2E2E2</color>
 </resources>

+ 2 - 0
healthconsultation/src/main/res/values/strings.xml

@@ -27,4 +27,6 @@
     <string name="camera" tools:ignore="ResourceName">拍摄</string>
     <string name="consultation_record" tools:ignore="ResourceName">问诊记录</string>
     <string name="evaluate" tools:ignore="ResourceName">评价</string>
+    <string name="patient_evaluate" tools:ignore="ResourceName">患者评价</string>
+    <string name="anonymous_user" tools:ignore="ResourceName">匿名用户</string>
 </resources>