Commit 69d9485468da59111ac2fec4ddcbcace6413197d
1 parent
95533522
首页修改
Showing
5 changed files
with
73 additions
and
47 deletions
metaCode/Classes/Config/Database/CNLiveIdentityDB.swift
| ... | ... | @@ -13,11 +13,15 @@ let CNLiveIdentityTableName = "CNLiveIdentityTable" |
| 13 | 13 | |
| 14 | 14 | ///身份model |
| 15 | 15 | class CNLiveIdentityModel: BaseModel,TableCodable { |
| 16 | - var id: String = "" | |
| 17 | - var name: String? | |
| 18 | - var icon: String? | |
| 19 | - var createTime: String? | |
| 20 | - var enable: Bool? | |
| 16 | + var id: String = ""//ID号 | |
| 17 | + var name: String? = ""//名称 | |
| 18 | + var icon: String? = ""//小圆图标 | |
| 19 | + var createTime: String? = ""//注册时间 | |
| 20 | + var enable: Bool?//没用 | |
| 21 | + var backgroundImg:String? = ""//首页背景图 | |
| 22 | + var backgroundColour:String? = ""//添加身份按钮背景色 | |
| 23 | + var description:String? = ""//首页身份说明描述 | |
| 24 | + var auth: Bool?//身份是否验证 | |
| 21 | 25 | |
| 22 | 26 | enum CodingKeys: String, CodingTableKey { |
| 23 | 27 | typealias Root = CNLiveIdentityModel |
| ... | ... | @@ -30,6 +34,10 @@ class CNLiveIdentityModel: BaseModel,TableCodable { |
| 30 | 34 | case icon |
| 31 | 35 | case createTime |
| 32 | 36 | case enable |
| 37 | + case backgroundImg | |
| 38 | + case backgroundColour | |
| 39 | + case description | |
| 40 | + case auth | |
| 33 | 41 | } |
| 34 | 42 | |
| 35 | 43 | } | ... | ... |
metaCode/Classes/Main/HomePage/Controller/CNMetaCodeHomePageController.swift
| ... | ... | @@ -138,11 +138,6 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel |
| 138 | 138 | |
| 139 | 139 | self.tabBarY = (self.tabBarController?.tabBar.top)! |
| 140 | 140 | |
| 141 | - | |
| 142 | -// for i in (0..<5) { | |
| 143 | -// self.dataArray.add("122") | |
| 144 | -// } | |
| 145 | - | |
| 146 | 141 | self.getUserIdentityApi() |
| 147 | 142 | |
| 148 | 143 | self.setupUI() |
| ... | ... | @@ -266,6 +261,8 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel |
| 266 | 261 | bannerView?.superScrollView = flowView.scrollView |
| 267 | 262 | bannerView?.associatedVCView = self.view |
| 268 | 263 | bannerView?.delegate = self |
| 264 | + let identityModel = dataArray[index] as! CNLiveIdentityModel | |
| 265 | + | |
| 269 | 266 | return bannerView |
| 270 | 267 | } |
| 271 | 268 | |
| ... | ... | @@ -395,6 +392,7 @@ class CNMetaCodeHomePageController:CNLiveBaseViewController, NewPagedFlowViewDel |
| 395 | 392 | self.dataArray.addObjects(from: listArray) |
| 396 | 393 | self.addPageView() |
| 397 | 394 | self.identityStatus = .haveBeenCertified |
| 395 | + self.backgroupView.updateData(idArray: listArray ) | |
| 398 | 396 | }else{ |
| 399 | 397 | self.identityStatus = .notCertified |
| 400 | 398 | } | ... | ... |
metaCode/Classes/Main/HomePage/View/CNHomePageBackgroupView.swift
| ... | ... | @@ -7,6 +7,8 @@ |
| 7 | 7 | |
| 8 | 8 | import Foundation |
| 9 | 9 | import UIKit |
| 10 | +import Kingfisher | |
| 11 | + | |
| 10 | 12 | class CNHomePageBackgroupSubView : UIView |
| 11 | 13 | { |
| 12 | 14 | ///前面的视图 |
| ... | ... | @@ -90,48 +92,55 @@ class CNHomePageBackgroupView: UIView{ |
| 90 | 92 | |
| 91 | 93 | //创建UI |
| 92 | 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 | 102 | let subView: CNHomePageBackgroupSubView = CNHomePageBackgroupSubView.init(frame: self.bounds) |
| 97 | 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 | 140 | let lastSubView: CNHomePageBackgroupSubView? = self.dataArray.last |
| 132 | 141 | lastSubView?.nextSubView = subView |
| 133 | 142 | subView.preSubView = lastSubView |
| 134 | - | |
| 143 | + | |
| 135 | 144 | self.dataArray.append(subView) |
| 136 | 145 | |
| 137 | 146 | if i==0 { |
| ... | ... | @@ -139,7 +148,7 @@ class CNHomePageBackgroupView: UIView{ |
| 139 | 148 | self.currentApearViewIndex = i |
| 140 | 149 | } |
| 141 | 150 | } |
| 142 | - | |
| 151 | + | |
| 143 | 152 | //倒序添加子view |
| 144 | 153 | for i in self.dataArray.enumerated().reversed() { |
| 145 | 154 | |
| ... | ... | @@ -148,10 +157,9 @@ class CNHomePageBackgroupView: UIView{ |
| 148 | 157 | |
| 149 | 158 | } |
| 150 | 159 | |
| 151 | - | |
| 160 | + | |
| 152 | 161 | let subView: CNHomePageBackgroupSubView = CNHomePageBackgroupSubView.init(frame: self.bounds) |
| 153 | 162 | subView.frame = self.bounds |
| 154 | - | |
| 155 | 163 | } |
| 156 | 164 | |
| 157 | 165 | //MARK: - 公开方法 | ... | ... |
metaCode/Classes/Main/HomePage/View/CNMainView.swift
| ... | ... | @@ -27,6 +27,14 @@ class CNFrontMainView : UIView{ |
| 27 | 27 | required init?(coder: NSCoder) { |
| 28 | 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 | 39 | lazy var imageView:UIImageView = { |
| 32 | 40 | |
| ... | ... | @@ -55,6 +63,10 @@ class CNFrontMainView : UIView{ |
| 55 | 63 | imageView.image = UIImage.init(named: "homePage_mainView_front"); |
| 56 | 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 | 70 | return contentView |
| 59 | 71 | |
| 60 | 72 | }() | ... | ... |
metaCode/Classes/Main/HomePage/ViewModel/CNHomePageViewModel.swift
| ... | ... | @@ -27,7 +27,7 @@ class CNLiveHomePageViewModel:NSObject { |
| 27 | 27 | //从网络获取 |
| 28 | 28 | CNLiveNetworking.setAllowRequestDefaultArgument(false) |
| 29 | 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 | 32 | if((error) != nil){ |
| 33 | 33 | //网络请求失败 | ... | ... |