|
|
@@ -0,0 +1,425 @@
|
|
|
+package cn.muchinfo.rma.view.base.login.register
|
|
|
+
|
|
|
+import android.app.Dialog
|
|
|
+import android.graphics.BitmapFactory
|
|
|
+import android.net.Uri
|
|
|
+import android.os.Bundle
|
|
|
+import android.view.Gravity
|
|
|
+import android.view.View
|
|
|
+import android.widget.EditText
|
|
|
+import androidx.lifecycle.MutableLiveData
|
|
|
+import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
+import cn.muchinfo.rma.netManage.base.InteractiveException
|
|
|
+import cn.muchinfo.rma.netManage.utils.UpLoadUtils
|
|
|
+import cn.muchinfo.rma.view.autoWidget.*
|
|
|
+import cn.muchinfo.rma.view.autoWidget.photopicter.PhotoUtils
|
|
|
+import cn.muchinfo.rma.view.base.BaseActivity
|
|
|
+import cn.muchinfo.rma.view.base.app.Constant
|
|
|
+import cn.muchinfo.rma.view.base.future.trade.itemPaddingView
|
|
|
+import cn.muchinfo.rma.view.base.future.trade.itemView
|
|
|
+import cn.muchinfo.rma.view.base.home.contract.verticalEmptyView
|
|
|
+import com.alibaba.fastjson.JSON
|
|
|
+import com.blankj.utilcode.util.EncodeUtils
|
|
|
+import com.blankj.utilcode.util.LogUtils
|
|
|
+import com.blankj.utilcode.util.SPUtils
|
|
|
+import com.blankj.utilcode.util.ToastUtils
|
|
|
+import com.zhy.http.okhttp.callback.StringCallback
|
|
|
+import mtp.polymer.com.autowidget.dialog.createLoadingDialog
|
|
|
+import mtp.polymer.com.autowidget.utils.TaskUiModel
|
|
|
+import mtp.polymer.com.autowidget.utils.bindTaskStatus
|
|
|
+import okhttp3.Call
|
|
|
+import org.jetbrains.anko.*
|
|
|
+import org.jetbrains.anko.sdk25.coroutines.textChangedListener
|
|
|
+import org.json.JSONArray
|
|
|
+import org.json.JSONException
|
|
|
+import org.json.JSONObject
|
|
|
+import java.io.File
|
|
|
+
|
|
|
+/**
|
|
|
+ * 企业用户注册页面
|
|
|
+ */
|
|
|
+class EnterpriseRegisterActivity : BaseActivity<RegisterViewModel>() {
|
|
|
+
|
|
|
+ private var uploadFile: String = ""//上传成功后服务给的图片地址
|
|
|
+ private val imageString: MutableLiveData<String> =
|
|
|
+ MutableLiveData<String>().apply { value = "" }//文件地址
|
|
|
+
|
|
|
+ private var loadingDialog: Dialog? = null
|
|
|
+
|
|
|
+ //输入的企业名称
|
|
|
+ lateinit var enterprise_name: EditText
|
|
|
+
|
|
|
+ //输入的验证码
|
|
|
+ lateinit var verification_code: EditText
|
|
|
+
|
|
|
+ //输入的登录账号
|
|
|
+ lateinit var login_code: EditText
|
|
|
+
|
|
|
+ //输入的登录密码
|
|
|
+ lateinit var login_password: EditText
|
|
|
+
|
|
|
+ //输入的联系人手机号
|
|
|
+ lateinit var phone_number : EditText
|
|
|
+
|
|
|
+ override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
+ super.onCreate(savedInstanceState)
|
|
|
+ verticalLayout {
|
|
|
+ viewModel.getVerificationCode()
|
|
|
+ loadingDialog = createLoadingDialog(hintStr = "请求中")
|
|
|
+ loadingDialog?.bindTaskStatus(context, viewModel.loadingDialogStatus)
|
|
|
+ background = resources.getDrawable(R.color.main_hit_bg_color)
|
|
|
+ //页面标题
|
|
|
+ topBar {
|
|
|
+ commonLeftButton()
|
|
|
+ commonTitle {
|
|
|
+ text = "企业用户注册"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "企业名称"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(66))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ editText {
|
|
|
+ hintColorStr = "#DDDDDD"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ enterprise_name = this
|
|
|
+ hint = "请输入企业名称"
|
|
|
+ background = null
|
|
|
+ textSizeAuto = 34
|
|
|
+ }.lparams(0, wrapContent, 1f) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+ }.lparams(matchParent, autoSize(166))
|
|
|
+
|
|
|
+ itemPaddingView()
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "验证码"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(66))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ editText {
|
|
|
+ hintColorStr = "#DDDDDD"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ verification_code = this
|
|
|
+ hint = "请输入验证码"
|
|
|
+ background = null
|
|
|
+ textSizeAuto = 34
|
|
|
+ }.lparams(0, wrapContent, 1f) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ imageView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ viewModel.getVerificationCode()
|
|
|
+ }
|
|
|
+ viewModel.imageCode.bindOptional(context){
|
|
|
+ setImageBitmap(BitmapFactory.decodeByteArray(EncodeUtils.base64Decode(it),0,EncodeUtils.base64Decode(it).size))
|
|
|
+ }
|
|
|
+
|
|
|
+ }.lparams(autoSize(180), autoSize(77)) {
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+ }.lparams(matchParent, autoSize(166))
|
|
|
+
|
|
|
+ itemPaddingView()
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "登录账号"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(66))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ editText {
|
|
|
+ hintColorStr = "#DDDDDD"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ login_code = this
|
|
|
+ hint = "请设置登录账号"
|
|
|
+ background = null
|
|
|
+ textSizeAuto = 34
|
|
|
+ }.lparams(0, wrapContent, 1f) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+ }.lparams(matchParent, autoSize(166))
|
|
|
+
|
|
|
+ itemPaddingView()
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "登录密码"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(66))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ editText {
|
|
|
+ hintColorStr = "#DDDDDD"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ login_password = this
|
|
|
+ hint = "请设置登录密码"
|
|
|
+ background = null
|
|
|
+ textSizeAuto = 34
|
|
|
+ }.lparams(0, wrapContent, 1f) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+ }.lparams(matchParent, autoSize(166))
|
|
|
+
|
|
|
+ itemPaddingView()
|
|
|
+
|
|
|
+ verticalLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "手机号码"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(66))
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ editText {
|
|
|
+ hintColorStr = "#DDDDDD"
|
|
|
+ textColorInt = R.color.rma_black_33
|
|
|
+ phone_number = this
|
|
|
+ hint = "请填写联系人手机号"
|
|
|
+ background = null
|
|
|
+ textSizeAuto = 34
|
|
|
+ }.lparams(0, wrapContent, 1f) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ marginEnd = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(100))
|
|
|
+ }.lparams(matchParent, autoSize(166))
|
|
|
+
|
|
|
+ itemPaddingView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ text = "营业执照"
|
|
|
+ textSizeAuto = 29
|
|
|
+ textColorInt = R.color.hint_text_color
|
|
|
+ }.lparams(wrapContent, wrapContent) {
|
|
|
+ marginStart = autoSize(36)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(66))
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ linearLayout {
|
|
|
+ imageString.bindOptional(context) {
|
|
|
+ visibility = if (it.isNullOrEmpty()) {
|
|
|
+ View.VISIBLE
|
|
|
+ } else {
|
|
|
+ View.GONE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ onThrottleFirstClick {
|
|
|
+ PhotoUtils().showPicker(this@EnterpriseRegisterActivity) {
|
|
|
+ it.firstOrNull()?.let {
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
+ TaskUiModel.inFlight()
|
|
|
+ UpLoadUtils(this@EnterpriseRegisterActivity).uploadPicture(
|
|
|
+ File(it),
|
|
|
+ object : StringCallback() {
|
|
|
+ override fun onError(
|
|
|
+ call: Call,
|
|
|
+ e: Exception,
|
|
|
+ id: Int
|
|
|
+ ) {
|
|
|
+ LogUtils.e("hidahdashdsdasd", e.message)
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
+ TaskUiModel.failed(
|
|
|
+ InteractiveException(
|
|
|
+ errorMessage = e.message ?: ""
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onResponse(
|
|
|
+ response: String,
|
|
|
+ id: Int
|
|
|
+ ) {
|
|
|
+ /*[{"originalName":"tem.jpg","fileName":"201907161657044712.jpg","fileSize":"0KB","fileType":"image/jpeg","filePath":"./uploadFile/20190716/201907161657044712.jpg","submitName":null}]*/
|
|
|
+ try {
|
|
|
+ viewModel.loadingDialogStatus.value =
|
|
|
+ TaskUiModel.success("上传成功")
|
|
|
+ val jsonArray = JSONArray(response)
|
|
|
+ LogUtils.eTag(
|
|
|
+ "图片",
|
|
|
+ JSON.toJSONString(jsonArray)
|
|
|
+ )
|
|
|
+ for (i in 0 until jsonArray.length()) {
|
|
|
+ uploadFile =
|
|
|
+ (jsonArray.get(i) as JSONObject).getString(
|
|
|
+ "filePath"
|
|
|
+ )
|
|
|
+ imageString.value = it
|
|
|
+ LogUtils.e("hidahdashd", uploadFile)
|
|
|
+ }
|
|
|
+ } catch (e: JSONException) {
|
|
|
+ e.printStackTrace()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 10000.0,
|
|
|
+ SPUtils.getInstance().getString(Constant.uploadUrl)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ background = resources.getDrawable(R.color.qhj_update_image_bg)
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ imageView {
|
|
|
+ imageResource = R.mipmap.qhj_picture
|
|
|
+ }.lparams(autoSize(96), autoSize(96))
|
|
|
+ }.lparams(autoSize(288), autoSize(288)) {
|
|
|
+ marginStart = autoSize(50)
|
|
|
+ }
|
|
|
+
|
|
|
+ imageView {
|
|
|
+ imageString.bindOptional(context) {
|
|
|
+ if (it.isNullOrEmpty()) {
|
|
|
+ visibility = View.GONE
|
|
|
+ } else {
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ setImageURI(Uri.parse(it))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ visibility = View.GONE
|
|
|
+ onThrottleFirstClick {
|
|
|
+ val path = imageString.value.guard {
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ PhotoUtils().showImageViewer(
|
|
|
+ this@EnterpriseRegisterActivity,
|
|
|
+ 1,
|
|
|
+ arrayListOf(path)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }.lparams(autoSize(288), autoSize(288)) {
|
|
|
+ marginStart = autoSize(50)
|
|
|
+ }
|
|
|
+ }.lparams(matchParent, autoSize(300))
|
|
|
+
|
|
|
+ verticalEmptyView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ if (check().not()){
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ viewModel.requestEnterpriseInfo(username = enterprise_name.text.toString(),vcode = verification_code.text.toString(),logincode = login_code.text.toString(),loginpwd = login_password.text.toString(),mobilephone = phone_number.text.toString(),cardfrontphotourl = uploadFile){
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ backgroundDrawable = createRoundRectDrawable("#2794FF", 20)
|
|
|
+ text = "注册"
|
|
|
+ textSizeAuto = 38
|
|
|
+ textColorInt = R.color.white
|
|
|
+ }.lparams(matchParent, autoSize(119)) {
|
|
|
+ marginStart = autoSize(59)
|
|
|
+ marginEnd = autoSize(59)
|
|
|
+ }
|
|
|
+
|
|
|
+ }.lparams(matchParent, autoSize(144)) {
|
|
|
+ gravity = Gravity.BOTTOM
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //注册前的输入内容校验
|
|
|
+ fun check() : Boolean{
|
|
|
+ if (enterprise_name.text.toString().isNullOrEmpty()){
|
|
|
+ ToastUtils.showLong("请输入企业名称")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (verification_code.text.toString().isNullOrEmpty()){
|
|
|
+ ToastUtils.showLong("请输入验证码")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (login_code.text.toString().isNullOrEmpty()){
|
|
|
+ ToastUtils.showLong("请输入登录账号")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (login_password.text.toString().isNullOrEmpty()){
|
|
|
+ ToastUtils.showLong("请输入登录密码")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (phone_number.text.toString().isNullOrEmpty()){
|
|
|
+ ToastUtils.showLong("请输入联系人手机号")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (uploadFile.isNullOrEmpty()){
|
|
|
+ ToastUtils.showLong("请上传营业执照")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+}
|