package com.fuban.user.ui.trip
|
|
import android.app.Activity
|
import android.widget.RadioButton
|
import androidx.core.os.bundleOf
|
import cn.sinata.xldutils.utils.myToast
|
import com.fuban.user.R
|
import com.fuban.user.network.HttpManager
|
import com.fuban.user.network.request
|
import com.fuban.user.ui.TransparentStatusBarActivity
|
import com.fuban.user.dialog.TipDialog
|
import kotlinx.android.synthetic.main.activity_complain.*
|
import org.jetbrains.anko.find
|
|
/**
|
* 取消订单
|
*/
|
class ComplainActivity : TransparentStatusBarActivity() {
|
|
override fun setContentView(): Int = R.layout.activity_complain
|
|
override fun initClick() {
|
rg.setOnCheckedChangeListener { group, checkedId ->
|
reason = find<RadioButton>(checkedId).text.toString()
|
if (checkedId == R.id.rb_8) {//其他理由
|
reason = "其他"
|
}
|
}
|
|
tv_action.setOnClickListener {
|
if (reason.isEmpty()) {
|
myToast("请选择投诉原因")
|
return@setOnClickListener
|
}
|
if (rg.checkedRadioButtonId == R.id.rb_8) {
|
val content = et_content.text.toString()
|
if (content.isEmpty()) {
|
myToast("请输入详细描述")
|
return@setOnClickListener
|
}
|
}
|
val tipDialog = TipDialog()
|
tipDialog.arguments = bundleOf("msg" to "是否确认投诉该司机?","ok" to "确认投诉","cancel" to "取消")
|
tipDialog.setCallback(object :TipDialog.OnClickCallback{
|
override fun onOk() {
|
submit()
|
}
|
|
override fun onCancel() {
|
}
|
})
|
tipDialog.show(supportFragmentManager,"complain")
|
}
|
}
|
|
override fun initView() {
|
title = "投诉"
|
}
|
|
private val id by lazy {
|
intent.getIntExtra("id", 0)
|
}
|
|
private val orderId by lazy {
|
intent.getIntExtra("orderId", 0)
|
}
|
|
private var reason = ""
|
|
|
private fun submit() {
|
showDialog()
|
val content = et_content.text.toString()
|
HttpManager.complaintService(id,content,reason).request(this){ _, _->
|
setResult(Activity.RESULT_OK)
|
val tipDialog = TipDialog()
|
tipDialog.arguments = bundleOf("msg" to "我们已收到您的投诉,我们会尽快安排处理,感谢您的投诉与建议!","isAlert" to true,"ok" to "确定")
|
tipDialog.setDismissCallback(object :TipDialog.OnDismiss{
|
override fun onDismiss() {
|
finish()
|
}
|
})
|
tipDialog.show(supportFragmentManager,"tip")
|
}
|
}
|
}
|