From 858bd6df13a6a6415d12d8e60141575574646f58 Mon Sep 17 00:00:00 2001
From: younger_times <841720330@qq.com>
Date: 星期一, 24 七月 2023 18:23:48 +0800
Subject: [PATCH] 新增

---
 WanPai/Root/Search/VC/CustomerSubListVC.swift |   40 +++++++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/WanPai/Root/Search/VC/CustomerSubListVC.swift b/WanPai/Root/Search/VC/CustomerSubListVC.swift
index 31bc505..667c7d0 100644
--- a/WanPai/Root/Search/VC/CustomerSubListVC.swift
+++ b/WanPai/Root/Search/VC/CustomerSubListVC.swift
@@ -7,16 +7,26 @@
 
 import UIKit
 import JQTools
+import RxSwift
+import RxRelay
+
+class CustomerContentViewModel:RefreshModel<NoticeItemModel>{
+    var type = BehaviorRelay<CustomerSubListVC.CustomerSubType>.init(value: .notice)
+    override func api() -> (Observable<BaseResponse<[NoticeItemModel]>>)? {
+        return Services.exploreNoticeList(type: type.value)
+    }
+}
 
 class CustomerSubListVC: BaseVC {
 
-    enum CustomerSubType {
-        case notice
-        case QA
+    private let viewModel = CustomerContentViewModel()
+
+    public enum CustomerSubType {
+        case notice,QA
     }
 
-    lazy var tableView:UITableView = {
-        let table = UITableView(frame: .zero, style: .plain)
+    lazy var tableView:BaseTableView = {
+        let table = BaseTableView(frame: .zero, style: .plain)
         table.separatorStyle = .none
         table.delegate = self
         table.dataSource = self
@@ -26,12 +36,10 @@
         return table
     }()
 
-    private var type:CustomerSubType!
-
 
     init(type: CustomerSubType!) {
         super.init(nibName: nil, bundle: nil)
-        self.type = type
+        viewModel.type.accept(type)
     }
 
     required init?(coder: NSCoder) {
@@ -42,13 +50,15 @@
     override func viewDidLoad() {
         super.viewDidLoad()
 
-
-        if type == .QA{
+        if viewModel.type.value == .QA{
             let headView = UIView()
             headView.backgroundColor = .jq_randomColor
             headView.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: JQ_ScreenW * 0.564)
             tableView.tableHeaderView = headView
         }
+
+        viewModel.configure(tableView,needMore: false)
+        viewModel.beginRefresh()
     }
 
     override func setUI() {
@@ -61,22 +71,26 @@
 
 extension CustomerSubListVC:UITableViewDelegate{
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-        let vc = CustomerContentDetailVC()
+        let model = viewModel.dataSource.value[indexPath.row]
+        let vc = CustomerContentDetailVC(id: model.noticeId, type: viewModel.type.value)
         push(vc: vc)
     }
 }
 
 extension CustomerSubListVC:UITableViewDataSource{
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-         return 15
+        return viewModel.dataSource.value.count
     }
 
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        if type == .notice{
+        let model = viewModel.dataSource.value[indexPath.row]
+        if  viewModel.type.value == .notice{
         let cell = tableView.dequeueReusableCell(withIdentifier: "_CustomerContentTCell") as! CustomerContentTCell
+            cell.noticeItemModel = model
         return cell
         }else{
             let cell = tableView.dequeueReusableCell(withIdentifier: "_CustomerContentQATCell") as! CustomerContentQATCell
+            cell.noticeItemModel = model
             return cell
         }
     }

--
Gitblit v1.7.1