From 642175113bf6f2c90894e689dacda50278cad570 Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期四, 19 九月 2024 15:50:11 +0800 Subject: [PATCH] complete most UI & Mock API --- XQMuse/Root/Me/VC/ContactCustomerVC.swift | 31 ++++++++++++++++++++++++++++--- 1 files changed, 28 insertions(+), 3 deletions(-) diff --git a/XQMuse/Root/Me/VC/ContactCustomerVC.swift b/XQMuse/Root/Me/VC/ContactCustomerVC.swift index ea559d8..b23bdc7 100644 --- a/XQMuse/Root/Me/VC/ContactCustomerVC.swift +++ b/XQMuse/Root/Me/VC/ContactCustomerVC.swift @@ -6,11 +6,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 = "联系客服" @@ -20,22 +31,36 @@ 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 vc = ContactCustomerDetailVC() + 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 cell = tableView.dequeueReusableCell(withIdentifier: "_ContactCustomerTCell", for: indexPath) as! ContactCustomerTCell + 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 10 + return viewModel.dataSource.value?.list.count ?? 0 } -- Gitblit v1.7.1