Commit 2ec2ef243f599d50afa2ca01c57cd87051466c69

Authored by 张旭
2 parents ee1b5907 a5d674bc
metaCode/Classes/Main/HomePage/View/CNMainView.swift
... ... @@ -150,6 +150,7 @@ class CNFrontMainView : UIView{
150 150 @objc func tapAction(){
151 151 tapTransformAciton!()
152 152 }
  153 +
153 154 @objc func addStandBtnAction() {
154 155 //跳转到添加身份页面
155 156 // currentViewController()?.navigationController?.pushViewController(CNLiveMineInputViewController.init(listModel: _idModel!), animated: false)
... ...
metaCode/Classes/Main/MinePage/ViewModel/CNLiveMineViewModel.swift
... ... @@ -269,32 +269,30 @@ class CNLiveMineViewModel: NSObject {
269 269 if CNLiveSaveStandDB.shared.searchAllObject().count > 0 {
270 270 //第一页
271 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 272 let have_id_auths = CNLiveSaveAuthDB.shared.searchAllObjectId()
282 273 let have_auths = NSMutableArray()
283 274 let no_auths = NSMutableArray()
284 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 291 CNLiveSaveStandDB.shared.deleteAllObjects()
293 292 CNLiveSaveStandDB.shared.insertObjects(objects: listModel.list)
294 293 }else{
295 294  
296 295 }
297   -
298 296 }else{
299 297 CNLiveSaveStandDB.shared.insertObjects(objects: listModel.list)
300 298 }
... ... @@ -338,9 +336,31 @@ class CNLiveMineViewModel: NSObject {
338 336 let errorCode = "\(resp["errorCode"] ?? "0")"
339 337 if (errorCode == "0") {
340 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 364 resultBlock(listModel,.success)
345 365 } else {
346 366 showMessage(message: resp["errorMessage"] as! String)
... ... @@ -443,13 +463,17 @@ class CNLiveMineViewModel: NSObject {
443 463 let errorCode = "\(resp["errorCode"] ?? "0")"
444 464 if (errorCode == "0") {
445 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 477 } else {
454 478 showMessage(message: resp["errorMessage"] as! String)
455 479 resultBlock(NSNull(),.failed)
... ...