// // OrderDViewController.swift // GeliBusinessPlatform // // Created by junye lu on 2020/5/13. // Copyright © 2020 junye lu. All rights reserved. // import UIKit import Photos protocol OrderDViewControllerDelegate { func refishingOrderDchange() } class OrderDViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,TitleAndBtnCellDelegate,GuanLianKehuVCDelegate,OrderDViewFooterViewDelegate,TitleAndTFCellDelegate,GeliAlertViewDelegate,GLAlertSelectViewDelegate,XiuGaiYuShouJiaViewControllerDelegate,ChangeGoodsPriceVCDelegate,GeliAlertTextFiledDelegate,GeliAlertTextViewDelegate,UpBillDataTableViewCellDelegate, DaiKeXiaDanGouWuCellDelegate, S_Y_View_Delegate{ func S_Y_View_Check_Detail() { print("查看溯源") let vc = S_Y_Detail_Vc() vc.user_type = 1 self.navigationController?.pushViewController(vc, animated: true) } func DaiKeXiaDanGouWuCellDelAction(cell: DaiKeXiaDanGouWuCell) { //此处无用 } func DaiKeXiaDanGouWuCellRemarkChange(cell: DaiKeXiaDanGouWuCell) { //此处无用 } func DaiKeXiaDanGouWuCell_check(cell: DaiKeXiaDanGouWuCell) { print("溯源") print("check S_Y") let vc = S_Y_View(frame: self.view.bounds) vc.delegate = self self.view.addSubview(vc) } var lmIdx = 100 func GLASClose(view: GLAlertSelectView, selectnum: Int, selectArr: Array<Int>) { if selectnum != 10086 { if view.titleLbl.text == "请选择支付方式" { zhiFuSelect = selectnum } if view.titleLbl.text == "请选择支付状态" { zhiFuStatusSelect = selectnum } if view.titleLbl.text == "请选择物流公司" { wuLiuSelect = selectnum } } view.removeFromSuperview() glSelectView = nil } var delegate:OrderDViewControllerDelegate? //MARK:--普通的是否可编辑 var isCaneditLatsData:Bool = true var orderId:Int? //订单编号 var isYuShou:Bool = true //是否预售 var dataArr:NSArray = [] //订单产品数据 var btmBtnsTitleArr:Array<String> = []//底栏按钮数据 var yuShouTitleArr = ["定金:","尾款:","商品合计:","物流费用:","其它费用:"] var nonYuShouTitleArr = ["商品合计:","物流费用:","其它费用:"] //旧的 // let YuShouPart3Arr = ["订单编号","下单时间","订单来源","提货方式","物流公司","运单号","支付方式","支付状态","买家留言","订单备注"] // let isYuShouPart3Arr = ["订单编号","下单时间","订单来源","提货方式","物流公司","运单号","定金支付方式","定金支付状态","尾款支付方式","尾款支付状态","买家留言","订单备注"] //新的 let YuShouPart3Arr = ["订单编号","下单时间","订单来源","关联凭证","提货方式","支付方式","支付状态","买家留言","订单备注"] let isYuShouPart3Arr = ["订单编号","下单时间","订单来源","关联凭证","提货方式","定金支付方式","定金支付状态","尾款支付方式","尾款支付状态","买家留言","订单备注"] let nonYuShouPart3Arr = ["收货人","联系电话","地址"] var glSelectView:GLAlertSelectView? let zhiFuFangShiArr = ["未支付","现金","转账(私)","转账(公)","转账(微信)","转账(支付宝)"] var zhiFuSelect:Int?//选择支付方式 let zhiFuStatus = ["未付款","欠款","月结","已付款"] var zhiFuStatusSelect:Int?//付款状态 // let wuLiuFSArr = ["京东冷链","顺丰冷运","达达速运"] var wuLiuFSArr:Array<String> = [] var wuLiuSelect:Int?//物流选择 @IBOutlet weak var btmOffset: NSLayoutConstraint! @IBOutlet weak var btmViewH: NSLayoutConstraint! @IBOutlet weak var bottomView: UIView! @IBOutlet weak var listView: UITableView! @IBOutlet weak var bottomBgView: UIView! //MARK: - 定金支付方式 var dj_payWay = 1 var wk_payWay = 1//尾款支付方式 //MARK:--加载数据 var dataMdoel: OrderDetailDataModel? = nil let UserToken = UserDefaults.standard.value(forKey: "user_token") func loadData() { HUD.flash(.progress) orderDetail(["user_token":UserToken as Any,"order_id":orderId as Any], success: { [self] (data) in HUD.hide(animated: true) let dataM = data as! OrderDetailModel self.dataMdoel = dataM.data if self.dataMdoel?.order_res?.order_type == 4 { self.isYuShou = true }else{ self.isYuShou = false } self.btmBtnsTitleArr.removeAll() self.bottomView.subviews.forEach { (view) in view.removeFromSuperview() } //MARK:--底部视图,根据数据显示 self.btmBtnsTitleArr = self.getOrderBottomBtnTitleStrByStatus(status: (self.dataMdoel?.order_res?.order_status)!, status_d: (self.dataMdoel?.order_res?.order_status_d)!) if self.btmBtnsTitleArr.count == 0 { self.btmViewH.constant = 0 self.bottomView.isHidden = true self.bottomBgView.isHidden = true self.btmOffset.constant = 0 }else{ self.bottomView.isHidden = false self.bottomBgView.isHidden = false if IS_IPHONE_X == false { self.btmOffset.constant = 0 } for i in 0 ..< self.btmBtnsTitleArr.count{ let title = self.btmBtnsTitleArr[i] let width = fullScreenWidth / CGFloat(self.btmBtnsTitleArr.count) let btn = UIButton(frame: CGRect(x: CGFloat(i) * width, y: 0, width: width, height: self.bottomView.bounds.size.height)) btn.setTitleColor(UIColor(named: "白色背景色"), for: .normal) btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 14) btn.setTitle(title, for: .normal) btn.addTarget(self, action: #selector(self.bottomBtnClick(sender:)), for: .touchUpInside) self.bottomView.addSubview(btn) self.bottomView.backgroundColor = UIColor.init(named: "按钮渐变色上") self.bottomBgView.backgroundColor = UIColor.init(named: "按钮渐变色上") let lineV = UIView() lineV.backgroundColor = UIColor.init(named: "白色背景色") self.bottomView.addSubview(lineV) lineV.snp.makeConstraints { (make) in make.left.equalTo(btn.snp_right) make.top.equalTo(12) make.width.equalTo(1) make.height.equalTo(self.bottomView.bounds.size.height - 24) } } } if self.dataMdoel?.order_res?.order_status == 2 || self.dataMdoel?.order_res?.order_status == 5{ self.isCaneditLatsData = false } for i in 0 ..< self.zhiFuFangShiArr.count { if self.dataMdoel!.order_res!.pay_type_cn! == self.zhiFuFangShiArr[i]{ self.zhiFuSelect = i } } if self.dataMdoel?.order_res?.invoice_img != nil { self.UpBillDataUploadImgiconUrl = (self.dataMdoel?.order_res?.invoice_img!)! }else{ if (self.dataMdoel?.order_res?.invoice_link!.count)! > 0 { self.segmentIndex = 0 } } if self.dataMdoel?.order_res?.invoice_link != nil { self.inputInfoTFString = (self.dataMdoel?.order_res?.invoice_link)! } //是否是分销订单 if self.dataMdoel?.order_res?.order_type == 5 { if self.dataMdoel?.order_res?.dbt_target == 2 { yuShouTitleArr.append("分销商") nonYuShouTitleArr.append("分销商") }else if self.dataMdoel?.order_res?.dbt_target == 3 { yuShouTitleArr.append("分销员") nonYuShouTitleArr.append("分销员") } } self.listView.reloadData() }) { (error) in } } override func viewDidLoad() { super.viewDidLoad() navbar.title = "订单详情" self.view.addSubview(navbar) loadData() SetTopFrameView(view: listView, btmView: bottomView) // Do any additional setup after loading the view. listView.separatorStyle = .none listView.register(UINib(nibName: "TitleAndBtnCell", bundle: nil), forCellReuseIdentifier: "TitleAndBtnCell") listView.register(UINib(nibName: "TitleAndTFCell", bundle: nil), forCellReuseIdentifier: "TitleAndTFCell") listView.register(UINib(nibName: "DaiKeXiaDanGouWuCell", bundle: nil), forCellReuseIdentifier: "DaiKeXiaDanGouWuCell") listView.register(UINib(nibName: "PingLunCell", bundle: nil), forCellReuseIdentifier: "PingLunCell") listView.register(UINib(nibName: "GLKHCell", bundle: nil), forCellReuseIdentifier: "GLKHCell") listView.register(UINib(nibName: "UpBillDataTableViewCell", bundle: nil), forCellReuseIdentifier: "UpBillDataTableViewCell") } var agreeType = 10086 //MARK:--修改价格(普通商品返回数据) func changeGoodsPriByData(sender: Array<OrderDetailGoodsModel>) { print("修改价格(普通商品返回数据)\(sender)") self.dataMdoel?.order_goods = sender loadData() } //MARK:--修改价格(预售返回数据) func changeYuShouGoodsByData(sender: EditOGPAdDataModel?, djText: String, wkText: String) { print("修改价格(预售返回数据)--只更新datamodel,不请求网络\(sender)") self.dataMdoel?.order_res?.sale_res?.dj_amount = sender!.dj_amount self.dataMdoel?.order_res?.sale_res?.wk_amount = sender!.wk_amount loadData() } //MARK:--编辑运单号回调数据 func sureGeliAlertTextFiledAction(sender: String) { editLwbno(["user_token":UserToken as Any,"order_id":orderId as Any,"lwb_no":sender as Any,], success: { (data) in let dataM = data as! UpDataModel if dataM.code == 1 { self.dataMdoel?.order_res?.lwb_no = sender self.listView.reloadData() } }) { (erro) in } } //MARK:--编辑订单备注回调数据 func sureGeliAlertTextViewAction(sender: String) { editField(["user_token":UserToken as Any,"function_id":"45","prval":orderId as Any,"value":sender as Any,], success: { (data) in let dataM = data as! UpDataModel if dataM.code == 1 { self.dataMdoel?.order_res?.order_postscript = sender self.listView.reloadData() } }) { (erro) in } } var btnLbl:UILabel! var invoiceList:UITableView! @objc func closeCoverAction(btn:UIButton){ btn.removeFromSuperview() btnLbl?.removeFromSuperview() invoiceList.removeFromSuperview() } //MARK:--发票信息栏目代理 var segmentIndex = 1 func segmentChangeIndex(index: Int) { segmentIndex = index listView.reloadData() } var inputInfoTFString = "" func UpBillDataTableViewCellSelectString(selectString: String, inputString: String) { switch selectString { case "查看发票信息": HUD.show(.progress) getInvoiceInfo(["user_token":UserToken as Any,"order_id":StringByInt(number: self.orderId!) as Any]) { [self] (data) in HUD.hide() let model = data as! InvoiceInfoModel let modelData = model.data as! InvoiceInfoDataModel var dataArray:Array<String> = [] dataArray.removeAll() if modelData.type == 1 {//增值税专用 dataArray.append("类型,增值税专用发票") dataArray.append("纳税人识别号," + modelData.duty_paragraph!) dataArray.append("注册地址," + modelData.address!) dataArray.append("注册电话," + modelData.tel!) dataArray.append("开户银行," + modelData.account_name!) dataArray.append("银行账号," + modelData.account!) dataArray.append("收票人姓名," + (modelData.send_address?.consignee)!) dataArray.append("收票人手机," + (modelData.send_address?.mobile)!) dataArray.append("收票人地址," + (modelData.send_address?.address)!) }else{//增值税普通 dataArray.append("类型,普通发票") if modelData.belong == 1 {//单位 dataArray.append("发票抬头,单位") dataArray.append("单位名称," + modelData.name!) dataArray.append("纳税人识别号," + modelData.duty_paragraph!) dataArray.append("单位地址," + modelData.address!) dataArray.append("单位电话," + modelData.tel!) dataArray.append("开户银行," + modelData.account_name!) dataArray.append("银行账号," + modelData.account!) var invoiceTag = "商品明细" if modelData.invoice_tag == 2{ invoiceTag = "商品类别" } dataArray.append("发票内容," + invoiceTag) dataArray.append("收票人手机," + (modelData.send_address?.mobile)!) dataArray.append("收票人邮箱," + modelData.email!) }else{//个人 dataArray.append("发票抬头,个人") dataArray.append("个人名称," + modelData.name!) var invoiceTag = "商品明细" if modelData.invoice_tag == 2{ invoiceTag = "商品类别" } dataArray.append("发票内容," + invoiceTag) dataArray.append("收票人手机," + (modelData.send_address?.mobile)!) dataArray.append("收票人信息," + (modelData.send_address?.consignee)!) dataArray.append("收票人邮箱," + modelData.email!) } } let view = GLMessageAlertView(frame: self.view.bounds) view.topLbl.text = "发票信息" view.datasArr = dataArray self.view.addSubview(view) } failture: { (error) in } break case "通知用户": HUD.show(.progress) invoiceNotice(["user_token":UserToken as Any,"order_id":StringByInt(number: self.orderId!) as Any]) { (data) in HUD.flash(.labeledSubSuccess(subtitle: "通知成功"),delay: 1.2) } failture: { (err) in } break case "上传发票": _ = self.presentHGImagePicker(maxSelected:1) { (assets) in //结果处理 print("共选择了\(assets.count)张图片,分别如下:") let option = PHImageRequestOptions() option.isSynchronous = true option.isNetworkAccessAllowed = true for asset in assets { PHImageManager.default().requestImage(for: asset, targetSize: PHImageManagerMaximumSize , contentMode: .default , options: option, resultHandler: { (image, _: [AnyHashable : Any]?) in print("上传图片==\(image)") self.UpBillDataUploadImg(imge: image!) }) } self.listView.reloadData() } break case "上传链接地址": HUD.show(.progress) editInvoiceImg(["user_token":UserToken as Any,"order_id":StringByInt(number: self.orderId!) as Any,"invoice_link":inputString as Any]) { (data) in self.inputInfoTFString = inputString HUD.flash(.labeledSubSuccess(subtitle: "修改成功"),delay: 1.2) self.listView.reloadData() } failture: { (err) in self.listView.reloadData() } break default: break } } var UpBillDataUploadImgiconUrl = "" func UpBillDataUploadImg (imge:UIImage){ let upLoadImg = imge HUD.show(.progress) saveFile(image: upLoadImg, ["user_token":UserToken as Any,"order_id":StringByInt(number: self.orderId!) as Any], success: { (data) in let dataM = data as! SaveFileModel if dataM.code == 1 { HUD.hide() self.loadData() } }) { (error) in print("图片上传失败\(error)") } } //MARK: - cell delegate func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if !isCaneditLatsData { return } if indexPath.section == 0 { let vc = GuanLianKehuVC() vc.delegate = self vc.order_id = self.orderId if self.dataMdoel?.order_res?.cus_id != 0 { vc.cus_id = self.dataMdoel?.order_res?.cus_id } self.navigationController?.pushViewController(vc, animated: true) } //订单信息操作 if indexPath.section == 5 { var isYushoucount = 0 if isYuShou { isYushoucount = 2 } if indexPath.row == 7 + isYushoucount{ print("备注") let alterView = GeliAlertTextView(frame: self.view.window!.bounds) alterView.delegate = self self.view.window?.addSubview(alterView) } } } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtnCell") as! TitleAndBtnCell cell.delegate = self switch indexPath.section { case 0: let cell = tableView.dequeueReusableCell(withIdentifier: "GLKHCell") as! GLKHCell cell.nameLbl.text = self.dataMdoel?.order_res?.user_name if self.dataMdoel?.order_res?.cus_id != 0 { cell.contentLbl.text = self.dataMdoel?.order_res?.cus_name }else{ //如果不刷新请求,那么就更新本地,建议还是刷新,暂不刷 cell.contentLbl.text = "请选择关联客户" if !isCaneditLatsData { cell.contentLbl.text = "-" } } return cell case 1: //MARK:--商品cell let cell = tableView.dequeueReusableCell(withIdentifier: "DaiKeXiaDanGouWuCell") as! DaiKeXiaDanGouWuCell cell.delegate = self cell.isDetail = true let rowModel = self.dataMdoel?.order_goods![indexPath.row] if self.dataMdoel?.order_goods != nil { if (self.dataMdoel?.order_goods!.count)! > 2 && check_all == false{ if indexPath.row == 1 { cell.btm_line.isHidden = true } } if indexPath.row == (self.dataMdoel?.order_goods!.count)! - 1 { cell.btm_line.isHidden = true } } cell.check_button.isHidden = false cell.imgView?.sd_setImage(with: URL(string: SERVERCE_ImageHost + (rowModel?.goods_thumb)!)) cell.content_tv.text = rowModel?.remark cell.titleLbl.text = rowModel?.goods_name if rowModel?.goods_attr != nil { cell.detailLbl.text = "规格:" + (rowModel?.goods_attr)! }else{ cell.detailLbl.text = "规格:-" } if isYuShou { cell.diLbl.isHidden = false cell.priceLbl.isHidden = false cell.yu_shou_img.isHidden = false cell.diLbl.text = "定金:¥" + (self.dataMdoel?.order_res?.sale_res?.dj_amount)! cell.priceLbl.text = "尾款:¥" + (self.dataMdoel?.order_res?.sale_res?.wk_amount)! } cell.count_lbl.text = "数量:" + StringByInt(number: (rowModel?.cart_number!)!) cell.detailLbl2.text = "小计:¥" + (self.dataMdoel?.order_res?.goods_amount)! return cell case 2: let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTFCell") as! TitleAndTFCell cell.textTF.isUserInteractionEnabled = false cell.line.isHidden = false if isYuShou { cell.nameLbl.text = yuShouTitleArr[indexPath.row] cell.textTF.text = yuShouTitleArr[indexPath.row] cell.delegate = self //MARK:--预售商品,定金,尾款,合计,物流费用,其他费用 cell switch indexPath.row { case 0: if self.dataMdoel?.order_res?.sale_res?.dj_pay_status == 1 { cell.textTF.text = "(已付)" + "¥" + (self.dataMdoel?.order_res?.sale_res?.dj_amount)! }else{ cell.textTF.text = "¥" + (self.dataMdoel?.order_res?.sale_res?.dj_amount)! } break case 1: if self.dataMdoel?.order_res?.sale_res?.wk_pay_status == 1 { cell.textTF.text = "(已付)" + "¥" + (self.dataMdoel?.order_res?.sale_res?.wk_amount)! }else{ cell.textTF.text = "¥" + (self.dataMdoel?.order_res?.sale_res?.wk_amount)! } break case 2: cell.textTF.text = "¥" + (self.dataMdoel?.order_res?.goods_amount)! break case 3: cell.textTF.text = "¥" + (self.dataMdoel?.order_res?.logistics_price)! break case 4: cell.textTF.text = "¥" + (self.dataMdoel?.order_res?.other_price)! break case 5: //分销才有 cell.textTF.text = (self.dataMdoel?.order_res?.target_name)! break default: break } if indexPath.row == yuShouTitleArr.count - 1 { cell.line.isHidden = true } }else{ //MARK:--普通商品合计,物流费用,其他费用 cell cell.nameLbl.text = nonYuShouTitleArr[indexPath.row] switch indexPath.row { case 0: cell.textTF.text = "¥" + (self.dataMdoel?.order_res?.goods_amount)! break case 1: cell.textTF.text = "¥" + (self.dataMdoel?.order_res?.logistics_price)! break case 2: cell.textTF.text = "¥" + (self.dataMdoel?.order_res?.other_price)! break case 3: //分销才有 cell.textTF.text = (self.dataMdoel?.order_res?.target_name)! break default: break } cell.delegate = self if indexPath.row == nonYuShouTitleArr.count - 1 { cell.line.isHidden = true } } return cell case 3: //MARK:--收货人信息cell let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTFCell") as! TitleAndTFCell cell.textTF.isUserInteractionEnabled = false cell.nameLbl.text = nonYuShouPart3Arr[indexPath.row] cell.line.isHidden = false cell.textTF.text = "-" if self.dataMdoel?.receiving != nil { switch indexPath.row { case 0: cell.textTF.text = self.dataMdoel?.receiving?.consignee case 1: cell.textTF.text = self.dataMdoel?.receiving?.mobile case 2: cell.textTF.text = self.dataMdoel?.receiving?.addr_str default: break } } return cell case 4: //MARK:--发票信息cell let cell = tableView.dequeueReusableCell(withIdentifier: "UpBillDataTableViewCell") as! UpBillDataTableViewCell cell.delegate = self cell.inputInfoTF.isHidden = true cell.inputInfoTfBgV.isHidden = true cell.updataBtn.isHidden = false cell.upDataTLbl.isHidden = false cell.inputInfoTF.text = inputInfoTFString if segmentIndex == 0 { cell.inputInfoTF.isHidden = false cell.inputInfoTfBgV.isHidden = false cell.updataBtn.isHidden = true cell.upDataTLbl.isHidden = true } if UpBillDataUploadImgiconUrl.count > 0 { cell.updataBtn.sd_setImage(with: URL(string:SERVERCE_ImageHost + UpBillDataUploadImgiconUrl), for: .normal, completed: nil) } cell.selectSegmentV.selectedSegmentIndex = segmentIndex return cell case 5: //MARK:--订单信息cell var isYushoucount = 0 if isYuShou { isYushoucount = 2 } if indexPath.row == (8 + isYushoucount){ let cell = tableView.dequeueReusableCell(withIdentifier: "PingLunCell") as! PingLunCell cell.tag = indexPath.row if isYuShou { cell.nameLbl.text = isYuShouPart3Arr[indexPath.row] }else{ cell.nameLbl.text = YuShouPart3Arr[indexPath.row] } switch indexPath.row { case 8: cell.contentLbl.text = self.dataMdoel?.order_res?.order_postscript if self.dataMdoel?.order_res?.order_postscript == nil { cell.contentLbl.text = "-" }else{ if self.dataMdoel?.order_res?.order_postscript?.count == 0 { cell.contentLbl.text = "请输入订单备注" if !isCaneditLatsData { cell.contentLbl.text = "-" } } } break default: break } if !isCaneditLatsData { cell.editIconImgV.isHidden = true cell.contentRight.constant = 15 }else{ cell.editIconImgV.isHidden = false cell.contentRight.constant = 45 } return cell } if indexPath.row == 5 || indexPath.row == 6 || indexPath.row == (5 + isYushoucount) || indexPath.row == (6 + isYushoucount){ if isYuShou { cell.nameLbl.text = isYuShouPart3Arr[indexPath.row] }else{ cell.nameLbl.text = YuShouPart3Arr[indexPath.row] } cell.arrowImg.isHidden = false cell.contentRight.constant = 32 if indexPath.row == 8 { if self.dataMdoel?.order_res?.sale_res?.wk_pay_type == 11 || self.dataMdoel?.order_res?.sale_res?.wk_pay_type == 12 { cell.arrowImg.isHidden = true cell.contentRight.constant = 15 } }else if indexPath.row == 6 { if isYuShou { if self.dataMdoel?.order_res?.sale_res?.dj_pay_type == 11 || self.dataMdoel?.order_res?.sale_res?.dj_pay_type == 12 { cell.arrowImg.isHidden = true cell.contentRight.constant = 15 } }else{ if self.dataMdoel?.order_res?.pay_type == 11 || self.dataMdoel?.order_res?.pay_type == 12 { cell.arrowImg.isHidden = true cell.contentRight.constant = 15 } } } switch indexPath.row { case 5: if isYuShou { cell.contentLbl.text = self.dataMdoel?.order_res?.sale_res?.dj_pay_type_cn }else{ cell.contentLbl.text = self.dataMdoel?.order_res?.pay_type_cn } break case 6: if isYuShou { cell.contentLbl.text = self.dataMdoel?.order_res?.sale_res?.dj_pay_status_cn }else{ cell.contentLbl.text = self.dataMdoel?.order_res?.pay_status_cn } cell.arrowImg.isHidden = true cell.contentRight.constant = 15 break case 7: if isYuShou { cell.contentLbl.text = self.dataMdoel?.order_res?.sale_res?.wk_pay_type_cn }else{ cell.contentLbl.text = StringByInt(number: (self.dataMdoel?.order_res?.sale_res?.wk_pay_type!)!) } break case 8: cell.contentLbl.text = self.dataMdoel?.order_res?.sale_res?.wk_pay_status_cn cell.arrowImg.isHidden = true cell.contentRight.constant = 15 break default: break } //追加pay_type if self.dataMdoel?.order_res?.pay_type == 1 || self.dataMdoel?.order_res?.pay_type == 2 || self.dataMdoel?.order_res?.pay_type == 6 || self.dataMdoel?.order_res?.pay_type == 11 || self.dataMdoel?.order_res?.pay_type == 12{ cell.arrowImg.isHidden = true cell.contentRight.constant = 15 } if !isCaneditLatsData { cell.arrowImg.isHidden = true cell.contentRight.constant = 15 } if cell.contentLbl.text?.count == 0 { cell.contentLbl.text = "-" } return cell } let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTFCell") as! TitleAndTFCell cell.textTF.isUserInteractionEnabled = false cell.line.isHidden = false if isYuShou { cell.nameLbl.text = isYuShouPart3Arr[indexPath.row] }else{ cell.nameLbl.text = YuShouPart3Arr[indexPath.row] } switch indexPath.row { case 0: cell.textTF.text = self.dataMdoel?.order_res?.order_sn break case 1: cell.textTF.text = TimeByDouble(sender: (self.dataMdoel?.order_res?.add_time!)!) break case 2: cell.textTF.text = self.dataMdoel?.order_res?.from_cn break case 3: cell.textTF.text = self.dataMdoel?.order_res?.order_associated_code break case 4: if self.dataMdoel?.order_res?.shipping_type == 1 { cell.textTF.text = "派送" }else{ cell.textTF.text = "自提" } break case (7 + isYushoucount): cell.textTF.text = self.dataMdoel?.order_res?.postscript break default: break } if cell.textTF.text?.count == 0 { cell.textTF.text = "-" } return cell default: break } return cell } var check_all = false //MARK:--查看全部商品 func OrderDViewFooterViewBtnClick(img:OrderDViewFooterView) { print("查看全部商品") check_all = !check_all self.listView.reloadData() // let vc = ShowAlGoodsViewController() // vc.order_goods = self.dataMdoel?.order_goods // self.navigationController?.pushViewController(vc, animated: true) } //MARK:--选择的关联客户返回数据 var selectKeHuData:CusListAllDataModel? = nil func GuanLianKehuSelect(keHuData: CusListAllDataModel) { print("选择的关联客户",keHuData) self.selectKeHuData = keHuData self.dataMdoel?.order_res?.cus_id = self.selectKeHuData?.cus_id self.dataMdoel?.order_res?.cus_name = self.selectKeHuData?.cus_name //暂时不刷新数据,只刷新视图 listView.reloadData() } //MARK:--请求物流公司信息 var lcModel : LogisticsCompanyModel? = nil func btnClick(content: String, cell: TitleAndBtnCell) { if !isCaneditLatsData { //MARK:-不能进行修改了 return; } switch cell.nameLbl.text { case "物流公司": if lcModel == nil { logisticsCompany(["user_token":UserToken as Any], success: { (data) in let dataM = data as! LogisticsCompanyModel if dataM.code == 1 { self.lcModel = dataM self.wuLiuFSArr.removeAll() self.lcModel?.data?.forEach({ (md) in self.wuLiuFSArr.append(md.lc_name!) }) if self.glSelectView == nil { let view = GLAlertSelectView(frame: self.view.bounds) view.tag = cell.tag view.titleLbl.text = "请选择物流公司" view.delegate = self view.dataArr = self.wuLiuFSArr if self.wuLiuSelect != nil { view.selectNum = self.wuLiuSelect! view.tempNum = view.selectNum } self.view.addSubview(view) self.glSelectView = view } } }) { (error) in } }else{ if glSelectView == nil { let view = GLAlertSelectView(frame: self.view.bounds) view.tag = cell.tag view.titleLbl.text = "请选择物流公司" view.delegate = self view.dataArr = wuLiuFSArr if wuLiuSelect != nil { view.selectNum = wuLiuSelect! view.tempNum = view.selectNum } self.view.addSubview(view) glSelectView = view } } break case "支付方式": if self.dataMdoel?.order_res?.pay_type == 11 || self.dataMdoel?.order_res?.pay_type == 12 || self.dataMdoel?.order_res?.pay_type == 1 || self.dataMdoel?.order_res?.pay_type == 2 || self.dataMdoel?.order_res?.pay_type == 6{ return } if glSelectView == nil { let view = GLAlertSelectView(frame: self.view.bounds) view.tag = cell.tag view.titleLbl.text = "请选择支付方式" view.delegate = self view.dataArr = zhiFuFangShiArr if zhiFuSelect != nil { view.selectNum = zhiFuSelect! view.tempNum = view.selectNum } if zhiFuSelect != 0 { view.isNonSelect = true } self.view.addSubview(view) glSelectView = view } break case "支付状态": //无需处理:根据网络变更 break case "定金支付方式": if self.dataMdoel?.order_res?.sale_res?.dj_pay_type == 11 || self.dataMdoel?.order_res?.sale_res?.dj_pay_type == 12 || self.dataMdoel?.order_res?.sale_res?.dj_pay_type == 1 || self.dataMdoel?.order_res?.sale_res?.dj_pay_type == 2 || self.dataMdoel?.order_res?.sale_res?.dj_pay_type == 6{ return } if glSelectView == nil { let view = GLAlertSelectView(frame: self.view.bounds) view.tag = cell.tag view.titleLbl.text = "请选择定金支付方式" view.delegate = self view.dataArr = zhiFuFangShiArr view.selectNum = dj_payWay if dj_payWay != 0 { view.isNonSelect = true } view.tempNum = view.selectNum self.view.addSubview(view) glSelectView = view } break case "尾款支付方式": if self.dataMdoel?.order_res?.sale_res?.wk_pay_type == 11 || self.dataMdoel?.order_res?.sale_res?.wk_pay_type == 12 || self.dataMdoel?.order_res?.sale_res?.wk_pay_type == 1 || self.dataMdoel?.order_res?.sale_res?.wk_pay_type == 2 || self.dataMdoel?.order_res?.sale_res?.wk_pay_type == 6{ return } print("尾款支付方式") print(cell.tag) if glSelectView == nil { let view = GLAlertSelectView(frame: self.view.bounds) view.tag = cell.tag view.titleLbl.text = "请选择定尾款支付方式" view.delegate = self view.dataArr = zhiFuFangShiArr view.selectNum = wk_payWay if wk_payWay != 0 { view.isNonSelect = true } view.tempNum = view.selectNum self.view.addSubview(view) glSelectView = view } break default: break } } func GLAlertSelectViewClick(selectNum: Int, view: GLAlertSelectView) { if view.titleLbl.text == "请选择定金支付方式"{ var pay_type = 0 if selectNum == 1 { pay_type = 7 }else if selectNum > 1 { pay_type = selectNum + 7 } editPayType(["user_token":UserToken as Any,"order_id":orderId as Any,"is_adsale":1 as Any,"amount_type":1 as Any,"pay_type":pay_type], success: { (data) in let dataM = data as! UpDataModel if dataM.code == 1 { self.dj_payWay = selectNum self.dataMdoel?.order_res?.sale_res?.dj_pay_type_cn = self.zhiFuFangShiArr[selectNum] if selectNum == 0 { self.dataMdoel?.order_res?.sale_res?.dj_pay_status_cn = "未付款" }else{ self.dataMdoel?.order_res?.sale_res?.dj_pay_status_cn = "已付款" } self.dataMdoel?.order_res?.sale_res?.dj_pay_type = pay_type NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.listView.reloadData() self.loadData() } }) { (error) in } } if view.titleLbl.text == "请选择定尾款支付方式"{ var pay_type = 0 if selectNum == 1 { pay_type = 7 }else if selectNum > 1 { pay_type = selectNum + 7 } editPayType(["user_token":UserToken as Any,"order_id":orderId as Any,"is_adsale":1 as Any,"amount_type":2 as Any,"pay_type":pay_type], success: { (data) in let dataM = data as! UpDataModel if dataM.code == 1 { self.wk_payWay = selectNum self.dataMdoel?.order_res?.sale_res?.wk_pay_type_cn = self.zhiFuFangShiArr[selectNum] if selectNum == 0 { self.dataMdoel?.order_res?.sale_res?.wk_pay_status_cn = "未付款" }else{ self.dataMdoel?.order_res?.sale_res?.wk_pay_status_cn = "已付款" } self.dataMdoel?.order_res?.sale_res?.wk_pay_type = pay_type NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.listView.reloadData() self.loadData() } }) { (error) in } } if view.titleLbl.text == "请选择支付方式" { //MARK:--选择支付方式回调 var pay_type = 0 if selectNum == 1 { pay_type = 7 }else if selectNum > 1 { pay_type = selectNum + 7 } editPayType(["user_token":UserToken as Any,"order_id":orderId as Any,"is_adsale":0 as Any,"amount_type":0 as Any,"pay_type":pay_type], success: { (data) in let dataM = data as! UpDataModel if dataM.code == 1 { self.zhiFuSelect = selectNum self.dataMdoel?.order_res?.pay_type_cn = self.zhiFuFangShiArr[selectNum] if selectNum == 0 { self.dataMdoel?.order_res?.pay_status_cn = "未付款" }else{ self.dataMdoel?.order_res?.pay_status_cn = "已付款" } NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.dataMdoel?.order_res?.pay_type = pay_type self.listView.reloadData() self.loadData() } }) { (error) in } }else if view.titleLbl.text == "请选择物流公司"{ let secltMd = self.lcModel?.data![selectNum] editField(["user_token":UserToken as Any,"function_id":"46","prval":orderId as Any,"value":secltMd!.lc_id as Any,], success: { (data) in let dataM = data as! UpDataModel if dataM.code == 1 { self.wuLiuSelect = selectNum self.dataMdoel?.order_res?.lc_name = self.wuLiuFSArr[selectNum] self.listView.reloadData() self.loadData() } }) { (erro) in } }else{ //MARK:--选择支付状态回调 zhiFuStatusSelect = selectNum self.dataMdoel?.order_res?.pay_status_cn = zhiFuStatus[selectNum] listView.reloadData() } glSelectView?.removeFromSuperview() glSelectView = nil } //MARK: - section delegate func numberOfSections(in tableView: UITableView) -> Int { if self.dataMdoel == nil { return 0 } return 6//(关联客户,商品展示,费用信息,收货人信息,发票信息,订单信息) } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if self.dataMdoel == nil { return 0 } switch section { case 0:return 1 //关联客服section case 1: //商品展示section if isYuShou{ return 1 }else{ var num = 0 if self.dataMdoel != nil { if (self.dataMdoel?.order_goods?.count)! < 2 { num = (self.dataMdoel?.order_goods?.count)! }else{ //abc if check_all { num = (self.dataMdoel?.order_goods?.count)! }else{ num = 2 } } } return num } case 2://费用信息section if isYuShou{ if self.dataMdoel?.order_res?.order_type == 5 { //分销 return yuShouTitleArr.count } return 5 }else{ if self.dataMdoel?.order_res?.order_type == 5 {//分销 return nonYuShouTitleArr.count } return 3 } case 3://收货人信息section if self.dataMdoel?.order_res?.shipping_type == 1{ return nonYuShouPart3Arr.count } return 0 case 4://发票信息section return 1 case 5://订单信息section if isYuShou { return isYuShouPart3Arr.count }else{ return YuShouPart3Arr.count } default: return 0 } } //MARK: - footer delegate func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { let view = UIView() switch section { case 1: if isYuShou == false { if (self.dataMdoel?.order_goods?.count)! > 2 { let view = OrderDViewFooterView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 33.5)) view.delegate = self view.check_all = check_all return view } } case 2: let view = OrderDViewSumFooter(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 59)) if self.dataMdoel?.order_res?.order_type == 5 { //分销的话 view.priceLbl.text = "¥" + (self.dataMdoel?.order_res!.sum_amount)! + "(佣金" + (self.dataMdoel?.order_res!.sum_commission_val)! + ")" }else{ view.priceLbl.text = "¥" + (self.dataMdoel?.order_res!.sum_amount)! } return view default: break } return view } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { switch section { case 1: if isYuShou == false { if (self.dataMdoel?.order_goods?.count)! > 2 { return 33.5 }else{ return 0.01 } }else{ return 0.01 } case 2: return 59 case 3: if self.dataMdoel?.order_res?.shipping_type != 1 { return 0.01 } default: break } return 10 } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { switch indexPath.section { case 1://商品展示heightrow return 250 case 4://发票信息heightrow if segmentIndex == 0 { return 180 } return 260 default: break } return 49 } //MARK: - header delegate func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let view = UIView() view.subviews.forEach { (subV) in subV.removeFromSuperview() } switch section { case 1: let view1 = TitleAndLblView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 49)) view1.nameLbl.text = "订单状态" //订单状态 if self.dataMdoel?.order_res?.order_status != nil && self.dataMdoel?.order_res?.order_status_d != nil && self.dataMdoel?.order_res!.goods_before_pay != nil { view1.contentLbl.text = orderStatusStrByInt(statusNumber: (self.dataMdoel?.order_res?.order_status)!, status_d: (self.dataMdoel?.order_res?.order_status_d)!, isBfPay:(self.dataMdoel?.order_res!.goods_before_pay)! , LmIdx: lmIdx) view.addSubview(view1) } return view case 3: let view1 = HeaderOnlyTitleView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 39)) view1.nameLbl.text = "收货信息" view.addSubview(view1) if self.dataMdoel?.order_res?.shipping_type == 1{ view1.isHidden = false }else{ view1.isHidden = true } return view case 4: let view1 = HeaderOnlyTitleView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 39)) view1.nameLbl.text = "发票信息" view.addSubview(view1) return view case 5: let view1 = HeaderOnlyTitleView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 39)) view1.nameLbl.text = "订单信息" view.addSubview(view1) return view default: break } return view } func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { switch section { case 1: return 49 case 2: return 1 case 3: if self.dataMdoel?.order_res?.shipping_type == 1{ return 39 }else{ return 0.01 } case 4,5: return 39 default: return 10 } } //MARK:--根据数据获取底部按钮操作 func getOrderBottomBtnTitleStrByStatus(status:Int,status_d:Int) -> Array<String> { var titleArr: Array<String> = [] switch status { case 0: // str = "未确定" "待付款" titleArr = ["打印","修改价格","拒绝接单","先货后款","同意接单"] if self.dataMdoel!.order_res?.goods_before_pay == 1 { titleArr = ["打印","修改价格","拒绝接单","同意接单"] } break case 1: // str = "已确定" "待付款" titleArr = ["打印","修改价格","付款码","取消订单"] if self.dataMdoel!.order_res?.shipping_status == 1 && self.dataMdoel!.order_res?.pay_status != 2 { titleArr = ["打印","修改价格","付款码","退货"] } break case 6: // str = "待发货" if self.dataMdoel?.order_res?.from == 3 || self.dataMdoel?.order_res?.from == 5 { titleArr = ["打印","取消订单并退款","发货"] if self.dataMdoel!.order_res?.pay_status != 2{ titleArr = ["打印","确认收款","取消订单","发货"] } }else{ titleArr = ["打印","退款","发货"] if self.dataMdoel!.order_res?.pay_status != 2{ titleArr = ["打印","取消订单","发货"] } if self.dataMdoel!.order_res?.goods_before_pay == 1 && lmIdx == 1{ titleArr.insert("付款码", at: 0) } } if self.dataMdoel?.order_res?.apply_cancel == 1 { titleArr = ["打印","同意取消订单","拒绝取消订单"] } break case 7: // str = "待收货" if self.dataMdoel?.order_res?.from == 3 || self.dataMdoel?.order_res?.from == 5 { titleArr = ["打印","退款","退款退货","确认收货"] if self.dataMdoel?.order_res?.pay_status != 2{//未收款 titleArr = ["打印","取消订单","确认收款","确认收货"] } }else{ titleArr = ["打印","退款"] if self.dataMdoel?.order_res?.pay_status != 2 { titleArr = ["打印","取消订单"] } if self.dataMdoel?.order_res?.goods_before_pay == 1 && lmIdx == 1{ titleArr = ["打印","付款码","取消订单"] } } if self.dataMdoel?.order_res?.apply_cancel == 1 { titleArr = ["打印","同意取消订单","拒绝取消订单"] } break //订单完成 case 5: titleArr = [] break case 9: // 退款中 if self.dataMdoel!.order_res?.order_status_d == 91 && self.dataMdoel!.order_res?.from == 3 || self.dataMdoel!.order_res?.from == 5 { titleArr = ["打印","确认收到退款"] } if self.dataMdoel!.order_res?.order_status_d == 93 { titleArr = ["打印","确认收到退货"] } break //订单关闭 case 8,2: titleArr = [] break case 10: titleArr = ["打印","退款退货"] if self.dataMdoel!.order_res?.pay_status != 2 { titleArr = ["打印","取消订单"] } if self.dataMdoel!.order_res?.from == 3 || self.dataMdoel!.order_res?.from == 5 { titleArr.append("确认收款") } if self.dataMdoel!.order_res?.goods_before_pay == 1 && lmIdx == 1{ titleArr.insert("付款码", at: 0) } break case 11: titleArr = ["打印","查看订单"] if self.dataMdoel!.order_res?.order_status_d == 111 || self.dataMdoel!.order_res?.order_status_d == 112 || self.dataMdoel!.order_res?.order_status_d == 113{ titleArr = ["打印","同意退款","拒绝退款"] } if self.dataMdoel!.order_res?.order_status_d == 114 || self.dataMdoel!.order_res?.order_status_d == 115 { titleArr = ["打印","同意退货","拒绝退货"] } if self.dataMdoel!.order_res?.order_status_d == 116 || self.dataMdoel!.order_res?.order_status_d == 117 { titleArr = ["打印","同意退款退货","拒绝退款退货"] } break default: titleArr = [] break } if self.dataMdoel!.order_res?.pay_status! != 2 { if status == 1 || status == 6 || status == 7 || status == 10 { if !titleArr.contains("付款码") && titleArr.count < 4 { titleArr.append("付款码") } } } return titleArr } //MARK: - 底部自定义方法 @objc func bottomBtnClick(sender:UIButton){ switch sender.titleLabel?.text { case "先货后款": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否先货后款?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1010 self.view.window?.addSubview(alertView) break case "修改价格": if isYuShou { let vc = XiuGaiYuShouJiaViewController() vc.delegate = self vc.dataModel = self.dataMdoel vc.orderID = self.orderId let rowModel = self.dataMdoel?.order_goods!.first vc.imgUrlstr = SERVERCE_ImageHost + (rowModel?.goods_thumb)! let goodsAmount = (self.dataMdoel?.order_res?.goods_amount!)! as NSString vc.totalPrice = goodsAmount.floatValue self.navigationController?.pushViewController(vc, animated: true) }else{ let vc = ChangeGoodsPriceVC() vc.dataArr = self.dataMdoel?.order_goods vc.orderID = self.orderId vc.delegate = self vc.wlPrice = self.dataMdoel?.order_res?.logistics_price as! String vc.qtPrice = self.dataMdoel?.order_res?.other_price! as! String self.navigationController?.pushViewController(vc,animated: true) } break case "打印": // orderId = 12599 printOrder(["user_token":UserToken as Any,"order_id":orderId as Any]) { [self] (data) in let d = data as! printOrder_model let vc = PrintListMgVc() vc.printData = d.data?.order_res vc.order_id = self.orderId! vc.selectIndex = (d.data?.order_res?.print_type)!-1 self.navigationController?.pushViewController(vc, animated: true) } failture: { (err) in } break case "确认订单": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否确认订单?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1001 self.view.window?.addSubview(alertView) break case "取消订单": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否确认取消订单?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1002 self.view.window?.addSubview(alertView) break case "发货": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否发货?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1003 self.view.window?.addSubview(alertView) break case "退款","取消订单并退款": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "暂不支持原路退款,请注意使用其他渠道退还金额" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "继续退款"), for: .normal) alertView.rightBtn.tag = 1004 self.view.window?.addSubview(alertView) break case "退货": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否退货?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1005 self.view.window?.addSubview(alertView) break case "同意取消订单": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否同意取消订单?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1006 self.view.window?.addSubview(alertView) break case "拒绝取消订单": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否拒绝取消订单?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1007 self.view.window?.addSubview(alertView) break case "同意接单": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否同意接单?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1008 self.view.window?.addSubview(alertView) break case "拒绝接单": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否拒绝接单?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1009 self.view.window?.addSubview(alertView) break case "确认收款": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否确认收款?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1099 self.view.window?.addSubview(alertView) break case "同意退款","同意退款退货","同意退货": if sender.titleLabel!.text == "同意退款"{ agreeType = 1 } if sender.titleLabel!.text == "同意退货"{ agreeType = 2 } let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否\(sender.titleLabel!.text!)?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1100 self.view.window?.addSubview(alertView) break case "拒绝退款","拒绝退款退货","拒绝退货": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否\(sender.titleLabel!.text!)?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1111 self.view.window?.addSubview(alertView) break case "确认收到退款": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否确认收到退款?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1011 self.view.window?.addSubview(alertView) break case "确认收到退货": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否确认收到退货?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1012 self.view.window?.addSubview(alertView) break case "确认收货": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否确认收货?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1020 self.view.window?.addSubview(alertView) break case "退款退货": let alertView = GeliAlertView(frame: self.view.window!.bounds) alertView.delegate = self; alertView.tishiLbl.text = "" alertView.titileLbl.text = "是否退款退货?" alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确认"), for: .normal) alertView.rightBtn.tag = 1021 self.view.window?.addSubview(alertView) break case "付款码": let alertView = GeliAltetCodeView(frame: self.view.window!.bounds) alertView.saveImgID = orderId self.view.window?.addSubview(alertView) break default: break } } //MARK:--确认和取消订单 //MARK:--弹窗代理 --还有其他弹窗,根据tag分类 func sureGeliAlertViewAction(sender: UIButton) { if sender.tag == 1001 { HUD.flash(.progress) orderConfirm(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "确认成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else if sender.tag == 1002{ HUD.flash(.progress) orderCancel(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "取消成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else if sender.tag == 1003 { HUD.flash(.progress) if isYuShou { sendOutAd(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "提交成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else{ sendOut(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "提交成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } } }else if sender.tag == 1004 { HUD.flash(.progress) orderRefund(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "提交成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else if sender.tag == 1006{ HUD.flash(.progress) orderCancelAudit(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any,"type":1 as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "已同意"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else if sender.tag == 1007{ HUD.flash(.progress) orderCancelAudit(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any,"type":2 as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "已拒绝"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else if sender.tag == 1008 { orderConfirm(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "确认成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else if sender.tag == 1010 { orderConfirm(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any,"goods_before_pay":1 as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "提交成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else if sender.tag == 1020 { confirmReceiving(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "确认成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) }) { (error) in } }else if sender.tag == 1021 { refundAndSalesReturn(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "提交成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) }) { (error) in } }else if sender.tag == 1099 { editPayType(["user_token":UserToken as Any,"order_id":self.dataMdoel?.order_res?.order_id as Any,"is_adsale":0 as Any,"amount_type":0 as Any,"pay_type":7 as Any], success: { (data) in let dataM = data as! UpDataModel if dataM.code == 1 { NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() } }) { (error) in } }else if sender.tag == 1100 { if agreeType == 10086 { refundAndSalesReturn(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "提交成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) }) { (error) in } return } refundOrSalesReturn(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any ,"type":agreeType as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "提交成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else if sender.tag == 1111 { var type = 1 if self.dataMdoel?.order_res?.order_status_d == 114 && self.dataMdoel?.order_res?.order_status_d == 115 { type = 2 } if self.dataMdoel?.order_res?.order_status_d == 116 && self.dataMdoel?.order_res?.order_status_d == 117 { type = 3 } orderRefundRefuse(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any,"type":type as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "拒绝成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) }) { (error) in } }else if sender.tag == 1011{ ConfirmRefund(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "提交成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else if sender.tag == 1012 {//确认收货 confirmReturnedGoods(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "提交成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else if sender.tag == 1009 { refuseOrder(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "取消成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else if sender.tag == 1005 { HUD.flash(.progress) if isYuShou { orderReturnedGoodsAd(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "提交成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } }else{ orderReturnedGoods(["user_token":UserToken as Any,"order_id" : self.dataMdoel?.order_res?.order_id as Any], success: { (data) in HUD.flash(.labeledSubSuccess(subtitle: "提交成功"),delay: 1.2) NotificationCenter.default.post(name: NSNotification.Name(rawValue: "orderChange"), object: nil) self.delegate?.refishingOrderDchange() self.loadData() }) { (error) in } } } } }