//
|
// 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
|
}
|
|
|
}
|