Commit fc9d06b93669ae566a48bbb011b5bf7edf528a3a
1 parent
ee9b8554
提交身份认证界面
Showing
11 changed files
with
536 additions
and
95 deletions
metaCode.xcodeproj/project.pbxproj
| @@ -52,7 +52,8 @@ | @@ -52,7 +52,8 @@ | ||
| 52 | 798A44FF2A30A0A800815935 /* CNLiveInputFeedBackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 798A44FE2A30A0A800815935 /* CNLiveInputFeedBackViewController.swift */; }; | 52 | 798A44FF2A30A0A800815935 /* CNLiveInputFeedBackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 798A44FE2A30A0A800815935 /* CNLiveInputFeedBackViewController.swift */; }; |
| 53 | 79A68C4A2A26E6CE00DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; | 53 | 79A68C4A2A26E6CE00DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; |
| 54 | 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; | 54 | 79A68C4C2A26EA6000DC3B43 /* (null) in Sources */ = {isa = PBXBuildFile; }; |
| 55 | - 79BA085D2AB18E8300D01875 /* CNLiveSaveAuthDataSourceDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BA085C2AB18E8300D01875 /* CNLiveSaveAuthDataSourceDB.swift */; }; | 55 | + 79BA085D2AB18E8300D01875 /* CNLiveSaveAuthDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79BA085C2AB18E8300D01875 /* CNLiveSaveAuthDB.swift */; }; |
| 56 | + 79EABB892AB4497700F3A4E2 /* CNLiveSaveStandDB.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79EABB882AB4497700F3A4E2 /* CNLiveSaveStandDB.swift */; }; | ||
| 56 | 79F4B1162A32B96B00993C03 /* CNLiveMineInfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F4B1152A32B96B00993C03 /* CNLiveMineInfoViewController.swift */; }; | 57 | 79F4B1162A32B96B00993C03 /* CNLiveMineInfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F4B1152A32B96B00993C03 /* CNLiveMineInfoViewController.swift */; }; |
| 57 | 79F4B11A2A32F21400993C03 /* CNLiveMineNickViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F4B1192A32F21400993C03 /* CNLiveMineNickViewController.swift */; }; | 58 | 79F4B11A2A32F21400993C03 /* CNLiveMineNickViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F4B1192A32F21400993C03 /* CNLiveMineNickViewController.swift */; }; |
| 58 | 79F4B11C2A33036E00993C03 /* CNLiveMineInfoAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F4B11B2A33036E00993C03 /* CNLiveMineInfoAlertView.swift */; }; | 59 | 79F4B11C2A33036E00993C03 /* CNLiveMineInfoAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79F4B11B2A33036E00993C03 /* CNLiveMineInfoAlertView.swift */; }; |
| @@ -156,7 +157,8 @@ | @@ -156,7 +157,8 @@ | ||
| 156 | 798A44FC2A309EBA00815935 /* CNLiveTypeFeedBackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveTypeFeedBackViewController.swift; sourceTree = "<group>"; }; | 157 | 798A44FC2A309EBA00815935 /* CNLiveTypeFeedBackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveTypeFeedBackViewController.swift; sourceTree = "<group>"; }; |
| 157 | 798A44FE2A30A0A800815935 /* CNLiveInputFeedBackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveInputFeedBackViewController.swift; sourceTree = "<group>"; }; | 158 | 798A44FE2A30A0A800815935 /* CNLiveInputFeedBackViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveInputFeedBackViewController.swift; sourceTree = "<group>"; }; |
| 158 | 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; }; | 159 | 79A68C512A26F59C00DC3B43 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = metaCode/Info.plist; sourceTree = "<group>"; }; |
| 159 | - 79BA085C2AB18E8300D01875 /* CNLiveSaveAuthDataSourceDB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveSaveAuthDataSourceDB.swift; sourceTree = "<group>"; }; | 160 | + 79BA085C2AB18E8300D01875 /* CNLiveSaveAuthDB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveSaveAuthDB.swift; sourceTree = "<group>"; }; |
| 161 | + 79EABB882AB4497700F3A4E2 /* CNLiveSaveStandDB.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveSaveStandDB.swift; sourceTree = "<group>"; }; | ||
| 160 | 79F4B1152A32B96B00993C03 /* CNLiveMineInfoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineInfoViewController.swift; sourceTree = "<group>"; }; | 162 | 79F4B1152A32B96B00993C03 /* CNLiveMineInfoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineInfoViewController.swift; sourceTree = "<group>"; }; |
| 161 | 79F4B1192A32F21400993C03 /* CNLiveMineNickViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineNickViewController.swift; sourceTree = "<group>"; }; | 163 | 79F4B1192A32F21400993C03 /* CNLiveMineNickViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineNickViewController.swift; sourceTree = "<group>"; }; |
| 162 | 79F4B11B2A33036E00993C03 /* CNLiveMineInfoAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineInfoAlertView.swift; sourceTree = "<group>"; }; | 164 | 79F4B11B2A33036E00993C03 /* CNLiveMineInfoAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveMineInfoAlertView.swift; sourceTree = "<group>"; }; |
| @@ -348,7 +350,8 @@ | @@ -348,7 +350,8 @@ | ||
| 348 | isa = PBXGroup; | 350 | isa = PBXGroup; |
| 349 | children = ( | 351 | children = ( |
| 350 | 7C7C62F52A4D72E9007A912E /* CNLiveIdentityDB.swift */, | 352 | 7C7C62F52A4D72E9007A912E /* CNLiveIdentityDB.swift */, |
| 351 | - 79BA085C2AB18E8300D01875 /* CNLiveSaveAuthDataSourceDB.swift */, | 353 | + 79BA085C2AB18E8300D01875 /* CNLiveSaveAuthDB.swift */, |
| 354 | + 79EABB882AB4497700F3A4E2 /* CNLiveSaveStandDB.swift */, | ||
| 352 | ); | 355 | ); |
| 353 | path = Database; | 356 | path = Database; |
| 354 | sourceTree = "<group>"; | 357 | sourceTree = "<group>"; |
| @@ -856,7 +859,7 @@ | @@ -856,7 +859,7 @@ | ||
| 856 | 7963989D2A260E6200D045EB /* CNLiveBaseViewController.swift in Sources */, | 859 | 7963989D2A260E6200D045EB /* CNLiveBaseViewController.swift in Sources */, |
| 857 | 798A44FB2A30999900815935 /* CNLiveAlertTool.swift in Sources */, | 860 | 798A44FB2A30999900815935 /* CNLiveAlertTool.swift in Sources */, |
| 858 | 790D01A52A2DF65E00C5978D /* CNLiveLoginPickerView.swift in Sources */, | 861 | 790D01A52A2DF65E00C5978D /* CNLiveLoginPickerView.swift in Sources */, |
| 859 | - 79BA085D2AB18E8300D01875 /* CNLiveSaveAuthDataSourceDB.swift in Sources */, | 862 | + 79BA085D2AB18E8300D01875 /* CNLiveSaveAuthDB.swift in Sources */, |
| 860 | 79282A3C2A2EDC2500B5F8CF /* NSString+CNLiveExtensions.swift in Sources */, | 863 | 79282A3C2A2EDC2500B5F8CF /* NSString+CNLiveExtensions.swift in Sources */, |
| 861 | 790B1FB82A41B6A60074CF00 /* CNLiveMineMessageViewController.swift in Sources */, | 864 | 790B1FB82A41B6A60074CF00 /* CNLiveMineMessageViewController.swift in Sources */, |
| 862 | 798A44F22A30674200815935 /* CNLiveMineSubBodyListView.swift in Sources */, | 865 | 798A44F22A30674200815935 /* CNLiveMineSubBodyListView.swift in Sources */, |
| @@ -866,6 +869,7 @@ | @@ -866,6 +869,7 @@ | ||
| 866 | 7CD675482A274167008354C1 /* PGIndexBannerSubiew.m in Sources */, | 869 | 7CD675482A274167008354C1 /* PGIndexBannerSubiew.m in Sources */, |
| 867 | 790D019F2A2DD66E00C5978D /* CNLiveLoginViewModel.swift in Sources */, | 870 | 790D019F2A2DD66E00C5978D /* CNLiveLoginViewModel.swift in Sources */, |
| 868 | 7C7C62F62A4D72E9007A912E /* CNLiveIdentityDB.swift in Sources */, | 871 | 7C7C62F62A4D72E9007A912E /* CNLiveIdentityDB.swift in Sources */, |
| 872 | + 79EABB892AB4497700F3A4E2 /* CNLiveSaveStandDB.swift in Sources */, | ||
| 869 | 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */, | 873 | 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */, |
| 870 | 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */, | 874 | 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */, |
| 871 | 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */, | 875 | 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */, |
metaCode/Classes/Config/Database/CNLiveSaveAuthDB.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveSaveAuthDataSourceDB.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by open on 2023/9/13. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import WCDBSwift | ||
| 10 | + | ||
| 11 | +///身份认证表名 | ||
| 12 | +let CNLiveAuthListTableName = "CNLiveAuthListTable" | ||
| 13 | + | ||
| 14 | +class CNLiveSaveAuthDB : NSObject{ | ||
| 15 | + | ||
| 16 | + ///数据库 | ||
| 17 | + var database: Database | ||
| 18 | + | ||
| 19 | + static let shared = CNLiveSaveAuthDB() | ||
| 20 | + | ||
| 21 | + //重新init方法为私有,不让外部调用 | ||
| 22 | + private override init() { | ||
| 23 | + //数据库地址 | ||
| 24 | + let filePath = NSHomeDirectory() + "/Documents/DB/CNLiveAuthListTable.db" | ||
| 25 | + database = Database(at: filePath) | ||
| 26 | + | ||
| 27 | + super.init() | ||
| 28 | + do { | ||
| 29 | + try database.create(table: CNLiveAuthListTableName, of: MineAuthListModel.self) | ||
| 30 | + } catch { | ||
| 31 | + print("创建失败") | ||
| 32 | + } | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + /// 新增一条数据 | ||
| 36 | + /// - Parameter object: 数据 | ||
| 37 | + func insterObject(object: MineAuthListModel){ | ||
| 38 | + let array: [MineAuthListModel] = [object] | ||
| 39 | + do{ | ||
| 40 | + try database.insert(array, intoTable: CNLiveAuthListTableName) | ||
| 41 | + }catch{ | ||
| 42 | + print("增加一条数据失败") | ||
| 43 | + } | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /// 批量增加数据 | ||
| 47 | + /// - Parameter objects: 数据组 | ||
| 48 | + func insertObjects(objects: [MineAuthListModel]) { | ||
| 49 | + if objects.count > 0 { | ||
| 50 | + do{ | ||
| 51 | + try database.insert(objects, intoTable: CNLiveAuthListTableName) | ||
| 52 | + }catch{ | ||
| 53 | + print("增加一条数据失败") | ||
| 54 | + } | ||
| 55 | + }else{ | ||
| 56 | + print("数据为空") | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /// 删除一条数据 | ||
| 61 | + /// - Parameter delete: 被删除的数据 | ||
| 62 | + func deleteObject(delete: MineAuthListModel){ | ||
| 63 | + | ||
| 64 | + do{ | ||
| 65 | + try database.delete(fromTable: CNLiveAuthListTableName, where: MineAuthListModel.Properties.identityId == delete.identityId) | ||
| 66 | + }catch{ | ||
| 67 | + print("删除一条数据失败") | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /// 删除本地所有数据 | ||
| 72 | + func deleteAllObjects() { | ||
| 73 | + do { | ||
| 74 | + try database.delete(fromTable: CNLiveAuthListTableName) | ||
| 75 | + } catch { | ||
| 76 | + print("数据删除失败") | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + /// 更新一条数据 | ||
| 82 | + /// - Parameter newObject: 更新的数据源 | ||
| 83 | + func updateObject(newObject: MineAuthListModel) { | ||
| 84 | + do{ | ||
| 85 | + //需要更新的字段 | ||
| 86 | + let updateProperties = [MineAuthListModel.Properties.name, | ||
| 87 | + MineAuthListModel.Properties.icon, | ||
| 88 | + MineAuthListModel.Properties.cardImg, | ||
| 89 | + MineAuthListModel.Properties.authTime, | ||
| 90 | + MineAuthListModel.Properties.code, | ||
| 91 | + MineAuthListModel.Properties.userStatus,] | ||
| 92 | + | ||
| 93 | + try database.update(table: CNLiveAuthListTableName, on:updateProperties, with: newObject,where: MineAuthListModel.Properties.identityId == newObject.identityId) | ||
| 94 | + }catch{ | ||
| 95 | + print("更新一条数据失败") | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + /// 更新多条数据 | ||
| 100 | + /// - Parameter newObjects: 新数据数组 | ||
| 101 | + func updateObjects(newObjects: [MineAuthListModel]) { | ||
| 102 | + do { | ||
| 103 | + let tempArray = NSMutableArray() | ||
| 104 | + for _ in newObjects { | ||
| 105 | + //需要更新的字段 | ||
| 106 | + let updateProperties = [MineAuthListModel.Properties.name, | ||
| 107 | + MineAuthListModel.Properties.icon, | ||
| 108 | + MineAuthListModel.Properties.cardImg, | ||
| 109 | + MineAuthListModel.Properties.authTime, | ||
| 110 | + MineAuthListModel.Properties.code, | ||
| 111 | + MineAuthListModel.Properties.userStatus,] | ||
| 112 | + tempArray.add(updateProperties) | ||
| 113 | + } | ||
| 114 | + try database.update(table: CNLiveAuthListTableName, on: tempArray as! [PropertyConvertible], with: newObjects) | ||
| 115 | + } catch { | ||
| 116 | + print("更新多条数据失败") | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + | ||
| 121 | + /// 获取所有数据 | ||
| 122 | + /// - Returns: 返回查找的所以数据 | ||
| 123 | + func searchAllObject() -> Array<MineAuthListModel>{ | ||
| 124 | + do{ | ||
| 125 | + let allData: [MineAuthListModel] = try database.getObjects(fromTable: CNLiveAuthListTableName) | ||
| 126 | + return allData | ||
| 127 | + }catch{ | ||
| 128 | + print("获取失败") | ||
| 129 | + return [] | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + /// 获取所有数据唯一值id | ||
| 134 | + /// - Returns: 返回查找的所以数据 | ||
| 135 | + func searchAllObjectId() -> Array<String>{ | ||
| 136 | + do{ | ||
| 137 | + let allData: [MineAuthListModel] = try database.getObjects(fromTable: CNLiveAuthListTableName) | ||
| 138 | + let tempArray = NSMutableArray.init() | ||
| 139 | + for item in allData { | ||
| 140 | + tempArray.add("\(item.identityId)") | ||
| 141 | + } | ||
| 142 | + return tempArray as! Array<String> | ||
| 143 | + }catch{ | ||
| 144 | + print("获取失败") | ||
| 145 | + return [] | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + /// 通过id获取特定数据 | ||
| 150 | + /// - Parameter identityId: id | ||
| 151 | + /// - Returns: 返回查找的数据 | ||
| 152 | + func searchOneObject(identityId: String) -> MineAuthListModel{ | ||
| 153 | + do { | ||
| 154 | + let searchPropertie = [MineAuthListModel.Properties.identityId] | ||
| 155 | + let array: [MineAuthListModel] = try database.getObjects(on: searchPropertie, fromTable: CNLiveAuthListTableName, where: MineAuthListModel.Properties.identityId == identityId) | ||
| 156 | + return array.count > 0 ? array.first! : MineAuthListModel.init() | ||
| 157 | + } catch { | ||
| 158 | + print("获取失败") | ||
| 159 | + return MineAuthListModel.init() | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | +} |
metaCode/Classes/Config/Database/CNLiveSaveAuthDataSourceDB.swift deleted
100644 → 0
| 1 | -// | ||
| 2 | -// CNLiveSaveAuthDataSourceDB.swift | ||
| 3 | -// metaCode | ||
| 4 | -// | ||
| 5 | -// Created by open on 2023/9/13. | ||
| 6 | -// | ||
| 7 | - | ||
| 8 | -import Foundation | ||
| 9 | -import WCDBSwift | ||
| 10 | - | ||
| 11 | -///身份认证表名 | ||
| 12 | -let CNLiveAuthListTableName = "CNLiveAuthListTable" | ||
| 13 | - | ||
| 14 | - | ||
| 15 | -class CNLiveAuthListDB : NSObject{ | ||
| 16 | - | ||
| 17 | - ///数据库 | ||
| 18 | - var database:Database | ||
| 19 | - | ||
| 20 | - //重新init方法为私有,不让外部调用 | ||
| 21 | - override init() { | ||
| 22 | - | ||
| 23 | - //数据库地址 | ||
| 24 | - let filePath = NSHomeDirectory() + "/Documents/DB/CNLiveAuthListTable.db" | ||
| 25 | - database = Database(at: filePath) | ||
| 26 | - | ||
| 27 | - super.init() | ||
| 28 | - do { | ||
| 29 | - try database.create(table: CNLiveAuthListTableName, of: MineAuthListModel.self) | ||
| 30 | - } catch { | ||
| 31 | - print("创建失败") | ||
| 32 | - } | ||
| 33 | - } | ||
| 34 | -} |
metaCode/Classes/Config/Database/CNLiveSaveStandDB.swift
0 → 100644
| 1 | +// | ||
| 2 | +// CNLiveSaveStanDB.swift | ||
| 3 | +// metaCode | ||
| 4 | +// | ||
| 5 | +// Created by open on 2023/9/15. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import WCDBSwift | ||
| 10 | + | ||
| 11 | +///身份列表表名 identityApi/allList 接口数据存储 | ||
| 12 | +let CNLiveStandListTableName = "CNLiveStandListTableName" | ||
| 13 | +class CNLiveSaveStandDB: NSObject { | ||
| 14 | + | ||
| 15 | + ///数据库 | ||
| 16 | + var database: Database | ||
| 17 | + | ||
| 18 | + static let shared = CNLiveSaveStandDB() | ||
| 19 | + | ||
| 20 | + //重新init方法为私有,不让外部调用 | ||
| 21 | + private override init() { | ||
| 22 | + //数据库地址 | ||
| 23 | + let filePath = NSHomeDirectory() + "/Documents/DB/CNLiveStandListTableName.db" | ||
| 24 | + database = Database(at: filePath) | ||
| 25 | + | ||
| 26 | + super.init() | ||
| 27 | + do { | ||
| 28 | + try database.create(table: CNLiveStandListTableName, of: StandListModel.self) | ||
| 29 | + } catch { | ||
| 30 | + print("创建失败") | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /// 新增一条数据 | ||
| 35 | + /// - Parameter object: 数据 | ||
| 36 | + func insterObject(object: StandListModel){ | ||
| 37 | + let array: [StandListModel] = [object] | ||
| 38 | + do{ | ||
| 39 | + try database.insert(array, intoTable: CNLiveStandListTableName) | ||
| 40 | + }catch{ | ||
| 41 | + print("增加一条数据失败") | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + /// 批量增加数据 | ||
| 46 | + /// - Parameter objects: 数据组 | ||
| 47 | + func insertObjects(objects: [StandListModel]) { | ||
| 48 | + if objects.count > 0 { | ||
| 49 | + do{ | ||
| 50 | + try database.insert(objects, intoTable: CNLiveStandListTableName) | ||
| 51 | + }catch{ | ||
| 52 | + print("增加一条数据失败") | ||
| 53 | + } | ||
| 54 | + }else{ | ||
| 55 | + print("数据为空") | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /// 删除一条数据 | ||
| 60 | + /// - Parameter delete: 被删除的数据 | ||
| 61 | + func deleteObject(delete: StandListModel){ | ||
| 62 | + | ||
| 63 | + do{ | ||
| 64 | + try database.delete(fromTable: CNLiveStandListTableName, where: StandListModel.Properties.id == delete.id) | ||
| 65 | + }catch{ | ||
| 66 | + print("删除一条数据失败") | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + /// 删除本地所有数据 | ||
| 71 | + func deleteAllObjects() { | ||
| 72 | + do { | ||
| 73 | + try database.delete(fromTable: CNLiveStandListTableName) | ||
| 74 | + } catch { | ||
| 75 | + print("数据删除失败") | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + | ||
| 80 | + /// 更新一条数据 | ||
| 81 | + /// - Parameter newObject: 更新的数据源 | ||
| 82 | + func updateObject(newObject: StandListModel){ | ||
| 83 | + do{ | ||
| 84 | + //需要更新的字段 | ||
| 85 | + let updateProperties = [StandListModel.Properties.name, | ||
| 86 | + StandListModel.Properties.enable, | ||
| 87 | + StandListModel.Properties.createTime, | ||
| 88 | + StandListModel.Properties.createTimeString, | ||
| 89 | + StandListModel.Properties.timeString, | ||
| 90 | + StandListModel.Properties.auth, | ||
| 91 | + StandListModel.Properties.backgroundImg, | ||
| 92 | + StandListModel.Properties.backgroundColor, | ||
| 93 | + StandListModel.Properties.backgroundColour, | ||
| 94 | + StandListModel.Properties.description, | ||
| 95 | + StandListModel.Properties.cardImg, | ||
| 96 | + StandListModel.Properties.downPath,] | ||
| 97 | + | ||
| 98 | + try database.update(table: CNLiveStandListTableName, on:updateProperties, with: newObject,where: StandListModel.Properties.id == newObject.id) | ||
| 99 | + }catch{ | ||
| 100 | + print("更新一条数据失败") | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + /// 更新多条数据 | ||
| 105 | + /// - Parameter newObjects: 新数据数组 | ||
| 106 | + func updateObjects(newObjects: [StandListModel]) { | ||
| 107 | + do { | ||
| 108 | + let tempArray = NSMutableArray() | ||
| 109 | + for _ in newObjects { | ||
| 110 | + //需要更新的字段 | ||
| 111 | + let updateProperties = [StandListModel.Properties.name, | ||
| 112 | + StandListModel.Properties.enable, | ||
| 113 | + StandListModel.Properties.createTime, | ||
| 114 | + StandListModel.Properties.createTimeString, | ||
| 115 | + StandListModel.Properties.timeString, | ||
| 116 | + StandListModel.Properties.auth, | ||
| 117 | + StandListModel.Properties.backgroundImg, | ||
| 118 | + StandListModel.Properties.backgroundColor, | ||
| 119 | + StandListModel.Properties.backgroundColour, | ||
| 120 | + StandListModel.Properties.description, | ||
| 121 | + StandListModel.Properties.cardImg, | ||
| 122 | + StandListModel.Properties.downPath,] | ||
| 123 | + tempArray.add(updateProperties) | ||
| 124 | + } | ||
| 125 | + try database.update(table: CNLiveStandListTableName, on: tempArray as! [PropertyConvertible], with: newObjects) | ||
| 126 | + } catch { | ||
| 127 | + print("更新多条数据失败") | ||
| 128 | + } | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + | ||
| 132 | + /// 获取所有数据 | ||
| 133 | + /// - Returns: 返回查找的所以数据 | ||
| 134 | + func searchAllObject() -> Array<StandListModel>{ | ||
| 135 | + do{ | ||
| 136 | + let allData: [StandListModel] = try database.getObjects(fromTable: CNLiveStandListTableName) | ||
| 137 | + return allData | ||
| 138 | + }catch{ | ||
| 139 | + print("获取失败") | ||
| 140 | + return [] | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + /// 获取所有数据唯一值id | ||
| 145 | + /// - Returns: 返回查找的所以数据 | ||
| 146 | + func searchAllObjectId() -> Array<String>{ | ||
| 147 | + do{ | ||
| 148 | + let allData: [StandListModel] = try database.getObjects(fromTable: CNLiveStandListTableName) | ||
| 149 | + let tempArray = NSMutableArray.init() | ||
| 150 | + for item in allData { | ||
| 151 | + tempArray.add("\(item.id)") | ||
| 152 | + } | ||
| 153 | + return tempArray as! Array<String> | ||
| 154 | + }catch{ | ||
| 155 | + print("获取失败") | ||
| 156 | + return [] | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + /// 通过id获取特定数据 | ||
| 161 | + /// - Parameter identityId: id | ||
| 162 | + /// - Returns: 返回查找的数据 | ||
| 163 | + func searchOneObject(identityId: String) -> StandListModel{ | ||
| 164 | + do { | ||
| 165 | + let searchPropertie = [StandListModel.Properties.id] | ||
| 166 | + let array: [StandListModel] = try database.getObjects(on: searchPropertie, fromTable: CNLiveStandListTableName, where: StandListModel.Properties.id == identityId) | ||
| 167 | + return array.count > 0 ? array.first! : StandListModel.init() | ||
| 168 | + } catch { | ||
| 169 | + print("获取失败") | ||
| 170 | + return StandListModel.init() | ||
| 171 | + } | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | +} |
metaCode/Classes/Main/MinePage/Controller/CNLiveMineAddInfoViewController.swift
| @@ -154,12 +154,14 @@ class CNLiveMineAddInfoViewController : CNLiveBaseViewController, UITableViewDel | @@ -154,12 +154,14 @@ class CNLiveMineAddInfoViewController : CNLiveBaseViewController, UITableViewDel | ||
| 154 | if listBaseModel.pageNum == 1 { | 154 | if listBaseModel.pageNum == 1 { |
| 155 | self!.dataArray.removeAllObjects() | 155 | self!.dataArray.removeAllObjects() |
| 156 | self!.dataArray.addObjects(from: (result as! MineAuthListBaseModel).list) | 156 | self!.dataArray.addObjects(from: (result as! MineAuthListBaseModel).list) |
| 157 | - self!.tableView.reloadData() | ||
| 158 | - self!.tableView.mj_header?.endRefreshing() | ||
| 159 | - self!.tableView.mj_footer?.endRefreshing() | ||
| 160 | } | 157 | } |
| 158 | + if listBaseModel.pageNum > 1 { | ||
| 159 | + self!.dataArray.addObjects(from: (result as! MineAuthListBaseModel).list) | ||
| 160 | + } | ||
| 161 | + self!.tableView.reloadData() | ||
| 162 | + self!.tableView.mj_header?.endRefreshing() | ||
| 163 | + self!.tableView.mj_footer?.endRefreshing() | ||
| 161 | if listBaseModel.total == listBaseModel.pageNum { | 164 | if listBaseModel.total == listBaseModel.pageNum { |
| 162 | - self!.tableView.mj_footer?.endRefreshing() | ||
| 163 | self!.tableView.mj_footer?.endRefreshingWithNoMoreData() | 165 | self!.tableView.mj_footer?.endRefreshingWithNoMoreData() |
| 164 | self!.tableView.reloadData() | 166 | self!.tableView.reloadData() |
| 165 | } | 167 | } |
| @@ -271,7 +273,7 @@ extension CNLiveMineAddInfoViewController { | @@ -271,7 +273,7 @@ extension CNLiveMineAddInfoViewController { | ||
| 271 | return MineStandInfoTableViewCell() | 273 | return MineStandInfoTableViewCell() |
| 272 | } | 274 | } |
| 273 | let listModel = listArray[indexPath.row] | 275 | let listModel = listArray[indexPath.row] |
| 274 | - cell.setupWithDataSource(icon: listModel.poster, name: listModel.title,number: listModel.subTitle, time: listModel.createTimeString) | 276 | + cell.setupWithMessageDataSource(icon: listModel.poster, name: listModel.title,number: listModel.subTitle, time: listModel.createTimeString) |
| 275 | cell.userInteractionEnabledWhileDragging = true | 277 | cell.userInteractionEnabledWhileDragging = true |
| 276 | return cell | 278 | return cell |
| 277 | } else { | 279 | } else { |
| @@ -279,7 +281,7 @@ extension CNLiveMineAddInfoViewController { | @@ -279,7 +281,7 @@ extension CNLiveMineAddInfoViewController { | ||
| 279 | return MineStandInfoTableViewCell() | 281 | return MineStandInfoTableViewCell() |
| 280 | } | 282 | } |
| 281 | let authModel = dataArray[indexPath.row] as! MineAuthListModel | 283 | let authModel = dataArray[indexPath.row] as! MineAuthListModel |
| 282 | - cell.setupWithDataSource(icon: authModel.icon!, name: authModel.name!,number: "\(authModel.code)") | 284 | + cell.setupWithAuthDataSource(icon: authModel.icon!, name: authModel.name!,number: authModel.code!) |
| 283 | cell.userInteractionEnabledWhileDragging = false | 285 | cell.userInteractionEnabledWhileDragging = false |
| 284 | return cell | 286 | return cell |
| 285 | } | 287 | } |
| @@ -319,6 +321,8 @@ extension CNLiveMineAddInfoViewController { | @@ -319,6 +321,8 @@ extension CNLiveMineAddInfoViewController { | ||
| 319 | to destinationIndexPath: IndexPath) { | 321 | to destinationIndexPath: IndexPath) { |
| 320 | objc_sync_enter(self) | 322 | objc_sync_enter(self) |
| 321 | swap(&dataArray[sourceIndexPath.row], &dataArray[destinationIndexPath.row]) | 323 | swap(&dataArray[sourceIndexPath.row], &dataArray[destinationIndexPath.row]) |
| 324 | + CNLiveSaveAuthDB.shared.deleteAllObjects() | ||
| 325 | + CNLiveSaveAuthDB.shared.insertObjects(objects: dataArray as! [MineAuthListModel]) | ||
| 322 | objc_sync_exit(self) | 326 | objc_sync_exit(self) |
| 323 | } | 327 | } |
| 324 | } | 328 | } |
metaCode/Classes/Main/MinePage/Controller/CNLiveMineAuthResultViewController.swift
| @@ -116,13 +116,14 @@ class CNLiveMineAuthResultViewController: CNLiveBaseViewController { | @@ -116,13 +116,14 @@ class CNLiveMineAuthResultViewController: CNLiveBaseViewController { | ||
| 116 | 116 | ||
| 117 | @objc func sendInfoActionMothod() { | 117 | @objc func sendInfoActionMothod() { |
| 118 | if _show_type == .result_failer || _show_type == .result_success { | 118 | if _show_type == .result_failer || _show_type == .result_success { |
| 119 | - let tempArray = NSMutableArray.init() | ||
| 120 | - self.navigationController?.viewControllers.forEach({ item in | ||
| 121 | - if (item.isKind(of: NSClassFromString("CNLiveMineInputViewController")!)) { | ||
| 122 | - tempArray.remove(item) | ||
| 123 | - } | ||
| 124 | - }) | ||
| 125 | - self.navigationController?.viewControllers = tempArray as! [CNLiveBaseViewController] | 119 | +// let tempArray = NSMutableArray.init() |
| 120 | +// self.navigationController?.viewControllers.forEach({ item in | ||
| 121 | +// if (item.isKind(of: NSClassFromString("CNLiveMineInputViewController")!)) { | ||
| 122 | +// tempArray.remove(item) | ||
| 123 | +// } | ||
| 124 | +// }) | ||
| 125 | +// self.navigationController?.viewControllers = tempArray as! [CNLiveBaseViewController] | ||
| 126 | + self.navigationController?.popToViewController(CNLiveMineAddInfoViewController.init(show_type: .add), animated: true) | ||
| 126 | } | 127 | } |
| 127 | } | 128 | } |
| 128 | } | 129 | } |
metaCode/Classes/Main/MinePage/Controller/CNLiveMineInputViewController.swift
| @@ -7,8 +7,10 @@ | @@ -7,8 +7,10 @@ | ||
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | import EmptyDataSet_Swift | 9 | import EmptyDataSet_Swift |
| 10 | +import HXPHPicker | ||
| 10 | 11 | ||
| 11 | -class CNLiveMineInputViewController : CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource, EmptyDataSetSource, EmptyDataSetDelegate{ | 12 | +typealias resultUploadImageBlock = (_ url: String) -> Void |
| 13 | +class CNLiveMineInputViewController : CNLiveBaseViewController, UITableViewDelegate, UITableViewDataSource, EmptyDataSetSource, EmptyDataSetDelegate, PhotoPickerControllerDelegate{ | ||
| 12 | 14 | ||
| 13 | let kMineBodyInputAuthCellIdentifier = "kMineBodyInputAuthCellIdentifier" | 15 | let kMineBodyInputAuthCellIdentifier = "kMineBodyInputAuthCellIdentifier" |
| 14 | lazy var tableView: UITableView = { | 16 | lazy var tableView: UITableView = { |
| @@ -40,8 +42,10 @@ class CNLiveMineInputViewController : CNLiveBaseViewController, UITableViewDeleg | @@ -40,8 +42,10 @@ class CNLiveMineInputViewController : CNLiveBaseViewController, UITableViewDeleg | ||
| 40 | lazy var dataArray: NSMutableArray = { | 42 | lazy var dataArray: NSMutableArray = { |
| 41 | return NSMutableArray.init() | 43 | return NSMutableArray.init() |
| 42 | }() | 44 | }() |
| 43 | - | 45 | + |
| 46 | + var select_image: UIImage! | ||
| 44 | var _listModel:StandListModel! | 47 | var _listModel:StandListModel! |
| 48 | + var tempCell:MineBodyInputAuthCell! | ||
| 45 | init(listModel:StandListModel) { | 49 | init(listModel:StandListModel) { |
| 46 | super.init(nibName:nil, bundle:nil) | 50 | super.init(nibName:nil, bundle:nil) |
| 47 | _listModel = listModel | 51 | _listModel = listModel |
| @@ -102,16 +106,31 @@ class CNLiveMineInputViewController : CNLiveBaseViewController, UITableViewDeleg | @@ -102,16 +106,31 @@ class CNLiveMineInputViewController : CNLiveBaseViewController, UITableViewDeleg | ||
| 102 | 106 | ||
| 103 | @objc func sendInfoActionMothod() { | 107 | @objc func sendInfoActionMothod() { |
| 104 | 108 | ||
| 105 | - CNLiveMineViewModel.requestsPOSTAuthInfo(identityId: "\(_listModel.id)", infos: self.dataArray) { [self] result, respStatue in | ||
| 106 | - if respStatue == .success { | ||
| 107 | - showMessage(message: "上传成功") | ||
| 108 | - DispatchQueue.main.asyncAfter(deadline: .now()+1) { [self] in | ||
| 109 | - self.navigationController?.pushViewController(CNLiveMineAuthResultViewController.init(listModel: _listModel,show_type: .result_success), animated: true) | 109 | + setupWithContentUploadImage { [self] url in |
| 110 | + self.tempCell._infoModel?.value = url | ||
| 111 | + CNLiveMineViewModel.requestsPOSTAuthInfo(identityId: "\(_listModel.id)", infos: self.dataArray) { [self] result, respStatue in | ||
| 112 | + if respStatue == .success { | ||
| 113 | + showMessage(message: "上传成功") | ||
| 114 | + DispatchQueue.main.asyncAfter(deadline: .now()+1) { [self] in | ||
| 115 | + self.navigationController?.pushViewController(CNLiveMineAuthResultViewController.init(listModel: _listModel,show_type: .result_success), animated: true) | ||
| 116 | + } | ||
| 110 | } | 117 | } |
| 111 | } | 118 | } |
| 112 | } | 119 | } |
| 113 | } | 120 | } |
| 114 | 121 | ||
| 122 | + private func setupWithContentUploadImage(resultUploadImageBlock: @escaping resultUploadImageBlock) { | ||
| 123 | + if select_image != nil { | ||
| 124 | + UploadManager.uploadImage(imageData: select_image.jpegData(compressionQuality: 1.0)! as NSData, progressBlock: {key, progress in | ||
| 125 | + print("获取进度==>\(progress)") | ||
| 126 | + }, successBlock: { key,url in | ||
| 127 | + resultUploadImageBlock(url) | ||
| 128 | + }) | ||
| 129 | + } else { | ||
| 130 | + resultUploadImageBlock("") | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | + | ||
| 115 | 134 | ||
| 116 | func setupHeaderAndFooter(is_last: Bool) -> UIView { | 135 | func setupHeaderAndFooter(is_last: Bool) -> UIView { |
| 117 | let mainView = UIView.init(frame: CGRect(x: 0, y: 0, width: Int(KSreenWidth), height: 10)); | 136 | let mainView = UIView.init(frame: CGRect(x: 0, y: 0, width: Int(KSreenWidth), height: 10)); |
| @@ -142,15 +161,36 @@ extension CNLiveMineInputViewController { | @@ -142,15 +161,36 @@ extension CNLiveMineInputViewController { | ||
| 142 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | 161 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| 143 | 162 | ||
| 144 | let cell = tableView.dequeueReusableCell(withIdentifier: kMineBodyInputAuthCellIdentifier) as! MineBodyInputAuthCell | 163 | let cell = tableView.dequeueReusableCell(withIdentifier: kMineBodyInputAuthCellIdentifier) as! MineBodyInputAuthCell |
| 145 | - cell.setListModel(infoModel: self.dataArray[indexPath.row] as! MineStandInfoModel, is_last: indexPath.row == self.dataArray.count - 1) { [weak self] in | ||
| 146 | - let is_result = self?.inspectResult() | ||
| 147 | - self?.setupWithSendBtnStatue(statue: is_result ?? true) | 164 | + cell.setListModel(infoModel: self.dataArray[indexPath.row] as! MineStandInfoModel, is_last: indexPath.row == self.dataArray.count - 1) {[weak self] type in |
| 165 | + if type == .end { | ||
| 166 | + let is_result = self?.inspectResult() | ||
| 167 | + self?.setupWithSendBtnStatue(statue: is_result ?? true) | ||
| 168 | + } | ||
| 169 | + if type == .select { | ||
| 170 | + var crop = PhotoCroppingConfiguration.init() | ||
| 171 | + crop.isRoundCrop = true | ||
| 172 | + let configuration = PhotoEditorConfiguration() | ||
| 173 | + configuration.state = .cropping | ||
| 174 | + configuration.cropping = crop | ||
| 175 | + configuration.fixedCropState = true | ||
| 176 | + let config = PhotoTools.getWXPickerConfig() | ||
| 177 | + config.selectMode = .single | ||
| 178 | + config.selectOptions = .photo | ||
| 179 | + config.photoEditor = configuration | ||
| 180 | + config.maximumSelectedPhotoCount = 1 | ||
| 181 | + let pickerController = PhotoPickerController(picker: config) | ||
| 182 | + pickerController.pickerDelegate = self | ||
| 183 | + pickerController.isOriginal = false | ||
| 184 | + self?.navigationController?.present(pickerController, animated: true, completion: nil) | ||
| 185 | + self?.tempCell = cell | ||
| 186 | + } | ||
| 148 | } | 187 | } |
| 149 | return cell | 188 | return cell |
| 150 | } | 189 | } |
| 151 | 190 | ||
| 152 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | 191 | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
| 153 | - return 50 | 192 | + let infoModel = self.dataArray[indexPath.row] as! MineStandInfoModel |
| 193 | + return infoModel.inputType == 6 ? 70 : 50 | ||
| 154 | } | 194 | } |
| 155 | 195 | ||
| 156 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | 196 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| @@ -169,6 +209,19 @@ extension CNLiveMineInputViewController { | @@ -169,6 +209,19 @@ extension CNLiveMineInputViewController { | ||
| 169 | } | 209 | } |
| 170 | } | 210 | } |
| 171 | 211 | ||
| 212 | + func pickerController(_ pickerController: PhotoPickerController, | ||
| 213 | + didFinishSelection result: PickerResult) { | ||
| 214 | + result.getImage { [weak self] (image, photoAsset, index) in | ||
| 215 | + if let image = image { | ||
| 216 | + self?.select_image = image | ||
| 217 | + }else { | ||
| 218 | + print("failed") | ||
| 219 | + } | ||
| 220 | + } completionHandler: { [weak self] (images) in | ||
| 221 | + self?.tempCell.iconView.image = images.first | ||
| 222 | + } | ||
| 223 | + } | ||
| 224 | + | ||
| 172 | private func inspectResult() -> Bool { | 225 | private func inspectResult() -> Bool { |
| 173 | var is_result: Bool = true | 226 | var is_result: Bool = true |
| 174 | for item in self.dataArray { | 227 | for item in self.dataArray { |
metaCode/Classes/Main/MinePage/View/CNLiveMineBodyListView.swift
| @@ -615,7 +615,12 @@ class MIneBodyFiveViewCell: UITableViewCell { | @@ -615,7 +615,12 @@ class MIneBodyFiveViewCell: UITableViewCell { | ||
| 615 | } | 615 | } |
| 616 | } | 616 | } |
| 617 | 617 | ||
| 618 | -typealias resultInputBlock = () -> Void | 618 | +enum CNLiveBodyInputAuthShowType { |
| 619 | + case end//输入结束后 | ||
| 620 | + case select//选择图片 | ||
| 621 | +} | ||
| 622 | + | ||
| 623 | +typealias resultInputBlock = (_ type: CNLiveBodyInputAuthShowType) -> Void | ||
| 619 | class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | 624 | class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { |
| 620 | 625 | ||
| 621 | lazy var mainView: UIView = { | 626 | lazy var mainView: UIView = { |
| @@ -643,6 +648,22 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | @@ -643,6 +648,22 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | ||
| 643 | return contentField | 648 | return contentField |
| 644 | }() | 649 | }() |
| 645 | 650 | ||
| 651 | + lazy var tapGesture = UITapGestureRecognizer() | ||
| 652 | + lazy var iconView: UIImageView = { | ||
| 653 | + let iconView = UIImageView.init() | ||
| 654 | + iconView.backgroundColor = .white | ||
| 655 | + iconView.image = UIImage.imageWithColor(color: HexColor("#f6f6f6")!, size: CGSizeMake(30, 30)) | ||
| 656 | + iconView.contentMode = .scaleToFill | ||
| 657 | + iconView.clipsToBounds = true | ||
| 658 | + iconView.layer.cornerRadius = 5 | ||
| 659 | + iconView.layer.masksToBounds = true | ||
| 660 | + iconView.isHidden = true | ||
| 661 | + iconView.isUserInteractionEnabled = true | ||
| 662 | + tapGesture.addTarget(self, action: #selector(setupSelectButtonAction)) | ||
| 663 | + iconView.addGestureRecognizer(tapGesture) | ||
| 664 | + return iconView | ||
| 665 | + }() | ||
| 666 | + | ||
| 646 | lazy var moreBtn: UIButton = { | 667 | lazy var moreBtn: UIButton = { |
| 647 | let moreBtn = UIButton.init(type: .custom) | 668 | let moreBtn = UIButton.init(type: .custom) |
| 648 | moreBtn.setImage(UIImage(named: "mine_header_message_gray_more"), for: .normal) | 669 | moreBtn.setImage(UIImage(named: "mine_header_message_gray_more"), for: .normal) |
| @@ -668,6 +689,7 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | @@ -668,6 +689,7 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | ||
| 668 | mainView.addSubview(nameLabel) | 689 | mainView.addSubview(nameLabel) |
| 669 | mainView.addSubview(moreBtn) | 690 | mainView.addSubview(moreBtn) |
| 670 | mainView.addSubview(contentField) | 691 | mainView.addSubview(contentField) |
| 692 | + mainView.addSubview(iconView) | ||
| 671 | mainView.addSubview(moreBtn) | 693 | mainView.addSubview(moreBtn) |
| 672 | mainView.addSubview(line_label) | 694 | mainView.addSubview(line_label) |
| 673 | setConstrainta() | 695 | setConstrainta() |
| @@ -681,7 +703,7 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | @@ -681,7 +703,7 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | ||
| 681 | 703 | ||
| 682 | } | 704 | } |
| 683 | 705 | ||
| 684 | - fileprivate var _infoModel : MineStandInfoModel? | 706 | + var _infoModel : MineStandInfoModel? |
| 685 | fileprivate var _resultInputBlock : resultInputBlock? | 707 | fileprivate var _resultInputBlock : resultInputBlock? |
| 686 | func setListModel(infoModel: MineStandInfoModel, is_last: Bool,resultInputBlock: @escaping resultInputBlock) { | 708 | func setListModel(infoModel: MineStandInfoModel, is_last: Bool,resultInputBlock: @escaping resultInputBlock) { |
| 687 | _infoModel = infoModel | 709 | _infoModel = infoModel |
| @@ -703,9 +725,10 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | @@ -703,9 +725,10 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | ||
| 703 | make.centerY.equalToSuperview() | 725 | make.centerY.equalToSuperview() |
| 704 | make.right.equalTo(moreBtn.snp.left) | 726 | make.right.equalTo(moreBtn.snp.left) |
| 705 | } | 727 | } |
| 706 | - }else if (infoModel.inputType == 4) {//禁止输入 显示下拉时间显示 | ||
| 707 | - contentField.isUserInteractionEnabled = false | 728 | + }else if (infoModel.inputType == 6) {//禁止输入 显示证件照 |
| 729 | + contentField.isHidden = true | ||
| 708 | moreBtn.isHidden = false | 730 | moreBtn.isHidden = false |
| 731 | + iconView.isHidden = false | ||
| 709 | contentField.snp.remakeConstraints { make in | 732 | contentField.snp.remakeConstraints { make in |
| 710 | make.centerY.equalToSuperview() | 733 | make.centerY.equalToSuperview() |
| 711 | make.right.equalTo(moreBtn.snp.left) | 734 | make.right.equalTo(moreBtn.snp.left) |
| @@ -736,6 +759,12 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | @@ -736,6 +759,12 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | ||
| 736 | make.centerY.equalToSuperview() | 759 | make.centerY.equalToSuperview() |
| 737 | make.right.equalToSuperview().offset(-5) | 760 | make.right.equalToSuperview().offset(-5) |
| 738 | } | 761 | } |
| 762 | + iconView.snp.makeConstraints { make in | ||
| 763 | + make.centerY.equalToSuperview() | ||
| 764 | + make.right.equalTo(moreBtn.snp.left) | ||
| 765 | + make.height.equalTo(50) | ||
| 766 | + make.width.equalTo(35) | ||
| 767 | + } | ||
| 739 | line_label.snp.makeConstraints { make in | 768 | line_label.snp.makeConstraints { make in |
| 740 | make.centerX.equalToSuperview() | 769 | make.centerX.equalToSuperview() |
| 741 | make.bottom.equalToSuperview().offset(-1) | 770 | make.bottom.equalToSuperview().offset(-1) |
| @@ -750,6 +779,10 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | @@ -750,6 +779,10 @@ class MineBodyInputAuthCell: UITableViewCell, UITextFieldDelegate { | ||
| 750 | 779 | ||
| 751 | func textFieldDidEndEditing(_ textField: UITextField) { | 780 | func textFieldDidEndEditing(_ textField: UITextField) { |
| 752 | _infoModel?.value = textField.text ?? "" | 781 | _infoModel?.value = textField.text ?? "" |
| 753 | - _resultInputBlock!() | 782 | + _resultInputBlock!(.end) |
| 783 | + } | ||
| 784 | + | ||
| 785 | + @objc func setupSelectButtonAction() { | ||
| 786 | + _resultInputBlock!(.select) | ||
| 754 | } | 787 | } |
| 755 | } | 788 | } |
metaCode/Classes/Main/MinePage/View/CNLiveMineSubBodyListView.swift
| @@ -154,13 +154,13 @@ class MineStandInfoTableViewCell: UITableViewCell { | @@ -154,13 +154,13 @@ class MineStandInfoTableViewCell: UITableViewCell { | ||
| 154 | return timeLabel | 154 | return timeLabel |
| 155 | }() | 155 | }() |
| 156 | 156 | ||
| 157 | - public func setupWithDataSource(icon: String, name: String,number: String) { | 157 | + public func setupWithAuthDataSource(icon: String, name: String,number: String) { |
| 158 | iconView.kf.setImage(with: URL(string: icon), placeholder: UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSize(width: 50, height: 50))) | 158 | iconView.kf.setImage(with: URL(string: icon), placeholder: UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSize(width: 50, height: 50))) |
| 159 | titleLabel.text = name | 159 | titleLabel.text = name |
| 160 | numberLabel.text = number | 160 | numberLabel.text = number |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | - public func setupWithDataSource(icon: String, name: String,number: String, time: String) { | 163 | + public func setupWithMessageDataSource(icon: String, name: String,number: String, time: String) { |
| 164 | if !icon.isEmpty { | 164 | if !icon.isEmpty { |
| 165 | iconView.kf.setImage(with: URL(string: icon), placeholder: UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSize(width: 40, height: 40))) | 165 | iconView.kf.setImage(with: URL(string: icon), placeholder: UIImage.imageWithColor(color: HexColor("#f9f9f9")!, size: CGSize(width: 40, height: 40))) |
| 166 | } else { | 166 | } else { |
| @@ -201,6 +201,7 @@ class MineStandInfoTableViewCell: UITableViewCell { | @@ -201,6 +201,7 @@ class MineStandInfoTableViewCell: UITableViewCell { | ||
| 201 | titleLabel.snp.makeConstraints { make in | 201 | titleLabel.snp.makeConstraints { make in |
| 202 | make.centerY.equalToSuperview().offset(-15) | 202 | make.centerY.equalToSuperview().offset(-15) |
| 203 | make.left.equalTo(iconView.snp.right).offset(10) | 203 | make.left.equalTo(iconView.snp.right).offset(10) |
| 204 | + make.right.equalToSuperview().offset(-10) | ||
| 204 | } | 205 | } |
| 205 | numberLabel.snp.makeConstraints { make in | 206 | numberLabel.snp.makeConstraints { make in |
| 206 | make.centerY.equalToSuperview().offset(15) | 207 | make.centerY.equalToSuperview().offset(15) |
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineBaseModel.swift
| @@ -110,6 +110,7 @@ class NewsListModel: BaseModel { | @@ -110,6 +110,7 @@ class NewsListModel: BaseModel { | ||
| 110 | } | 110 | } |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | +// !!!: /api/identityApi/allList 接口数据 | ||
| 113 | class StandListBaseModel: BaseModel { | 114 | class StandListBaseModel: BaseModel { |
| 114 | var prePage: Int = 0 | 115 | var prePage: Int = 0 |
| 115 | var pageSize: Int = 0 | 116 | var pageSize: Int = 0 |
| @@ -133,7 +134,7 @@ class StandListBaseModel: BaseModel { | @@ -133,7 +134,7 @@ class StandListBaseModel: BaseModel { | ||
| 133 | var pages: Int = 0 | 134 | var pages: Int = 0 |
| 134 | } | 135 | } |
| 135 | 136 | ||
| 136 | -class StandListModel: BaseModel { | 137 | +final class StandListModel: BaseModel, TableCodable { |
| 137 | 138 | ||
| 138 | var icon: String? | 139 | var icon: String? |
| 139 | var name: String? | 140 | var name: String? |
| @@ -176,8 +177,30 @@ class StandListModel: BaseModel { | @@ -176,8 +177,30 @@ class StandListModel: BaseModel { | ||
| 176 | return tuple | 177 | return tuple |
| 177 | }) | 178 | }) |
| 178 | } | 179 | } |
| 180 | + | ||
| 181 | + enum CodingKeys: String, CodingTableKey { | ||
| 182 | + typealias Root = StandListModel | ||
| 183 | + static let objectRelationalMapping = TableBinding(CodingKeys.self){ | ||
| 184 | + //设置表的主键key为id,用来区分数据唯一性, 如果id为int类型,可以按实现按顺序递增 | ||
| 185 | + BindColumnConstraint(id, isPrimary: true) | ||
| 186 | + } | ||
| 187 | + case id //不修改数据库字段名,和属性名保持一直 | ||
| 188 | + case name //不修改数据库字段名,和属性名保持一直 | ||
| 189 | + case enable | ||
| 190 | + case createTime | ||
| 191 | + case createTimeString | ||
| 192 | + case timeString | ||
| 193 | + case auth | ||
| 194 | + case backgroundImg | ||
| 195 | + case backgroundColor | ||
| 196 | + case backgroundColour | ||
| 197 | + case description | ||
| 198 | + case cardImg | ||
| 199 | + case downPath | ||
| 200 | + } | ||
| 179 | } | 201 | } |
| 180 | 202 | ||
| 203 | +// !!!: /api/identityApi/getIdentity 接口标记 | ||
| 181 | class MineStandInfoBaseModel: BaseModel { | 204 | class MineStandInfoBaseModel: BaseModel { |
| 182 | var authInfos = [MineStandInfoModel]() | 205 | var authInfos = [MineStandInfoModel]() |
| 183 | var icon: String? | 206 | var icon: String? |
| @@ -197,7 +220,7 @@ class MineStandInfoModel: BaseModel { | @@ -197,7 +220,7 @@ class MineStandInfoModel: BaseModel { | ||
| 197 | var children = [MineStandInfoModel]() | 220 | var children = [MineStandInfoModel]() |
| 198 | } | 221 | } |
| 199 | 222 | ||
| 200 | - | 223 | +// !!!: api/identityApi/myList 数据返回 |
| 201 | class MineAuthListBaseModel: BaseModel { | 224 | class MineAuthListBaseModel: BaseModel { |
| 202 | required init() {} | 225 | required init() {} |
| 203 | 226 | ||
| @@ -223,7 +246,7 @@ class MineAuthListBaseModel: BaseModel { | @@ -223,7 +246,7 @@ class MineAuthListBaseModel: BaseModel { | ||
| 223 | var pages: Int = 0 | 246 | var pages: Int = 0 |
| 224 | } | 247 | } |
| 225 | 248 | ||
| 226 | -final class MineAuthListModel: BaseModel, TableCodable { | 249 | +final class MineAuthListModel: BaseModel , TableCodable { |
| 227 | 250 | ||
| 228 | required init() {} | 251 | required init() {} |
| 229 | 252 | ||
| @@ -231,7 +254,7 @@ final class MineAuthListModel: BaseModel, TableCodable { | @@ -231,7 +254,7 @@ final class MineAuthListModel: BaseModel, TableCodable { | ||
| 231 | var name: String? = "" | 254 | var name: String? = "" |
| 232 | var icon: String? = "" | 255 | var icon: String? = "" |
| 233 | var authTime: Int = 0 | 256 | var authTime: Int = 0 |
| 234 | - var code: Int = 0 | 257 | + var code: String? = "" |
| 235 | var identityId: Int = 0 | 258 | var identityId: Int = 0 |
| 236 | var userStatus: Int = 0 | 259 | var userStatus: Int = 0 |
| 237 | 260 |
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineViewModel.swift
| @@ -25,13 +25,6 @@ enum CNLiveMineResponseType { | @@ -25,13 +25,6 @@ enum CNLiveMineResponseType { | ||
| 25 | case noNetwork | 25 | case noNetwork |
| 26 | case unkonw | 26 | case unkonw |
| 27 | } | 27 | } |
| 28 | - | ||
| 29 | -enum CNLiveMineSortType { | ||
| 30 | - case homepage //主页 | ||
| 31 | - case authlist //我的身份信息列表界面 | ||
| 32 | - case minelist //我的界面->我的身份 | ||
| 33 | -} | ||
| 34 | - | ||
| 35 | enum CNLiveMineGetWriteType { | 28 | enum CNLiveMineGetWriteType { |
| 36 | case nodate //未填写 | 29 | case nodate //未填写 |
| 37 | case havedate //已填写 | 30 | case havedate //已填写 |
| @@ -271,8 +264,43 @@ class CNLiveMineViewModel: NSObject { | @@ -271,8 +264,43 @@ class CNLiveMineViewModel: NSObject { | ||
| 271 | let resp = result as! NSDictionary | 264 | let resp = result as! NSDictionary |
| 272 | let errorCode = "\(resp["errorCode"] ?? "0")" | 265 | let errorCode = "\(resp["errorCode"] ?? "0")" |
| 273 | if (errorCode == "0") { | 266 | if (errorCode == "0") { |
| 274 | - let newsModel = dictionaryToModel(resp as! [String : Any], StandListBaseModel.self,"data") as! StandListBaseModel | ||
| 275 | - resultBlock(newsModel,.success) | 267 | + let listModel = dictionaryToModel(resp as! [String : Any], StandListBaseModel.self,"data") as! StandListBaseModel |
| 268 | + | ||
| 269 | + if CNLiveSaveStandDB.shared.searchAllObject().count > 0 { | ||
| 270 | + //第一页 | ||
| 271 | + if page == 1 { | ||
| 272 | + //在这里主要判断是不是有删除身份的情况 | ||
| 273 | +// let no_id_auths = CNLiveSaveStandDB.shared.searchAllObjectId() | ||
| 274 | +// if no_id_auths.count == listModel.list.count { | ||
| 275 | +// //对获取的数据进行数据更新 | ||
| 276 | +// CNLiveSaveStandDB.shared.updateObjects(newObjects: listModel.list) | ||
| 277 | +// | ||
| 278 | +// } else {//说明服务器有增加/减少的情况 | ||
| 279 | +// | ||
| 280 | +// } | ||
| 281 | + let have_id_auths = CNLiveSaveAuthDB.shared.searchAllObjectId() | ||
| 282 | + let have_auths = NSMutableArray() | ||
| 283 | + let no_auths = NSMutableArray() | ||
| 284 | + for item in listModel.list { | ||
| 285 | + item.auth ? have_auths.add(item) : no_auths.add(item) | ||
| 286 | + } | ||
| 287 | + if have_auths.count == have_id_auths.count { | ||
| 288 | + for item in have_auths { | ||
| 289 | + | ||
| 290 | + } | ||
| 291 | + } | ||
| 292 | + CNLiveSaveStandDB.shared.deleteAllObjects() | ||
| 293 | + CNLiveSaveStandDB.shared.insertObjects(objects: listModel.list) | ||
| 294 | + }else{ | ||
| 295 | + | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | + }else{ | ||
| 299 | + CNLiveSaveStandDB.shared.insertObjects(objects: listModel.list) | ||
| 300 | + } | ||
| 301 | + | ||
| 302 | + | ||
| 303 | + resultBlock(listModel,.success) | ||
| 276 | } else { | 304 | } else { |
| 277 | showMessage(message: resp["errorMessage"] as! String) | 305 | showMessage(message: resp["errorMessage"] as! String) |
| 278 | resultBlock(NSNull(),.failed) | 306 | resultBlock(NSNull(),.failed) |
| @@ -310,6 +338,9 @@ class CNLiveMineViewModel: NSObject { | @@ -310,6 +338,9 @@ class CNLiveMineViewModel: NSObject { | ||
| 310 | let errorCode = "\(resp["errorCode"] ?? "0")" | 338 | let errorCode = "\(resp["errorCode"] ?? "0")" |
| 311 | if (errorCode == "0") { | 339 | if (errorCode == "0") { |
| 312 | let listModel = dictionaryToModel(resp as! [String : Any], MineAuthListBaseModel.self,"data") as! MineAuthListBaseModel | 340 | let listModel = dictionaryToModel(resp as! [String : Any], MineAuthListBaseModel.self,"data") as! MineAuthListBaseModel |
| 341 | + | ||
| 342 | + | ||
| 343 | + | ||
| 313 | resultBlock(listModel,.success) | 344 | resultBlock(listModel,.success) |
| 314 | } else { | 345 | } else { |
| 315 | showMessage(message: resp["errorMessage"] as! String) | 346 | showMessage(message: resp["errorMessage"] as! String) |
| @@ -344,7 +375,8 @@ class CNLiveMineViewModel: NSObject { | @@ -344,7 +375,8 @@ class CNLiveMineViewModel: NSObject { | ||
| 344 | let key = (info as! MineStandInfoModel).name ?? "" | 375 | let key = (info as! MineStandInfoModel).name ?? "" |
| 345 | let authInfoId = (info as! MineStandInfoModel).authInfoId | 376 | let authInfoId = (info as! MineStandInfoModel).authInfoId |
| 346 | let inputType = (info as! MineStandInfoModel).inputType | 377 | let inputType = (info as! MineStandInfoModel).inputType |
| 347 | - if value.count == 0 { | 378 | + let nonEmpty = (info as! MineStandInfoModel).nonEmpty |
| 379 | + if value.count == 0 && nonEmpty { | ||
| 348 | if inputType == 3 { | 380 | if inputType == 3 { |
| 349 | showMessage(message: "请选择\(key)") | 381 | showMessage(message: "请选择\(key)") |
| 350 | return | 382 | return |
| @@ -502,18 +534,6 @@ class CNLiveMineViewModel: NSObject { | @@ -502,18 +534,6 @@ class CNLiveMineViewModel: NSObject { | ||
| 502 | } | 534 | } |
| 503 | } | 535 | } |
| 504 | 536 | ||
| 505 | - | ||
| 506 | - /// 首页及身份认证界面数据获取及排序 | ||
| 507 | - /// - Parameters: | ||
| 508 | - /// - sortType: 回去数据来源 | ||
| 509 | - /// - resultBlock: 数据返回 | ||
| 510 | - static func requestHomePageDataSourceList(sortType: CNLiveMineSortType,resultBlock: @escaping resultBlock) { | ||
| 511 | -// CNLiveMineViewModel.requestsGETAuthInfoList(page: 1) { result, respStatue in | ||
| 512 | -// | ||
| 513 | -// } | ||
| 514 | - | ||
| 515 | - } | ||
| 516 | - | ||
| 517 | /// 获取十位时间戳 | 537 | /// 获取十位时间戳 |
| 518 | static var timeStamp: Int { | 538 | static var timeStamp: Int { |
| 519 | let timeInterval: TimeInterval = NSDate().timeIntervalSince1970 | 539 | let timeInterval: TimeInterval = NSDate().timeIntervalSince1970 |