Commit a5d674bc945be3d0df722779a773d1febf397765
1 parent
6ece0a35
提交修改
Showing
2 changed files
with
48 additions
and
23 deletions
metaCode/Classes/Main/HomePage/View/CNMainView.swift
| @@ -150,6 +150,7 @@ class CNFrontMainView : UIView{ | @@ -150,6 +150,7 @@ class CNFrontMainView : UIView{ | ||
| 150 | @objc func tapAction(){ | 150 | @objc func tapAction(){ |
| 151 | tapTransformAciton!() | 151 | tapTransformAciton!() |
| 152 | } | 152 | } |
| 153 | + | ||
| 153 | @objc func addStandBtnAction() { | 154 | @objc func addStandBtnAction() { |
| 154 | //跳转到添加身份页面 | 155 | //跳转到添加身份页面 |
| 155 | currentViewController()?.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _idModel!), animated: true) | 156 | currentViewController()?.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _idModel!), animated: true) |
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineViewModel.swift
| @@ -269,32 +269,30 @@ class CNLiveMineViewModel: NSObject { | @@ -269,32 +269,30 @@ class CNLiveMineViewModel: NSObject { | ||
| 269 | if CNLiveSaveStandDB.shared.searchAllObject().count > 0 { | 269 | if CNLiveSaveStandDB.shared.searchAllObject().count > 0 { |
| 270 | //第一页 | 270 | //第一页 |
| 271 | if page == 1 { | 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() | 272 | let have_id_auths = CNLiveSaveAuthDB.shared.searchAllObjectId() |
| 282 | let have_auths = NSMutableArray() | 273 | let have_auths = NSMutableArray() |
| 283 | let no_auths = NSMutableArray() | 274 | let no_auths = NSMutableArray() |
| 284 | for item in listModel.list { | 275 | for item in listModel.list { |
| 285 | - item.auth ? have_auths.add(item) : no_auths.add(item) | 276 | + //这里需要及时去刷新认证状态 如果没有及时刷新这里回出现已经认证的状态不会进行排序 |
| 277 | + item.auth && have_id_auths.contains("\(item.id)") ? have_auths.add(item) : no_auths.add(item) | ||
| 286 | } | 278 | } |
| 287 | - if have_auths.count == have_id_auths.count { | ||
| 288 | - for item in have_auths { | ||
| 289 | - | 279 | + let tempArray = NSMutableArray() |
| 280 | + for item in have_auths { | ||
| 281 | + let standModel = item as! StandListModel | ||
| 282 | + let old_index = have_auths.index(of: standModel) | ||
| 283 | + let new_index = have_id_auths.firstIndex(of: "\(standModel.id)") | ||
| 284 | + if old_index != new_index { | ||
| 285 | + swap(&have_auths[new_index!], &have_auths[old_index]) | ||
| 290 | } | 286 | } |
| 291 | } | 287 | } |
| 288 | + tempArray.addObjects(from: have_auths as! [Any]) | ||
| 289 | + tempArray.addObjects(from: no_auths as! [Any]) | ||
| 290 | + listModel.list = tempArray as! [StandListModel] | ||
| 292 | CNLiveSaveStandDB.shared.deleteAllObjects() | 291 | CNLiveSaveStandDB.shared.deleteAllObjects() |
| 293 | CNLiveSaveStandDB.shared.insertObjects(objects: listModel.list) | 292 | CNLiveSaveStandDB.shared.insertObjects(objects: listModel.list) |
| 294 | }else{ | 293 | }else{ |
| 295 | 294 | ||
| 296 | } | 295 | } |
| 297 | - | ||
| 298 | }else{ | 296 | }else{ |
| 299 | CNLiveSaveStandDB.shared.insertObjects(objects: listModel.list) | 297 | CNLiveSaveStandDB.shared.insertObjects(objects: listModel.list) |
| 300 | } | 298 | } |
| @@ -338,9 +336,31 @@ class CNLiveMineViewModel: NSObject { | @@ -338,9 +336,31 @@ class CNLiveMineViewModel: NSObject { | ||
| 338 | let errorCode = "\(resp["errorCode"] ?? "0")" | 336 | let errorCode = "\(resp["errorCode"] ?? "0")" |
| 339 | if (errorCode == "0") { | 337 | if (errorCode == "0") { |
| 340 | let listModel = dictionaryToModel(resp as! [String : Any], MineAuthListBaseModel.self,"data") as! MineAuthListBaseModel | 338 | let listModel = dictionaryToModel(resp as! [String : Any], MineAuthListBaseModel.self,"data") as! MineAuthListBaseModel |
| 341 | - | ||
| 342 | - | ||
| 343 | - | 339 | + if page == 1 { |
| 340 | + let have_id_auths = CNLiveSaveAuthDB.shared.searchAllObjectId() | ||
| 341 | + if have_id_auths.count > 0 { | ||
| 342 | + let tempArray_have = NSMutableArray() | ||
| 343 | + let tempArray_no = NSMutableArray() | ||
| 344 | + for item in listModel.list { | ||
| 345 | + if (have_id_auths.contains("\(item.identityId)")) { | ||
| 346 | + tempArray_have.add(item) | ||
| 347 | + }else{ | ||
| 348 | + tempArray_no.add(item) | ||
| 349 | + } | ||
| 350 | + } | ||
| 351 | + let tempArray = NSMutableArray() | ||
| 352 | + tempArray.adding(tempArray_have) | ||
| 353 | + tempArray.adding(tempArray_no) | ||
| 354 | + listModel.list = tempArray as! [MineAuthListModel] | ||
| 355 | + CNLiveSaveAuthDB.shared.deleteAllObjects() | ||
| 356 | + CNLiveSaveAuthDB.shared.insertObjects(objects: listModel.list) | ||
| 357 | + }else{ | ||
| 358 | + //本地没值 不进行处理 | ||
| 359 | + } | ||
| 360 | + } else { | ||
| 361 | + //多条数据 | ||
| 362 | + | ||
| 363 | + } | ||
| 344 | resultBlock(listModel,.success) | 364 | resultBlock(listModel,.success) |
| 345 | } else { | 365 | } else { |
| 346 | showMessage(message: resp["errorMessage"] as! String) | 366 | showMessage(message: resp["errorMessage"] as! String) |
| @@ -443,13 +463,17 @@ class CNLiveMineViewModel: NSObject { | @@ -443,13 +463,17 @@ class CNLiveMineViewModel: NSObject { | ||
| 443 | let errorCode = "\(resp["errorCode"] ?? "0")" | 463 | let errorCode = "\(resp["errorCode"] ?? "0")" |
| 444 | if (errorCode == "0") { | 464 | if (errorCode == "0") { |
| 445 | let newsModel = dictionaryToModel(resp as! [String : Any], MineStandInfoBaseModel.self,"data") as! MineStandInfoBaseModel | 465 | let newsModel = dictionaryToModel(resp as! [String : Any], MineStandInfoBaseModel.self,"data") as! MineStandInfoBaseModel |
| 446 | - let tempArray = NSMutableArray() | ||
| 447 | - for authinfo in newsModel.authInfos { | ||
| 448 | -// if authinfo.input { | ||
| 449 | - tempArray.add(authinfo) | ||
| 450 | -// } | 466 | + if type == .nodate { |
| 467 | + let tempArray = NSMutableArray() | ||
| 468 | + for authinfo in newsModel.authInfos { | ||
| 469 | + if authinfo.input { | ||
| 470 | + tempArray.add(authinfo) | ||
| 471 | + } | ||
| 472 | + } | ||
| 473 | + resultBlock(tempArray,.success) | ||
| 474 | + }else { | ||
| 475 | + resultBlock(newsModel.authInfos,.success) | ||
| 451 | } | 476 | } |
| 452 | - resultBlock(tempArray,.success) | ||
| 453 | } else { | 477 | } else { |
| 454 | showMessage(message: resp["errorMessage"] as! String) | 478 | showMessage(message: resp["errorMessage"] as! String) |
| 455 | resultBlock(NSNull(),.failed) | 479 | resultBlock(NSNull(),.failed) |