lmw
2023-04-03 16ea883d3c03fd8b910f9282aa1bc08378d40d54
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
package com.zhaoyang.driver.ui.mine
 
import android.view.View
import androidx.core.content.ContextCompat
import cn.sinata.xldutils.utils.*
import com.bumptech.glide.Glide
import com.zhaoyang.driver.R
import com.zhaoyang.driver.base.MyBaseActivity
import com.zhaoyang.driver.base.local.BasePhotoActivity
import com.zhaoyang.driver.bean.DriverBean
import com.zhaoyang.driver.bean.FaceBean
import com.zhaoyang.driver.bean.UserBean
import com.zhaoyang.driver.netUtls.*
import com.zhaoyang.driver.ui.DialogUtil
import com.zhaoyang.driver.utils.Cache.CacheKey
import com.zhaoyang.driver.utils.DateUtil
import com.zhaoyang.driver.utils.ImageUtils
import com.zhaoyang.driver.utils.MyUtils
import com.zhaoyang.driver.utils.PhoneCheckUtil
import com.zhaoyang.driver.utils.citypickerview.picker.widget.builder.TimePickerBuilder
import com.zhaoyang.driver.utils.citypickerview.picker.widget.listener.OnTimeSelectListener
import com.zhaoyang.driver.utils.glide.GlideUtil
import com.google.gson.Gson
import kotlinx.android.synthetic.main.activity_driver_attestation.*
import kotlinx.android.synthetic.main.activity_driver_attestation.et_name
import kotlinx.android.synthetic.main.activity_driver_attestation.et_people_code
import kotlinx.android.synthetic.main.activity_driver_attestation.iv_driver_img
import kotlinx.android.synthetic.main.activity_driver_attestation.iv_id_card
import kotlinx.android.synthetic.main.activity_driver_attestation.iv_net_img
import kotlinx.android.synthetic.main.activity_driver_attestation.ll_driver_two
import kotlinx.android.synthetic.main.activity_driver_attestation.ll_select_driver_time
import kotlinx.android.synthetic.main.activity_driver_attestation.rl_net_img
import kotlinx.android.synthetic.main.activity_driver_attestation.tv_next_two
import kotlinx.android.synthetic.main.activity_driver_attestation.tv_select_driver_time
import kotlinx.android.synthetic.main.activity_driver_attestation.tv_select_sex
import kotlinx.android.synthetic.main.dialog_sex_show.view.*
import kotlinx.android.synthetic.main.driver_two.*
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast
import java.util.*
 
/**
 * @ClassName DriverAttestationActivity
 * @Description TODO
 * @Author Administrator
 * @Date 2021/3/23 16:35
 * @Version 1.0
 */
class DriverAttestationActivity: BasePhotoActivity() {
 
    var user = CacheKey.getUserInfo()
 
    override fun setContentView() {
        setContentView(R.layout.activity_driver_attestation)
    }
 
    override fun initView() {
        ////(1:待审核 2:正常 3:冻结 4:拒绝)
        setTitleText("司机审核")
        tv_statue.visible()
        tv_next_two.visible()
        if (user.name.isNullOrEmpty()){
            tv_statue.gone()
        }else{
            GlideUtil.load(this, user.idCardImgUrl1, iv_id_card, 1)
            GlideUtil.load(this, user.driveCardImgUrl, iv_driver_img, 1)
            GlideUtil.load(this, user.networkCarlssueImg, iv_net_img, 1)
            et_name.setText(user.name)
            et_name.setSelection(user.name.length)
            tv_select_sex.text = user.sexStr
            et_people_code.setText(user.idCard)
            et_people_code.setSelection(user.idCard.length)
            tv_select_driver_time.text = user.getDriverLicenseDate
            setUpData(upBean)
            when(user.authState){
                "1" -> {
                    tv_statue.text = "审核中"
                    tv_statue.textColor(this,R.color.color_F07207)
                    tv_next_two.gone()
                    enableFalse()
                }
 
                "2" -> {
                    tv_statue.text = "审核通过"
                    tv_statue.visible()
                    tv_statue.textColor(this,R.color.color_F3F4F5)
                    tv_next_two.gone()
                    enableFalse()
                }
 
                "3" -> {
                    tv_statue.text = "已冻结"
                    tv_statue.textColor(this,R.color.color_F3F4F5)
                    tv_next_two.gone()
                    enableFalse()
                }
 
                "4" -> {
                    tv_statue.text = "审核失败"
                    tv_statue.textColor(this,R.color.color_F3F4F5)
                    tv_next_two.text = "修改提交"
                }
            }
        }
 
    }
 
    private fun setUpData(upBean: DriverBean) {
        upBean.idCardImgUrl1 = user.idCardImgUrl1
        upBean.driveCardImgUrl = user.driveCardImgUrl
        upBean.networkCarlssueImg = user.networkCarlssueImg
        upBean.name = user.name
        upBean.sex = user.sex
        upBean.idCard = user.idCard
        upBean.getDriverLicenseDate = user.getDriverLicenseDate
    }
 
    fun enableFalse(){
        iv_id_card.isEnabled = false
        iv_driver_img.isEnabled = false
        iv_net_img.isEnabled = false
        et_name.isEnabled = false
        tv_select_sex.isEnabled = false
        et_people_code.isEnabled = false
        ll_select_driver_time.isEnabled = false
    }
 
    var selectPhone = 0 //1 身份证 2:头像 3:驾驶证 4:网约车资格证
 
    override fun setOnclick() {
        iv_id_card.setOnClickListener {
            selectPhone = 1
            MyUtils.getInstans().hideKeyboard(ll_driver_two)
            showSelectPhone()
        }
 
        iv_driver_img.setOnClickListener {
            selectPhone = 3
            MyUtils.getInstans().hideKeyboard(ll_driver_two)
            showSelectPhone()
        }
 
        iv_net_img.setOnClickListener {
            selectPhone = 4
            MyUtils.getInstans().hideKeyboard(ll_driver_two)
            showSelectPhone()
        }
 
        tv_select_sex.setOnClickListener {
            MyUtils.getInstans().hideKeyboard(ll_driver_two)
            showSex()
        }
 
        ll_select_driver_time.setOnClickListener {
            MyUtils.getInstans().hideKeyboard(ll_driver_two)
            showTimePicker()
        }
 
        tv_next_two.clickDelay {
            calldriver()
        }
 
    }
 
    val upBean by lazy {
        DriverBean()
    }
 
    override fun getPhoneUrl(url: String, type: Int, path: String) {
        super.getPhoneUrl(url, type,path)
        when (selectPhone) {
            1 -> {
                upBean.idCardImgUrl1 = url
                GlideUtil.load(this, url, iv_id_card, 1)
                getIDCardDetail(path)
            }
 
            3 -> {
                upBean.driveCardImgUrl = url
                GlideUtil.load(this, url, iv_driver_img, 1)
            }
            4 -> {
                upBean.networkCarlssueImg = url
                GlideUtil.load(this, url, iv_net_img, 1)
            }
        }
    }
 
    public fun getIDCardDetail(imgPath: String) {
        val bodys = getMapByAny()
        bodys["src"] = ImageUtils.imageToBase64(imgPath)
        FaceHttpManager.getInstance().post("sfzread", bodys, object : FaceObserver(this) {
            override fun success(responseString: String?) {
                //            success(responseString);
                val baseBean = Gson().fromJson(responseString, FaceBean::class.java)
                if (!baseBean.msg.id.isNullOrEmpty()){
                    upBean.name = baseBean.msg.name
                    upBean.idCard = baseBean.msg.id
                    upBean.sex = if(baseBean.msg.sex == "男") 1 else 2
                    et_name.setText(upBean.name)
                    tv_select_sex.text = baseBean.msg.sex
                    et_people_code.setText(upBean.idCard)
                    et_people_code.setSelection(upBean.idCard.length)
                }
                dismissDialog()
            }
 
            override fun onError(code: Int, msg: String?, resposeString: String?) {
 
            }
        })
 
 
        try {
            /**
             * 重要提示如下:
             * HttpUtils请从
             * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
             * 下载
             *
             * 相应的依赖请参照
             * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
             */
//            val response: HttpResponse =
//                HttpUtils.doPost(host, path, method, headers, querys, bodys)
//            System.out.println(response.toString())
//            System.out.println(EntityUtils.toString(response.getEntity()));
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
 
 
    private fun showSex() {
        var pop = DialogUtil.getPopupwindow(this, R.layout.dialog_sex_show)
        pop.showDown(window.decorView)
        pop.contentView.tv_select_girl.isSelected = false
        pop.contentView.tv_select_boy.isSelected = true
        pop.contentView.tv_cancel.setOnClickListener {
            pop.dismiss()
        }
        pop.contentView.tv_ok_sex.setOnClickListener {
            upBean.sex = if (pop.contentView.tv_select_girl.isSelected) 2 else 1
            tv_select_sex.text = upBean.sexStr
            pop.dismiss()
        }
        pop.contentView.tv_select_girl.setOnClickListener {
            pop.contentView.tv_select_girl.alpha = 1f
            pop.contentView.tv_select_girl.setColor(this,R.color.main_yellow)
            pop.contentView.tv_select_boy.setColor(this,R.color.black)
            pop.contentView.tv_select_boy.alpha = 0.6f
            pop.contentView.tv_select_girl.isSelected = true
            pop.contentView.tv_select_boy.isSelected = false
        }
        pop.contentView.tv_select_boy.setOnClickListener {
            pop.contentView.tv_select_girl.setColor(this,R.color.black)
            pop.contentView.tv_select_boy.setColor(this,R.color.main_yellow)
            pop.contentView.tv_select_girl.alpha = 0.6f
            pop.contentView.tv_select_boy.alpha = 1f
            pop.contentView.tv_select_girl.isSelected = false
            pop.contentView.tv_select_boy.isSelected = true
        }
    }
 
 
    fun showTimePicker() {
        var startCalendar = Calendar.getInstance()
        var endCalendar = Calendar.getInstance()
        startCalendar.set(1900, 1, 1)
        endCalendar.timeInMillis = (System.currentTimeMillis() - (1000L * 3600L * 24L * 365L * 3L))
        var timePic = TimePickerBuilder(this,
            OnTimeSelectListener { date, v ->
                upBean.getDriverLicenseDate = DateUtil.getTime(DateUtil.TYPE1, date.time)
                tv_select_driver_time.text = DateUtil.getTime(DateUtil.TYPE1, date.time)
            })
            .setTitleText("")
            .setBgColor(ContextCompat.getColor(this, R.color.white))
            .setCancelColor(ContextCompat.getColor(this, R.color.black_333333))
            .setSubmitColor(ContextCompat.getColor(this, R.color.main_yellow))
            .setRangDate(startCalendar, endCalendar)
            .setDate(endCalendar)
            .setSubmitText("确认")
            .setLineSpacingMultiplier(2f)
            .build()
        timePic.show()
    }
 
    private fun calldriver() {
        if (et_name.getString().isEmpty()) {
            toast("请输入姓名")
            return
        }
        if (et_people_code.getString().isEmpty()) {
            toast("请输入身份证")
            return
        }
        if (!PhoneCheckUtil.isLegalId(et_people_code.getContent())) {
            toast("身份证格式错误")
            return
        }
        if (upBean.driveCardImgUrl.isNullOrEmpty()) {
            toast("请上传驾驶证照片")
            return
        }
        if (upBean.getDriverLicenseDate.isNullOrEmpty()) {
            toast("请选择驾龄")
            return
        }
        if (rl_net_img.visibility == View.VISIBLE &&  upBean.networkCarlssueImg.isNullOrEmpty()) {
            toast("请上传网约车资格证照片")
            return
        }
        if (upBean.sex == -1) {
            toast("请选择性别")
            return
        }
        if (upBean.idCardImgUrl1.isNullOrEmpty()) {
            toast("请上传身份证正面照")
            return
        }
        upBean.name = et_name.getString()
        upBean.idCard = et_people_code.getString()
        var map = getMapByAny()
        map["driveCardImgUrl"] = upBean.driveCardImgUrl
        map["driverContactAddress"] = upBean.driverContactAddress
        map["driverContactAddress_"] = upBean.driverContactAddress_
        map["getDriverLicenseDate"] = upBean.getDriverLicenseDate
        map["headImgUrl"] = upBean.headImgUrl
        map["idCard"] = upBean.idCard
        map["placeOfPractice"] = "四川省,凉山彝族自治州,西昌市"
        map["idCardImgUrl1"] = upBean.idCardImgUrl1
        map["idCardImgUrl2"] = upBean.idCardImgUrl2
        map["name"] = upBean.name
        map["networkCarlssueImg"] = upBean.networkCarlssueImg
//        map["password"] = Md5.getMd5Value(upBean.password)
//        map["phone"] = upBean.phone
        map["placeOfEmployment"] = "513401"
        map["sex"] = upBean.sex
        if (!upBean.taxiAptitudeCard.isNullOrEmpty()){
            map["taxiAptitudeCard"] = upBean.taxiAptitudeCard
        }
        map["type"] = "1"
        map["uid"] = CacheKey.getUserId()
        callNet(Api.updateDriver, map, {
            callMine{
                toast("成功")
                onBackPressed()
            }
        }, {
        })
    }
 
    private fun callMine(function:()-> Unit) {
        var map = getMapByAny()
        callNet(Api.queryInfo,map){
            var user = gson.fromJson<UserBean>(it, UserBean::class.java)
            CacheKey.saveUserInfo(user.data)
            function()
        }
    }
 
}