package com.kuanzhai.user.ui.mine
|
|
import android.webkit.WebChromeClient
|
import android.webkit.WebSettings
|
import android.webkit.WebViewClient
|
import com.kuanzhai.user.R
|
import com.kuanzhai.user.network.HttpManager
|
import com.kuanzhai.user.network.entity.Card
|
import com.kuanzhai.user.network.request
|
import com.kuanzhai.user.ui.TransparentStatusBarActivity
|
import com.kuanzhai.user.utils.Const
|
import kotlinx.android.synthetic.main.activity_card_detail.*
|
import kotlinx.android.synthetic.main.item_card_coupon.view.*
|
|
class MyCardDetailActivity:TransparentStatusBarActivity() {
|
override fun setContentView() = R.layout.activity_card_detail
|
|
private val card by lazy { intent.getParcelableExtra<Card>("card") }
|
private val orderType by lazy { intent.getIntExtra("type",0) }
|
|
override fun initClick() {
|
}
|
|
override fun initView() {
|
title = "会员卡详情"
|
card?.apply {
|
tv_type.text = when(orderType){
|
Const.OrderType.TYPE_TAXI->"出租车"
|
Const.OrderType.TYPE_SPECIAL->"快车/专车"
|
Const.OrderType.TYPE_CROSS_CITY->"跨城出行"
|
Const.OrderType.TYPE_TRANS_CROSS->"跨城物流"
|
Const.OrderType.TYPE_SAME_CITY->"同城物流"
|
else->""
|
}
|
tv_type_1.text = tv_type.text
|
tv_title.text = name
|
tv_describe.text = "%s|%s可用".format(getCardInfo(),cityName)
|
val deadline = if (endTime.isNotEmpty()) "有效期至:${endTime}" else ""
|
val count = if (time.isNotEmpty()&&deadline.isNotEmpty()) "还剩${lastTime}次" else if (lastTime.isNotEmpty()) "剩余次数:还剩${lastTime}次" else ""
|
tv_deadline.text = if (deadline.isNotEmpty()&&count.isNotEmpty()) "$deadline | $count"
|
else if (deadline.isNotEmpty()) deadline else count
|
tv_deadline_1.text = "购买后%s天内有效".format(validDate)
|
tv_detail.text = "购买后%s\n%s可用".format(getCardInfo(),cityName)
|
}
|
|
val settings = tv_rule.settings
|
settings.javaScriptEnabled = true
|
settings.javaScriptCanOpenWindowsAutomatically = true
|
settings.defaultTextEncodingName = "utf-8"
|
settings.domStorageEnabled = true
|
settings.setSupportZoom(true)
|
// settings.textZoom = 200
|
settings.useWideViewPort = true
|
settings.loadWithOverviewMode = true
|
settings.layoutAlgorithm = WebSettings.LayoutAlgorithm.TEXT_AUTOSIZING
|
tv_rule.webChromeClient = object : WebChromeClient() {}
|
tv_rule.webViewClient = object : WebViewClient() {}
|
|
getData()
|
}
|
|
private fun getData() {
|
HttpManager.getMyTaxiCardInfo(card!!.id).request(this){ _, data->
|
data?.couponList?.forEach {
|
val inflate = layoutInflater.inflate(R.layout.item_my_card_coupon, ll_coupon, false)
|
inflate.tv_title_coupon.text = it.couponName
|
inflate.tv_range.text =
|
if (it.type == 2)
|
"%s满%.2f元减%.2f元".format(if (it.userType == 0) "无门槛" else it.getCardRangeStr(),it.fullMoney,it.money)
|
else
|
"%s%.2f元抵扣券".format(if (it.userType == 0) "无门槛" else it.getCardRangeStr(),it.money)
|
inflate.tv_money.text = "%.2f".format(it.money)
|
ll_coupon.addView(inflate)
|
}
|
val sHead =
|
"<html><head><meta name=\"viewport\" content=\"width=device-width, " + "initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes\" />" + "<style>img{max-width:100% !important;height:auto !important;}</style>" + "<style>body{max-width:100% !important;}</style>" + "</head><body>"
|
tv_rule.loadDataWithBaseURL(null,sHead+data!!.note, "text/html; charset=utf-8", "utf-8",null)
|
if (data.timeQuantum.isNullOrEmpty()||data.timeQuantum[0] == "00:00:00 - 23:59:59"){
|
tv_type_1.text = "全天可用"
|
}else{
|
val joinToString = data.timeQuantum.joinToString("") {
|
it.replace(" ", "") + (if (data.timeQuantum.indexOf(it) % 2 == 0) " " else "\n")
|
}
|
tv_type_1.text = joinToString.substring(0,joinToString.length-1) +"可用"
|
}
|
}
|
}
|
|
}
|