//
|
// MineOnlineCustomerServiceVC.swift
|
// OKProject
|
//
|
// Created by alvin_y on 2020/6/17.
|
// Copyright © 2020 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
|
/// 在线客服
|
class MineOnlineCustomerServiceVC: YYViewController {
|
|
/// 提交
|
@IBOutlet weak var button_submit: YYButton!
|
|
/// 字符
|
@IBOutlet weak var label_character: UILabel!
|
|
/// 输入框
|
@IBOutlet weak var textView: YYTextView!
|
|
let viewModel = MineOnlineCustomerServiceViewModel()
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
|
// Do any additional setup after loading the view.
|
}
|
|
|
//MARK: - UI
|
override func setupViews() {
|
super.setupViews()
|
navigationItem.title = "在线客服"
|
view.backgroundColor = UIColor.color(light: UIColor.color(hexString: "#F3F4F5"), dark: UIColor.color(hexString: "#F3F4F5"))
|
navigationItem.rightBarButtonItem = UIBarButtonItem.yy_creat(title: "记录", UIFont.systemFont(ofSize: 14), UIColor.color(light: UIColor.color(hexString: "#666666"), dark: UIColor.color(hexString: "#666666")), target: self, action: #selector(record)).item
|
}
|
|
//MARK: - Rx
|
override func bindRx() {
|
super.bindRx()
|
|
textView.rx.text.orEmpty.bind(to: viewModel.content).disposed(by: disposeBag)
|
|
textView.rx.text.subscribe(onNext: {[unowned self] (_) in
|
let leng = self.textView.text.length
|
self.label_character.text = "还可以输入\(200 - leng)字"
|
}).disposed(by: disposeBag)
|
|
button_submit.rx.tap.subscribe(onNext: {[unowned self] (_) in
|
if self.textView.text.isEmpty{
|
alert(text: "请输入留言内容")
|
return
|
}
|
self.viewModel.leaveMessage()
|
}).disposed(by: disposeBag)
|
|
|
/// 留言
|
viewModel.requestSubject
|
.subscribe(onNext: {[unowned self] (status) in
|
switch status{
|
case .loading:
|
self.show()
|
break
|
case .success(_):
|
self.hide()
|
self.textView.text = nil
|
alert(text: "留言成功")
|
// alert(popup: .single, title: "提示", text: "留言成功!我们将尽快处理", submitTitle: "确定", cancelTitle: nil, submitClick: {
|
//
|
// }) {}
|
break
|
case .error(let error):
|
self.hide()
|
alert(text: error.localizedDescription)
|
break
|
}
|
}).disposed(by: rx.disposeBag)
|
}
|
|
|
/// 记录
|
@objc func record(){
|
let vc = MineLeaveMessageRecordVC()
|
self.yy_push(vc: vc)
|
}
|
}
|