package com.kuanzhai.user.ui.mine
|
|
import cn.bingoogolapple.qrcode.zxing.QRCodeEncoder
|
import cn.sinata.xldutils.invisible
|
import cn.sinata.xldutils.utils.parserTime
|
import cn.sinata.xldutils.visible
|
import com.kuanzhai.user.R
|
import com.kuanzhai.user.network.entity.BusinessCoupon
|
import com.kuanzhai.user.ui.TransparentStatusBarActivity
|
import kotlinx.android.synthetic.main.activity_coupon_detail.*
|
import org.jetbrains.anko.backgroundResource
|
import org.jetbrains.anko.dip
|
|
class CouponDetailActivity:TransparentStatusBarActivity() {
|
override fun setContentView() = R.layout.activity_coupon_detail
|
|
private val data by lazy { intent.getParcelableExtra<BusinessCoupon>("data") }
|
private val disable by lazy { intent.getBooleanExtra("disable",false) }
|
|
override fun initClick() {
|
}
|
|
override fun initView() {
|
title = "我的优惠券"
|
data?.apply {
|
if (type == 1){
|
tv_money.text = "%.2f".format(discount)
|
tv_range.text = "店铺购买满%.2f使用".format(fullAmount)
|
}else{
|
tv_range.text = content
|
gp_money.invisible()
|
tv_type.visible()
|
}
|
tv_title.text = name
|
val l = endTime.parserTime() - System.currentTimeMillis()
|
tv_info.text = if (l<=0) "已到期" else "距离到期仅剩%d天".format(l /(24*60*60*1000L)+1)
|
iv_avatar.setImageURI(headImg)
|
tv_name.text = merchantName
|
tv_shop.text = "商家地址:%s\n姓名:%s\n电话:%s".format(address,contactName,contactPhone)
|
val syncEncodeQRCode =
|
QRCodeEncoder.syncEncodeQRCode("merchantCoupon:%s".format(code), dip(150))
|
iv_code.setImageBitmap(syncEncodeQRCode)
|
}
|
if (disable){
|
cl_left.backgroundResource = R.mipmap.bg_coupon_grey
|
cl_right.backgroundResource = R.mipmap.bg_coupon_right_grey
|
iv_tag.visible()
|
}
|
}
|
|
}
|