package com.medical.ydl.medical.pay

import android.content.Context
import android.content.Intent
import com.medical.ydl.medical.modular.MedicalPayIn
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.utils.StatusBarUtils
import kotlinx.android.synthetic.main.medical_pay_success_activity.*
import java.util.*

/**
 * 医疗 成功页
 * */

class MedicalPaySuccessActivity : BaseActivity() {
    companion object {
        //跳转药品订单列表
        private const val MEDICAL_ORDER_LIST_KEY = "medical_order_list"
        private const val PRICE_KEY = "price"
        private const val ORDER_KEY = "orderId"
        private lateinit var mPrice: String
        private lateinit var mOrderId: String

        /**
         * @param price 价格
         * @param orderId 订单id
         * */
        @JvmStatic
        fun start(context: Context, price: String, orderId: String) {
            val starter = Intent(context, MedicalPaySuccessActivity::class.java)
                .putExtra(PRICE_KEY, price)
                .putExtra(ORDER_KEY, orderId)
            context.startActivity(starter)
        }
    }

    override fun layoutResId(): Int {
        return R.layout.medical_pay_success_activity
    }

    override fun initDataAndEvent() {
        initStatus()
        mPrice = intent.getStringExtra(PRICE_KEY)
        mOrderId = intent.getStringExtra(ORDER_KEY)
        price.text = mPrice


        iv_back.setOnClickListener {
            onBackPressed()
        }
        to_order.setOnClickListener {
            //查看药品订单
            NewH5Activity.start(
                this@MedicalPaySuccessActivity,
                H5Params(
                    HttpConfig.MEDICAL_H5URL + "ct/drug/order/details" + "?drugOrderId=" + mOrderId + "&hideNavBar=1",
                    "订单详情"
                )
            )
        }

    }

    override fun onBackPressed() {
        MedicalPayIn.mainIntentToWebView(MEDICAL_ORDER_LIST_KEY,"")
        finish()
    }


    private fun initStatus() {
        StatusBarUtils.setTransparentForImageView(this@MedicalPaySuccessActivity, null)
        StatusBarUtils.statusBarLightMode(this@MedicalPaySuccessActivity)
    }
}