// // RetailManageDetailViewController.swift // GeliBusinessPlatform // // Created by 刘俊宏 on 2020/11/12. // Copyright © 2020 junye lu. All rights reserved. // import UIKit class RetailManageDetailViewController: BaseViewController ,UITableViewDelegate,UITableViewDataSource, DaiKeXiaDanGouWuCellDelegate, S_Y_View_Delegate{ func DaiKeXiaDanGouWuCell_select_pi_ci(cell: DaiKeXiaDanGouWuCell) { print("选择批次3") } func S_Y_View_Check_Detail(data: OrderDetailGoodsSourceModel) { print("查看溯源") let browser = JXPhotoBrowser() browser.numberOfItems = { (data.report_picture!.count) } browser.pageIndex = 0 browser.reloadCellAtIndex = { context in let browserCell = context.cell as? JXPhotoBrowserImageCell let url = URL(string:SERVERCE_ImageHost + (data.report_picture![context.index])) browserCell?.imageView.sd_setImage(with: url, placeholderImage: nil, options: [], completed: { (_, _, _, _) in browserCell?.setNeedsLayout() }) } browser.show() } func DaiKeXiaDanGouWuCellDelAction(cell: DaiKeXiaDanGouWuCell) { //此处无用 } func DaiKeXiaDanGouWuCellRemarkChange(cell: DaiKeXiaDanGouWuCell) { //此处无用 } func DaiKeXiaDanGouWuCell_check(cell: DaiKeXiaDanGouWuCell) { //查溯源 print("check S_Y") if (dataMdoel?.order_goods!.count)! > 0 { let target = dataMdoel?.order_goods![cell.tag] if (target?.goods_source!.count)! > 0 { let vc = S_Y_View(frame: self.view.bounds) vc.delegate = self vc.data = target?.goods_source self.view.addSubview(vc) } } } let goodsTitleArr = ["商品合计"] let fenxiaoTitleArr = ["分销角色","结算方式","佣金方式","佣金结算时间","佣金分销结算"] let orderTitleArr = ["订单编号","下单时间","订单来源","支付方式","支付状态","买家留言","订单备注"] @IBOutlet weak var listView: UITableView! override func viewDidLoad() { super.viewDidLoad() navbar.title = "分销订单详情" self.view.addSubview(navbar) SetTopFrameView(view: listView, btmView: self.view) listView.separatorStyle = .none listView.register(UINib(nibName: "GLKHCell", bundle: nil), forCellReuseIdentifier: "GLKHCell") listView.register(UINib(nibName: "DaiKeXiaDanGouWuCell", bundle: nil), forCellReuseIdentifier: "DaiKeXiaDanGouWuCell") listView.register(UINib(nibName: "TitleAndTFCell", bundle: nil), forCellReuseIdentifier: "TitleAndTFCell") loadData() } //MARK:--加载数据 var orderId:Int? //订单编号 var dbt_shop_id:Int? = nil var dataMdoel: OrderDetailDataModel? = nil let UserToken = UserDefaults.standard.value(forKey: "user_token") func loadData() { HUD.flash(.progress) if dbt_shop_id != nil { orderDetail(["user_token":UserToken as Any,"order_id":orderId as Any,"dbt_shop_id" : dbt_shop_id as Any], success: { [self] (data) in HUD.hide(animated: true) let dataM = data as! OrderDetailModel self.dataMdoel = dataM.data self.listView.reloadData() }) { (error) in self.listView.isHidden = true } }else{ 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 self.listView.reloadData() }) { (error) in self.listView.isHidden = true } } } func numberOfSections(in tableView: UITableView) -> Int { if self.dataMdoel == nil { return 0 } return 5 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { switch section { case 0: return 1 case 1: return (self.dataMdoel?.order_goods!.count)! //商品 case 2: return goodsTitleArr.count case 3: return fenxiaoTitleArr.count case 4: return orderTitleArr.count default: return 0 } } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTFCell") as! TitleAndTFCell cell.textTF.isUserInteractionEnabled = false switch indexPath.section { case 0: let cell = tableView.dequeueReusableCell(withIdentifier: "GLKHCell") as! GLKHCell cell.nameLbl.text = self.dataMdoel?.order_res?.user_name cell.contentLbl.text = self.dataMdoel?.order_res!.pay_status_cn cell.contentLbl.textColor = UIColor(named: "蓝色字体颜色") cell.contentLbl_right.constant = -8 cell.gotoImgV.isHidden = true return cell case 1: let cell = tableView.dequeueReusableCell(withIdentifier: "DaiKeXiaDanGouWuCell") as! DaiKeXiaDanGouWuCell cell.isFx = true let rowModel = self.dataMdoel?.order_goods![indexPath.row] cell.titleLbl.text = rowModel?.goods_name cell.imgView?.sd_setImage(with: URL(string: SERVERCE_ImageHost + (rowModel?.goods_thumb)!)) if rowModel?.goods_attr != nil { cell.detailLbl.text = "规格:" + (rowModel?.goods_attr)! }else{ cell.detailLbl.text = "规格:-" } let s_p = rowModel?.goods_price as! NSString let p_count = Float((rowModel?.cart_number)!) * s_p.floatValue cell.count_lbl.text = "单价:" + (rowModel?.goods_price)! cell.yong_jin_lbl.text = "小计:" + String(format: "%.2f", p_count) cell.dan_jia_lbl.text = "佣金:¥" + (rowModel?.commission_val)! cell.xiao_ji_lbl.text = "数量:" + StringByInt(number: (rowModel?.cart_number!)!) cell.delegate = self cell.tag = indexPath.row cell.arrow_img.isHidden = true cell.check_button.isHidden = true if (rowModel?.goods_source!.count)! > 0 { cell.arrow_img.isHidden = false cell.check_button.isHidden = false } return cell case 2: cell.nameLbl.text = goodsTitleArr[indexPath.row] cell.textTF.text = "¥" + (self.dataMdoel?.order_res!.goods_amount)! case 3: switch indexPath.row { case 0: if self.dataMdoel?.order_res?.dbt_target == 1 { cell.textTF.text = "供应商" + "(" + (self.dataMdoel?.order_res?.target_name)! + ")" }else if self.dataMdoel?.order_res?.dbt_target == 2 { cell.textTF.text = "分销商" + "(" + (self.dataMdoel?.order_res?.target_name)! + ")" }else if self.dataMdoel?.order_res?.dbt_target == 3{ cell.textTF.text = "分销员" + "(" + (self.dataMdoel?.order_res?.target_name)! + ")" }else{ cell.textTF.text = "-" } case 1: if self.dataMdoel?.dbt_info?.dbt_type == 1 { cell.textTF.text = "人工结算" }else if self.dataMdoel?.dbt_info?.dbt_type == 2{ cell.textTF.text = "自动结算" }else{ cell.textTF.text = "-" } case 2: if self.dataMdoel?.dbt_info?.commission_type != nil{ if (self.dataMdoel?.dbt_info?.commission_type!.count)! > 0{ cell.textTF.text = self.dataMdoel?.dbt_info?.commission_type }else{ cell.textTF.text = "-" } }else{ cell.textTF.text = "-" } case 3: if self.dataMdoel?.dbt_info?.commission_time != nil{ if (self.dataMdoel?.dbt_info?.commission_time!.count)! > 0{ cell.textTF.text = self.dataMdoel?.dbt_info?.commission_time }else{ cell.textTF.text = "-" } }else{ cell.textTF.text = "-" } case 4: cell.textTF.text = "¥" + (self.dataMdoel?.order_res!.sum_commission_val)! default: cell.textTF.text = "-" break } cell.nameLbl.text = fenxiaoTitleArr[indexPath.row] case 4: cell.nameLbl.text = orderTitleArr[indexPath.row] switch indexPath.row { case 0: cell.textTF.text = self.dataMdoel?.order_res?.order_sn case 1: cell.textTF.text = TimeByDouble(sender: (self.dataMdoel?.order_res?.add_time!)!) case 2: cell.textTF.text = self.dataMdoel?.order_res?.from_cn case 3: cell.textTF.text = self.dataMdoel?.order_res?.pay_type_cn case 4: cell.textTF.text = self.dataMdoel?.order_res?.pay_status_cn case 5: cell.textTF.text = self.dataMdoel?.order_res?.postscript if self.dataMdoel?.order_res?.postscript?.count == 0 { cell.textTF.text = "-" } case 6: cell.textTF.text = self.dataMdoel?.order_res?.order_postscript if self.dataMdoel?.order_res?.order_postscript?.count == 0 { cell.textTF.text = "-" } default: cell.textTF.text = "" break } default: break } return cell } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if indexPath.section == 1 { return 220 } return 49 } func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { if section == 3 || section == 4 { return 39 } return 0.5 } func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let view = UIView() view.subviews.forEach { (subV) in subV.removeFromSuperview() } switch section { case 3: let view1 = HeaderOnlyTitleView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 39)) view1.nameLbl.text = "分销信息" view.addSubview(view1) 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 default: break } return view } func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { let view = UIView() view.subviews.forEach { (subV) in subV.removeFromSuperview() } if section == 2 { let view = OrderDViewSumFooter(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 59)) view.priceLbl.text = "¥" + (self.dataMdoel?.order_res!.sum_amount)! + "(总佣金" + (self.dataMdoel?.order_res!.sum_commission_val)! + "元)" return view } return view } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { if section == 2 { return 59 } if section == 3 { return 10 } return 0.5 } }