Commit dd5d3f13 authored by pete谢兆麟's avatar pete谢兆麟

邀请有礼UI和逻辑

parent af824118
......@@ -288,6 +288,8 @@
047AA3EA2C4A6FB7009C4554 /* YHDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3E92C4A6FB7009C4554 /* YHDetailViewController.swift */; };
047AA3ED2C4A70F6009C4554 /* YHHeadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3EC2C4A70F6009C4554 /* YHHeadView.swift */; };
047AA3F02C4F912D009C4554 /* YHListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3EF2C4F912D009C4554 /* YHListViewModel.swift */; };
047AA3F42C50E5C7009C4554 /* YHInvitationWithGiftsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3F32C50E5C7009C4554 /* YHInvitationWithGiftsViewModel.swift */; };
047AA3F62C50E773009C4554 /* YHShareCashOutModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047AA3F52C50E773009C4554 /* YHShareCashOutModel.swift */; };
0480976B2BA15269000B9DCA /* YHCertificateInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */; };
0480976D2BA158A1000B9DCA /* YHCertificateListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */; };
048097712BA18D66000B9DCA /* YHCertificateSearchBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */; };
......@@ -905,6 +907,8 @@
047AA3E92C4A6FB7009C4554 /* YHDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHDetailViewController.swift; sourceTree = "<group>"; };
047AA3EC2C4A70F6009C4554 /* YHHeadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHeadView.swift; sourceTree = "<group>"; };
047AA3EF2C4F912D009C4554 /* YHListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHListViewModel.swift; sourceTree = "<group>"; };
047AA3F32C50E5C7009C4554 /* YHInvitationWithGiftsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHInvitationWithGiftsViewModel.swift; sourceTree = "<group>"; };
047AA3F52C50E773009C4554 /* YHShareCashOutModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHShareCashOutModel.swift; sourceTree = "<group>"; };
0480976A2BA15269000B9DCA /* YHCertificateInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateInfoCell.swift; sourceTree = "<group>"; };
0480976C2BA158A1000B9DCA /* YHCertificateListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateListVC.swift; sourceTree = "<group>"; };
048097702BA18D66000B9DCA /* YHCertificateSearchBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateSearchBar.swift; sourceTree = "<group>"; };
......@@ -1313,6 +1317,7 @@
0419A0952C48F79100A5FCFA /* InvitationWithGifts(邀请有礼) */ = {
isa = PBXGroup;
children = (
047AA3F22C50E2D0009C4554 /* VM */,
0419A0982C48F81D00A5FCFA /* V */,
0419A0972C48F81300A5FCFA /* M */,
0419A0962C48F80B00A5FCFA /* C */,
......@@ -1332,6 +1337,7 @@
0419A0972C48F81300A5FCFA /* M */ = {
isa = PBXGroup;
children = (
047AA3F52C50E773009C4554 /* YHShareCashOutModel.swift */,
);
path = M;
sourceTree = "<group>";
......@@ -2211,6 +2217,14 @@
path = VM;
sourceTree = "<group>";
};
047AA3F22C50E2D0009C4554 /* VM */ = {
isa = PBXGroup;
children = (
047AA3F32C50E5C7009C4554 /* YHInvitationWithGiftsViewModel.swift */,
);
path = VM;
sourceTree = "<group>";
};
04808C022B4686510056D53C /* Frameworks */ = {
isa = PBXGroup;
children = (
......@@ -3403,6 +3417,7 @@
A567E5962BD7643D00D5D5A0 /* YHConfigModel.swift in Sources */,
04FD85722C21786900BEF9C5 /* YHNameCardInfoView.swift in Sources */,
044D0C182C22AB7300C5CF5E /* YHEditBaseInfoFootView.swift in Sources */,
047AA3F42C50E5C7009C4554 /* YHInvitationWithGiftsViewModel.swift in Sources */,
04CE1AD52C2AD91F001CB80A /* YHActivityTravelViewController.swift in Sources */,
A514E5DC2B60A2B700C93951 /* YHServiceCenterSecondViewController.swift in Sources */,
A5EF21372BA6E2D1005027E6 /* YHQuestionAndAnswerModel.swift in Sources */,
......@@ -3936,6 +3951,7 @@
045EEECC2B9F171A0022A143 /* YHScoreResultModel.swift in Sources */,
045EEEDC2B9F171A0022A143 /* YHQualificationDetailVC.swift in Sources */,
045EEEF52B9F171A0022A143 /* YHSpouseInfoContainerVC.swift in Sources */,
047AA3F62C50E773009C4554 /* YHShareCashOutModel.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
......@@ -12,6 +12,7 @@ class YHInvitationWithGiftsViewController: YHBaseViewController {
var tableView: UITableView!
var bottomViewForShare: YHInvitationWithGiftsShareBottomView!
var viewModel: YHInvitationWithGiftsViewModel = YHInvitationWithGiftsViewModel()
lazy var headView : YHInvitationWithGiftsHeadView = {
let headView = YHInvitationWithGiftsHeadView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 666))
......@@ -36,6 +37,8 @@ extension YHInvitationWithGiftsViewController: UITableViewDelegate, UITableViewD
return cell
} else {
let cell = tableView.dequeueReusableCell(withClass: YHInvitationWithGiftsSecondTableViewCell.self)
cell.headData = self.viewModel.overviewModel
cell.tableData = self.viewModel.recordModel
return cell
}
}
......@@ -44,8 +47,14 @@ extension YHInvitationWithGiftsViewController: UITableViewDelegate, UITableViewD
if indexPath.row == 0 {
return 209
} else if indexPath.row == 1 {
if self.viewModel.recordModel.list.count == 0 {
return 345
} else if self.viewModel.recordModel.list.count <= 10 {
return CGFloat(305 + 40 * self.viewModel.recordModel.list.count)
} else {
return 673
}
}
return 0
}
......@@ -132,6 +141,19 @@ extension YHInvitationWithGiftsViewController {
}
func loadData() {
viewModel.getCashOutRecord {[weak self] success, error in
guard let self = self else { return }
self.headView.dataSource = self.viewModel.model
}
viewModel.getOverviewRecord {[weak self] success, error in
guard let self = self else { return }
self.tableView.reloadData()
}
viewModel.postRecord(page: 1) {[weak self] success, error in
guard let self = self else { return }
self.tableView.reloadData()
}
}
}
//
// YHShareCashOutModel.swift
// galaxy
//
// Created by EDY on 2024/7/24.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHShareCashOutModel: YHBaseModel {
var mobile: String = ""
var amount: String = ""
var time: String = ""
}
class YHShareOverviewModel: YHBaseModel {
var register_count: Int = 0
var evaluated_count: Int = 0
var signed_up_count: Int = 0
var cycle: YHShareOverviewCycleModel = YHShareOverviewCycleModel()
}
class YHShareOverviewCycleModel: YHBaseModel {
var begin_date: String = ""
var end_date: String = ""
}
class YHShareRecordModel: YHBaseModel {
var page_count: Int = 0
var list: [YHShareRecordListModel] = []
}
class YHShareRecordListModel: YHBaseModel {
var mobile: String = ""
var register_time: String = ""
var is_registered: Bool = false
var is_evaluated: Bool = false
var is_signed_up: Bool = false
}
......@@ -11,6 +11,35 @@ import UIKit
class YHInvitationWithGiftsHeadView: UIView {
var centerImageView: UIImageView!
var bottomImageView: UIImageView!
var bgView: UIView!
var marqueeLabel: UILabel!
var timer: Timer?
var currentOffset: CGFloat = 0
var dataSource: [YHShareCashOutModel]? {
didSet {
guard let dataSource = dataSource else { return }
if dataSource.count == 0 {
bgView.isHidden = true
} else {
bgView.isHidden = false
var index = 0
let model = dataSource.first ?? YHShareCashOutModel()
marqueeLabel.text = "\(model.mobile) 已提现 \(model.amount) 元"
timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { [weak self] _ in
index = index + 1
UIView.animate(withDuration: 0.5) {
self?.marqueeLabel.frame.origin.y = -30
} completion: { flag in
let resultIndex = index % dataSource.count
let resultModel = dataSource[resultIndex]
self?.marqueeLabel.text = "\(resultModel.mobile) 已提现 \(resultModel.amount) 元"
self?.marqueeLabel.frame.origin.y = 0
}
}
}
}
}
override init(frame: CGRect) {
super.init(frame: frame)
......@@ -47,6 +76,38 @@ class YHInvitationWithGiftsHeadView: UIView {
make.bottom.equalTo(-8)
}
bgView = {
let view = UIView()
view.backgroundColor = .white
view.clipsToBounds = true
view.layer.masksToBounds = true
view.layer.cornerRadius = 15
view.isHidden = true
return view
}()
addSubview(bgView)
bgView.snp.makeConstraints { make in
make.height.equalTo(30)
make.width.equalTo(209)
make.centerX.equalToSuperview()
make.top.equalTo(328)
}
marqueeLabel = {
let label = UILabel()
label.font = UIFont.PFSC_M(ofSize: 14)
label.textColor = .black
label.textAlignment = .center
return label
}()
bgView.addSubview(marqueeLabel)
marqueeLabel.snp.makeConstraints { make in
make.left.right.top.bottom.equalToSuperview()
}
}
deinit {
timer?.invalidate()
}
func updateAllViews() {
......
......@@ -28,6 +28,36 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell {
var peopleFiveView: YHInvitationPeopleItemView!
var tableView: UITableView!
var headData: YHShareOverviewModel? {
didSet {
guard let model = headData else { return }
if model.cycle.begin_date.count == 0 || model.cycle.end_date.count == 0 {
timeLabel.text = "推荐周期:暂无(推荐好友签约后生成周期)"
} else {
timeLabel.text = "您的推荐周期:\(model.cycle.begin_date)\(model.cycle.end_date)"
}
numberOneView.titleLabel.text = "\(model.register_count)"
numberTwoView.titleLabel.text = "\(model.evaluated_count)"
numberThreeView.titleLabel.text = "\(model.signed_up_count)"
}
}
var tableData: YHShareRecordModel? {
didSet {
if tableData?.list.count == 0 {
let label = UILabel(frame: CGRect(x: 0, y: 0, width: self.width - 30, height: 40))
label.text = "还未有推荐信息,快分享给好友吧~"
label.textColor = UIColor.mainTextColor30
label.font = UIFont.PFSC_M(ofSize: 12)
label.textAlignment = .center
self.tableView.tableFooterView = label
} else {
self.tableView.tableFooterView = UIView()
}
self.tableView.reloadData()
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
......@@ -148,6 +178,7 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell {
numberTwoView = {
let view = YHInvitationNumberItemView()
view.bottomLabel.text = "已测评"
return view
}()
numberBgView.addSubview(numberTwoView)
......@@ -171,6 +202,7 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell {
numberThreeView = {
let view = YHInvitationNumberItemView()
view.bottomLabel.text = "已签约"
return view
}()
numberBgView.addSubview(numberThreeView)
......@@ -309,11 +341,12 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell {
extension YHInvitationWithGiftsSecondTableViewCell: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 100
return tableData?.list.count ?? 0
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withClass: YHInvitationWithGiftsPeopleTableViewCell.self)
cell.dataSource = tableData?.list[indexPath.row]
return cell
}
......@@ -345,7 +378,28 @@ class YHInvitationWithGiftsPeopleTableViewCell: UITableViewCell {
var peopleThreeView: YHInvitationPeopleItemView!
var peopleFourView: YHInvitationPeopleItemView!
var peopleFiveView: YHInvitationPeopleItemView!
var dataSource: YHShareRecordListModel? {
didSet {
guard let dataSource = dataSource else { return }
peopleOneView.titleLabel.text = dataSource.mobile
peopleTwoView.titleLabel.text = dataSource.register_time
if dataSource.is_registered {
peopleThreeView.bgImageView.image = UIImage(named: "invitation_with_gifts_people_true")
} else {
peopleThreeView.bgImageView.image = UIImage(named: "invitation_with_gifts_people_false")
}
if dataSource.is_evaluated {
peopleFourView.bgImageView.image = UIImage(named: "invitation_with_gifts_people_true")
} else {
peopleFourView.bgImageView.image = UIImage(named: "invitation_with_gifts_people_false")
}
if dataSource.is_signed_up {
peopleFiveView.bgImageView.image = UIImage(named: "invitation_with_gifts_people_true")
} else {
peopleFiveView.bgImageView.image = UIImage(named: "invitation_with_gifts_people_false")
}
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
......
//
// YHInvitationWithGiftsViewModel.swift
// galaxy
//
// Created by EDY on 2024/7/24.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHInvitationWithGiftsViewModel: YHBaseViewModel {
var model: [YHShareCashOutModel] = []
var overviewModel: YHShareOverviewModel = YHShareOverviewModel()
var recordModel: YHShareRecordModel = YHShareRecordModel()
// 提取纪录
func getCashOutRecord(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Share.cashOut
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
guard let result = [YHShareCashOutModel].deserialize(from: dic as? [Any]) else {
callBackBlock(false,nil)
return
}
self.model = (result as! [YHShareCashOutModel])
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
func getOverviewRecord(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Share.overview
let _ = YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
guard let result = YHShareOverviewModel.deserialize(from: dic as? [String:Any]) else {
callBackBlock(false,nil)
return
}
self.overviewModel = result
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
func postRecord(page: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Share.record
let param: [String: Any] = ["page": 1,
"pagesize": 20]
let _ = YHNetRequest.postRequest(url: strUrl, params: param) { [weak self] json, code in
guard let self = self else { return }
//1. json字符串 转 对象
if json.code == 200 {
let dic = json.data
guard let result = YHShareRecordModel.deserialize(from: dic as? [String:Any]) else {
callBackBlock(false,nil)
return
}
self.recordModel = result
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
}
......@@ -365,4 +365,10 @@ class YHAllApiName {
static let businessCardAuthorize = "super-app/business-card/authorize"
}
struct Share {
static let cashOut = "super-app/cash-out/record"
static let overview = "super-app/overview/record"
static let record = "super-app/record/list"
}
}
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