123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- //
- // AddEvaluateViewController.swift
- // ADHTuanCan
- //
- // Created by 敖德亨 on 2023/11/10.
- //
- import UIKit
- import RxCocoa
- import RxSwift
- import TZImagePickerController
- class AddEvaluateViewController: ADHBaseVC {
- @IBOutlet weak var tableView: UITableView!
-
- @IBOutlet weak var topContent: NSLayoutConstraint!
- /// 订单ID
- var orderId : NSNumber?{
- didSet{
- self.viewModel.getNeedEvaluateListModel.id = orderId
- self.viewModel.upEvaluateListModel.orderId = orderId
- }
- }
- let viewModel : EvaluateViewModel = EvaluateViewModel.init()
- let diposableBag = DisposeBag()
- var dataSource : [NeedEvaluateListModel]?
-
- override func viewDidLoad() {
- super.viewDidLoad()
- let navStyle = MCNavBarStyle()
- navStyle.styleForBackImage = UIImage.init(named: "黑色返回")!
- navStyle.styleForTitleColor = UIColor.black
- self.navBar = MCNavBarView.init(title: LanguagesUtil.createTextBy(Ctext: "发表评价", Etext: "Comment"), subTitle: nil,style: navStyle)
- self.topContent.constant = kNavAndStatuHeight + 1
- self.navBar?.backgroundColor = UIColor.white
-
- tableView.register(withType: AddEvaluateCell.self)
-
- self.getDataList()
- }
-
- // MARK: - 获取列表
- func getDataList(){
- self.hud.showLoading()
-
- self.viewModel.signalGetNeedEvaluateList()?.on(success: { dd in
- self.dataSource = self.viewModel.needEvaluateList
- self.tableView.reloadData()
- self.hud.hidden()
-
-
- }, error: { error in
- self.hud.showFailure(error.msg ?? LanguagesUtil.createTextBy(Ctext: "网络错误", Etext: "network error"))
- })
- }
- func addUploadImg(model : NeedEvaluateListModel , reindexPath : IndexPath){
-
- let num = 4 - (model.links?.count ?? 0)
-
- let imagePickerVC = TZImagePickerController(maxImagesCount: num, delegate: self)
- imagePickerVC?.allowTakeVideo = false
- imagePickerVC?.allowPickingOriginalPhoto = true
- // imagePickerVC?.photoPreviewPageUIConfigBlock?.previewViewBgColor = UIColor.black
- imagePickerVC?.navigationBar.barTintColor = UIColor.white
- imagePickerVC?.navigationBar.tintColor = UIColor.black
- // imagePickerVC?.navigationItem.backAction = UIColor.black
-
- imagePickerVC?.didFinishPickingPhotosHandle = {[weak self] photos , assset, iskkk in
- NSLog("\(photos?.count ?? 0)")
-
- var imgDatas : [Data]? = []
- for item in photos!{
- guard let jpegData = item.jpegData(compressionQuality: 0.5)else {return}
- imgDatas?.append(jpegData)
- }
- self?.hud.showLoading()
- MCHttpUtil.uploadImg(imageDates: imgDatas!, url: "/blade-resource/oss/endpoint/put-file-attach") { models in
- self?.hud.hidden()
- // var links : [String]? = []
- for item in models{
- let sss : PhotoUrlModel = item
- model.links?.append(sss.link ?? "")
- }
- // model.links?.append(contentsOf: links ?? [])
- self?.tableView.reloadRows(at: [reindexPath], with: .none)
- } error: { errorMsg in
- self?.hud.showFailure("\(errorMsg)")
- }
- }
- self.present(imagePickerVC!, animated: true)
- }
-
- @IBAction func saveAction(_ sender: UIButton) {
-
- self.hud.showLoading()
-
- self.viewModel.upEvaluateListModel.orderMealReviews = []
- for item in self.viewModel.needEvaluateList! {
- let model : NeedEvaluateListModel = item
- self.viewModel.upEvaluateListModel.orderMealReviews?.append(model)
- }
- self.viewModel.signalUpEvaluate()?.on(success: { dd in
- NotificationCenter.default.post(name: NSNotification.Name("刷新订单列表"), object: self, userInfo:nil)
- self.hud.showSuccess()
- self.navigationController?.popViewController(animated: true)
-
- }, error: { error in
- self.hud.showFailure(error.msg ?? LanguagesUtil.createTextBy(Ctext: "网络错误", Etext: "network error"))
- })
-
- }
- }
- extension AddEvaluateViewController : UITableViewDelegate,UITableViewDataSource{
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return self.dataSource?.count ?? 0
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "AddEvaluateCell") as! AddEvaluateCell;
- let model : NeedEvaluateListModel = self.dataSource![indexPath.row]
- cell.configModel(model: model)
- cell.reloadBlock = {[weak self] in
- let reindexPath = IndexPath(item: indexPath.row, section: 0)
- self?.tableView.reloadRows(at: [reindexPath], with: .none)
- }
-
- cell.addImgBlock = {[weak self] in
- let reindexPath = IndexPath(item: indexPath.row, section: 0)
- self?.addUploadImg(model: model, reindexPath: reindexPath)
- }
-
- return cell
- }
-
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
- return 0.01
- }
-
- func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
- return 0.01
- }
-
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-
-
- }
-
- }
- extension AddEvaluateViewController : TZImagePickerControllerDelegate{
- // func setdeid
- }
|