Commit 6358671a authored by Steven杜宇's avatar Steven杜宇

// 生活详情

parent 0adae1fe
...@@ -271,6 +271,7 @@ ...@@ -271,6 +271,7 @@
0468D4362B57752F00CFB916 /* YHUserModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4352B57752F00CFB916 /* YHUserModel.swift */; }; 0468D4362B57752F00CFB916 /* YHUserModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4352B57752F00CFB916 /* YHUserModel.swift */; };
0468D43A2B579EAC00CFB916 /* YHLoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4392B579EAC00CFB916 /* YHLoginViewModel.swift */; }; 0468D43A2B579EAC00CFB916 /* YHLoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0468D4392B579EAC00CFB916 /* YHLoginViewModel.swift */; };
0472E25C2C521E64008EAB6E /* YHHomeIdentityListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0472E25B2C521E64008EAB6E /* YHHomeIdentityListVC.swift */; }; 0472E25C2C521E64008EAB6E /* YHHomeIdentityListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0472E25B2C521E64008EAB6E /* YHHomeIdentityListVC.swift */; };
0472E25E2C534723008EAB6E /* YHLifeDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0472E25D2C534723008EAB6E /* YHLifeDetailViewController.swift */; };
04754A952B96FF3D00F8ADCA /* UITextField+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04754A942B96FF3D00F8ADCA /* UITextField+Extension.swift */; }; 04754A952B96FF3D00F8ADCA /* UITextField+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04754A942B96FF3D00F8ADCA /* UITextField+Extension.swift */; };
047619E92BA9867100F45358 /* YHCountryHotView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047619E82BA9867100F45358 /* YHCountryHotView.swift */; }; 047619E92BA9867100F45358 /* YHCountryHotView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047619E82BA9867100F45358 /* YHCountryHotView.swift */; };
047619ED2BA9B9C900F45358 /* area.plist in Resources */ = {isa = PBXBuildFile; fileRef = 047619EC2BA9B9C900F45358 /* area.plist */; }; 047619ED2BA9B9C900F45358 /* area.plist in Resources */ = {isa = PBXBuildFile; fileRef = 047619EC2BA9B9C900F45358 /* area.plist */; };
...@@ -892,6 +893,7 @@ ...@@ -892,6 +893,7 @@
046AB7772BD674170086C6F1 /* galaxyDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = galaxyDebug.entitlements; sourceTree = "<group>"; }; 046AB7772BD674170086C6F1 /* galaxyDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = galaxyDebug.entitlements; sourceTree = "<group>"; };
046AB7782BD674170086C6F1 /* galaxyTestEnv.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = galaxyTestEnv.entitlements; sourceTree = "<group>"; }; 046AB7782BD674170086C6F1 /* galaxyTestEnv.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = galaxyTestEnv.entitlements; sourceTree = "<group>"; };
0472E25B2C521E64008EAB6E /* YHHomeIdentityListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeIdentityListVC.swift; sourceTree = "<group>"; }; 0472E25B2C521E64008EAB6E /* YHHomeIdentityListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeIdentityListVC.swift; sourceTree = "<group>"; };
0472E25D2C534723008EAB6E /* YHLifeDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLifeDetailViewController.swift; sourceTree = "<group>"; };
04754A942B96FF3D00F8ADCA /* UITextField+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+Extension.swift"; sourceTree = "<group>"; }; 04754A942B96FF3D00F8ADCA /* UITextField+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+Extension.swift"; sourceTree = "<group>"; };
047619E82BA9867100F45358 /* YHCountryHotView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCountryHotView.swift; sourceTree = "<group>"; }; 047619E82BA9867100F45358 /* YHCountryHotView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCountryHotView.swift; sourceTree = "<group>"; };
047619EC2BA9B9C900F45358 /* area.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = area.plist; sourceTree = "<group>"; }; 047619EC2BA9B9C900F45358 /* area.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = area.plist; sourceTree = "<group>"; };
...@@ -2165,6 +2167,7 @@ ...@@ -2165,6 +2167,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
047AA3DC2C4A6126009C4554 /* YHLifeViewController.swift */, 047AA3DC2C4A6126009C4554 /* YHLifeViewController.swift */,
0472E25D2C534723008EAB6E /* YHLifeDetailViewController.swift */,
); );
path = C; path = C;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -3609,6 +3612,7 @@ ...@@ -3609,6 +3612,7 @@
04FA8B302C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift in Sources */, 04FA8B302C0874CA00ABE43F /* YHOneKeyLoginViewModel.swift in Sources */,
04A7BD0F2BA41C9800BD35A2 /* YHMyDocumentsModel.swift in Sources */, 04A7BD0F2BA41C9800BD35A2 /* YHMyDocumentsModel.swift in Sources */,
04174D642BCD52BD000BA46D /* YHDeviceInfoViewController.swift in Sources */, 04174D642BCD52BD000BA46D /* YHDeviceInfoViewController.swift in Sources */,
0472E25E2C534723008EAB6E /* YHLifeDetailViewController.swift in Sources */,
A5ACE92E2B4564F7002C94D2 /* YHValidateCodeInputView.swift in Sources */, A5ACE92E2B4564F7002C94D2 /* YHValidateCodeInputView.swift in Sources */,
045EEED82B9F171A0022A143 /* YHQuestionInfo.swift in Sources */, 045EEED82B9F171A0022A143 /* YHQuestionInfo.swift in Sources */,
A567E5B82BD7643D00D5D5A0 /* YHSearchItemLayout.swift in Sources */, A567E5B82BD7643D00D5D5A0 /* YHSearchItemLayout.swift in Sources */,
......
...@@ -67,9 +67,10 @@ class YHHomeIdentityListVC: YHBaseViewController { ...@@ -67,9 +67,10 @@ class YHHomeIdentityListVC: YHBaseViewController {
let lineView = UIView() let lineView = UIView()
lineView.backgroundColor = .separatorColor lineView.backgroundColor = .separatorColor
view.addSubview(lineView) view.addSubview(lineView)
segmentedView.snp.makeConstraints { make in let left = 20.0-Self.tabGap
make.left.equalTo(0) self.segmentedView.snp.makeConstraints { make in
make.right.equalTo(0) make.left.equalTo(left)
make.right.equalTo(-left)
make.height.equalTo(44) make.height.equalTo(44)
make.top.equalTo(headImgView.snp.bottom).offset(8.0) make.top.equalTo(headImgView.snp.bottom).offset(8.0)
} }
...@@ -133,13 +134,6 @@ class YHHomeIdentityListVC: YHBaseViewController { ...@@ -133,13 +134,6 @@ class YHHomeIdentityListVC: YHBaseViewController {
self.tableView.snp.makeConstraints { make in self.tableView.snp.makeConstraints { make in
make.top.left.right.bottom.equalToSuperview() make.top.left.right.bottom.equalToSuperview()
} }
let left = 20.0-Self.tabGap
self.segmentedView.snp.remakeConstraints { make in
make.left.equalTo(left)
make.right.equalTo(-left)
make.height.equalTo(44)
make.top.equalTo(headImgView.snp.bottom).offset(8.0)
}
} }
} }
...@@ -211,8 +205,8 @@ extension YHHomeIdentityListVC: UIScrollViewDelegate { ...@@ -211,8 +205,8 @@ extension YHHomeIdentityListVC: UIScrollViewDelegate {
var model = TabBarShareModel() var model = TabBarShareModel()
model.showFlag = true model.showFlag = true
if let product = self.viewModel.detailModel.products.first { if let product = self.viewModel.detailModel.products.first {
let url = "https://test-hkdiy-h5.galaxy-immi.com/superAppBridge.html#/commodity_info?categoryId=2&levelId=\(self.detailId)&productId=\(product.id)&from=wxapp" let path = "/pages/commodityInfo/commodityInfo?categoryId=2&levelId=\(self.detailId)&productId=\(product.id)&from=wxApp"
model.shareUrl = url model.shareUrl = path
} }
model.codeUrl = self.viewModel.detailModel.imageURLDefault model.codeUrl = self.viewModel.detailModel.imageURLDefault
......
//
// YHLifeDetailViewController.swift
// galaxy
//
// Created by edy on 2024/7/26.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
import JXSegmentedView
class YHLifeDetailViewController: YHBaseViewController {
var detailId: String = ""
var codeUrl: String = ""
var downloadUrl: String = ""
var imgItems:[YHHomeIdentityItem] = []
var scrollContentY: CGFloat = 0.0
var isShowBottomView: Bool = false
lazy var viewModel: YHHomePageViewModel = {
let vm = YHHomePageViewModel()
return vm
}()
lazy var shareView: YHShareViewOnTablebarView = {
let view = YHShareViewOnTablebarView()
view.block = { tag in
if tag == 0 {
//分享小程序
if let product = self.viewModel.detailModel.products.first {
let path = "/pages/commodityInfo/commodityInfo?categoryId=2&levelId=\(self.detailId)&productId=\(product.id)&from=wxApp"
YHShareManager.shared.shareToMiniProgram(path:path, shareTitle: "")
}
} else {
//预约咨询
YHConsultantQRCodeView.codeView(self.codeUrl, downloadUrl: self.downloadUrl).show()
}
}
return view
}()
lazy var tableView: UITableView = {
let tableView = UITableView(frame: CGRect.zero, style:.grouped)
tableView.contentInsetAdjustmentBehavior = .never
tableView.showsVerticalScrollIndicator = false
tableView.backgroundColor = UIColor.white
tableView.separatorStyle = .none
tableView.register(YHHomeIdentityCell.self, forCellReuseIdentifier: YHHomeIdentityCell.cellReuseIdentifier)
tableView.delegate = self
tableView.dataSource = self
tableView.bounces = false
tableView.tableHeaderView = self.headerView
tableView.separatorStyle = .none
return tableView
}()
static let headerHeight: CGFloat = KScreenWidth+44.0+9.0
lazy var headerView:UIView = {
let view = UIView(frame: CGRectMake(0, 0, KScreenWidth, Self.headerHeight))
view.clipsToBounds = true
view.backgroundColor = .white
view.addSubview(self.headImgView)
headImgView.snp.makeConstraints { make in
make.left.top.right.equalToSuperview()
make.height.equalTo(headImgView.snp.width)
}
self.segmentedView.dataSource = segmentedDataSource
view.addSubview(self.segmentedView)
let lineView = UIView()
lineView.backgroundColor = .separatorColor
view.addSubview(lineView)
let left = 20.0-Self.tabGap
self.segmentedView.snp.makeConstraints { make in
make.left.equalTo(left)
make.right.equalTo(-left)
make.height.equalTo(44)
make.top.equalTo(headImgView.snp.bottom).offset(8.0)
}
lineView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(1.0)
}
return view
}()
lazy var headImgView: UIImageView = {
let imgView = UIImageView()
imgView.image = UIImage(named: "global_default_image")
imgView.clipsToBounds = true
return imgView
}()
lazy var segmentedView : JXSegmentedView = {
let segmentedView = JXSegmentedView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 44))
segmentedView.delegate = self
//配置指示器
let indicator = JXSegmentedIndicatorLineView()
indicator.indicatorWidth = 16
indicator.indicatorHeight = 2
indicator.indicatorCornerRadius = 0.0
indicator.indicatorColor = .brandMainColor
segmentedView.indicators = [indicator]
segmentedView.defaultSelectedIndex = 0
return segmentedView
}()
static let tabWidth = 64.0
// 默认为4个tab
static let tabGap = (KScreenWidth-20.0*2-tabWidth*4.0)/3.0
lazy var segmentedDataSource: JXSegmentedTitleDataSource = {
let dataSource = JXSegmentedTitleDataSource()
dataSource.titleNormalFont = UIFont.PFSC_R(ofSize: 16)
dataSource.titleNormalColor = UIColor.init(hex: 0x94A3B8)
dataSource.titleSelectedFont = UIFont.PFSC_M(ofSize: 16)
dataSource.titleSelectedColor = .mainTextColor
dataSource.itemWidth = Self.tabWidth
dataSource.itemSpacing = Self.tabGap
dataSource.itemWidthSelectedZoomScale = 1.0
return dataSource
}()
var titles: [String] = []
override func viewDidLoad() {
super.viewDidLoad()
createUI()
loadData()
}
func createUI() {
gk_navigationBar.isHidden = true
self.view.backgroundColor = .white
self.view.addSubview(self.tableView)
self.view.addSubview(self.shareView)
self.shareView.snp.makeConstraints { make in
make.left.right.bottom.equalToSuperview()
make.height.equalTo(YHShareViewOnTablebarView.viewH)
}
self.tableView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalTo(self.shareView.snp.top)
}
}
}
extension YHLifeDetailViewController: JXSegmentedViewDelegate {
func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
if 0 <= index, index < self.imgItems.count {
self.tableView.scrollToRow(at: IndexPath(row: index, section: 0), at: .top, animated: true)
}
}
}
extension YHLifeDetailViewController: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHHomeIdentityCell.cellReuseIdentifier, for: indexPath) as! YHHomeIdentityCell
if 0 <= indexPath.row, indexPath.row < self.imgItems.count {
let item = self.imgItems[indexPath.row]
cell.image = item.img
}
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if 0 <= indexPath.row, indexPath.row < self.imgItems.count {
let item = self.imgItems[indexPath.row]
return item.getSize().height
}
return KScreenWidth
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.imgItems.count
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.01
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.01
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
}
extension YHLifeDetailViewController {
func loadData() {
let params:[String: Any] = ["categoryId": "2",
"levelId": self.detailId]
self.viewModel.getGoodsCategoryDetail(params: params) {
[weak self] success, error in
guard let self = self else { return }
self.titles.removeAll()
self.imgItems.removeAll()
for product in self.viewModel.detailModel.products {
self.headImgView.kf.setImage(with: URL(string: product.image), placeholder: UIImage(named: "global_default_image"))
for detail in product.details {
let item = YHHomeIdentityItem()
item.url = detail.image
self.imgItems.append(item)
self.titles.append(detail.name)
}
}
self.segmentedDataSource.titles = self.titles
self.segmentedView.dataSource = self.segmentedDataSource
self.segmentedView.reloadDataWithoutListContainer()
self.tableView.reloadData()
requestImages()
}
}
func requestImages() {
let ossGroup = DispatchGroup()
for item in self.imgItems {
ossGroup.enter()
item.imgView.kf.setImage(with: URL(string: item.url)) { result in
switch result {
case .success(let value):
item.img = value.image
case .failure(let error):
print("image download failed: \(error.localizedDescription)")
}
self.tableView.reloadData()
ossGroup.leave()
}
}
ossGroup.notify(queue: .main) {
self.tableView.reloadData()
}
}
}
...@@ -139,15 +139,22 @@ extension YHLifeViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -139,15 +139,22 @@ extension YHLifeViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let model = self.viewModel.detailModel.products[indexPath.row] let model = self.viewModel.detailModel.products[indexPath.row]
let vc = YHH5WebViewVC()
// TODO: - 谢
vc.url = YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/commodity_info?categoryId=2&levelId=5&productId=30&from=wxApp"
vc.isWithBottomViewFlag = true
vc.isShareToMiniProgramFlag = true
vc.shareMiniPath = "/serviceHousekeeper/pages/documentEdit/documentEdit"
let vc = YHLifeDetailViewController()
vc.detailId = "4"//model.id
vc.codeUrl = self.viewModel.detailModel.imageURLDefault
vc.downloadUrl = self.viewModel.detailModel.imageURLDefaultDownload
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
// let vc = YHH5WebViewVC()
//
// // TODO: - 谢
// vc.url = YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/commodity_info?categoryId=2&levelId=5&productId=30&from=wxApp"
// vc.isWithBottomViewFlag = true
// vc.isShareToMiniProgramFlag = true
// vc.shareMiniPath = "/serviceHousekeeper/pages/documentEdit/documentEdit"
//
// self.navigationController?.pushViewController(vc)
} }
} }
......
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