Commit a7db224a9c966e7cddec148f8004f40d6f788fb0
Merge branch 'master' of http://bj.gitlab.cnlive.com/ios-team/CNLiveMateCode
# Conflicts: # metaCode/Classes/Config/Database/CNLiveIdentityDB.swift
Showing
5 changed files
with
75 additions
and
48 deletions
metaCode/Classes/Config/Database/CNLiveIdentityDB.swift
| @@ -12,12 +12,17 @@ import WCDBSwift | @@ -12,12 +12,17 @@ import WCDBSwift | ||
| 12 | let CNLiveIdentityTableName = "CNLiveIdentityTable" | 12 | let CNLiveIdentityTableName = "CNLiveIdentityTable" |
| 13 | 13 | ||
| 14 | ///身份model | 14 | ///身份model |
| 15 | -final class CNLiveIdentityModel: BaseModel,TableCodable { | ||
| 16 | - var id: String = "" | ||
| 17 | - var name: String? | ||
| 18 | - var icon: String? | ||
| 19 | - var createTime: String? | ||
| 20 | - var enable: Bool? | 15 | + |
| 16 | +class CNLiveIdentityModel: BaseModel,TableCodable { | ||
| 17 | + var id: String = ""//ID号 | ||
| 18 | + var name: String? = ""//名称 | ||
| 19 | + var icon: String? = ""//小圆图标 | ||
| 20 | + var createTime: String? = ""//注册时间 | ||
| 21 | + var enable: Bool?//没用 | ||
| 22 | + var backgroundImg:String? = ""//首页背景图 | ||
| 23 | + var backgroundColour:String? = ""//添加身份按钮背景色 | ||
| 24 | + var description:String? = ""//首页身份说明描述 | ||
| 25 | + var auth: Bool?//身份是否验证 | ||
| 21 | 26 | ||
| 22 | enum CodingKeys: String, CodingTableKey { | 27 | enum CodingKeys: String, CodingTableKey { |
| 23 | typealias Root = CNLiveIdentityModel | 28 | typealias Root = CNLiveIdentityModel |
| @@ -30,6 +35,10 @@ final class CNLiveIdentityModel: BaseModel,TableCodable { | @@ -30,6 +35,10 @@ final class CNLiveIdentityModel: BaseModel,TableCodable { | ||
| 30 | case icon | 35 | case icon |
| 31 | case createTime | 36 | case createTime |
| 32 | case enable | 37 | case enable |
| 38 | + case backgroundImg | ||
| 39 | + case backgroundColour | ||
| 40 | + case description | ||
| 41 | + case auth | ||
| 33 | } | 42 | } |
| 34 | 43 | ||
| 35 | } | 44 | } |
metaCode/Classes/Main/HomePage/Controller/CNMetaCodeHomePageController.swift
| @@ -138,11 +138,6 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -138,11 +138,6 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 138 | 138 | ||
| 139 | self.tabBarY = (self.tabBarController?.tabBar.top)! | 139 | self.tabBarY = (self.tabBarController?.tabBar.top)! |
| 140 | 140 | ||
| 141 | - | ||
| 142 | -// for i in (0..<5) { | ||
| 143 | -// self.dataArray.add("122") | ||
| 144 | -// } | ||
| 145 | - | ||
| 146 | self.getUserIdentityApi() | 141 | self.getUserIdentityApi() |
| 147 | 142 | ||
| 148 | self.setupUI() | 143 | self.setupUI() |
| @@ -266,6 +261,8 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -266,6 +261,8 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 266 | bannerView?.superScrollView = flowView.scrollView | 261 | bannerView?.superScrollView = flowView.scrollView |
| 267 | bannerView?.associatedVCView = self.view | 262 | bannerView?.associatedVCView = self.view |
| 268 | bannerView?.delegate = self | 263 | bannerView?.delegate = self |
| 264 | + let identityModel = dataArray[index] as! CNLiveIdentityModel | ||
| 265 | + | ||
| 269 | return bannerView | 266 | return bannerView |
| 270 | } | 267 | } |
| 271 | 268 | ||
| @@ -395,6 +392,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | @@ -395,6 +392,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel | ||
| 395 | self.dataArray.addObjects(from: listArray) | 392 | self.dataArray.addObjects(from: listArray) |
| 396 | self.addPageView() | 393 | self.addPageView() |
| 397 | self.identityStatus = .haveBeenCertified | 394 | self.identityStatus = .haveBeenCertified |
| 395 | + self.backgroupView.updateData(idArray: listArray ) | ||
| 398 | }else{ | 396 | }else{ |
| 399 | self.identityStatus = .notCertified | 397 | self.identityStatus = .notCertified |
| 400 | } | 398 | } |
metaCode/Classes/Main/HomePage/View/CNHomePageBackgroupView.swift
| @@ -7,6 +7,8 @@ | @@ -7,6 +7,8 @@ | ||
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | import UIKit | 9 | import UIKit |
| 10 | +import Kingfisher | ||
| 11 | + | ||
| 10 | class CNHomePageBackgroupSubView : UIView | 12 | class CNHomePageBackgroupSubView : UIView |
| 11 | { | 13 | { |
| 12 | ///前面的视图 | 14 | ///前面的视图 |
| @@ -90,48 +92,55 @@ class CNHomePageBackgroupView: UIView{ | @@ -90,48 +92,55 @@ class CNHomePageBackgroupView: UIView{ | ||
| 90 | 92 | ||
| 91 | //创建UI | 93 | //创建UI |
| 92 | func initUI(){ | 94 | func initUI(){ |
| 95 | + | ||
| 93 | 96 | ||
| 94 | - for i in (0..<5){ | ||
| 95 | - | 97 | + } |
| 98 | + | ||
| 99 | + func updateData(idArray:Array<CNLiveIdentityModel>){ | ||
| 100 | + for i in (0..<idArray.count){ | ||
| 101 | + | ||
| 96 | let subView: CNHomePageBackgroupSubView = CNHomePageBackgroupSubView.init(frame: self.bounds) | 102 | let subView: CNHomePageBackgroupSubView = CNHomePageBackgroupSubView.init(frame: self.bounds) |
| 97 | subView.frame = self.bounds | 103 | subView.frame = self.bounds |
| 98 | - | ||
| 99 | - | ||
| 100 | - if (i == 0) { | ||
| 101 | - subView.setTitle(title: "志愿者") | ||
| 102 | - subView.setImage(image: UIImage(named: "homePage_backgroup_red")) | ||
| 103 | - subView.name = "志愿者" | ||
| 104 | - } | ||
| 105 | - else if(i == 1){ | ||
| 106 | - subView.setTitle(title: "退伍军人") | ||
| 107 | - subView.setImage(image: UIImage(named: "homePage_backgroup_blue")) | ||
| 108 | - subView.name = "退伍军人" | ||
| 109 | - | ||
| 110 | - } | ||
| 111 | - else if(i == 2){ | ||
| 112 | - subView.setTitle(title: "慈善家") | ||
| 113 | - subView.setImage(image: UIImage(named: "homePage_backgroup_red")) | ||
| 114 | - subView.name = "慈善家" | ||
| 115 | 104 | ||
| 116 | - } | ||
| 117 | - else if(i == 3){ | ||
| 118 | - subView.setTitle(title: "退休干部") | ||
| 119 | - subView.setImage(image: UIImage(named: "homePage_backgroup_blue")) | ||
| 120 | - subView.name = "退休干部" | ||
| 121 | - | ||
| 122 | - } | ||
| 123 | - else if(i == 4){ | ||
| 124 | - subView.setTitle(title: "退休医生") | ||
| 125 | - subView.setImage(image: UIImage(named: "homePage_backgroup_red")) | ||
| 126 | - subView.name = "退伍军人" | 105 | + let idModel:CNLiveIdentityModel = idArray[i] |
| 106 | + let navTitle:String = idModel.name! | ||
| 107 | + subView.setTitle(title: navTitle) | ||
| 108 | + subView.imageView.kf.setImage(with: URL(string: idModel.backgroundImg!)) | ||
| 109 | + //.setImageWith(URL(string: idModel.backgroundImg ?? "")!, placeholderImage: UIImage(named: "homePage_backgroup_red")) | ||
| 110 | +// if (i == 0) { | ||
| 111 | +// | ||
| 112 | +// subView.name = navTitle | ||
| 113 | +// } | ||
| 114 | +// else if(i == 1){ | ||
| 115 | +// subView.setTitle(title: "退伍军人") | ||
| 116 | +// subView.setImage(image: UIImage(named: "homePage_backgroup_blue")) | ||
| 117 | +// subView.name = "退伍军人" | ||
| 118 | +// | ||
| 119 | +// } | ||
| 120 | +// else if(i == 2){ | ||
| 121 | +// subView.setTitle(title: "慈善家") | ||
| 122 | +// subView.setImage(image: UIImage(named: "homePage_backgroup_red")) | ||
| 123 | +// subView.name = "慈善家" | ||
| 124 | +// | ||
| 125 | +// } | ||
| 126 | +// else if(i == 3){ | ||
| 127 | +// subView.setTitle(title: "退休干部") | ||
| 128 | +// subView.setImage(image: UIImage(named: "homePage_backgroup_blue")) | ||
| 129 | +// subView.name = "退休干部" | ||
| 130 | +// | ||
| 131 | +// } | ||
| 132 | +// else if(i == 4){ | ||
| 133 | +// subView.setTitle(title: "退休医生") | ||
| 134 | +// subView.setImage(image: UIImage(named: "homePage_backgroup_red")) | ||
| 135 | +// subView.name = "退伍军人" | ||
| 136 | +// | ||
| 137 | +// } | ||
| 127 | 138 | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | //更新双向链表 | 139 | //更新双向链表 |
| 131 | let lastSubView: CNHomePageBackgroupSubView? = self.dataArray.last | 140 | let lastSubView: CNHomePageBackgroupSubView? = self.dataArray.last |
| 132 | lastSubView?.nextSubView = subView | 141 | lastSubView?.nextSubView = subView |
| 133 | subView.preSubView = lastSubView | 142 | subView.preSubView = lastSubView |
| 134 | - | 143 | + |
| 135 | self.dataArray.append(subView) | 144 | self.dataArray.append(subView) |
| 136 | 145 | ||
| 137 | if i==0 { | 146 | if i==0 { |
| @@ -139,7 +148,7 @@ class CNHomePageBackgroupView: UIView{ | @@ -139,7 +148,7 @@ class CNHomePageBackgroupView: UIView{ | ||
| 139 | self.currentApearViewIndex = i | 148 | self.currentApearViewIndex = i |
| 140 | } | 149 | } |
| 141 | } | 150 | } |
| 142 | - | 151 | + |
| 143 | //倒序添加子view | 152 | //倒序添加子view |
| 144 | for i in self.dataArray.enumerated().reversed() { | 153 | for i in self.dataArray.enumerated().reversed() { |
| 145 | 154 | ||
| @@ -148,10 +157,9 @@ class CNHomePageBackgroupView: UIView{ | @@ -148,10 +157,9 @@ class CNHomePageBackgroupView: UIView{ | ||
| 148 | 157 | ||
| 149 | } | 158 | } |
| 150 | 159 | ||
| 151 | - | 160 | + |
| 152 | let subView: CNHomePageBackgroupSubView = CNHomePageBackgroupSubView.init(frame: self.bounds) | 161 | let subView: CNHomePageBackgroupSubView = CNHomePageBackgroupSubView.init(frame: self.bounds) |
| 153 | subView.frame = self.bounds | 162 | subView.frame = self.bounds |
| 154 | - | ||
| 155 | } | 163 | } |
| 156 | 164 | ||
| 157 | //MARK: - 公开方法 | 165 | //MARK: - 公开方法 |
metaCode/Classes/Main/HomePage/View/CNMainView.swift
| @@ -27,6 +27,14 @@ class CNFrontMainView : UIView{ | @@ -27,6 +27,14 @@ class CNFrontMainView : UIView{ | ||
| 27 | required init?(coder: NSCoder) { | 27 | required init?(coder: NSCoder) { |
| 28 | fatalError("init(coder:) has not been implemented") | 28 | fatalError("init(coder:) has not been implemented") |
| 29 | } | 29 | } |
| 30 | + lazy var nameLabel: UILabel = { | ||
| 31 | + let nameLabel = UILabel.init() | ||
| 32 | + nameLabel.textColor = .white | ||
| 33 | + nameLabel.font = Font_16 | ||
| 34 | + nameLabel.text = "啊啊" | ||
| 35 | + nameLabel.textColor = .red | ||
| 36 | + return nameLabel | ||
| 37 | + }() | ||
| 30 | 38 | ||
| 31 | lazy var imageView:UIImageView = { | 39 | lazy var imageView:UIImageView = { |
| 32 | 40 | ||
| @@ -55,6 +63,10 @@ class CNFrontMainView : UIView{ | @@ -55,6 +63,10 @@ class CNFrontMainView : UIView{ | ||
| 55 | imageView.image = UIImage.init(named: "homePage_mainView_front"); | 63 | imageView.image = UIImage.init(named: "homePage_mainView_front"); |
| 56 | contentView.addSubview(imageView) | 64 | contentView.addSubview(imageView) |
| 57 | 65 | ||
| 66 | + nameLabel.frame = CGRect(x: 0, y: 0, width: 100, height: 30) | ||
| 67 | + nameLabel.text = "啊啊" | ||
| 68 | + contentView.addSubview(nameLabel) | ||
| 69 | + | ||
| 58 | return contentView | 70 | return contentView |
| 59 | 71 | ||
| 60 | }() | 72 | }() |
metaCode/Classes/Main/HomePage/ViewModel/CNHomePageViewModel.swift
| @@ -27,7 +27,7 @@ class CNLiveHomePageViewModel:NSObject { | @@ -27,7 +27,7 @@ class CNLiveHomePageViewModel:NSObject { | ||
| 27 | //从网络获取 | 27 | //从网络获取 |
| 28 | CNLiveNetworking.setAllowRequestDefaultArgument(false) | 28 | CNLiveNetworking.setAllowRequestDefaultArgument(false) |
| 29 | CNLiveNetworking.setupShowDataResult(false) | 29 | CNLiveNetworking.setupShowDataResult(false) |
| 30 | - CNLiveNetworking.requestNetwork(with: .GET, urlString: "\(APPBaseMCUrl)/identityApi/list?sid=\(UserInfoManager.shared.userInfo.uid)&page=1&pageSize=1000", param: nil, cacheType: .networkOnly) { task , result, error in | 30 | + CNLiveNetworking.requestNetwork(with: .GET, urlString: "\(APPBaseMCUrl)/identityApi/allList?sid=\(UserInfoManager.shared.userInfo.uid)&page=1&pageSize=1000", param: nil, cacheType: .networkOnly) { task , result, error in |
| 31 | 31 | ||
| 32 | if((error) != nil){ | 32 | if((error) != nil){ |
| 33 | //网络请求失败 | 33 | //网络请求失败 |