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

Merge commit '3478e572' into xiezhaolin

parents 3717647d 3478e572
...@@ -13,13 +13,6 @@ class YHTabBarViewController: ESTabBarController { ...@@ -13,13 +13,6 @@ class YHTabBarViewController: ESTabBarController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
handleTabBarLine() handleTabBarLine()
// self.tabBar.shadowImage = UIImage()
// self.tabBar.backgroundImage = UIImage()
// NotificationCenter.default.addObserver(self, selector: #selector(hideTabBar), name: BsConstant.BsNotification.tabBarHideNotification, object: nil)
//
// NotificationCenter.default.addObserver(self, selector: #selector(showTabBar), name: BsConstant.BsNotification.tabBarShowNotification, object: nil)
} }
} }
......
...@@ -10,11 +10,28 @@ import UIKit ...@@ -10,11 +10,28 @@ import UIKit
class YHSearchInfomationVC: YHBaseViewController { class YHSearchInfomationVC: YHBaseViewController {
var items:[String] = ["阿斯顿法师法师法师","发大水发生大法师懂法守法三大发沙发沙发沙发沙发沙发啥打法上大V撒大V啊三大发啥打法四大法守法","发大水发生大法师懂法守法三大发沙发沙发沙发沙发沙发啥打法上大V撒大V啊三大发啥打法四大法守法发大水发生大法师懂法守法三大发沙发沙发沙发沙发沙发啥打法上大V撒大V啊三大发啥打法四大法守法","啊发顺丰"] var items:[YHHomeListModel] = []
lazy var viewModel : YHHomePageViewModel = {
let viewModel = YHHomePageViewModel()
return viewModel
}()
lazy var searchBar: YHSearchInfoBar = { lazy var searchBar: YHSearchInfoBar = {
let bar = YHSearchInfoBar(frame: CGRect(x: 20, y: k_Height_NavigationtBarAndStatuBar+8.0, width: KScreenWidth-40, height: 36.0)) let bar = YHSearchInfoBar(frame: CGRect(x: 20, y: k_Height_NavigationtBarAndStatuBar+8.0, width: KScreenWidth-40, height: 36.0))
bar.searchBlock = {
[weak self] text in
guard let self = self else { return }
self.viewModel.searchArticleList(text ?? "") {
[weak self] success, error in
guard let self = self else { return }
items.removeAll()
if let arr = self.viewModel.arrHomeNewsData {
items.append(contentsOf: arr)
}
self.tableView.reloadData()
}
}
return bar return bar
}() }()
...@@ -54,6 +71,7 @@ class YHSearchInfomationVC: YHBaseViewController { ...@@ -54,6 +71,7 @@ class YHSearchInfomationVC: YHBaseViewController {
view.addSubview(searchBar) view.addSubview(searchBar)
view.addSubview(searchHistoryView) view.addSubview(searchHistoryView)
view.addSubview(tableView) view.addSubview(tableView)
searchBar.textField.becomeFirstResponder()
searchBar.snp.makeConstraints { make in searchBar.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20) make.left.equalToSuperview().offset(20)
...@@ -92,7 +110,7 @@ extension YHSearchInfomationVC: UITableViewDelegate, UITableViewDataSource { ...@@ -92,7 +110,7 @@ extension YHSearchInfomationVC: UITableViewDelegate, UITableViewDataSource {
if 0 <= indexPath.section && indexPath.section < items.count { if 0 <= indexPath.section && indexPath.section < items.count {
let item = items[indexPath.section] let item = items[indexPath.section]
cell.titleLabel.text = items[indexPath.section] cell.updateModel(item)
} }
return cell return cell
} }
...@@ -104,7 +122,7 @@ extension YHSearchInfomationVC: UITableViewDelegate, UITableViewDataSource { ...@@ -104,7 +122,7 @@ extension YHSearchInfomationVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.section && indexPath.section < items.count { if 0 <= indexPath.section && indexPath.section < items.count {
let text = items[indexPath.section] let articleInfo = items[indexPath.section]
self.tableView.isHidden = true self.tableView.isHidden = true
self.searchHistoryView.isHidden = false self.searchHistoryView.isHidden = false
} }
......
...@@ -23,6 +23,7 @@ class YHHomeListModel: YHBaseModel { ...@@ -23,6 +23,7 @@ class YHHomeListModel: YHBaseModel {
var type: Int = 0 //文章类型 '文章类型 1视频 2图文 3图片', var type: Int = 0 //文章类型 '文章类型 1视频 2图文 3图片',
var is_like : Bool = false var is_like : Bool = false
var media_url : String = "" var media_url : String = ""
var like_count : Int = 0
......
...@@ -121,10 +121,29 @@ private extension YHHkLifeAndIdItemView { ...@@ -121,10 +121,29 @@ private extension YHHkLifeAndIdItemView {
@objc func tapView(gestureRecognizer:UITapGestureRecognizer) { @objc func tapView(gestureRecognizer:UITapGestureRecognizer) {
if itemType == .hkID { if itemType == .hkID {
//香港身份 //香港身份
if let vc = UIApplication.shared.keyWindow?.rootViewController as? YHTabBarViewController {
vc.selectedIndex = 1
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
if let vcs = vc.viewControllers,vcs.count > 1 {
if let nvc = vcs[1] as? YHNavigationController,let vvc = nvc.topViewController as? YHServiceViewController {
vvc.jumpToItemIndex(itemIndex: 0)
}
}
}
}
} else if itemType == .hklife { } else if itemType == .hklife {
//香港生活 //香港生活
if let vc = UIApplication.shared.keyWindow?.rootViewController as? YHTabBarViewController {
vc.selectedIndex = 1
DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
if let vcs = vc.viewControllers,vcs.count > 1 {
if let nvc = vcs[1] as? YHNavigationController,let vvc = nvc.topViewController as? YHServiceViewController {
vvc.jumpToItemIndex(itemIndex: 1)
}
}
}
}
} else { } else {
printLog("errorr:未处理") printLog("errorr:未处理")
} }
......
...@@ -7,8 +7,7 @@ ...@@ -7,8 +7,7 @@
// //
import UIKit import UIKit
import Kingfisher
class YHSearchInfoCell: UITableViewCell { class YHSearchInfoCell: UITableViewCell {
...@@ -41,6 +40,13 @@ class YHSearchInfoCell: UITableViewCell { ...@@ -41,6 +40,13 @@ class YHSearchInfoCell: UITableViewCell {
return label return label
}() }()
func updateModel(_ model: YHHomeListModel) {
titleLabel.text = model.title
if let url = URL(string: model.img_url) {
headImgView.kf.setImage(with: url)
}
}
func setupUI() { func setupUI() {
contentView.backgroundColor = .white contentView.backgroundColor = .white
......
...@@ -200,4 +200,36 @@ extension YHHomePageViewModel { ...@@ -200,4 +200,36 @@ extension YHHomePageViewModel {
callBackBlock(false,err) callBackBlock(false,err)
} }
} }
// 搜索
func searchArticleList(_ title: String, callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
let params: [String : Any] = ["page": 1,
"page_size": 10,
"title": title]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.article
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)
}
}
} }
...@@ -83,7 +83,7 @@ class YHServiceViewController: YHBaseViewController { ...@@ -83,7 +83,7 @@ class YHServiceViewController: YHBaseViewController {
segmentedView.indicators = [indicator] segmentedView.indicators = [indicator]
segmentedView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1) segmentedView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1)
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
...@@ -105,6 +105,11 @@ class YHServiceViewController: YHBaseViewController { ...@@ -105,6 +105,11 @@ class YHServiceViewController: YHBaseViewController {
listContainerView.frame = CGRect(x: 0, y: k_Height_safeAreaInsetsTop() + 48, width: view.bounds.size.width, height: view.bounds.size.height - 48 - k_Height_safeAreaInsetsTop()) listContainerView.frame = CGRect(x: 0, y: k_Height_safeAreaInsetsTop() + 48, width: view.bounds.size.width, height: view.bounds.size.height - 48 - k_Height_safeAreaInsetsTop())
} }
} }
extension YHServiceViewController {
func jumpToItemIndex(itemIndex : Int) {
self.segmentedView.selectItemAt(index: itemIndex)
}
}
extension YHServiceViewController: JXSegmentedViewDelegate { extension YHServiceViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) { func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
......
...@@ -174,7 +174,7 @@ extension YHHomeCollectionViewCell { ...@@ -174,7 +174,7 @@ extension YHHomeCollectionViewCell {
make.right.equalToSuperview().offset(-8) make.right.equalToSuperview().offset(-8)
make.bottom.equalTo(-36) make.bottom.equalTo(-36)
} }
numLable.text = listModel.collect_count.string numLable.text = listModel.like_count.string
heartImageViewBtn.isSelected = listModel.is_like heartImageViewBtn.isSelected = listModel.is_like
if listModel.type == 1 { if listModel.type == 1 {
......
...@@ -10,7 +10,7 @@ import UIKit ...@@ -10,7 +10,7 @@ import UIKit
class YHMyNotifySettingVC: YHBaseViewController { class YHMyNotifySettingVC: YHBaseViewController {
var items:[YHPermissionItem] = [YHPermissionItem(title: "接收推送消息通知".local, enableStatus: false)] var items:[YHPermissionItem] = [YHPermissionItem(title: "接收推送消息通知".local, type:.notify, enableStatus: false)]
lazy var tableView: UITableView = { lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped) let tableView = UITableView(frame:.zero, style:.grouped)
......
...@@ -8,22 +8,34 @@ ...@@ -8,22 +8,34 @@
import UIKit import UIKit
enum YHPermissionType: Int {
case none = 0
case network = 1
case photo = 2
case camera = 3
case location = 4
case file = 5
case notify = 6
}
class YHPermissionItem { class YHPermissionItem {
var type: YHPermissionType = .none
var title:String = "" var title:String = ""
var enableStatus:Bool = false var enableStatus:Bool = false
init(title: String, enableStatus: Bool) { init(title: String, type:YHPermissionType, enableStatus: Bool) {
self.title = title self.title = title
self.type = type
self.enableStatus = enableStatus self.enableStatus = enableStatus
} }
} }
class YHMyPermissionSettingVC: YHBaseViewController { class YHMyPermissionSettingVC: YHBaseViewController {
var items:[YHPermissionItem] = [YHPermissionItem(title: "网络".local, enableStatus: true), var items:[YHPermissionItem] = [YHPermissionItem(title: "网络".local, type:.network, enableStatus: true),
YHPermissionItem(title: "照片".local, enableStatus: true), YHPermissionItem(title: "照片".local, type:.photo, enableStatus: true),
YHPermissionItem(title: "相机".local, enableStatus: false), YHPermissionItem(title: "相机".local, type:.camera, enableStatus: false),
YHPermissionItem(title: "位置".local, enableStatus: true), YHPermissionItem(title: "位置".local, type:.location, enableStatus: true),
YHPermissionItem(title: "文件".local, enableStatus: false)] YHPermissionItem(title: "文件".local, type:.file, enableStatus: false)]
lazy var tableView: UITableView = { lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped) let tableView = UITableView(frame:.zero, style:.grouped)
...@@ -76,7 +88,28 @@ extension YHMyPermissionSettingVC: UITableViewDelegate, UITableViewDataSource { ...@@ -76,7 +88,28 @@ extension YHMyPermissionSettingVC: UITableViewDelegate, UITableViewDataSource {
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.row && indexPath.row < items.count {
let item = items[indexPath.row]
if item.type == .photo || item.type == .camera {
let url = URL(string: UIApplication.openSettingsURLString)
if let url = url, UIApplication .shared.canOpenURL(url) {
UIApplication .shared.open(url, options: [:], completionHandler: {
(success) in
})
}
return
}
if item.type == .location {
if let url = URL(string: "App-prefs:Photos") {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
} else if item.type == .file {
}
}
} }
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat { private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
......
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