新增邮箱注册页面表单校验,包括: - 邮箱格式校验 - 密码格式校验(至少8位, 包含大小写字母和数字) - 确认密码校验 - 服务条款和推广信息勾选校验 新增错误提示,包括: - 邮箱格式错误 - 密码格式错误 - 确认密码不一致 - 未勾选服务条款 - 未勾选推广信息 优化 用户体验,包括: - 使用 CheckboxWithLabel 组件优化勾选框样式 - 使用字符串资源 - 调整页面布局
43 lines
974 B
Kotlin
43 lines
974 B
Kotlin
package com.aiosman.riderpro.data
|
|
|
|
import com.google.gson.Gson
|
|
import com.google.gson.annotations.SerializedName
|
|
import okhttp3.ResponseBody
|
|
|
|
/**
|
|
* 错误返回
|
|
*/
|
|
class ServiceException(
|
|
override val message: String,
|
|
val code: Int? = 0,
|
|
val data: Any? = null,
|
|
val error: String? = null,
|
|
val name: String? = null,
|
|
) : Exception(
|
|
message
|
|
)
|
|
|
|
data class ApiErrorResponse(
|
|
@SerializedName("code")
|
|
val code: Int?,
|
|
@SerializedName("error")
|
|
val error: String?,
|
|
@SerializedName("message")
|
|
val name: String?,
|
|
) {
|
|
fun toServiceException(): ServiceException {
|
|
return ServiceException(
|
|
message = error ?: name ?: "",
|
|
code = code,
|
|
error = error,
|
|
name = name
|
|
)
|
|
}
|
|
}
|
|
|
|
fun parseErrorResponse(errorBody: ResponseBody?): ApiErrorResponse? {
|
|
return errorBody?.let {
|
|
val gson = Gson()
|
|
gson.fromJson(it.charStream(), ApiErrorResponse::class.java)
|
|
}
|
|
} |