中建365-二期开发-bug修复

develop
wlh 1 year ago
parent 3f31373b05
commit c12c462f2a

@ -138,10 +138,7 @@
android:launchMode="singleTop"
android:screenOrientation="portrait" />
<activity
android:name=".activity.InfoSimpleAct"
android:launchMode="singleTop"
android:screenOrientation="portrait" />
<activity android:name=".activity.HealthScienceAct"
android:launchMode="singleTop"
android:screenOrientation="portrait" />

@ -1,200 +0,0 @@
package com.zj365.dc.activity
import android.content.Intent
import android.text.Editable
import android.text.TextWatcher
import android.util.Log
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.luck.picture.lib.PictureSelector
import com.luck.picture.lib.config.PictureConfig
import com.tamsiree.rxkit.RxActivityTool
import com.tamsiree.rxkit.RxKeyboardTool
import com.xty.base.act.BaseVmAct
import com.xty.common.TimeSelect
import com.xty.common.TimeUtils
import com.xty.common.arouter.ARouterUrl
import com.xty.common.arouter.RouteManager
import com.xty.common.event.MyInfoEvent
import com.xty.common.picture.PictureUtils
import com.xty.common.setImage
import com.xty.common.util.CommonToastUtils
import com.zj365.dc.R
import com.zj365.dc.databinding.ActInfoSimpleBinding
import com.zj365.dc.vm.InfoSimpleVm
import org.greenrobot.eventbus.EventBus
import java.util.regex.Pattern
/**
* 基本信息
* 简单信息填写
*/
@Route(path = ARouterUrl.INFO_SIMPLE)
class InfoSimpleAct : BaseVmAct<InfoSimpleVm>() {
val binding by lazy { ActInfoSimpleBinding.inflate(layoutInflater) }
override fun setLayout() = binding.root
private var isBinding: Boolean = false
private var sexType = 1
private var birthdayType = 1
var phone: String = ""
private var pwd: String = ""
private val timeSelect by lazy { TimeSelect(this) {} }
private val textListener by lazy {
object : TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
override fun afterTextChanged(s: Editable?) {
binding.mName.removeTextChangedListener(this)
val str = s.toString().trim()
if (str.isNotEmpty()) {
val isNum = Pattern.matches("[0-9]", str.substring(0, 1))
if (isNum) {
if (str.length > 2) {
binding.mName.setText(str.substring(1, str.length))
} else {
binding.mName.setText("")
}
CommonToastUtils.showToast(R.string.name_first_num)
}
}
binding.mName.addTextChangedListener(this)
}
}
}
override fun initData() {
super.initData()
isDarkBar = true
phone = intent.getStringExtra("phone").toString()
pwd = intent.getStringExtra("password").toString()
}
override fun initView() {
super.initView()
statusBar(binding.title.mView)
binding.title.mTvTitle.text = getString(R.string.base_info)
binding.title.mIvBack.setOnClickListener { finish() }
binding.mImage.setOnClickListener { PictureUtils.openCamera(this) }
timeSelect.startDate.set(1922, 0, 1)
binding.llBirthday.setOnClickListener {
RxKeyboardTool.hideSoftInput(this)
timeSelect.selectTime(binding.mBirthday)
}
sexType = if (binding.checkSex.isChecked) 2 else 1
birthdayType = if (binding.checkBirthday.isChecked) 2 else 1
binding.bindingTv.setOnClickListener {
isBinding = true
turnToSaveBaseData()
}
binding.mName.addTextChangedListener(textListener)
binding.mSubmit.setOnClickListener {
isBinding = false
turnToSaveBaseData()
}
}
/**
* 调用接口保存
*/
private fun turnToSaveBaseData() {
val birthDay = binding.mBirthday.text.toString().trim()
val name = binding.mName.text.toString().trim()
if (TimeUtils.getAgeByBirth(birthDay) < 14) {
CommonToastUtils.showToast("需要年满14岁才可使用")
isBinding = false
return
}
val avatar = binding.mImage.tag
val datanal = avatar?.toString() ?: ""
val sexValue = if (binding.checkSex.isChecked) "2" else "1"
birthdayType = if (binding.checkBirthday.isChecked) 2 else 1
//调用接口
if (name.trim().isEmpty()) {
mViewModel.submit(datanal, null, sexValue, birthdayType.toString(), birthDay)
} else {
mViewModel.submit(datanal, name, sexValue, birthdayType.toString(), birthDay)
}
}
override fun liveObserver() {
mViewModel.setBasic.observe(this) {
//不管点击绑定还是完成都会去登录
EventBus.getDefault().post(MyInfoEvent())
mViewModel.login(phone, pwd)
if (isBinding) {
return@observe
}
CommonToastUtils.showSucceedToast("信息设置成功")
}
mViewModel.mLogin.observe(this) {
//登录成功请求用户token
mViewModel.getImUserSig("user_${it.data.id}")
}
mViewModel.getImUserSig.observe(this) {
Log.e("simon", "login" + it.data)
/*TUILogin.login(
applicationContext,
0,
it.paramsData,
it.data,
object : TUICallback() {
override fun onSuccess() {
Log.e("simon", "onSuccess")
if (!isBinding) { //如果是直接点击完成,跳转到主页面
ARouter.getInstance().build(ARouterUrl.MAIN_ACT).navigation()
RxActivityTool.finishAllActivity()
} else { //如果是去绑定设备,跳转到设备选择界面,同是给予标记,告诉该界面已经登录
bundle.clear()
bundle.putBoolean("isLogin", true)
RouteManager.goAct(ARouterUrl.DEVICE_CHOICE, bundle)
}
}
override fun onError(errorCode: Int, errorMessage: String?) {
Log.e("simon", "onError")
}
})*/
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode === RESULT_OK) {
when (requestCode) {
PictureConfig.CHOOSE_REQUEST -> {
var result = PictureSelector.obtainMultipleResult(data)
if (result.size > 0) {
var path = if (result[0].compressPath.isEmpty()) {
result[0].androidQToPath
} else {
result[0].compressPath
}
binding.mImage.setImage(this, path)
binding.mImage.tag = path
}
}
1000 -> {
finish()
}
}
}
}
}

@ -1,123 +0,0 @@
package com.zj365.dc.vm
import androidx.lifecycle.MutableLiveData
import com.tamsiree.rxkit.RxTool
import com.xty.base.vm.BaseVm
import com.xty.common.Const
import com.xty.common.MMkvHelper
import com.xty.common.util.CommonToastUtils
import com.xty.network.model.ImageUploadBean
import com.xty.network.model.MainBean
import com.xty.network.model.NotAccepted
import com.xty.network.model.RespBody
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.withContext
import okhttp3.Headers
import okhttp3.MultipartBody
import org.json.JSONObject
import java.io.File
class InfoSimpleVm : BaseVm() {
val setBasic by lazy { MutableLiveData<RespBody<NotAccepted>>() }
val mLogin by lazy { MutableLiveData<RespBody<MainBean.User>>() }
val getImUserSig by lazy { MutableLiveData<RespBody<String>>() }
fun login(account: String, pwd: String) {
startHttp {
val json = JSONObject()
json.put("phone", account)
json.put("userPwd", RxTool.Md5(pwd))
//json.put("userPwd", pwd)
val login = apiInterface().login(retrofits.getRequestBody(json.toString()))
if (login.body()?.code == 500) {
login.body()?.msg?.let { CommonToastUtils.showToast(it) }
return@startHttp
}
saveToken(login.raw().headers)
val bodys = login.body() as RespBody
MMkvHelper.put(Const.USER_ID, bodys.data.id)
bodys.getCodeStatus(mLogin, nowData, loading)
}
}
private fun saveToken(headers: Headers) {
val headerIterator = headers.iterator()
while (headerIterator.hasNext()) {
val next = headerIterator.next()
if (Const.Auth_Token == next.first) MMkvHelper.put(Const.Auth_Token, next.second)
if (Const.Auth_Id == next.first) MMkvHelper.put(Const.Auth_Id, next.second)
}
}
fun getImUserSig(identifier: String) {
startHttp {
val imUserSig = apiInterface().getImUserSig(identifier)
imUserSig.body()?.getCodeStatus(getImUserSig, nowData, paramsData = identifier)
}
}
fun submit(path: String, name: String?, sex: String, birthDaytype: String, birthDay: String) {
startHttp {
withContext(Dispatchers.IO) {
var fileId = ""
if (path.isNullOrEmpty()) {
} else {
val image = async { uploadImage(path) }
val await = image.await()
fileId = await.fileId
}
val upload = async { uploadInfo(name, sex, fileId, birthDaytype, birthDay) }
val await = upload.await() //个人信息上传
if (await.code != 0) {
CommonToastUtils.showToast(await.msg)
}
}
}
}
private suspend fun uploadInfo(
name: String?,
sex: String,
fileId: String = "",
birthdayType: String,
birthDay: String
): RespBody<NotAccepted> {
val json = JSONObject()
json.put("name", name)
json.put("sex", sex)
if (sex == "1") {
json.put("height", "170")
json.put("weight", "65")
} else {
json.put("height", "160")
json.put("weight", "49")
}
json.put("birthday", birthDay)
json.put("birthdayType", birthdayType)
if (!fileId.isNullOrEmpty()) {
json.put("avatarUrl", fileId)
}
val rb = retrofits.getRequestBody(json.toString())
val body = apiInterface().setUpdateUser(rb)
body.getCodeStatus(setBasic, nowData)
return body
}
private suspend fun uploadImage(path: String): ImageUploadBean {
val f = File(path)
val fileRb = MultipartBody.Part.createFormData(
"file",
f.name,
retrofits.getMultiPartFileRb(f)
)
val body = apiInterface().uploadImage(fileRb)
return body.data
}
}

@ -1,291 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/title"
layout="@layout/title_white_bar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:background="@color/white"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@color/col_f1f" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_6"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_6">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:drawablePadding="@dimen/dp_10"
android:ellipsize="end"
android:paddingLeft="@dimen/dp_12"
android:paddingTop="@dimen/dp_12"
android:paddingBottom="@dimen/dp_12"
android:singleLine="true"
android:text="@string/head_portrait"
android:textColor="@color/col_455"
android:textSize="@dimen/dp_14" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/mImage"
android:layout_width="@dimen/dp_46"
android:layout_height="@dimen/dp_46"
android:layout_marginRight="@dimen/dp_12"
android:layout_toLeftOf="@+id/right_im"
android:src="@mipmap/ic_default_man" />
<ImageView
android:id="@+id/right_im"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="@dimen/dp_3"
android:src="@mipmap/arrow_right"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@color/col_f1f" />
<RelativeLayout
android:id="@+id/mRelName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="@dimen/dp_10">
<TextView
android:id="@+id/m1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:drawablePadding="@dimen/dp_10"
android:ellipsize="end"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_15"
android:paddingBottom="@dimen/dp_15"
android:singleLine="true"
android:text="@string/name"
android:textColor="@color/col_455"
android:textSize="@dimen/dp_14" />
<EditText
android:id="@+id/mName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/m1"
android:background="@null"
android:gravity="center|right"
android:paddingTop="@dimen/dp_15"
android:paddingBottom="@dimen/dp_15"
android:singleLine="true"
android:textColor="@color/col_455"
android:textSize="@dimen/dp_16"
tools:text="旅行者2号" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@color/col_f1f" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingRight="@dimen/dp_10">
<com.xty.common.weight.RequiredTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_weight="2"
android:drawablePadding="@dimen/dp_10"
android:ellipsize="end"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_14"
android:paddingBottom="@dimen/dp_14"
android:singleLine="true"
android:text="@string/sex"
android:textColor="@color/col_455"
android:textSize="@dimen/dp_14" />
<CheckBox
android:id="@+id/check_sex"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:background="@drawable/selector_check_sex_new"
android:button="@null"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@color/col_f1f" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingRight="@dimen/dp_12"
android:orientation="horizontal">
<com.xty.common.weight.RequiredTextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:background="@null"
android:paddingLeft="@dimen/dp_10"
android:text="@string/birthday_type"
android:textColor="@color/col_455"
android:paddingTop="@dimen/dp_14"
android:paddingBottom="@dimen/dp_14"
android:singleLine="true"
android:textSize="@dimen/dp_14" />
<CheckBox
android:id="@+id/check_birthday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:background="@drawable/selector_check_birthday"
android:button="@null"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@color/col_f1f" />
<LinearLayout
android:id="@+id/ll_birthday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.xty.common.weight.RequiredTextView
android:id="@+id/mBirthday_date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@null"
android:paddingLeft="@dimen/dp_10"
android:text="@string/birthday"
android:paddingTop="@dimen/dp_14"
android:textColor="@color/col_455"
android:paddingBottom="@dimen/dp_14"
android:singleLine="true"
android:textSize="@dimen/dp_14" />
<TextView
android:id="@+id/mBirthday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:drawablePadding="@dimen/dp_8"
android:layout_marginRight="@dimen/dp_12"
android:textSize="@dimen/dp_16"
android:hint=" 请选择生日 "
tools:text="2023-02-03"
android:textColorHint="@color/col_7b8"
android:textColor="@color/col_313"
android:drawableRight="@mipmap/arrow_right"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginRight="@dimen/dp_10"
android:background="@color/col_f1f" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_12"
android:layout_marginEnd="@dimen/dp_12"
android:textColor="@color/col_c7c"
android:textSize="@dimen/sp_13"
android:layout_marginBottom="@dimen/dp_50"
android:layout_marginTop="@dimen/dp_10"
android:text="请完善以上基本信息,以便于更好的为您提供健管的服务"/>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginBottom="@dimen/dp_30"
android:gravity="bottom"
android:layout_weight="1"
android:layout_gravity="bottom"
android:layout_height="wrap_content">
<TextView
android:id="@+id/bindingTv"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:paddingTop="@dimen/dp_8"
android:gravity="center"
android:layout_marginLeft="@dimen/dp_20"
android:paddingBottom="@dimen/dp_8"
android:paddingRight="@dimen/dp_20"
android:paddingLeft="@dimen/dp_20"
android:background="@drawable/shape_btn_select_bg_white"
android:textColor="@color/col_02c"
android:textSize="@dimen/dp_16"
android:text="去绑定手表"/>
<TextView
android:id="@+id/mSubmit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingTop="@dimen/dp_8"
android:paddingBottom="@dimen/dp_8"
android:layout_marginLeft="@dimen/dp_20"
android:autoSizeMaxTextSize="@dimen/dp_20"
android:layout_marginRight="@dimen/dp_20"
android:background="@drawable/shape_btn_select_bg"
android:gravity="center"
android:padding="@dimen/dp_10"
android:text="完成"
android:textColor="@color/white"
android:textSize="@dimen/dp_16" />
</LinearLayout>
</LinearLayout>

@ -12,7 +12,7 @@ class ARouterUrl {
const val BIND_WX_PHONE = "/com/zj365/dc/act/BindWxPhone"
const val DEVICE_CONNECT = "/com/zj365/dc/activity/DeviceConnectAct"
const val DEVICE_CHOICE = "/com/zj365/dc/activity/DeviceChoiceAct"
const val INFO_SIMPLE = "/com/zj365/dc/act/InfoSimpleAct"
// const val INFO_SIMPLE = "/com/zj365/dc/act/InfoSimpleAct"
const val DEVICE_SEARCH = "/com/zj365/dc/activity/DeviceSearchBodyFatAct"
const val DEVICE_BIND = "/com/zj365/dc/activity/DeviceBindAct"
const val SCIENCE_LIST = "/com/zj365/dc/activity/HealthScienceAct"
@ -57,7 +57,6 @@ class ARouterUrl {
const val ONLINE_MAKE = "/health/com/zj365/health/act/OnLineMakeAct"
const val HEALTH_STATUS = "/health/com/zj365/health/act/HealthStatusAct"
const val HEALTH_24HOUR_REPORT = "/health/com/zj365/health/act/Health24HourReportAct"
const val HEALTH_24HOUR_REPORT_OLD = "/health/com/zj365/health/act/Health24HourReportAct"
const val HEALTH_REPORT = "/health/com/zj365/health/act/HealthReportAct"
const val HEALTH_ESTIMATE = "/health/com/zj365/health/act/HealthEstimateActivity"
const val HEALTH_SKY_HOUR_REPORT = "/health/com/zj365/health/act/HealthSkyHourReportAct"

@ -81,6 +81,7 @@ class HealthRecordMainAct : BaseVmAct<HealthRecordMainVm>() {
binding.mProgress.progress = it.data.userSchedule * 10
binding.clBody.tvScore.text = "${it.data.surveys.score}"
mSurveysList = it.data.surveys.list
binding.tvConfirmTest.visibility = View.GONE
mSurveysList.forEach {
if (it.status == 0){
binding.tvConfirmTest.visibility = View.VISIBLE

@ -105,7 +105,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="次/分"
tools:text="次/分"
android:textColor="@color/col_6B6"
android:textSize="@dimen/sp_12"
android:textStyle="bold" />

@ -105,7 +105,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="次/分"
tools:text="次/分"
android:textColor="@color/col_6B6"
android:textSize="@dimen/sp_12"
android:textStyle="bold" />

@ -106,7 +106,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="次/分"
tools:text="次/分"
android:textColor="@color/col_6B6"
android:textSize="@dimen/sp_12"
android:textStyle="bold" />

Loading…
Cancel
Save