package com.kuanzhai.driver.ui.merchant
|
|
import android.view.View
|
import cn.sinata.xldutils.utils.clickDelay
|
import cn.sinata.xldutils.utils.getContent
|
import cn.sinata.xldutils.utils.gone
|
import com.kuanzhai.driver.R
|
import com.kuanzhai.driver.base.local.BasePhotoActivity
|
import com.kuanzhai.driver.bean.MerchantInfo
|
import com.kuanzhai.driver.netUtls.Api
|
import com.kuanzhai.driver.netUtls.callNet
|
import com.kuanzhai.driver.netUtls.getMapByAny
|
import com.kuanzhai.driver.utils.glide.GlideUtil
|
import kotlinx.android.synthetic.main.activity_merchant_comein.*
|
import org.jetbrains.anko.toast
|
|
/**
|
* @ClassName MerchantComeInActivity
|
* @Description TODO
|
* @Author Administrator
|
* @Date 2022/2/9 15:04
|
* @Version 1.0
|
*/
|
class MerchantComeInActivity: BasePhotoActivity() {
|
|
val hint by lazy {
|
intent.getStringExtra("hint")
|
}
|
|
val auditStatus by lazy { //1=待审核,2=已同意,3=已拒绝 0 未申请
|
intent.getIntExtra("auditStatus",-1)
|
}
|
|
var img = ""
|
var merImg = ""
|
|
override fun setContentView() {
|
setContentView(R.layout.activity_merchant_comein)
|
}
|
|
override fun initView() {
|
setTitleText("商家入驻")
|
tv_hint.visibility = if (auditStatus == 3) View.VISIBLE else View.GONE
|
tv_hint.text = "*拒绝理由:$hint"
|
if (auditStatus == 1){
|
ll_send.gone()
|
}
|
if (auditStatus == 0){
|
ll_wait.gone()
|
}
|
if (auditStatus == 3){
|
ll_wait.gone()
|
}
|
if (auditStatus == 3){
|
callMerchant(){
|
img = it.data.businessLicense
|
GlideUtil.load(this,it.data.businessLicense,iv_img,1)
|
merImg = it.data.headImg
|
GlideUtil.loady(this,it.data.headImg,iv_mer_img)
|
et_name.setText(it.data.contactName)
|
et_phone.setText(it.data.contactPhone)
|
et_shop_name.setText(it.data.name)
|
et_site.setText(it.data.address)
|
}
|
}
|
}
|
|
var typeT = 1
|
override fun setOnclick() {
|
iv_img.clickDelay {
|
typeT = 1
|
showSelectPhone()
|
}
|
|
iv_mer_img.clickDelay {
|
typeT = 2
|
showSelectPhone()
|
}
|
|
tv_commit.clickDelay {
|
if (et_name.getContent().isEmpty()){
|
toast("请填写名字")
|
return@clickDelay
|
}
|
if (et_phone.getContent().isEmpty()){
|
toast("请填写联系人电话")
|
return@clickDelay
|
}
|
if (et_shop_name.getContent().isEmpty()){
|
toast("请填写店铺名称")
|
return@clickDelay
|
}
|
if (et_site.getContent().isEmpty()){
|
toast("请填写经营地址")
|
return@clickDelay
|
}
|
if (img.isEmpty()){
|
toast("请上传营业执照")
|
return@clickDelay
|
}
|
if (merImg.isEmpty()){
|
toast("请上传商家头像")
|
return@clickDelay
|
}
|
var map = getMapByAny()
|
map["address"] = et_site.getContent()
|
map["businessLicense"] = img
|
map["contactName"] = et_name.getContent()
|
map["contactPhone"] = et_phone.getContent()
|
map["name"] = et_shop_name.getContent()
|
map["headImg"] = merImg
|
callNet(Api.registeredMerchant,map){
|
toast("已申请,等待审核")
|
onBackPressed()
|
}
|
}
|
}
|
|
override fun getPhoneUrl(url: String, type: Int) {
|
super.getPhoneUrl(url, type)
|
if (typeT == 1){
|
img = url
|
GlideUtil.load(this,url,iv_img,1)
|
}
|
if (typeT == 2){
|
merImg = url
|
GlideUtil.loady(this,url,iv_mer_img)
|
}
|
|
}
|
|
|
private fun callMerchant(function:(MerchantInfo) -> Unit) {
|
var map = getMapByAny()
|
callNet(Api.getMerchant, map) {
|
var merchatInfo = gson.fromJson<MerchantInfo>(it, MerchantInfo::class.java)
|
function(merchatInfo)
|
|
}
|
}
|
}
|