lmw
3 天以前 dbd287f9349ed52c8e861c2aadecff9a9bd83f3a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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()
        }
    }
 
}