//
|
// VoiceSettingVC.swift
|
// OKProject
|
//
|
// Created by 杨锴 on 2023/6/12.
|
// Copyright © 2023 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
import QMUIKit
|
|
|
class VoiceSettingVC: YYViewController {
|
|
@IBOutlet weak var label_hint: QMUIButton!
|
@IBOutlet weak var view_hint: UIView!
|
@IBOutlet weak var btn_handle: UIButton!
|
|
private let userInfoViewModel = HomeLeftMenuViewModel()
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
title = "车内录音设置"
|
|
|
userInfoViewModel.queryUserInfo()
|
userInfoViewModel.requestSubject
|
.subscribe(onNext: {[unowned self] (status) in
|
switch status{
|
case .loading:
|
break
|
case .success(let model):
|
guard let data = model as? UserInfoModel else{return}
|
app.userInfo.save(model: data)
|
|
switch data.soundSet{
|
case 1:
|
label_hint.setTitle("车内录音功能已开启", for: .normal)
|
view_hint.backgroundColor = UIColor(hexString: "#45B494")
|
btn_handle.setTitle("立即关闭车内录音", for: .normal)
|
btn_handle.backgroundColor = UIColor.red
|
case 0:
|
label_hint.setTitle("车内录音功能已关闭", for: .normal)
|
view_hint.backgroundColor = UIColor(hexString: "#B1B1B1")
|
btn_handle.setTitle("立即开启车内录音", for: .normal)
|
btn_handle.backgroundColor = UIColor(hexString: "#45B494")
|
default:break
|
}
|
|
break
|
case .error(let error):
|
alert(text: error.localizedDescription)
|
break
|
}
|
}).disposed(by: rx.disposeBag)
|
}
|
|
override func setupViews() {
|
view.backgroundColor = UIColor(hexString: "#F3F4F5")
|
label_hint.imagePosition = .left
|
label_hint.spacingBetweenImageAndTitle = 7
|
}
|
|
@IBAction func handleAction(_ sender: UIButton) {
|
if app.userInfo.soundSet == 0{
|
alert(popup: .double, title: "是否开启车内录音?", text: "开启后下一订单即生效", submitTitle: "确认开启", cancelTitle: "取消") {
|
self.show()
|
APIManager.shared.provider.rx.request(.soundSet(isOn: true)).mapThenValidate(Nothing.self).subscribe(onSuccess: {result in
|
self.hide()
|
alert(text: "车内录音将在下一订单开启")
|
self.userInfoViewModel.queryUserInfo()
|
}) { error in
|
alert(text: error.localizedDescription)
|
}.disposed(by: self.disposeBag)
|
} cancelClick: {
|
|
}
|
}else{
|
alert(popup: .double, title: "是否关闭车内录音?", text: "关闭后立即生效", submitTitle: "确认关闭", cancelTitle: "取消") {
|
self.show()
|
APIManager.shared.provider.rx.request(.soundSet(isOn: false)).mapThenValidate(Nothing.self).subscribe(onSuccess: {result in
|
self.hide()
|
alert(text: "已关闭车内录音功能")
|
self.userInfoViewModel.queryUserInfo()
|
}) { error in
|
alert(text: error.localizedDescription)
|
}.disposed(by: self.disposeBag)
|
} cancelClick: {
|
|
}
|
}
|
}
|
}
|