package com.zhaoyang.driver.ui.main.major
|
|
import cn.sinata.xldutils.utils.callPhone
|
import cn.sinata.xldutils.utils.clickDelay
|
import cn.sinata.xldutils.utils.gone
|
import cn.sinata.xldutils.utils.visible
|
import com.zhaoyang.driver.R
|
import com.zhaoyang.driver.base.MyApplication
|
import com.zhaoyang.driver.base.MyBaseActivity
|
import com.zhaoyang.driver.bean.PhoneCheckBean
|
import com.zhaoyang.driver.netUtls.Api
|
import com.zhaoyang.driver.netUtls.callNet
|
import com.zhaoyang.driver.netUtls.getMapByAny
|
import kotlinx.android.synthetic.main.activity_input_price.*
|
import org.jetbrains.anko.toast
|
import java.lang.Exception
|
|
class InputPriceActivity : MyBaseActivity() {
|
override fun setContentView() {
|
setContentView(R.layout.activity_input_price)
|
}
|
|
val orderType by lazy {
|
intent.getStringExtra("orderType")
|
}
|
|
val orderId by lazy {
|
intent.getStringExtra("orderId")
|
}
|
|
val estimatedPrice by lazy {
|
intent.getDoubleExtra("estimatedPrice",0.0)
|
}
|
|
override fun initView() {
|
setTitleText("确认费用")
|
rb_order.text = "按预估费(¥%.2f)".format(estimatedPrice)
|
tv_money.text = "¥%.2f".format(estimatedPrice)
|
var map = getMapByAny()
|
map["code"] = MyApplication.aMapLocation?.adCode
|
callNet(Api.queryCustomerPhone,map){
|
var bean = gson.fromJson<PhoneCheckBean>(it, PhoneCheckBean::class.java)
|
tv_phone.text = "费用将由平台确认,如需加急请拨打:${bean.data.platform}"
|
}
|
}
|
|
override fun setOnclick() {
|
rg_type.setOnCheckedChangeListener { group, checkedId ->
|
if (checkedId == R.id.rb_order){
|
tv_money.visible()
|
tv_1.visible()
|
et_price.gone()
|
}else{
|
tv_money.gone()
|
tv_1.gone()
|
et_price.visible()
|
}
|
}
|
|
tv_login.clickDelay {
|
var d = 0.0
|
if (rb_input.isChecked){
|
val s = et_price.text.toString()
|
if (s.isNullOrEmpty()){
|
toast("请输入收费金额")
|
return@clickDelay
|
}
|
try {
|
d = s.toDouble()
|
if (d == 0.0){
|
toast("金额不能为0")
|
return@clickDelay
|
}
|
}catch (e:Exception){
|
toast("请输入正确的金额")
|
return@clickDelay
|
}
|
}
|
confirmPrice(d)
|
}
|
|
}
|
|
private fun confirmPrice(d:Double){
|
var map = getMapByAny()
|
map["orderId"] = orderId
|
map["orderType"] = orderType
|
map["priceType"] = if (rb_input.isChecked) 3 else 2
|
map["updatePrice"] = if (rb_input.isChecked) d else estimatedPrice
|
callNet(Api.updatePrice,map){
|
toast("提交成功,等待平台审核")
|
setResult(RESULT_OK)
|
finish()
|
}
|
}
|
|
}
|