杨锴
2024-09-19 642175113bf6f2c90894e689dacda50278cad570
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
//  ContactCustomerVC.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/8/22.
//
 
import UIKit
import RxSwift
 
class ContactCustomerViewModel:RefreshInnerModel<CommonQuestionModel>{
                override func api() -> (Observable<BaseResponse<BaseResponseList<CommonQuestionModel>>>)? {
                                return Services.commonQuestion(page: page, pageSize: 20)
                }
}
 
class ContactCustomerVC: BaseVC {
 
                @IBOutlet weak var tableView: UITableView!
                @IBOutlet weak var image_qrCode: UIImageView!
                
                private var viewModel = ContactCustomerViewModel()
                private var customerImage:UIImage?
 
    override func viewDidLoad() {
        super.viewDidLoad()
                                title = "联系客服"
 
                                tableView.separatorStyle = .none
                                tableView.delegate = self
                                tableView.dataSource = self
                                tableView.showsVerticalScrollIndicator = false
                                tableView.register(UINib(nibName: "ContactCustomerTCell", bundle: nil), forCellReuseIdentifier: "_ContactCustomerTCell")
 
                                viewModel.configure(tableView)
                                viewModel.beginRefresh()
 
                                Services.getCustomerCode().subscribe(onNext: {data in
                                                if let m = data.data{
                                                                self.customerImage = UIImage.jq_GenerateQRCode(with: m, width: 200)
                                                                self.image_qrCode.image = self.customerImage
                                                }
                                }).disposed(by: disposeBag)
    }
}
 
extension ContactCustomerVC:UITableViewDelegate & UITableViewDataSource{
                func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
                                let model = viewModel.dataSource.value!.list[indexPath.row]
                                let vc = ContactCustomerDetailVC(model,customerImage: customerImage)
                                push(vc: vc)
                }
 
                func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
                                let model = viewModel.dataSource.value!.list[indexPath.row]
                                let cell = tableView.dequeueReusableCell(withIdentifier: "_ContactCustomerTCell", for: indexPath) as!
                                ContactCustomerTCell
                                cell.setCommonQuestionModel(model)
                                return cell
                }
 
                func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
                                return viewModel.dataSource.value?.list.count ?? 0
                }
 
 
}