lmw
2023-06-16 03972ad1d3ce6ffe0be0395c0a4d5dcb4474031f
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
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()
        }
    }
 
}