//
|
// ContactCustomerVC.swift
|
// XQMuse
|
//
|
// Created by 无故事王国 on 2024/8/22.
|
//
|
|
import UIKit
|
import RxSwift
|
import JQTools
|
|
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!
|
private var customerImageView:UIImageView?
|
|
private var headView:UIView = {
|
let v = UIView()
|
return v
|
}()
|
|
private var viewModel = ContactCustomerViewModel()
|
private var customerImage:UIImage?
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
title = "联系客服"
|
|
headView.bounds = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: 248)
|
customerImageView = UIImageView()
|
headView.addSubview(customerImageView!)
|
customerImageView!.snp.makeConstraints { make in
|
make.top.equalTo(50.5)
|
make.centerX.equalToSuperview()
|
make.width.height.equalTo(130.8)
|
}
|
|
let hintL = UILabel()
|
hintL.text = "扫码添加客服微信"
|
hintL.textColor = UIColor(hexString: "#333333")
|
hintL.font = .systemFont(ofSize: 13, weight: .medium)
|
headView.addSubview(hintL)
|
hintL.snp.makeConstraints { make in
|
make.top.equalTo(customerImageView!.snp.bottom).offset(13)
|
make.centerX.equalToSuperview()
|
}
|
|
tableView.tableHeaderView = headView
|
tableView.separatorStyle = .none
|
tableView.backgroundColor = .clear
|
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.customerImageView?.sd_setImage(with: URL(string: m))
|
}
|
}).disposed(by: disposeBag)
|
|
// let longPress = UILongPressGestureRecognizer(target: self, action: #selector(longPressCopyAction(_:)))
|
// longPress.minimumPressDuration = 0.8
|
// image_qrCode.isUserInteractionEnabled = true
|
// image_qrCode.addGestureRecognizer(longPress)
|
}
|
|
@objc private func longPressCopyAction(_ gesture:UILongPressGestureRecognizer){
|
// if gesture.state == .began{
|
// if let img = image_qrCode.image{
|
// image_qrCode.isUserInteractionEnabled = false
|
// UIImageWriteToSavedPhotosAlbum(img, nil,nil, nil)
|
// alertSuccess(msg: "保存成功")
|
// }
|
// }
|
}
|
}
|
|
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, heightForHeaderInSection section: Int) -> CGFloat {
|
return 51
|
}
|
|
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
|
var headView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "headerView")
|
if headView == nil{
|
headView = UITableViewHeaderFooterView(reuseIdentifier: "headerView")
|
headView?.contentView.backgroundColor = .white
|
let label = UILabel()
|
label.text = "问题类型"
|
label.font = .systemFont(ofSize: 15, weight: .bold)
|
headView?.contentView.addSubview(label)
|
label.snp.makeConstraints { make in
|
make.left.equalTo(18)
|
make.bottom.equalToSuperview().offset(-4.5)
|
}
|
}
|
headView?.backgroundColor = .white
|
return headView
|
}
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
return viewModel.dataSource.value?.list.count ?? 0
|
}
|
|
|
}
|