Pu Zhibing
2025-12-11 ab0c19e49fabdb8cc6eea454ea455bce2efbb718
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
package com.igo.user.ui.logistics
 
import android.Manifest
import android.animation.ObjectAnimator
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.CheckBox
import android.widget.CheckedTextView
import android.widget.EditText
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.constraintlayout.widget.Group
import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import cn.sinata.xldutils.defaultScheduler
import cn.sinata.xldutils.fragment.BaseFragment
import cn.sinata.xldutils.gone
import cn.sinata.xldutils.toBrowser
import cn.sinata.xldutils.utils.SPUtils
import cn.sinata.xldutils.utils.SpanBuilder
import cn.sinata.xldutils.utils.myToast
import cn.sinata.xldutils.utils.optInt
import cn.sinata.xldutils.utils.showAllowingStateLoss
import cn.sinata.xldutils.utils.toTime
import cn.sinata.xldutils.visible
import com.amap.api.col.sln3.it
import com.facebook.drawee.view.SimpleDraweeView
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.LatLng
import com.google.gson.Gson
import com.igo.user.IGoApplication
import com.igo.user.IGoApplication.Companion.chooseCityLat
import com.igo.user.IGoApplication.Companion.chooseCityLon
import com.igo.user.IGoApplication.Companion.lat
import com.igo.user.IGoApplication.Companion.lon
import com.igo.user.R
import com.igo.user.dialog.ChooseReserveTimeDialog
import com.igo.user.dialog.SingleWheelDialog
import com.igo.user.dialog.TipDialog
import com.igo.user.interfaces.StringCallback
import com.igo.user.network.HttpManager
import com.igo.user.network.entity.GeoBean
import com.igo.user.network.request
import com.igo.user.network.requestByF
import com.igo.user.ui.MainActivity
import com.igo.user.ui.mine.FinishMailActivity
import com.igo.user.ui.mine.OrderActivity
import com.igo.user.ui.mine.TripOrderFragment
import com.igo.user.ui.trip.ChoosePositionActivity
import com.igo.user.ui.trip.OrderDetailActivity
import com.igo.user.ui.trip.TripActivity
import com.igo.user.utils.Const
import com.igo.user.utils.google.AMapKit
import com.igo.user.utils.pay.PayListener
import com.igo.user.utils.pay.PayUtil
import com.tbruyelle.rxpermissions2.RxPermissions
import io.reactivex.subscribers.DisposableSubscriber
import org.jetbrains.anko.backgroundResource
import org.jetbrains.anko.find
import org.jetbrains.anko.sdk27.coroutines.onClick
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.support.v4.dip
import org.jetbrains.anko.support.v4.find
import org.jetbrains.anko.support.v4.runOnUiThread
import org.jetbrains.anko.support.v4.startActivity
import org.jetbrains.anko.support.v4.startActivityForResult
import org.jetbrains.anko.support.v4.toast
 
class LogisticsFragment:BaseFragment(), PayListener {
    override fun contentViewId() = R.layout.fragment_logistics
 
    var type = Const.OrderType.TYPE_SAME_CITY //默认为同城物流
 
    private val DEFAULT_SCALE_LEVEL = 18f
    private var startByChoose = false //true 通过选择出发地移动地图,false 通过手势拖动地图
    private var startByLocal = false //true 通过复位按钮移动地图,false 通过手势拖动地图
 
    //取件经纬度
    private var startLon = 0.0
    private var startLat = 0.0
    private var startName = ""
    //收件信息
    private var receiveName = ""
    private var receivePhone = ""
    private var receiveRegion = ""
//    private var provinceIndex = 0
//    private var cityIndex = 0
//    private var regionIndex = 0
    private var receiveAddress = ""
    private var endLat = 0.0
    private var endLon = 0.0
    private var timeFormat = "" //取件时间:例 2020-09-17 21:00:00
 
    private var isFirstOrder = true
    //货物信息
    private var goodsType = 1 //货物类型(1=普通货物,2=贵重货物)
    private var goodsNum = 1 //货物数量
    private var remark = ""
 
    private var orderMoney = 0.0 //物流费用
    private var fastMoney = 0 //加急费用
 
    lateinit var aMap: GoogleMap
 
    private val mainActivity by lazy {
        activity as MainActivity
    }
 
    private var carTypeId = 0 //车型id
    private var carTypeIndex = -1 //选中的位置
 
    private val tv_tips by lazy { find<TextView>(R.id.tv_tips) }
    private val iv_location by lazy { find<View>(R.id.iv_location) }
    private val tv_start by lazy { find<TextView>(R.id.tv_start) }
    private val tv_receiver by lazy { find<TextView>(R.id.tv_receiver) }
    private val tv_type by lazy { find<EditText>(R.id.tv_type) }
    private val tv_time by lazy { find<TextView>(R.id.tv_time) }
    private val tv_action by lazy { find<TextView>(R.id.tv_action) }
    private val tv_center by lazy { find<TextView>(R.id.tv_center) }
    private val cb_fast by lazy { find<CheckBox>(R.id.cb_fast) }
    private val iv_center_logistics by lazy { find<ImageView>(R.id.iv_center_logistics) }
    private val group_fast by lazy { find<Group>(R.id.group_fast) }
    private val cl_types by lazy { find<View>(R.id.cl_types) }
    private val tv_empty by lazy { find<View>(R.id.tv_empty) }
    private val tv_error by lazy { find<View>(R.id.tv_error) }
    private val tv_retry by lazy { find<View>(R.id.tv_retry) }
    private val ll_type by lazy { find<LinearLayout>(R.id.ll_type) }
 
    private val tipsDialog by lazy {
        val dialog = SingleWheelDialog()
        dialog.arguments = bundleOf("title" to "修改加急金额","subTitle" to "加急费用归司机所有,添加将提高应答率","data" to (1..20).map { "${it}元" })
        dialog.setCallback(object :StringCallback{
            override fun onRlt(rlt: String) {
                tv_tips.text = rlt
                fastMoney = rlt.substring(0,rlt.length-1).toInt()
            }
        })
        dialog
    }
    private val successDialog by lazy {
        val dialog = TipDialog()
        dialog.arguments = bundleOf("msg" to getString(R.string.您已下单成功),"isAlert" to true)
        dialog.setDismissCallback(object :TipDialog.OnDismiss{
            override fun onDismiss() {
                startActivity<OrderActivity>("type" to TripOrderFragment.TYPE_LOGISTICS)
            }
        })
        dialog
    }
 
 
    override fun onFirstVisibleToUser() {
        initMap()
        initClick()
        PayUtil.addPayListener(this)
    }
 
    private fun initClick() {
        //点击归位
        iv_location.setOnClickListener {
            startByLocal = true
            aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(IGoApplication.lat, IGoApplication.lon),DEFAULT_SCALE_LEVEL))
        }
        tv_start.onClick {
            startActivityForResult<ChoosePositionActivity>(Const.RequestCode.LOGISTICS_START,"isLogistics" to true)
        }
        tv_receiver.onClick {
            if (mainActivity.checkLogin()){
                if (startName.isEmpty()){
                    myToast(getString(R.string.请先选择起点))
                    return@onClick
                }
                /*if (SPUtils.instance().getString(Const.User.EMAIL).isEmpty()){ //当前登录但没有设置邮箱,强制设置邮箱
                    startActivity<FinishMailActivity>("isRegister" to true,"isPackage" to true)
                }else*/
 
                startActivityForResult<ReceiverActivity>(Const.RequestCode.LOGISTICS_RECEIVER,"name" to receiveName,"type" to type,
                    "phone" to receivePhone,"region" to receiveRegion,"address" to receiveAddress,"startLat" to startLat,"startLon" to startLon,
                    "endLat" to endLat,"endLon" to endLon)
 
            }
        }
//        tv_type.onClick {
//            if (startName.isEmpty()){
//                myToast("请选择取件地点")
//                return@onClick
//            }
//            if (receiveAddress.isEmpty()){
//                myToast("请完善收货人信息")
//                return@onClick
//            }
//            if (mainActivity.checkLogin())
//                startActivityForResult<GoodsTypeActivity>(Const.RequestCode.LOGISTICS_TYPE,"address" to receiveRegion+receiveAddress,
//                    "lat" to startLat,"lon" to startLon,"type" to type)
//        }
        tv_time.onClick {
            val chooseReserveTimeDialog = ChooseReserveTimeDialog()
            chooseReserveTimeDialog.arguments = bundleOf("title" to "设置取货时间")
            chooseReserveTimeDialog.setCallback(object :ChooseReserveTimeDialog.Callback{
                override fun onOk(s: String, formatS: String) {
                    tv_time.text = s
                    timeFormat = formatS
                }
            })
            chooseReserveTimeDialog.show(childFragmentManager,"timeLogistics")
        }
        tv_tips.onClick {
            if (cb_fast.isChecked&&!tipsDialog.isAdded){
                tipsDialog.show(childFragmentManager,"tips")
            }
        }
        tv_action.onClick {
//            if (timeFormat.isEmpty()){
//                myToast("请选择司机取货时间")
//                return@onClick
//            }
//            if (type == Const.OrderType.TYPE_SAME_CITY&&cb_fast.isChecked&&fastMoney == 0){
//                myToast("请选择加急费用")
//                return@onClick
//            }
            if (isFirstOrder){
                startActivityForResult<LogisticsGuideActivity>(Const.RequestCode.LOGISTICS_RULE)
            }else
                createOrder()
        }
        cb_fast.setOnCheckedChangeListener { _, isChecked ->
            if (!isChecked){
                fastMoney = 0
                tv_tips.text = ""
            }
        }
        tv_retry.onClick {
            getPrice()
        }
    }
 
    var savedInstanceState: Bundle? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        this.savedInstanceState = savedInstanceState
    }
 
    private var locCount = 0L //定位次数
 
    private fun initMap() {
        val fragment = childFragmentManager.findFragmentById(R.id.mMapView) as SupportMapFragment
        AMapKit.initMap(fragment){
            aMap = it
            aMap.moveCamera(
                CameraUpdateFactory.newLatLngZoom(
                    LatLng(IGoApplication.lat, IGoApplication.lon),DEFAULT_SCALE_LEVEL))
            enableMyLocation()
            aMap.uiSettings.isMyLocationButtonEnabled = false
            aMap.setOnMyLocationChangeListener {
                Log.e(Const.Tag,"物流:lat:"+it.latitude+",lon:"+it.longitude)
                IGoApplication.lat = it.latitude
                IGoApplication.lon = it.longitude
//                IGoApplication.address = it.address
//                IGoApplication.cityCode = it.extras.getString("adcode")?:""
                if (locCount<1){
                    if (mainActivity.lat!=0.0)
                        aMap.moveCamera(
                            CameraUpdateFactory.newLatLngZoom(
                                LatLng(
                                    mainActivity.lat,
                                    mainActivity.lon
                                ),DEFAULT_SCALE_LEVEL))
                    else
                        aMap.moveCamera(
                            CameraUpdateFactory.newLatLngZoom(
                                LatLng(it.latitude, it.longitude),DEFAULT_SCALE_LEVEL))
                }
                locCount++
            }
            aMap.setOnCameraMoveStartedListener {
                if (startByLocal)
                    tv_center.text = getString(R.string.local_ing)
            }
            aMap.setOnCameraIdleListener {
                if (!startByChoose&&iv_center_logistics.visibility == View.VISIBLE) {
                    startLat = aMap.cameraPosition.target.latitude
                    startLon = aMap.cameraPosition.target.longitude
                    getPoi(startLat, startLon)
                }
                startByChoose = false
                startByLocal = false
                val objectAnimator =
                    ObjectAnimator.ofFloat(iv_center_logistics, "translationY", 0f, -30f, 0f).setDuration(600)
                val objectAnimator1 =
                    ObjectAnimator.ofFloat(tv_center, "translationY", 0f, -30f, 0f).setDuration(600)
                objectAnimator.start()
                objectAnimator1.start()
                tv_center.text = getString(R.string.在这里领取)
            }
        }
    }
 
    /**
     * Enables the My Location layer if the fine location permission has been granted.
     */
    @SuppressLint("MissingPermission")
    private fun enableMyLocation() {
        // 1. Check if permissions are granted, if so, enable the my location layer
        if (ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED ||
            ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED
        ) {
            aMap.isMyLocationEnabled = true
            return
        }
        // 2. If if a permission rationale dialog should be shown  //todo 权限说明弹窗
//        if (ActivityCompat.shouldShowRequestPermissionRationale(
//                requireActivity(),
//                Manifest.permission.ACCESS_FINE_LOCATION
//            ) || ActivityCompat.shouldShowRequestPermissionRationale(
//                requireActivity(),
//                Manifest.permission.ACCESS_COARSE_LOCATION
//            )
//        ) {
//            PermissionUtils.RationaleDialog.newInstance(
//                LOCATION_PERMISSION_REQUEST_CODE, true
//            ).show(supportFragmentManager, "dialog")
//            return
//        }
        val subscribe = RxPermissions(requireActivity()).request(
            Manifest.permission.ACCESS_FINE_LOCATION,
            Manifest.permission.ACCESS_COARSE_LOCATION
        ).subscribe {
            if (it)
                enableMyLocation()
            else{
                myToast(getString(R.string.没有权限))
            }
        }
    }
 
 
    private fun createOrder(){
        showDialog()
        HttpManager.smallLogistics(carTypeId,"$endLon,$endLat",goodsNum,goodsType,"${receiveAddress}",IGoApplication.lat,
            IGoApplication.lon,receiveName,receivePhone,tv_type.text.toString(),startName,startLat,startLon,fastMoney,System.currentTimeMillis().toTime(),type,
            if (cb_fast.isChecked) 2 else 1).requestByF(this){_,data->
            data?.run {
//                if (optInt("state") == 7){
//                    val tipDialog = TipDialog()
//                    tipDialog.arguments = bundleOf("msg" to getString(R.string.有订单未支付),"ok" to getString(R.string.立即支付),"cancel" to getString(R.string.取消))
//                    tipDialog.setCallback(object :TipDialog.OnClickCallback{
//                        override fun onOk() {
//                            startActivity<OrderDetailActivity>("type" to type,"id" to optInt("id"))
//                        }
//
//                        override fun onCancel() {
//                        }
//                    })
//                    tipDialog.show(childFragmentManager,"unpay")
//                }else{
                    //startActivity<TripActivity>("type" to type, "id" to optInt("id"))
                startActivity<OrderDetailActivity>( "id" to optInt("id"), "type" to type)
                    back()
//                }
            }
 
        }
    }
 
    /**
     * @param way 1=微信,2=支付宝,3=余额,4=现金
     */
    private fun pay(way:Int,id:Int,couponId:Int?,cardId:String?){
        HttpManager.payTaxiOrder(id,way,4,couponId,cardId).requestByF(this){_,data->
            if (way in 3..4)
                onPaySuccess()
            else{
                requireActivity().toBrowser(data.toString()?:"")
            }
        }
    }
 
    /**
     * 返回
     * @param isBackHome true:直接返回到首页
     */
    fun back(isBackHome:Boolean = true) {
        isFirstOrder = true
        group_fast.gone()
        tv_action.gone()
        cl_types.gone()
        ll_type.removeAllViews()
        carTypeIndex = -1
        carTypeId = 0
        iv_center_logistics.visible()
        tv_center.visible()
        iv_location.visible()
        mainActivity.updateTitleVisibility(false,false)
        mainActivity.updateLogisticsTitle(false)
        mainActivity.updateTabVisibility(true)
        aMap.uiSettings.isScrollGesturesEnabled = true
        aMap.uiSettings.isZoomGesturesEnabled = true
        if (isBackHome){
            tv_receiver.text = ""
            receiveAddress = ""
            receiveRegion = ""
            receiveName = ""
            receivePhone = ""
            endLat = 0.0
            endLon = 0.0
//            provinceIndex = 0
//            cityIndex = 0
//            regionIndex = 0
        }
        tv_type.setText("")
        tv_start.isEnabled = true
        tv_receiver.isEnabled = true
        tv_type.isEnabled = true
        tv_time.text = ""
        timeFormat = ""
        cb_fast.isChecked = false
        tv_tips.text = ""
        fastMoney = 0
    }
 
    /**检查返回状态*/
    fun checkBack():Boolean{
        return try {
            if (tv_action.visibility == View.VISIBLE){ //先返回到上一步
                back()
                false
            }else
                true
        }catch (e: Exception){
            true
        }
    }
 
    /**
     * 获取支付金额
     */
    private fun getPrice(){
        if (startName.isNotEmpty()&&endLat!=0.0){
            tv_action.visible()
            cl_types.gone()
            showDialog()
            aMap.uiSettings.isScrollGesturesEnabled = false
            aMap.uiSettings.isZoomGesturesEnabled = false
            ll_type.removeAllViews()
            ll_type.gone()
            HttpManager.queryPayMoney("$startLon,$startLat","$endLon,$endLat",type).requestByF(this,true,{_,data->
                if (data?.isEmpty() == true){
                    tv_empty.visible()
                    tv_action.isEnabled = false
                } else{
                    tv_action.isEnabled = true
                    tv_error.gone()
                    tv_retry.gone()
                    data!!.forEachIndexed { index, it ->
                        val view = layoutInflater.inflate(R.layout.item_car_price, ll_type,false)
                        val tv_name = view.find<CheckedTextView>(R.id.tv_name)
                        val tv_price = view.find<CheckedTextView>(R.id.tv_price)
                        val iv_car = view.find<SimpleDraweeView>(R.id.iv_car)
                        val ll_car = view.find<View>(R.id.ll_car)
                        tv_name.text = it.name
                        tv_price.text = getString(R.string.预估价格,it.amount).replace(",",".")
                        iv_car.setImageURI(it.img)
                        if (index == 0){   //默认选择第一个
                            carTypeId = it.id
                            carTypeIndex = 0
                            tv_name.isChecked = true
                            tv_price.isChecked = true
                            ll_car.elevation = dip(3).toFloat()
                            ll_car.backgroundResource = R.drawable.bg_white_6dp
                        }
                        view.onClick {_->
                            showCarPriceNote(it.fareTypeNote)
                            if (index!= carTypeIndex){
                                tv_name.isChecked = true
                                tv_price.isChecked = true
                                ll_car.elevation = dip(3).toFloat()
                                ll_car.backgroundResource = R.drawable.bg_white_6dp
                                if (carTypeIndex!=-1)
                                    ll_type.getChildAt(carTypeIndex).apply {
                                        val tv_name = find<CheckedTextView>(R.id.tv_name)
                                        val tv_price = find<CheckedTextView>(R.id.tv_price)
                                        val ll_car = find<View>(R.id.ll_car)
                                        tv_name.isChecked = false
                                        tv_price.isChecked = false
                                        ll_car.elevation = 0f
                                        ll_car.backgroundResource = 0
                                    }
                                carTypeIndex = index
                                carTypeId = it.id
                            }
                        }
                        ll_type.addView(view)
                    }
                }
            }){_,_->
                tv_error.visible()
                tv_retry.visible()
                tv_action.isEnabled = false
            }
        }
    }
 
    fun changeType(newType:Int){
        if (newType != type){
            type = newType
        }
    }
 
    /**
     * 运费说明
     * 点击车型图片即弹窗说明
     */
    private fun showCarPriceNote(msg:String){
        val tipDialog = TipDialog()
        tipDialog.arguments = bundleOf("msg" to msg,"isAlert" to true,"noTitle" to true)
        tipDialog.showAllowingStateLoss(childFragmentManager,"note")
    }
 
    /**
     *   获取poi信息
     */
    private var poiSearchDisposable: DisposableSubscriber<GeoBean>? = null
 
    fun getPoi(lat: Double?, lng: Double?) {
        if (lat == null || lng == null) {
            return
        }
        //如果上一次还没处理完,取消订阅
        if (poiSearchDisposable != null && !poiSearchDisposable!!.isDisposed) {
            poiSearchDisposable?.dispose()
        }
        poiSearchDisposable = object : DisposableSubscriber<GeoBean>() {
            override fun onComplete() {
 
            }
 
            override fun onNext(t: GeoBean?) {
                val address = if (t != null&&t.status == "OK") {
                    t.results.firstOrNull()?.formatted_address
                } else {
                    null
                }
                if(activity==null||activity?.isFinishing==true) return
                runOnUiThread {
                    startName = address?:""
                    tv_start?.text = address
                }
            }
 
            override fun onError(t: Throwable?) {
                if(activity==null||activity?.isFinishing==true) return
                runOnUiThread {
                    startName = ""
                    tv_start.text = getString(R.string.选择领取点)
                }
            }
        }
        HttpManager.geoCode(lat, lng).defaultScheduler().subscribe(poiSearchDisposable)
    }
 
 
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode == Activity.RESULT_OK){
            if (requestCode == Const.RequestCode.LOGISTICS_RULE){
                createOrder()
            }
            if (data!=null)
                when(requestCode) {
                Const.RequestCode.LOGISTICS_START -> {
                    startLat = data.getDoubleExtra("lat", 0.0)
                    startLon = data.getDoubleExtra("lon", 0.0)
 
 
 
                    startByChoose = true
                    aMap.animateCamera(CameraUpdateFactory.newLatLng(LatLng(startLat, startLon)))
                    startName = data.getStringExtra("name") ?: ""
                    tv_start.text = startName
                    getPrice()
                }
                Const.RequestCode.LOGISTICS_RECEIVER -> {
                    receiveName = data.getStringExtra("name") ?: ""
                    receivePhone = data.getStringExtra("phone") ?: ""
                    receiveRegion = data.getStringExtra("region") ?: ""
                    receiveAddress = data.getStringExtra("address") ?: ""
 
 
 
 
                    endLat = data.getDoubleExtra("lat",0.0)
                    endLon = data.getDoubleExtra("lon",0.0)
 
                   /* HttpManager.judgingTheCity("${endLat},${endLon}","${startLat},${startLon}").request(mainActivity,true,{_,data->
 
                        Log.e( "onActivityResult: ", "同一城市")
                        toast("同一城市")
                    }){a,b->
                        toast("报错")
                        Log.e( "onActivityResult: error", Gson().toJson(a))
                        Log.e( "onActivityResult: error", Gson().toJson(b))
                    }*/
 
                    val receiver = "%s  %s\n%s%s".format(
                        receiveName,
                        receivePhone,
                        receiveRegion,
                        receiveAddress
                    )
                    tv_receiver.text = SpanBuilder(receiver).color(
                        requireActivity(), receiver.length - receiveAddress.length - receiveRegion.length,
                        receiver.length, R.color.textColor99
                    ).size(
                        receiver.length - receiveAddress.length - receiveRegion.length,
                        receiver.length, 12
                    ).build()
                    getPrice()
                }
                Const.RequestCode.LOGISTICS_TYPE->{
//                    isFirstOrder = data.getBooleanExtra("isFirstOrder",false)
//                    goodsType = data.getIntExtra("goodsType",0)
//                    goodsNum = data.getIntExtra("goodsNum",0)
//                    remark = data.getStringExtra("remark")?:""
//                    tv_type.text = "%sX%d".format(if (goodsType == 1) "普通小件" else "贵重物品",goodsNum)
                }
            }
        }
    }
 
    override fun onDestroy() {
        super.onDestroy()
        PayUtil.removePayListener(this)
    }
 
    override fun onPaySuccess() {
        if (!successDialog.isAdded)
            successDialog.show(requireFragmentManager(),"suc")
    }
 
    override fun onPayCancel() {
        startActivity<OrderActivity>("type" to TripOrderFragment.TYPE_LOGISTICS)
    }
}