package com.zxhl.main.page.activity

import android.text.TextUtils
import android.util.Log
import android.view.View
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.NetConfig
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.model.box.DepotEntity
import com.zxhl.cms.utils.JumpUtils
import com.zxhl.cms.utils.RxBus
import com.zxhl.cms.utils.Utils
import com.zxhl.main.R
import com.zxhl.main.page.contract.GoodsReceiveContract
import com.zxhl.main.page.presenter.GoodsReceivePresenter
import kotlinx.android.synthetic.main.activity_layout_goods_receive.*

class GoodsReceiveActivity : BaseActivity(), GoodsReceiveContract.View {
    private var mPresenter: GoodsReceivePresenter? = null
    private var id: String? = ""
    private var mobile: String? = ""
    override fun onClick(v: View?) {

    }
    override fun before() {
        super.before()
        setStatusBarBackground(AppContext.get().resources.getColor(R.color.white))
    }


    override fun layoutID(): Int {
        return R.layout.activity_layout_goods_receive
    }

    override fun init() {
        id_img_back?.setOnClickListener {
            finish()
        }
        id_tv_kefu?.setOnClickListener {
            JumpUtils.webJump("客服",NetConfig.H5.WEB_URL_CUSTOMER_SERVICE)
        }
        val goodsBean: DepotEntity = intent.getSerializableExtra("goodsbean") as DepotEntity
        Log.e("MXL", "数据" + goodsBean?.id + goodsBean?.products)
        mPresenter = GoodsReceivePresenter(this)
        // mPresenter?.goodsPickUp("", "")
        id_img_goods_main?.setLoadImageUrl(goodsBean.products?.mainImage, false)
        id_tv_goods_name?.text = goodsBean.products?.productName
        id_tv_jinbi?.text = goodsBean.amountSpent
        id = goodsBean.id

        id_tv_receive?.setOnClickListener {
            if (!TextUtils.isEmpty(id_edit_goods_moble.text.toString())
            ) {
                mPresenter?.goodsPickUp(id, id_edit_goods_moble.text.toString())
            } else {
                Utils.showToast(this, "请输入正确的账号")
            }
        }
    }

    //提货成功
    override fun pickupSuccess() {
        JumpUtils.ShipmentSuccessJump()
        finish()
    }

    override fun pickupFail() {
        Utils.showToast(this, "信息输入有误")
    }
}