package com.fanghua.driver.ui.mine.money_bag
|
|
import android.content.Intent
|
import com.fanghua.driver.R
|
import com.fanghua.driver.base.BaseEvent
|
import com.fanghua.driver.base.local.BasePhotoActivity
|
import com.fanghua.driver.bean.BaseBean
|
import com.fanghua.driver.netUtls.Api
|
import com.fanghua.driver.netUtls.callNet
|
import com.fanghua.driver.netUtls.getMapByAny
|
import com.google.gson.Gson
|
import kotlinx.android.synthetic.main.activity_up_qr_code.*
|
import org.greenrobot.eventbus.EventBus
|
import org.jetbrains.anko.startActivityForResult
|
import org.jetbrains.anko.toast
|
|
class UpQrCodeActivity:BasePhotoActivity() {
|
override fun setContentView() {
|
setContentView(R.layout.activity_up_qr_code)
|
}
|
|
private var code = ""
|
|
override fun initView() {
|
setTitleText("收款码")
|
code = intent.getStringExtra("code")?:""
|
if (code.isNotEmpty()){
|
tv_action.text = "更换"
|
iv_code.setImageURI(code)
|
}
|
}
|
|
override fun setOnclick() {
|
iv_code.setOnClickListener {
|
if (tv_action.text == "保存"){
|
showSelectPhone()
|
}
|
}
|
|
tv_action.setOnClickListener {
|
if (tv_action.text == "保存"){
|
if (code.isEmpty()){
|
toast("请上传收款码")
|
}else{
|
val intent = Intent()
|
intent.putExtra("code",code)
|
setResult(RESULT_OK,intent)
|
finish()
|
}
|
}else{
|
startActivityForResult<UpQrCodeActivity>(1)
|
}
|
}
|
}
|
|
override fun getPhoneUrl(url: String, type: Int, path: String) {
|
code = url
|
iv_code.setImageURI(code)
|
}
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
super.onActivityResult(requestCode, resultCode, data)
|
if (resultCode == RESULT_OK&&data!=null){
|
code = data.getStringExtra("code")?:""
|
iv_code.setImageURI(code)
|
val key = if (intent.getStringExtra("way") == "微信") "wxCollectionCode" else "zfbCollectionCode"
|
val map = getMapByAny()
|
map[key] = code
|
callNet(Api.saveDriverInfo,map){
|
val bean = Gson().fromJson(it, BaseBean::class.java)
|
if (bean.resultUtil.code == 10000){
|
EventBus.getDefault().post(BaseEvent(BaseEvent.CODE_CHANGE,key,code))
|
toast("更换成功")
|
}else
|
toast(bean.resultUtil.msg)
|
}
|
}
|
}
|
}
|