| | |
| | | |
| | | import UIKit |
| | | import RxSwift |
| | | import JQTools |
| | | |
| | | class ContactCustomerViewModel:RefreshInnerModel<CommonQuestionModel>{ |
| | | override func api() -> (Observable<BaseResponse<BaseResponseList<CommonQuestionModel>>>)? { |
| | |
| | | class ContactCustomerVC: BaseVC { |
| | | |
| | | @IBOutlet weak var tableView: UITableView! |
| | | @IBOutlet weak var image_qrCode: UIImageView! |
| | | |
| | | private var customerImageView:UIImageView? |
| | | |
| | | private var headView:UIView = { |
| | | let v = UIView() |
| | | return v |
| | | }() |
| | | |
| | | private var viewModel = ContactCustomerViewModel() |
| | | private var customerImage:UIImage? |
| | | |
| | |
| | | super.viewDidLoad() |
| | | title = "联系客服" |
| | | |
| | | tableView.separatorStyle = .none |
| | | 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 |
| | |
| | | |
| | | 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 |
| | | 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) |
| | | // 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: "保存成功") |
| | | } |
| | | } |
| | | // if gesture.state == .began{ |
| | | // if let img = image_qrCode.image{ |
| | | // image_qrCode.isUserInteractionEnabled = false |
| | | // UIImageWriteToSavedPhotosAlbum(img, nil,nil, nil) |
| | | // alertSuccess(msg: "保存成功") |
| | | // } |
| | | // } |
| | | } |
| | | } |
| | | |
| | |
| | | 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 |
| | | } |