|
|
@@ -11,6 +11,9 @@ import android.view.inputmethod.EditorInfo
|
|
|
import android.widget.EditText
|
|
|
import androidx.lifecycle.MutableLiveData
|
|
|
import cn.muchinfo.rma.R
|
|
|
+import cn.muchinfo.rma.global.GlobalDataCollection
|
|
|
+import cn.muchinfo.rma.global.data.BrokerApplyData
|
|
|
+import cn.muchinfo.rma.global.database.DataBase
|
|
|
import cn.muchinfo.rma.lifecycle.bindOptional
|
|
|
import cn.muchinfo.rma.netManage.base.InteractiveException
|
|
|
import cn.muchinfo.rma.netManage.utils.UpLoadUtils
|
|
|
@@ -20,15 +23,17 @@ import cn.muchinfo.rma.view.autoWidget.photopicter.utils.ImageCaptureManager
|
|
|
import cn.muchinfo.rma.view.base.BaseActivity
|
|
|
import cn.muchinfo.rma.view.base.app.Constant
|
|
|
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.ActivityUtils
|
|
|
import com.blankj.utilcode.util.LogUtils
|
|
|
import com.blankj.utilcode.util.SPUtils
|
|
|
+import com.blankj.utilcode.util.ToastUtils
|
|
|
import com.tbruyelle.rxpermissions2.RxPermissions
|
|
|
import com.zhy.http.okhttp.callback.StringCallback
|
|
|
-import mtp.polymer.com.autowidget.dialog.SelectData
|
|
|
-import mtp.polymer.com.autowidget.dialog.creatBottomSheetDialog
|
|
|
+import mtp.polymer.com.autowidget.dialog.*
|
|
|
import mtp.polymer.com.autowidget.utils.TaskUiModel
|
|
|
+import mtp.polymer.com.autowidget.utils.bindTaskStatus
|
|
|
import okhttp3.Call
|
|
|
import org.jetbrains.anko.*
|
|
|
import org.json.JSONArray
|
|
|
@@ -39,12 +44,16 @@ import java.io.File
|
|
|
/**
|
|
|
* 申请推广码页面
|
|
|
*/
|
|
|
-class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
+class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>() {
|
|
|
+
|
|
|
+ //页面状态 1:新增 2:修改重新提交 3:展示数据
|
|
|
+ val type by lazy { intent.getStringExtra("type") }
|
|
|
+
|
|
|
+ //用来审核通过和重新提交实用的数据
|
|
|
+ val data by lazy { intent.getParcelableExtra<BrokerApplyData>("data") as BrokerApplyData }
|
|
|
|
|
|
//以下是正面照
|
|
|
- private var positiveUploadFile: String = ""//上传成功后服务给的图片地址
|
|
|
- val positiveImageString: MutableLiveData<String> =
|
|
|
- MutableLiveData<String>().apply { value = "" }//文件地址
|
|
|
+ private var positiveUploadFile: MutableLiveData<String> = MutableLiveData()//上传成功后服务给的图片地址
|
|
|
|
|
|
val positiveImagePhotoString: MutableLiveData<String> =
|
|
|
MutableLiveData<String>().apply { value = "" }//拍照后的文件地址
|
|
|
@@ -52,16 +61,17 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
val positiveImageCaptureManager by lazy { ImageCaptureManager(this) }
|
|
|
|
|
|
//以下是反面照
|
|
|
- private var reverseUploadFile: String = ""//上传成功后服务给的图片地址
|
|
|
- val reverseImageString: MutableLiveData<String> =
|
|
|
- MutableLiveData<String>().apply { value = "" }//文件地址
|
|
|
+ private var reverseUploadFile: MutableLiveData<String> = MutableLiveData()//上传成功后服务给的图片地址
|
|
|
|
|
|
val reverseImagePhotoString: MutableLiveData<String> =
|
|
|
MutableLiveData<String>().apply { value = "" }//拍照后的文件地址
|
|
|
val reverseImageCaptureManager by lazy { ImageCaptureManager(this) }
|
|
|
|
|
|
//输入的姓名
|
|
|
- lateinit var name_edittext : EditText
|
|
|
+ lateinit var name_edittext: EditText
|
|
|
+
|
|
|
+ //输入的身份证号
|
|
|
+ lateinit var card_number_edittext: EditText
|
|
|
|
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
|
super.onActivityResult(requestCode, resultCode, data)
|
|
|
@@ -69,7 +79,7 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
positiveImageCaptureManager.galleryAddPic()
|
|
|
positiveImagePhotoString.postValue(positiveImageCaptureManager.currentPhotoPath)
|
|
|
LogUtils.eTag("dasdasdsadasdad", positiveImageCaptureManager.currentPhotoPath)
|
|
|
- }else if (requestCode == 102 && resultCode == Activity.RESULT_OK) {//反面照拍照后
|
|
|
+ } else if (requestCode == 102 && resultCode == Activity.RESULT_OK) {//反面照拍照后
|
|
|
reverseImageCaptureManager.galleryAddPic()
|
|
|
reverseImagePhotoString.postValue(reverseImageCaptureManager.currentPhotoPath)
|
|
|
LogUtils.eTag("dasdasdsadasdad", reverseImageCaptureManager.currentPhotoPath)
|
|
|
@@ -79,6 +89,14 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
super.onCreate(savedInstanceState)
|
|
|
verticalLayout {
|
|
|
+ if (type == "2" || type == "3") {
|
|
|
+ positiveUploadFile.postValue(data.cardfrontphotourl)
|
|
|
+ reverseUploadFile.postValue(data.cardbackphotourl)
|
|
|
+ }
|
|
|
+ createLoadingDialog(hintStr = "请求中...").bindTaskStatus(
|
|
|
+ context,
|
|
|
+ viewModel.loadingDialogStatus
|
|
|
+ )
|
|
|
background = resources.getDrawable(R.color.main_hit_bg_color)
|
|
|
//页面标题
|
|
|
topBar {
|
|
|
@@ -105,6 +123,12 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
|
|
|
|
|
|
editText {
|
|
|
+ if (type == "2") {
|
|
|
+ setText(data.customername)
|
|
|
+ } else if (type == "3") {
|
|
|
+ setText(data.customername)
|
|
|
+ isEnabled = false
|
|
|
+ }
|
|
|
name_edittext = this
|
|
|
hint = "请输入姓名"
|
|
|
background = null
|
|
|
@@ -134,7 +158,13 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
|
|
|
|
|
|
editText {
|
|
|
- name_edittext = this
|
|
|
+ if (type == "2") {
|
|
|
+ setText(data.cardnum)
|
|
|
+ } else if (type == "3") {
|
|
|
+ setText(data.cardnum)
|
|
|
+ isEnabled = false
|
|
|
+ }
|
|
|
+ card_number_edittext = this
|
|
|
hint = "请输入身份证号码"
|
|
|
background = null
|
|
|
inputType = EditorInfo.TYPE_CLASS_TEXT
|
|
|
@@ -167,7 +197,7 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
gravity = Gravity.CENTER_HORIZONTAL
|
|
|
linearLayout {
|
|
|
backgroundResource = R.mipmap.qhj_add_positive_idcard
|
|
|
- positiveImageString.bindOptional(context) {
|
|
|
+ positiveUploadFile.bindOptional(context) {
|
|
|
visibility = if (it.isNullOrEmpty()) {
|
|
|
View.VISIBLE
|
|
|
} else {
|
|
|
@@ -176,7 +206,8 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
}
|
|
|
visibility = View.VISIBLE
|
|
|
onThrottleFirstClick {
|
|
|
- if (positiveImageString.value.isNullOrEmpty().not()){
|
|
|
+
|
|
|
+ if (type == "3") {
|
|
|
return@onThrottleFirstClick
|
|
|
}
|
|
|
|
|
|
@@ -185,17 +216,23 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
SelectData(id = "2", value = "相册")
|
|
|
)
|
|
|
creatBottomSheetDialog("请选择上传", selectDataList) {
|
|
|
- if (this.id == "1"){
|
|
|
+ if (this.id == "1") {
|
|
|
RxPermissions(this@ApplyPromotionCodeActivity).request(
|
|
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
|
- Manifest.permission.CAMERA)
|
|
|
+ Manifest.permission.CAMERA
|
|
|
+ )
|
|
|
.subscribe { granted ->
|
|
|
if (granted) {//打开相机拍照
|
|
|
- val intent = positiveImageCaptureManager.dispatchTakePictureIntent()
|
|
|
- ActivityUtils.startActivityForResult(this@ApplyPromotionCodeActivity, intent, 101)
|
|
|
+ val intent =
|
|
|
+ positiveImageCaptureManager.dispatchTakePictureIntent()
|
|
|
+ ActivityUtils.startActivityForResult(
|
|
|
+ this@ApplyPromotionCodeActivity,
|
|
|
+ intent,
|
|
|
+ 101
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
- }else if (this.id == "2"){
|
|
|
+ } else if (this.id == "2") {
|
|
|
PhotoUtils().showPicker(this@ApplyPromotionCodeActivity) {
|
|
|
it.firstOrNull()?.let {
|
|
|
viewModel.loadingDialogStatus.value =
|
|
|
@@ -231,12 +268,15 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
JSON.toJSONString(jsonArray)
|
|
|
)
|
|
|
for (i in 0 until jsonArray.length()) {
|
|
|
- positiveUploadFile =
|
|
|
+ positiveUploadFile.postValue(
|
|
|
(jsonArray.get(i) as JSONObject).getString(
|
|
|
"filePath"
|
|
|
)
|
|
|
- positiveImageString.value = it
|
|
|
- LogUtils.e("hidahdashd", positiveUploadFile)
|
|
|
+ )
|
|
|
+ LogUtils.e(
|
|
|
+ "hidahdashd",
|
|
|
+ positiveUploadFile
|
|
|
+ )
|
|
|
}
|
|
|
} catch (e: JSONException) {
|
|
|
e.printStackTrace()
|
|
|
@@ -288,11 +328,11 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
JSON.toJSONString(jsonArray)
|
|
|
)
|
|
|
for (i in 0 until jsonArray.length()) {
|
|
|
- positiveUploadFile =
|
|
|
+ positiveUploadFile.postValue(
|
|
|
(jsonArray.get(i) as JSONObject).getString(
|
|
|
"filePath"
|
|
|
)
|
|
|
- positiveImageString.value = it
|
|
|
+ )
|
|
|
LogUtils.e("hidahdashd", positiveUploadFile)
|
|
|
}
|
|
|
} catch (e: JSONException) {
|
|
|
@@ -310,17 +350,21 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
}.lparams(autoSize(480), autoSize(288))
|
|
|
|
|
|
imageView {
|
|
|
- positiveImageString.bindOptional(context) {
|
|
|
+ positiveUploadFile.bindOptional(context) {
|
|
|
if (it.isNullOrEmpty()) {
|
|
|
visibility = View.GONE
|
|
|
} else {
|
|
|
visibility = View.VISIBLE
|
|
|
- setImageURI(Uri.parse(it))
|
|
|
+ showImage(
|
|
|
+ SPUtils.getInstance().getString(Constant.openApiUrl) + it.substring(
|
|
|
+ 1
|
|
|
+ )
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
visibility = View.GONE
|
|
|
onThrottleFirstClick {
|
|
|
- val path = positiveImageString.value.guard {
|
|
|
+ val path = positiveUploadFile.value.guard {
|
|
|
return@onThrottleFirstClick
|
|
|
}
|
|
|
PhotoUtils().showImageViewer(
|
|
|
@@ -329,10 +373,8 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
arrayListOf(path)
|
|
|
)
|
|
|
}
|
|
|
- }.lparams(autoSize(480), autoSize(288)) {
|
|
|
- marginStart = autoSize(250)
|
|
|
- }
|
|
|
- }.lparams(matchParent, autoSize(288)){
|
|
|
+ }.lparams(autoSize(480), autoSize(288))
|
|
|
+ }.lparams(matchParent, autoSize(288)) {
|
|
|
topMargin = autoSize(40)
|
|
|
}
|
|
|
|
|
|
@@ -340,7 +382,7 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
gravity = Gravity.CENTER_HORIZONTAL
|
|
|
linearLayout {
|
|
|
backgroundResource = R.mipmap.qhj_add_positive_idcard
|
|
|
- reverseImageString.bindOptional(context) {
|
|
|
+ reverseUploadFile.bindOptional(context) {
|
|
|
visibility = if (it.isNullOrEmpty()) {
|
|
|
View.VISIBLE
|
|
|
} else {
|
|
|
@@ -349,7 +391,7 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
}
|
|
|
visibility = View.VISIBLE
|
|
|
onThrottleFirstClick {
|
|
|
- if (reverseImageString.value.isNullOrEmpty().not()){
|
|
|
+ if (type == "3") {
|
|
|
return@onThrottleFirstClick
|
|
|
}
|
|
|
|
|
|
@@ -358,17 +400,23 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
SelectData(id = "2", value = "相册")
|
|
|
)
|
|
|
creatBottomSheetDialog("请选择上传", selectDataList) {
|
|
|
- if (this.id == "1"){
|
|
|
+ if (this.id == "1") {
|
|
|
RxPermissions(this@ApplyPromotionCodeActivity).request(
|
|
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
|
|
- Manifest.permission.CAMERA)
|
|
|
+ Manifest.permission.CAMERA
|
|
|
+ )
|
|
|
.subscribe { granted ->
|
|
|
if (granted) {//打开相机拍照
|
|
|
- val intent = reverseImageCaptureManager.dispatchTakePictureIntent()
|
|
|
- ActivityUtils.startActivityForResult(this@ApplyPromotionCodeActivity, intent, 102)
|
|
|
+ val intent =
|
|
|
+ reverseImageCaptureManager.dispatchTakePictureIntent()
|
|
|
+ ActivityUtils.startActivityForResult(
|
|
|
+ this@ApplyPromotionCodeActivity,
|
|
|
+ intent,
|
|
|
+ 102
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
- }else if (this.id == "2"){
|
|
|
+ } else if (this.id == "2") {
|
|
|
PhotoUtils().showPicker(this@ApplyPromotionCodeActivity) {
|
|
|
it.firstOrNull()?.let {
|
|
|
viewModel.loadingDialogStatus.value =
|
|
|
@@ -404,12 +452,15 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
JSON.toJSONString(jsonArray)
|
|
|
)
|
|
|
for (i in 0 until jsonArray.length()) {
|
|
|
- reverseUploadFile =
|
|
|
+ reverseUploadFile.postValue(
|
|
|
(jsonArray.get(i) as JSONObject).getString(
|
|
|
"filePath"
|
|
|
)
|
|
|
- reverseImageString.value = it
|
|
|
- LogUtils.e("hidahdashd", reverseUploadFile)
|
|
|
+ )
|
|
|
+ LogUtils.e(
|
|
|
+ "hidahdashd",
|
|
|
+ reverseUploadFile
|
|
|
+ )
|
|
|
}
|
|
|
} catch (e: JSONException) {
|
|
|
e.printStackTrace()
|
|
|
@@ -461,11 +512,11 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
JSON.toJSONString(jsonArray)
|
|
|
)
|
|
|
for (i in 0 until jsonArray.length()) {
|
|
|
- reverseUploadFile =
|
|
|
+ reverseUploadFile.postValue(
|
|
|
(jsonArray.get(i) as JSONObject).getString(
|
|
|
"filePath"
|
|
|
)
|
|
|
- reverseImageString.value = it
|
|
|
+ )
|
|
|
LogUtils.e("hidahdashd", reverseUploadFile)
|
|
|
}
|
|
|
} catch (e: JSONException) {
|
|
|
@@ -483,17 +534,21 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
}.lparams(autoSize(480), autoSize(288))
|
|
|
|
|
|
imageView {
|
|
|
- reverseImageString.bindOptional(context) {
|
|
|
+ reverseUploadFile.bindOptional(context) {
|
|
|
if (it.isNullOrEmpty()) {
|
|
|
visibility = View.GONE
|
|
|
} else {
|
|
|
visibility = View.VISIBLE
|
|
|
- setImageURI(Uri.parse(it))
|
|
|
+ showImage(
|
|
|
+ SPUtils.getInstance().getString(Constant.openApiUrl) + it.substring(
|
|
|
+ 1
|
|
|
+ )
|
|
|
+ )
|
|
|
}
|
|
|
}
|
|
|
visibility = View.GONE
|
|
|
onThrottleFirstClick {
|
|
|
- val path = reverseImageString.value.guard {
|
|
|
+ val path = reverseUploadFile.value.guard {
|
|
|
return@onThrottleFirstClick
|
|
|
}
|
|
|
PhotoUtils().showImageViewer(
|
|
|
@@ -502,13 +557,88 @@ class ApplyPromotionCodeActivity : BaseActivity<MyPromotionCodeViewModel>(){
|
|
|
arrayListOf(path)
|
|
|
)
|
|
|
}
|
|
|
- }.lparams(autoSize(480), autoSize(288)) {
|
|
|
- marginStart = autoSize(250)
|
|
|
- }
|
|
|
- }.lparams(matchParent, autoSize(288)){
|
|
|
+ }.lparams(autoSize(480), autoSize(288))
|
|
|
+ }.lparams(matchParent, autoSize(288)) {
|
|
|
topMargin = autoSize(40)
|
|
|
}
|
|
|
+
|
|
|
+ verticalEmptyView()
|
|
|
+
|
|
|
+ linearLayout {
|
|
|
+ if (type == "3"){
|
|
|
+ visibility = View.GONE
|
|
|
+ }else{
|
|
|
+ visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ background = resources.getDrawable(R.color.white)
|
|
|
+ gravity = Gravity.CENTER_VERTICAL
|
|
|
+ textView {
|
|
|
+ onThrottleFirstClick {
|
|
|
+ if (type == "1") {
|
|
|
+ if (check().not()) {
|
|
|
+ return@onThrottleFirstClick
|
|
|
+ }
|
|
|
+ viewModel.customerRefernumOperateReq(
|
|
|
+ customername = name_edittext.text.toString(),
|
|
|
+ cardnum = card_number_edittext.text.toString(),
|
|
|
+ cardfrontphotourl = positiveUploadFile.value ?: "",
|
|
|
+ cardbackphotourl = reverseUploadFile.value ?: ""
|
|
|
+ ) {
|
|
|
+ ToastUtils.showLong("您的推广码申请已提交,请耐心等待审核!")
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ }else if (type == "2"){
|
|
|
+ val intent = Intent()
|
|
|
+ intent.putExtra("type","1")
|
|
|
+ intent.putExtra("data",BrokerApplyData())
|
|
|
+ ActivityUtils.startActivity(intent)
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ gravity = Gravity.CENTER
|
|
|
+ backgroundResource = R.mipmap.rma_submit_bg
|
|
|
+ if (type == "1"){
|
|
|
+ text = "提交申请"
|
|
|
+ }else if (type == "2") {
|
|
|
+ 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 (name_edittext.text.isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入姓名")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (card_number_edittext.text.isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请输入身份证号码")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ if (positiveUploadFile.value.isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请上传证件正面照")
|
|
|
+ return false
|
|
|
}
|
|
|
+
|
|
|
+ if (reverseUploadFile.value.isNullOrEmpty()) {
|
|
|
+ ToastUtils.showLong("请上传证件反面照")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ return true
|
|
|
}
|
|
|
|
|
|
}
|