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

// 我的

parent e9e38729
...@@ -57,17 +57,25 @@ class YHMyNewViewController: YHBaseViewController { ...@@ -57,17 +57,25 @@ class YHMyNewViewController: YHBaseViewController {
lazy var userInfoView: YHMyUserInfoView = { lazy var userInfoView: YHMyUserInfoView = {
let view = YHMyUserInfoView.createView() let view = YHMyUserInfoView.createView()
view.avatarClickBlock = { view.enterClick = {
[weak self] in [weak self] in
guard let self = self else { return } guard let self = self else { return }
if !checkLogin() { return } if !checkLogin() { return }
enterMyNameCard()
}
view.avatarClickBlock = {
[weak self] in
guard let self = self else { return }
if !checkLogin() { return }
} }
view.nickNameClickBlock = { view.nickNameClickBlock = {
[weak self] in [weak self] in
guard let self = self else { return } guard let self = self else { return }
if !checkLogin() { return } if !checkLogin() { return }
} }
view.likeClick = { view.likeClick = {
[weak self] in [weak self] in
guard let self = self else { return } guard let self = self else { return }
...@@ -76,6 +84,7 @@ class YHMyNewViewController: YHBaseViewController { ...@@ -76,6 +84,7 @@ class YHMyNewViewController: YHBaseViewController {
vc.myDefaultNavItemIndex = 0 vc.myDefaultNavItemIndex = 0
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
} }
view.collectClick = { view.collectClick = {
[weak self] in [weak self] in
guard let self = self else { return } guard let self = self else { return }
...@@ -85,6 +94,7 @@ class YHMyNewViewController: YHBaseViewController { ...@@ -85,6 +94,7 @@ class YHMyNewViewController: YHBaseViewController {
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
print("收藏") print("收藏")
} }
view.recentScanClick = { view.recentScanClick = {
[weak self] in [weak self] in
guard let self = self else { return } guard let self = self else { return }
...@@ -190,16 +200,13 @@ class YHMyNewViewController: YHBaseViewController { ...@@ -190,16 +200,13 @@ class YHMyNewViewController: YHBaseViewController {
var serviceGroupArr:[PersonalModuleItem] = [] var serviceGroupArr:[PersonalModuleItem] = []
var otherGroupArr:[PersonalModuleItem] = [] var otherGroupArr:[PersonalModuleItem] = []
// if YHUatHelper.shared.getUatModuleStatusBy(module: .Mine_MyCard) == 1 { // 我的名片
// let item = PersonalModuleItem(icon: "mine_item_card", title: "我的名片".local, type:.myCard) // userInfoView.arrowImgView.isHidden = (YHUatHelper.shared.getUatModuleStatusBy(module: .Mine_MyCard) != 1)
// items.append(item)
// }
// 邀请好友和积分商城 // 邀请好友和积分商城
do { do {
let item = PersonalModuleItem(icon: "mine_item_invite", title: "邀请好友".local, desc: "推荐好友享好礼", type:.scoreCenter) let item = PersonalModuleItem(icon: "mine_item_invite", title: "邀请好友".local, desc: "推荐好友享好礼", type:.inviteFriends)
scoreGroupArr.append(item) scoreGroupArr.append(item)
} }
...@@ -239,12 +246,12 @@ class YHMyNewViewController: YHBaseViewController { ...@@ -239,12 +246,12 @@ class YHMyNewViewController: YHBaseViewController {
} }
if YHUatHelper.shared.getUatModuleStatusBy(module: .Mine_EvaluationCode) == 1 { if YHUatHelper.shared.getUatModuleStatusBy(module: .Mine_EvaluationCode) == 1 {
let item = PersonalModuleItem(icon: "mine_item_code", title: "我的测评码".local, type:.myTestCode) let item = PersonalModuleItem(icon: "mine_item_code", title: "测评码".local, type:.myTestCode)
otherGroupArr.append(item) otherGroupArr.append(item)
} }
if YHUatHelper.shared.getUatModuleStatusBy(module: .Mine_AboutYinHeHarbour) == 1 { if YHUatHelper.shared.getUatModuleStatusBy(module: .Mine_AboutYinHeHarbour) == 1 {
let item = PersonalModuleItem(icon: "mine_item_appoint", title: "关于银河湾".local, type:.appointGalaxyBay) let item = PersonalModuleItem(icon: "mine_item_appoint", title: "银河湾".local, type:.appointGalaxyBay)
otherGroupArr.append(item) otherGroupArr.append(item)
} }
...@@ -261,7 +268,6 @@ class YHMyNewViewController: YHBaseViewController { ...@@ -261,7 +268,6 @@ class YHMyNewViewController: YHBaseViewController {
functionGroupArr.append(scoreGroup) functionGroupArr.append(scoreGroup)
functionGroupArr.append(serviceGroup) functionGroupArr.append(serviceGroup)
functionGroupArr.append(otherGroup) functionGroupArr.append(otherGroup)
tableView.reloadData() tableView.reloadData()
} }
...@@ -287,8 +293,18 @@ extension YHMyNewViewController : UITableViewDelegate, UITableViewDataSource { ...@@ -287,8 +293,18 @@ extension YHMyNewViewController : UITableViewDelegate, UITableViewDataSource {
if group.type == .score { if group.type == .score {
let cell2 = tableView.dequeueReusableCell(withIdentifier: YHMyFunctionGroup2Cell.cellReuseIdentifier, for: indexPath) as! YHMyFunctionGroup2Cell let cell2 = tableView.dequeueReusableCell(withIdentifier: YHMyFunctionGroup2Cell.cellReuseIdentifier, for: indexPath) as! YHMyFunctionGroup2Cell
cell2.updateGroup(group) cell2.updateGroup(group)
cell2.clickItem = {
[weak self] item in
guard let self = self else { return }
self.clickItem(item)
}
return cell2 return cell2
} }
cell.clickItem = {
[weak self] item in
guard let self = self else { return }
self.clickItem(item)
}
cell.updateGroup(group) cell.updateGroup(group)
} }
return cell return cell
...@@ -299,113 +315,6 @@ extension YHMyNewViewController : UITableViewDelegate, UITableViewDataSource { ...@@ -299,113 +315,6 @@ extension YHMyNewViewController : UITableViewDelegate, UITableViewDataSource {
return UITableView.automaticDimension return UITableView.automaticDimension
} }
// func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// if (indexPath.row >= items.count) { return }
//
// if !checkLogin() {
// return
// }
//
// let item: PersonalModuleItem = items[indexPath.row]
// switch item.type {
// case .myCard://我的名片
// if let userId = YHLoginManager.shared.userModel?.id, !userId.isEmpty {
// let vc = YHNameCardViewController()
// vc.userId = userId
// self.navigationController?.pushViewController(vc)
// } else {
// YHHUD.show(.progress(message: "加载中..."))
// self.loginViewModel.getUserId {
// [weak self] uid in
// YHHUD.hide()
// guard let self = self else { return }
// if !uid.isEmpty {
// YHLoginManager.shared.userModel?.id = uid
// let vc = YHNameCardViewController()
// vc.userId = uid
// self.navigationController?.pushViewController(vc)
// }
// }
// }
// case .myMessage://我的消息
// printLog("我的消息")
// goToMessagePage()
//
// case .scoreCenter:////积分中心
// printLog("积分中心")
// if let param = YHLoginManager.shared.userModel?.token,param.count>5 {
// printLog(param)
// var url = YHBaseUrlManager.shared.curH5URL() + "superApp/integral"
// url = url + "?param=" + YHLoginManager.shared.h5Token
//
// let vc = YHH5WebViewVC()
// vc.title = "积分中心"
// vc.navTitle = "积分中心"
// vc.url = url
// vc.isFullScreenFlag = false
// vc.isSupportWebviewInterBackFlag = true
// self.navigationController?.pushViewController(vc)
// }
// case .myTestCode://我的测评码
// printLog("我的测评码")
// let vc = YHHomeWebViewController()
// vc.title = "香港身份测评码"
// vc.vcTitle = "香港身份测评码"
// vc.showSavePicBottomFlag = true
// vc.url = "https://cdn-public.galaxy-immi.com/app/cepingma.png"
// self.navigationController?.pushViewController(vc)
// case .appointGalaxyBay://预约银河湾
// printLog("预约银河湾")
// let vc = YHListViewController()
// self.navigationController?.pushViewController(vc)
// case .myActivity:
// printLog("我的活动")
// let vc = YHActivityListViewController()
// vc.type = 1
// self.navigationController?.pushViewController(vc)
// case .aboutUs:
// let vc = YHAboutGalaxyViewController()
// self.navigationController?.pushViewController(vc)
// case .myOrder:
//// 我的订单
// if let token = YHLoginManager.shared.userModel?.token,token.count > 5 {
// var url = YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/order/my"
// url = url + "?param=" + YHLoginManager.shared.h5Token
// printLog("URL: \(url)")
// let vc = YHH5WebViewVC()
// vc.url = url
// vc.isFullScreenFlag = false
// vc.navTitle = "我的订单"
// vc.isSupportWebviewInterBackFlag = true
// UIViewController.current?.navigationController?.pushViewController(vc)
// }
// case .mycart:
//// 我的订单
// if let token = YHLoginManager.shared.userModel?.token,token.count > 5 {
// var url = YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/goods/cart"
// url = url + "?param=" + YHLoginManager.shared.h5Token
// printLog("URL: \(url)")
// var tUrl = url
// if !url.contains("navigationH=") {
// tUrl = url + "?navigationH=\(k_Height_NavigationtBarAndStatuBar)"
// if url.contains("?") {
// tUrl = url + "&navigationH=\(k_Height_NavigationtBarAndStatuBar)"
// }
// }
// let vc = YHH5WebViewVC()
// vc.url = tUrl
// vc.isFullScreenFlag = false
// vc.navTitle = "购物车"
// vc.isSupportWebviewInterBackFlag = true
// UIViewController.current?.navigationController?.pushViewController(vc)
// }
// case .serviceStep:
// UIViewController.current?.tabBarController?.selectedIndex = 1
// default:
// printLog("不需要响应")
// }
// }
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat { private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
return 113.0 return 113.0
...@@ -603,3 +512,134 @@ extension YHMyNewViewController { ...@@ -603,3 +512,134 @@ extension YHMyNewViewController {
} }
} }
extension YHMyNewViewController {
func enterMyNameCard() {
if let userId = YHLoginManager.shared.userModel?.id, !userId.isEmpty {
let vc = YHNameCardViewController()
vc.userId = userId
self.navigationController?.pushViewController(vc)
} else {
YHHUD.show(.progress(message: "加载中..."))
self.loginViewModel.getUserId {
[weak self] uid in
YHHUD.hide()
guard let self = self else { return }
if !uid.isEmpty {
YHLoginManager.shared.userModel?.id = uid
let vc = YHNameCardViewController()
vc.userId = uid
self.navigationController?.pushViewController(vc)
}
}
}
}
func inviteFriends() {
//判断是否登录成功
if YHLoginManager.shared.isLogin() {
let vc = YHInvitationWithGiftsViewController()
self.navigationController?.pushViewController(vc)
} else {
YHOneKeyLoginManager.shared.oneKeyLogin()
YHLoginManager.shared.loginSuccessActionBlock = {[weak self] in
guard self != nil else { return }
let vc = YHInvitationWithGiftsViewController()
self?.navigationController?.pushViewController(vc)
YHLoginManager.shared.loginSuccessActionBlock = nil
}
}
}
func clickItem(_ item: PersonalModuleItem) {
if !checkLogin() {
return
}
switch item.type {
case .myCard://我的名片
enterMyNameCard()
case .myMessage://我的消息
printLog("我的消息")
goToMessagePage()
case .scoreCenter:////积分中心
printLog("积分中心")
if let param = YHLoginManager.shared.userModel?.token,param.count>5 {
printLog(param)
var url = YHBaseUrlManager.shared.curH5URL() + "superApp/integral"
url = url + "?param=" + YHLoginManager.shared.h5Token
let vc = YHH5WebViewVC()
vc.title = "积分中心"
vc.navTitle = "积分中心"
vc.url = url
vc.isFullScreenFlag = false
vc.isSupportWebviewInterBackFlag = true
self.navigationController?.pushViewController(vc)
}
case .myTestCode://我的测评码
printLog("我的测评码")
let vc = YHHomeWebViewController()
vc.title = "香港身份测评码"
vc.vcTitle = "香港身份测评码"
vc.showSavePicBottomFlag = true
vc.url = "https://cdn-public.galaxy-immi.com/app/cepingma.png"
self.navigationController?.pushViewController(vc)
case .appointGalaxyBay://预约银河湾
printLog("预约银河湾")
let vc = YHListViewController()
self.navigationController?.pushViewController(vc)
case .myActivity:
printLog("我的活动")
let vc = YHActivityListViewController()
vc.type = 1
self.navigationController?.pushViewController(vc)
case .aboutUs:
let vc = YHAboutGalaxyViewController()
self.navigationController?.pushViewController(vc)
case .myOrder:
// 我的订单
if let token = YHLoginManager.shared.userModel?.token,token.count > 5 {
var url = YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/order/my"
url = url + "?param=" + YHLoginManager.shared.h5Token
printLog("URL: \(url)")
let vc = YHH5WebViewVC()
vc.url = url
vc.isFullScreenFlag = false
vc.navTitle = "我的订单"
vc.isSupportWebviewInterBackFlag = true
UIViewController.current?.navigationController?.pushViewController(vc)
}
case .mycart:
// 我的订单
if let token = YHLoginManager.shared.userModel?.token,token.count > 5 {
var url = YHBaseUrlManager.shared.curH5URL() + "superAppBridge.html#/goods/cart"
url = url + "?param=" + YHLoginManager.shared.h5Token
printLog("URL: \(url)")
var tUrl = url
if !url.contains("navigationH=") {
tUrl = url + "?navigationH=\(k_Height_NavigationtBarAndStatuBar)"
if url.contains("?") {
tUrl = url + "&navigationH=\(k_Height_NavigationtBarAndStatuBar)"
}
}
let vc = YHH5WebViewVC()
vc.url = tUrl
vc.isFullScreenFlag = false
vc.navTitle = "购物车"
vc.isSupportWebviewInterBackFlag = true
UIViewController.current?.navigationController?.pushViewController(vc)
}
case .serviceStep:
UIViewController.current?.tabBarController?.selectedIndex = 1
case .inviteFriends:
inviteFriends()
default:
printLog("不需要响应")
}
}
}
...@@ -18,6 +18,7 @@ enum YHPersonalModuleItemType: Int { ...@@ -18,6 +18,7 @@ enum YHPersonalModuleItemType: Int {
case myProgress case myProgress
case myActivity case myActivity
case scoreCenter case scoreCenter
case inviteFriends
case recommend case recommend
case myPoster case myPoster
case myTestCode case myTestCode
......
...@@ -12,6 +12,9 @@ class YHMyFunctionGroup2Cell: UITableViewCell { ...@@ -12,6 +12,9 @@ class YHMyFunctionGroup2Cell: UITableViewCell {
static let cellReuseIdentifier = "YHMyFunctionGroup2Cell" static let cellReuseIdentifier = "YHMyFunctionGroup2Cell"
static let itemHeight = 74.0 static let itemHeight = 74.0
var clickItem:((PersonalModuleItem)->())?
func updateGroup(_ group: YHFunctionGroupInfo) { func updateGroup(_ group: YHFunctionGroupInfo) {
groupArr = group.arr groupArr = group.arr
} }
...@@ -105,7 +108,11 @@ extension YHMyFunctionGroup2Cell: UICollectionViewDelegate, UICollectionViewData ...@@ -105,7 +108,11 @@ extension YHMyFunctionGroup2Cell: UICollectionViewDelegate, UICollectionViewData
} }
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if 0 <= indexPath.item && indexPath.item < groupArr.count {
let item: PersonalModuleItem = groupArr[indexPath.item]
if let click = clickItem {
click(item)
}
}
} }
} }
...@@ -12,6 +12,8 @@ class YHMySectionGroupCell: UITableViewCell { ...@@ -12,6 +12,8 @@ class YHMySectionGroupCell: UITableViewCell {
static let cellReuseIdentifier = "YHMySectionGroupCell" static let cellReuseIdentifier = "YHMySectionGroupCell"
var clickItem:((PersonalModuleItem)->())?
func updateGroup(_ group: YHFunctionGroupInfo) { func updateGroup(_ group: YHFunctionGroupInfo) {
titleLabel.text = group.title titleLabel.text = group.title
groupArr = group.arr groupArr = group.arr
...@@ -134,7 +136,11 @@ extension YHMySectionGroupCell: UICollectionViewDelegate, UICollectionViewDataSo ...@@ -134,7 +136,11 @@ extension YHMySectionGroupCell: UICollectionViewDelegate, UICollectionViewDataSo
} }
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if 0 <= indexPath.item && indexPath.item < groupArr.count {
let item: PersonalModuleItem = groupArr[indexPath.item]
if let click = clickItem {
click(item)
}
}
} }
} }
...@@ -19,6 +19,7 @@ class YHMyUserInfoView: UIView { ...@@ -19,6 +19,7 @@ class YHMyUserInfoView: UIView {
var likeClick:(()->Void)? var likeClick:(()->Void)?
var collectClick:(()->Void)? var collectClick:(()->Void)?
var recentScanClick:(()->Void)? var recentScanClick:(()->Void)?
var enterClick:(()->Void)?
lazy var contentView: UIView = { lazy var contentView: UIView = {
let view = UIView() let view = UIView()
...@@ -111,6 +112,12 @@ class YHMyUserInfoView: UIView { ...@@ -111,6 +112,12 @@ class YHMyUserInfoView: UIView {
return imgV return imgV
}() }()
lazy var enterBtn: UIButton = {
let btn = UIButton()
btn.addTarget(self, action: #selector(enterBtnClicked), for: .touchUpInside)
return btn
}()
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
self.clipsToBounds = true self.clipsToBounds = true
...@@ -140,6 +147,7 @@ class YHMyUserInfoView: UIView { ...@@ -140,6 +147,7 @@ class YHMyUserInfoView: UIView {
contentView.addSubview(line2View) contentView.addSubview(line2View)
contentView.addSubview(arrowImgView) contentView.addSubview(arrowImgView)
contentView.addSubview(enterBtn)
contentView.snp.makeConstraints { make in contentView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
...@@ -210,12 +218,21 @@ class YHMyUserInfoView: UIView { ...@@ -210,12 +218,21 @@ class YHMyUserInfoView: UIView {
make.right.equalTo(0) make.right.equalTo(0)
} }
enterBtn.snp.makeConstraints { make in
make.right.top.bottom.equalToSuperview()
make.width.equalTo(enterBtn.snp.height)
}
update(count: 0, label: likeLabel) update(count: 0, label: likeLabel)
update(count: 0, label: collectLabel) update(count: 0, label: collectLabel)
update(count: 0, label: scanLabel) update(count: 0, label: scanLabel)
} }
@objc func enterBtnClicked() {
enterClick?()
}
func updateAvatar() { func updateAvatar() {
let headImgName = YHLoginManager.shared.isLogin() ? "people_head_default" : "mine_head_logout" let headImgName = YHLoginManager.shared.isLogin() ? "people_head_default" : "mine_head_logout"
avarImgView.image = UIImage(named: headImgName) avarImgView.image = UIImage(named: headImgName)
......
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