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

// 签到成功页

parent 7fd12ff1
This diff is collapsed.
//
// YHActivitySignSuccessViewController.swift
// galaxy
//
// Created by Dufet on 2025/10/14.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHActivitySignSuccessViewController: YHBaseViewController {
private let tableView = UITableView(frame: .zero, style: .grouped)
private var hasPrize: Bool = false
private var prize: Prize?
private var event: CheckInEvent?
override func viewDidLoad() {
super.viewDidLoad()
setupUI()
setupWithPrize() // 切换到 setupWithoutPrize() 查看无奖品情况
}
private func setupUI() {
view.backgroundColor = UIColor(red: 0.85, green: 0.90, blue: 0.95, alpha: 1)
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.register(YHSignPrizeCell.self, forCellReuseIdentifier: YHSignPrizeCell.cellReuseIdentifier)
tableView.register(YHSignActivityInfoCell.self, forCellReuseIdentifier: YHSignActivityInfoCell.cellReuseIdentifier)
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.top.equalTo(k_Height_NavigationtBarAndStatuBar)
make.left.right.bottom.equalToSuperview()
}
}
// 有奖品的情况
private func setupWithPrize() {
hasPrize = true
prize = Prize(
greeting: "你好,侯林先生",
instruction: "请联系现场工作人员领取您的奖品",
image: "prize_sofa"
)
event = CheckInEvent(
title: "翱翔云端·探索无限",
subtitle: "2025无人机创新科技沙龙",
date: "2025-09-13 周六 09:30",
location: "银河集团香港体验中心(香港湾仔港湾道26号华润大厦27楼2705室)",
subLocation: "请于机导航至银河集团香港体验中心",
thumbnailImage: "event_thumb"
)
tableView.reloadData()
}
// 无奖品的情况
private func setupWithoutPrize() {
hasPrize = false
prize = nil
event = CheckInEvent(
title: "翱翔云端·探索无限",
subtitle: "2025无人机创新科技沙龙",
date: "2024-08-06 周日 09:30",
location: "本元大厦26A银河集团体验中心",
subLocation: "距地铁10号线亮马站D口步行62",
thumbnailImage: "event_thumb"
)
tableView.reloadData()
}
}
// MARK: - UITableViewDelegate & DataSource
extension YHActivitySignSuccessViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if hasPrize {
return 2 // 标题 + 奖品 + 活动信息
} else {
return 1 // 标题 + 活动信息
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if hasPrize {
if indexPath.row == 0 {
// 奖品 Cell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHSignPrizeCell.cellReuseIdentifier, for: indexPath) as? YHSignPrizeCell else {
return UITableViewCell()
}
if let prize = prize {
cell.configure(with: prize)
}
return cell
} else {
// 活动信息 Cell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHSignActivityInfoCell.cellReuseIdentifier, for: indexPath) as? YHSignActivityInfoCell else {
return UITableViewCell()
}
if let event = event {
cell.configure(with: event)
}
return cell
}
} else {
// 无奖品时,第二个就是活动信息 Cell
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHSignActivityInfoCell.cellReuseIdentifier, for: indexPath) as? YHSignActivityInfoCell else {
return UITableViewCell()
}
if let event = event {
cell.configure(with: event)
}
return cell
}
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = YHSignSuccessHeaderView()
return view
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 83
}
}
......@@ -74,3 +74,19 @@ class YHActivityModel: SmartCodable {
}
}
// MARK: - 数据模型
struct CheckInEvent {
let title: String
let subtitle: String
let date: String
let location: String
let subLocation: String
let thumbnailImage: String?
}
struct Prize {
let greeting: String
let instruction: String
let image: String
}
//
// YHSignSuccessCell.swift
// galaxy
//
// Created by Dufet on 2025/10/14.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHSignActivityInfoCell: UITableViewCell {
static let cellReuseIdentifier = "YHSignActivityInfoCell"
private let containerView = UIView()
private let titleLabel = UILabel()
private let subtitleLabel = UILabel()
private let thumbnailImageView = UIImageView()
private let timeLabel = UILabel()
private let timeValueLabel = UILabel()
private let locationLabel = UILabel()
private let locationValueLabel = UILabel()
private let subLocationLabel = UILabel()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupUI() {
backgroundColor = .clear
selectionStyle = .none
containerView.backgroundColor = UIColor(white: 0.98, alpha: 1)
containerView.layer.cornerRadius = 12
contentView.addSubview(containerView)
titleLabel.font = .systemFont(ofSize: 16, weight: .medium)
titleLabel.textColor = .black
titleLabel.numberOfLines = 0
containerView.addSubview(titleLabel)
subtitleLabel.font = .systemFont(ofSize: 16, weight: .medium)
subtitleLabel.textColor = .black
subtitleLabel.numberOfLines = 0
containerView.addSubview(subtitleLabel)
thumbnailImageView.contentMode = .scaleAspectFit
thumbnailImageView.layer.cornerRadius = 4
thumbnailImageView.clipsToBounds = true
thumbnailImageView.backgroundColor = .systemBlue.withAlphaComponent(0.2)
containerView.addSubview(thumbnailImageView)
timeLabel.text = "时间"
timeLabel.font = .systemFont(ofSize: 14)
timeLabel.textColor = .gray
containerView.addSubview(timeLabel)
timeValueLabel.font = .systemFont(ofSize: 14)
timeValueLabel.textColor = .black
timeValueLabel.numberOfLines = 0
containerView.addSubview(timeValueLabel)
locationLabel.text = "地点"
locationLabel.font = .systemFont(ofSize: 14)
locationLabel.textColor = .gray
containerView.addSubview(locationLabel)
locationValueLabel.font = .systemFont(ofSize: 14)
locationValueLabel.textColor = .black
locationValueLabel.numberOfLines = 0
containerView.addSubview(locationValueLabel)
subLocationLabel.font = .systemFont(ofSize: 12)
subLocationLabel.textColor = .lightGray
subLocationLabel.numberOfLines = 0
containerView.addSubview(subLocationLabel)
// 约束
containerView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(8)
make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
make.bottom.equalToSuperview().offset(-8)
}
titleLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(20)
make.left.equalToSuperview().offset(20)
make.right.equalTo(thumbnailImageView.snp.left).offset(-12)
}
subtitleLabel.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(4)
make.left.equalToSuperview().offset(20)
make.right.equalTo(thumbnailImageView.snp.left).offset(-12)
}
thumbnailImageView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.width.height.equalTo(60)
}
timeLabel.snp.makeConstraints { make in
make.top.equalTo(subtitleLabel.snp.bottom).offset(20)
make.left.equalToSuperview().offset(20)
make.width.equalTo(50)
}
timeValueLabel.snp.makeConstraints { make in
make.centerY.equalTo(timeLabel)
make.left.equalTo(timeLabel.snp.right).offset(12)
make.right.equalToSuperview().offset(-20)
}
locationLabel.snp.makeConstraints { make in
make.top.equalTo(timeLabel.snp.bottom).offset(16)
make.left.equalToSuperview().offset(20)
make.width.equalTo(50)
}
locationValueLabel.snp.makeConstraints { make in
make.top.equalTo(locationLabel)
make.left.equalTo(locationLabel.snp.right).offset(12)
make.right.equalToSuperview().offset(-20)
}
subLocationLabel.snp.makeConstraints { make in
make.top.equalTo(locationValueLabel.snp.bottom).offset(8)
make.left.equalTo(locationValueLabel)
make.right.equalToSuperview().offset(-20)
make.bottom.equalToSuperview().offset(-20)
}
}
func configure(with event: CheckInEvent) {
titleLabel.text = event.title
subtitleLabel.text = event.subtitle
timeValueLabel.text = event.date
locationValueLabel.text = event.location
subLocationLabel.text = event.subLocation
if let imageName = event.thumbnailImage, let image = UIImage(named: imageName) {
thumbnailImageView.image = image
}
}
}
//
// YHSignPrizeCellTableViewCell.swift
// galaxy
//
// Created by Dufet on 2025/10/14.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHSignPrizeCell: UITableViewCell {
static let cellReuseIdentifier = "YHSignPrizeCell"
private let containerView = UIView()
private let greetingLabel = UILabel()
private let instructionLabel = UILabel()
private let prizeImageView = UIImageView()
private let overlayButton = UIButton()
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupUI() {
backgroundColor = .clear
selectionStyle = .none
containerView.backgroundColor = UIColor(white: 0.98, alpha: 1)
containerView.layer.cornerRadius = 12
contentView.addSubview(containerView)
greetingLabel.font = .systemFont(ofSize: 20, weight: .medium)
greetingLabel.textColor = .black
containerView.addSubview(greetingLabel)
instructionLabel.font = .systemFont(ofSize: 14)
instructionLabel.textColor = .gray
containerView.addSubview(instructionLabel)
prizeImageView.contentMode = .scaleAspectFill
prizeImageView.clipsToBounds = true
prizeImageView.layer.cornerRadius = 8
prizeImageView.backgroundColor = .lightGray
containerView.addSubview(prizeImageView)
overlayButton.setTitle("一步了解", for: .normal)
overlayButton.setTitleColor(.white, for: .normal)
overlayButton.titleLabel?.font = .systemFont(ofSize: 14)
overlayButton.layer.cornerRadius = 16
overlayButton.layer.borderWidth = 1
overlayButton.layer.borderColor = UIColor.white.cgColor
prizeImageView.addSubview(overlayButton)
containerView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(8)
make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
make.bottom.equalToSuperview().offset(-8)
}
greetingLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(20)
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
}
instructionLabel.snp.makeConstraints { make in
make.top.equalTo(greetingLabel.snp.bottom).offset(8)
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
}
prizeImageView.snp.makeConstraints { make in
make.top.equalTo(instructionLabel.snp.bottom).offset(16)
make.left.equalToSuperview().offset(20)
make.right.equalToSuperview().offset(-20)
make.bottom.equalToSuperview().offset(-20)
make.height.equalTo(200)
}
overlayButton.snp.makeConstraints { make in
make.left.equalToSuperview().offset(16)
make.bottom.equalToSuperview().offset(-16)
make.width.equalTo(100)
make.height.equalTo(32)
}
}
func configure(with prize: Prize) {
greetingLabel.text = prize.greeting
instructionLabel.text = prize.instruction
if let image = UIImage(named: prize.image) {
prizeImageView.image = image
}
}
}
//
// YHSignSuccessHeaderView.swift
// galaxy
//
// Created by Dufet on 2025/10/14.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHSignSuccessHeaderView: UIView {
private let checkIconView = UIImageView()
private let titleLabel = UILabel()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private func setupUI() {
backgroundColor = .clear
checkIconView.image = UIImage(systemName: "checkmark.circle")
checkIconView.tintColor = .black
addSubview(checkIconView)
titleLabel.text = "签到成功"
titleLabel.font = .systemFont(ofSize: 28, weight: .semibold)
titleLabel.textColor = .black
addSubview(titleLabel)
checkIconView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(24)
make.left.equalToSuperview().offset(32)
make.width.height.equalTo(36)
make.bottom.equalToSuperview().offset(-24)
}
titleLabel.snp.makeConstraints { make in
make.centerY.equalTo(checkIconView)
make.left.equalTo(checkIconView.snp.right).offset(12)
}
}
}
......@@ -764,6 +764,13 @@ extension YHMyNewViewController {
}
func clickItem(_ item: PersonalModuleItem) {
if true {
let vc = YHActivitySignSuccessViewController()
self.navigationController?.pushViewController(vc)
return
}
if !checkLogin() {
return
}
......
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