Commit b356a990 authored by Steven杜宇's avatar Steven杜宇

// vip

parent b1abbf19
......@@ -8,6 +8,13 @@
import UIKit
enum YHUserVipLevel: Int {
case none = 0
case gold = 1
case platinum = 2
case diamond = 3
}
class YHUserVipFunctionInfoView: UIView {
var title: String = "" {
......@@ -54,6 +61,11 @@ class YHUserVipFunctionInfoView: UIView {
fatalError("init(coder:) has not been implemented")
}
func update(titleColor: UIColor, descColor: UIColor) {
titleLabel.textColor = titleColor
descLabel.textColor = descColor
}
private func createUI() {
self.addSubview(lineView)
......@@ -85,9 +97,15 @@ class YHUserVipFunctionInfoView: UIView {
class YHUserVipInfoView: UIView {
var vipLevel: YHUserVipLevel = .none {
didSet {
updateVipLevel(vipLevel)
}
}
lazy var bgImgView: UIImageView = {
let imgV = UIImageView()
imgV.image = UIImage(named: "mine_member_bg_vip_1")
imgV.image = UIImage(named: "mine_member_bg_vip_0")
return imgV
}()
......@@ -205,29 +223,77 @@ class YHUserVipInfoView: UIView {
make.bottom.equalTo(0)
}
self.update(growValue: 0)
self.vipLevel = .none
self.update(growValue: 0, vipLevel: self.vipLevel)
}
func updateVipLevel(_ vipLevel: YHUserVipLevel) {
if vipLevel == .gold {
self.bgImgView.image = UIImage(named: "mine_member_bg_vip_1")
self.titleLabel.text = "黄金会员"
self.titleLabel.textColor = .white
self.rightBtn.backgroundColor = UIColor(hex: 0x5A2C0E)
self.rightBtn.setTitleColor(.white, for: .normal)
function1View.update(titleColor: .white, descColor: UIColor(hex: 0xFFFFFF, alpha: 0.6))
function2View.update(titleColor: .white, descColor: UIColor(hex: 0xFFFFFF, alpha: 0.6))
function3View.update(titleColor: .white, descColor: UIColor(hex: 0xFFFFFF, alpha: 0.6))
} else if vipLevel == .platinum {
self.bgImgView.image = UIImage(named: "mine_member_bg_vip_2")
self.titleLabel.text = "铂金会员"
self.titleLabel.textColor = .white
self.rightBtn.backgroundColor = UIColor(hex: 0x382F6B)
self.rightBtn.setTitleColor(.white, for: .normal)
function1View.update(titleColor: .white, descColor: UIColor(hex: 0xFFFFFF, alpha: 0.6))
function2View.update(titleColor: .white, descColor: UIColor(hex: 0xFFFFFF, alpha: 0.6))
function3View.update(titleColor: .white, descColor: UIColor(hex: 0xFFFFFF, alpha: 0.6))
} else if vipLevel == .diamond {
self.bgImgView.image = UIImage(named: "mine_member_bg_vip_3")
self.titleLabel.text = "钻石会员"
self.titleLabel.textColor = .init(hex: 0xE0C9AF)
self.rightBtn.backgroundColor = UIColor(hex: 0xE0C9AF)
self.rightBtn.setTitleColor(.init(hex: 0x12296F), for: .normal)
function1View.update(titleColor: UIColor(hex: 0xE0C9AF), descColor: UIColor(hex: 0xE0C9AF, alpha: 0.6))
function2View.update(titleColor: UIColor(hex: 0xE0C9AF), descColor: UIColor(hex: 0xE0C9AF, alpha: 0.6))
function3View.update(titleColor: UIColor(hex: 0xE0C9AF), descColor: UIColor(hex: 0xE0C9AF, alpha: 0.6))
} else {
self.bgImgView.image = UIImage(named: "mine_member_bg_vip_0")
self.titleLabel.text = "大众会员"
self.titleLabel.textColor = .white
self.rightBtn.backgroundColor = UIColor(hex: 0x323849)
self.rightBtn.setTitleColor(.white, for: .normal)
function1View.update(titleColor: .white, descColor: UIColor(hex: 0xFFFFFF, alpha: 0.6))
function2View.update(titleColor: .white, descColor: UIColor(hex: 0xFFFFFF, alpha: 0.6))
function3View.update(titleColor: .white, descColor: UIColor(hex: 0xFFFFFF, alpha: 0.6))
}
}
func update(growValue: Int) {
func update(growValue: Int, vipLevel: YHUserVipLevel) {
let text = "当前成长值"
let count = " \(growValue)"
var textColor = UIColor(hex: 0xFFFFFF, alpha: 0.6)
if vipLevel == .diamond {
textColor = UIColor(hex: 0xE0C9AF, alpha: 0.6)
}
let attrStr = NSMutableAttributedString(string: "")
let countAttrStr = NSAttributedString(
string: count,
attributes: [NSAttributedString.Key.foregroundColor: UIColor(hex: 0xFFFFFF, alpha: 0.6),
attributes: [NSAttributedString.Key.foregroundColor: textColor,
NSAttributedString.Key.font: UIFont(name: "DINAlternate-Bold", size: 13)!])
let titleAttrStr = NSAttributedString(
string: text,
attributes: [NSAttributedString.Key.foregroundColor: UIColor(hex: 0xFFFFFF, alpha: 0.6),
attributes: [NSAttributedString.Key.foregroundColor: textColor,
NSAttributedString.Key.font: UIFont.PFSC_R(ofSize: 12)])
attrStr.append(titleAttrStr)
attrStr.append(countAttrStr)
growValueLabel.attributedText = attrStr
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 2033197226@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 2033197226@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -5,12 +5,12 @@
"scale" : "1x"
},
{
"filename" : "Group 2033197226@2x.png",
"filename" : "Group 2033197225@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 2033197226@3x.png",
"filename" : "Group 2033197225@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
......@@ -5,12 +5,12 @@
"scale" : "1x"
},
{
"filename" : "Group 2033197225@2x.png",
"filename" : "会员入口卡片-铂金@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 2033197225@3x.png",
"filename" : "会员入口卡片-铂金@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "mine_member_bg_vip_4@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "mine_member_bg_vip_4@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -5,12 +5,12 @@
"scale" : "1x"
},
{
"filename" : "Group 2033197211@2x.png",
"filename" : "Group 2033197212@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 2033197211@3x.png",
"filename" : "Group 2033197212@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
......@@ -5,12 +5,12 @@
"scale" : "1x"
},
{
"filename" : "Group 2033197212@2x.png",
"filename" : "mine_vip_2@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 2033197212@3x.png",
"filename" : "Group 2033197214@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 2033197215@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 2033197215@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment