123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- //
- // YMMainGoodCollectionCell.swift
- // MvpGoods
- //
- // Created by 小花 on 2019/4/9.
- // Copyright © 2019 MVP. All rights reserved.
- //
- import UIKit
- class YMMainGoodCollectionCell: UICollectionViewCell {
-
- // var imgView: UIImageView!
- // var titleLabel: UILabel?
- // var originPrice: UILabel?
- // var disPrice: UILabel?
- // var ticketBg: UIImageView?
- // var disPriceBg: UIImageView?
- // var disPriceType: UILabel?
- //
-
- convenience required init?(coder aDecoder: NSCoder) {
- self.init()
- }
-
- override init(frame: CGRect) {
- super.init(frame: frame)
- self.backgroundColor = UIColor.white
- configSubViews()
- }
-
- var model: YMMainGoodModel? {
- didSet {
- imgView.setFadeImage(with: model?.img)
- titleLabel.text = model?.title
- originPrice.text = "¥\(model?.price ?? ("未知"))"
- let ticket = model!.coupon_price
- ticketNum.text = "\(ticket ?? 0)"+"元"
- disPrice.text = "¥"+(model?.discount_price ?? "")
- }
- }
-
- func configSubViews() {
- self.contentView.addSubview(titleLabel)
- self.contentView.addSubview(imgView)
- self.contentView.addSubview(originPrice)
- self.contentView.addSubview(ticketBg)
- ticketBg.addSubview(ticketType)
- ticketBg.addSubview(ticketNum)
- self.contentView.addSubview(disPriceBg)
- disPriceBg.addSubview(disPrice)
- disPriceBg.addSubview(disText)
-
- imgView.snp.makeConstraints { (make) in
- make.left.equalTo(13)
- make.top.equalTo(10)
- make.bottom.equalTo(-10)
- make.width.equalTo(imgView.snp.height)
- }
-
- titleLabel.snp.makeConstraints { (make) in
- make.left.equalTo(imgView.snp.right).offset(8)
- make.right.equalTo(-10)
- make.top.equalTo(14)
- }
-
- originPrice.snp.makeConstraints { (make) in
- make.left.equalTo(titleLabel.snp.left)
- make.centerY.equalTo(imgView.snp.centerY)
- }
-
- ticketBg.snp.makeConstraints { (make) in
- make.left.equalTo(imgView.snp.right).offset(fitSize(x: 80))
- make.centerY.equalTo(imgView.snp.centerY)
- make.width.equalTo(62)
- make.height.equalTo(15)
- }
-
- ticketType.snp.makeConstraints { (make) in
- make.left.top.bottom.equalTo(0)
- make.width.equalTo(20)
- }
-
- ticketNum.snp.makeConstraints { (make) in
- make.top.right.bottom.equalTo(0)
- make.height.left.equalTo(20)
- }
-
- disPriceBg.snp.makeConstraints { (make) in
- make.left.equalTo(titleLabel)
- make.bottom.equalTo(imgView.snp.bottom).offset(-4)
- make.width.equalTo(102)
- make.height.equalTo(17)
- }
-
- disPrice.snp.makeConstraints { (make) in
- make.left.equalTo(5)
- make.top.equalTo(0)
- make.bottom.equalTo(0)
- make.width.equalTo(41)
- }
-
- disText.snp.makeConstraints { (make) in
- make.left.equalTo(51)
- make.top.right.bottom.equalTo(0)
- }
-
-
- }
-
- lazy var imgView: UIImageView = {
- let img = UIImageView()
- img.backgroundColor = UIColor.gloadGrayColor()
- return img
- }()
-
- lazy var titleLabel: UILabel = {
- let title = UILabel()
- title.textColor = UIColor.hexadecimalColor(hexadecimal: "#262626")
- title.font = UIFont.boldSystemFont(ofSize: 15)
- title.numberOfLines = 2
-
- return title
- }()
-
- lazy var originPrice: UILabel = {
- let price = UILabel()
- price.textColor = UIColor.gloadRedColor()
- price.font = UIFont.systemFont(ofSize: 16)
- return price;
- }()
-
- lazy var ticketBg: UIImageView = {
- let ticket = UIImageView()
- ticket.image = UIImage(named: "ticketBg")
- return ticket;
- }()
-
- lazy var ticketType: UILabel = {
- let type = UILabel()
- type.textColor = UIColor.white
- type.font = UIFont.systemFont(ofSize: 9)
- type.textAlignment = NSTextAlignment.center
- type.text = "券"
- return type
- }()
-
- lazy var ticketNum: UILabel = {
- let num = UILabel()
- num.textColor = UIColor.white
- num.font = UIFont.systemFont(ofSize: 9)
- num.textAlignment = NSTextAlignment.center
- return num
- }()
-
- lazy var disPriceBg: UIImageView = {
- let bg = UIImageView()
- bg.image = UIImage(named: "disBg")
- return bg
- }()
-
- lazy var disText: UILabel = {
- let text = UILabel()
- text.text = "券后价"
- text.textColor = UIColor.hexadecimalColor(hexadecimal: "#443F36")
- text.font = UIFont.systemFont(ofSize: 12)
- text.textAlignment = NSTextAlignment.center
- return text
- }()
-
- lazy var disPrice: UILabel = {
- let dis = UILabel()
- dis.textColor = UIColor.hexadecimalColor(hexadecimal: "#FFE4A0")
- // dis.textAlignment = NSTextAlignment.center
- dis.adjustsFontSizeToFitWidth = true
- dis.baselineAdjustment = UIBaselineAdjustment.alignCenters
-
- return dis
- }()
-
-
-
- }
|