lmw
2023-06-25 a988e7c15f5ce63785b77e01c89bec2565668982
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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)
 
        }
    }
}