| | |
| | | import Photos |
| | | import QMUIKit |
| | | |
| | | class SearchStoreDetailFeedbackVC: BaseVC { |
| | | class SearchStoreDetailFeedbackVC: BaseVC, RatingBarDelegate { |
| | | func ratingDidChange(ratingBar: RatingBar, rating: CGFloat) { |
| | | score = rating.double |
| | | } |
| | | |
| | | @IBOutlet weak var stackView: UIStackView! |
| | | @IBOutlet weak var view_start: RatingBar! |
| | | @IBOutlet weak var collectionView: UICollectionView! |
| | | @IBOutlet weak var textView: QMUITextView! |
| | | private var id:Int! |
| | | private var items = NSMutableArray() |
| | | private var imgs = [UIImage]() |
| | | private var imgUrls = [String]() |
| | | private var score = 0.0 |
| | | |
| | | init(id:Int) { |
| | | super.init(nibName: nil, bundle: nil) |
| | |
| | | collectionView.register(UINib(nibName: "UploadImgCCell", bundle: nil), forCellWithReuseIdentifier: "_UploadImgCCell") |
| | | items.add("Empty") |
| | | collectionView.reloadData() |
| | | } |
| | | |
| | | @IBAction func startAction(_ sender: UIButton) { |
| | | let tag = sender.tag |
| | | |
| | | for v in (stackView.arrangedSubviews as! [UIButton]){ |
| | | v.isSelected = v.tag <= tag |
| | | } |
| | | view_start.delegate = self |
| | | } |
| | | |
| | | @IBAction func addAction(_ sender: UIButton) { |
| | | let score = ((stackView.arrangedSubviews as! [UIButton]).filter({$0.isSelected}).last?.tag ?? 9) - 9 |
| | | |
| | | guard score != 0 else {alertError(msg: "请先为门店评分");return} |
| | | |
| | | guard !textView.text.isEmpty else { |
| | |
| | | showHUD("图片上传中") |
| | | imgs.uploadImgToService(needCompress: true).subscribe { texts in |
| | | self.imgUrls = texts |
| | | self.uploadData(score: score) |
| | | self.uploadData(score: self.score) |
| | | } onError: { error in |
| | | alert(msg: error.localizedDescription) |
| | | }.disposed(by: disposeBag) |
| | | }else{ |
| | | self.uploadData(score: score) |
| | | self.uploadData(score: self.score) |
| | | } |
| | | } |
| | | |
| | | private func uploadData(score:Int){ |
| | | Services.evaluationStore(id: id, content: textView.text, imgs: imgUrls.joined(separator: ","), score: score).subscribe(onNext: {data in |
| | | private func uploadData(score:Double){ |
| | | Services.evaluationStore(id: id, content: textView.text, imgs: imgUrls.joined(separator: ","), score: score).subscribe(onNext: {data in |
| | | alertSuccess(msg: "评价成功") |
| | | DispatchQueue.main.asyncAfter(deadline: .now()+1) { |
| | | self.navigationController?.popViewController(animated: true) |