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

我的点赞和我的收藏和我的浏览

parent 83b16a32
......@@ -238,6 +238,8 @@
048B2A442BC7901900A93BF0 /* YHHomeWebViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048B2A432BC7901900A93BF0 /* YHHomeWebViewModel.swift */; };
048B2A462BC7912400A93BF0 /* YHWebModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048B2A452BC7912400A93BF0 /* YHWebModel.swift */; };
048B2A482BC7CE4800A93BF0 /* YHFourKingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048B2A472BC7CE4800A93BF0 /* YHFourKingViewController.swift */; };
048B2A4A2BC7D9DC00A93BF0 /* YHMyLikeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048B2A492BC7D9DC00A93BF0 /* YHMyLikeViewController.swift */; };
048B2A4D2BC7DAE800A93BF0 /* YHMyLikeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 048B2A4C2BC7DAE800A93BF0 /* YHMyLikeViewModel.swift */; };
0493B3DC2BA7EFE600AF9393 /* YHCertificateSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0493B3DB2BA7EFE600AF9393 /* YHCertificateSearchViewController.swift */; };
0493B3DE2BA80C2300AF9393 /* YHCertificateFilterButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0493B3DD2BA80C2300AF9393 /* YHCertificateFilterButton.swift */; };
049537852BA9B28500AF7E59 /* YHCertificateTemplateCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049537842BA9B28500AF7E59 /* YHCertificateTemplateCell.swift */; };
......@@ -682,6 +684,8 @@
048B2A432BC7901900A93BF0 /* YHHomeWebViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeWebViewModel.swift; sourceTree = "<group>"; };
048B2A452BC7912400A93BF0 /* YHWebModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHWebModel.swift; sourceTree = "<group>"; };
048B2A472BC7CE4800A93BF0 /* YHFourKingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHFourKingViewController.swift; sourceTree = "<group>"; };
048B2A492BC7D9DC00A93BF0 /* YHMyLikeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyLikeViewController.swift; sourceTree = "<group>"; };
048B2A4C2BC7DAE800A93BF0 /* YHMyLikeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHMyLikeViewModel.swift; sourceTree = "<group>"; };
0493B3DB2BA7EFE600AF9393 /* YHCertificateSearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateSearchViewController.swift; sourceTree = "<group>"; };
0493B3DD2BA80C2300AF9393 /* YHCertificateFilterButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateFilterButton.swift; sourceTree = "<group>"; };
049537842BA9B28500AF7E59 /* YHCertificateTemplateCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateTemplateCell.swift; sourceTree = "<group>"; };
......@@ -1560,6 +1564,14 @@
path = Frameworks;
sourceTree = "<group>";
};
048B2A4B2BC7DACF00A93BF0 /* ViewModel */ = {
isa = PBXGroup;
children = (
048B2A4C2BC7DAE800A93BF0 /* YHMyLikeViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
};
04A671562B9F18C800C1FB91 /* MyCertificates(我的证书) */ = {
isa = PBXGroup;
children = (
......@@ -1924,6 +1936,7 @@
A5ACE8E72B4564F7002C94D2 /* Mine(我的) */ = {
isa = PBXGroup;
children = (
048B2A4B2BC7DACF00A93BF0 /* ViewModel */,
A5ACE8EB2B4564F7002C94D2 /* V */,
A5ACE8E92B4564F7002C94D2 /* C */,
);
......@@ -1936,6 +1949,7 @@
A5ACE8EA2B4564F7002C94D2 /* YHMyViewController.swift */,
04C693612B723AB8004C1758 /* YHMySettingViewController.swift */,
049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */,
048B2A492BC7D9DC00A93BF0 /* YHMyLikeViewController.swift */,
);
path = C;
sourceTree = "<group>";
......@@ -2571,6 +2585,7 @@
045EEF212B9F171A0022A143 /* YHMainInformationTableViewCell.swift in Sources */,
A5ACE9462B4564F7002C94D2 /* YHHUDSquareBaseView.swift in Sources */,
A5551FFE2B4C26CE00510980 /* YHBaseViewModel.swift in Sources */,
048B2A4A2BC7D9DC00A93BF0 /* YHMyLikeViewController.swift in Sources */,
045EEED92B9F171A0022A143 /* YHEducationDetailVC.swift in Sources */,
045EEF1A2B9F171A0022A143 /* YHAddressViewController.swift in Sources */,
A5C382CA2B5E1F4C00C5E65C /* YHLoginTipsView.swift in Sources */,
......@@ -2601,6 +2616,7 @@
A5ACE9282B4564F7002C94D2 /* YHSmsCodeView.swift in Sources */,
0468D4262B495A5400CFB916 /* YHPickPhoneAddressViewController.swift in Sources */,
043F0AB42BC7B80F006CB887 /* YHTestViewController.swift in Sources */,
048B2A4D2BC7DAE800A93BF0 /* YHMyLikeViewModel.swift in Sources */,
A5C5B32D2B57D66000A7C5D1 /* YHBbxCollectionViewCell.swift in Sources */,
04C693622B723AB8004C1758 /* YHMySettingViewController.swift in Sources */,
045EEECD2B9F171A0022A143 /* YHScoreDataModel.swift in Sources */,
......
//
// YHMyLikeViewController.swift
// galaxy
//
// Created by EDY on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHMyLikeViewController: YHBaseViewController {
let viewModel: YHMyLikeViewModel = YHMyLikeViewModel()
var tableFootView: YHServiceTableFootView!
var id = 1
var dataSouce: [YHHomeListModel?] = [] {
didSet {
self.tableFootView.items = dataSouce
}
}
override func viewDidLoad() {
super.viewDidLoad()
var title = "我的收藏"
if id == 1 {
title = "我的点赞"
} else if id == 2{
title = "我的收藏"
} else {
title = "我的浏览"
}
gk_navTitle = title
setupUI()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
loadData()
}
}
extension YHMyLikeViewController {
func loadData() {
if id == 1 || id == 2 {
self.viewModel.getList(id) {[weak self] success, error in
guard let self = self else { return }
self.dataSouce = self.viewModel.arrHomeNewsData ?? []
}
} else {
self.viewModel.getList(callBackBlock: {[weak self] success, error in
guard let self = self else { return }
self.dataSouce = self.viewModel.arrHomeNewsData ?? []
})
}
}
func setupUI() {
gk_navBarAlpha = 1
tableFootView = {
let view = YHServiceTableFootView()
return view
}()
view.addSubview(tableFootView)
tableFootView.snp.makeConstraints { make in
make.bottom.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
}
}
}
......@@ -100,18 +100,27 @@ class YHMyViewController: YHBaseViewController, ConstraintRelatableTarget {
[weak self] in
guard let self = self else { return }
if !checkLogin() { return }
let vc = YHMyLikeViewController()
vc.id = 1
self.navigationController?.pushViewController(vc)
print("点赞")
}
view.collectClick = {
[weak self] in
guard let self = self else { return }
if !checkLogin() { return }
let vc = YHMyLikeViewController()
vc.id = 2
self.navigationController?.pushViewController(vc)
print("收藏")
}
view.recentScanClick = {
[weak self] in
guard let self = self else { return }
if !checkLogin() { return }
let vc = YHMyLikeViewController()
vc.id = 3
self.navigationController?.pushViewController(vc)
print("最近浏览")
}
return view
......
//
// YHMyLikeViewModel.swift
// galaxy
//
// Created by EDY on 2024/4/11.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHMyLikeViewModel: YHBaseViewModel {
var arrHomeNewsData: [YHHomeListModel]?
}
extension YHMyLikeViewModel {
// 1点赞 2收藏
func getList(_ type: Int, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["page": 1,
"page_size": 10,
"operate_type": type]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.user
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 = YHHomeListTotalModel.deserialize(from: dic as? Dictionary) else {
self.arrHomeNewsData = []
callBackBlock(false,nil)
return
}
for item in result.data {
item.calHeightParam()
}
self.arrHomeNewsData = result.data
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 getList(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["page": 1,
"page_size": 10]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.userLook
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 = YHHomeListTotalModel.deserialize(from: dic as? Dictionary) else {
self.arrHomeNewsData = []
callBackBlock(false,nil)
return
}
for item in result.data {
item.calHeightParam()
}
self.arrHomeNewsData = result.data
callBackBlock(true, nil)
} else {
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { err in
callBackBlock(false,err)
}
}
}
......@@ -26,6 +26,10 @@ class YHAllApiName {
static let star = "infoflow/article/collect"
//资讯点赞
static let like = "infoflow/article/like"
//我的点赞和收藏
static let user = "infoflow/user/consult"
//我的浏览
static let userLook = "infoflow/user/view"
}
//order 模块
......
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