Commit 0e534b5e authored by lujunye's avatar lujunye

2

parent c8c15dc5
...@@ -9,7 +9,13 @@ ...@@ -9,7 +9,13 @@
import UIKit import UIKit
class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlertTbAddViewCellDelegate,TitleAndSelectCellDelegate{ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlertTbAddViewCellDelegate,TitleAndSelectCellDelegate{
var is_dls = false {
didSet{
if is_dls {
title_lbl.text = "新增代理商"
}
}
}
var is_gys = false { var is_gys = false {
didSet{ didSet{
if is_gys{ if is_gys{
...@@ -34,6 +40,11 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -34,6 +40,11 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
} }
var dls_centers:Array<getAllAge_data_model> = [] {
didSet{
bottom_tableview.reloadData()
}
}
var centers:Array<getAllShopDataModel> = []{ var centers:Array<getAllShopDataModel> = []{
...@@ -58,6 +69,9 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -58,6 +69,9 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
if title_lbl.text == "新增供应商" { if title_lbl.text == "新增供应商" {
return gys_centers.count return gys_centers.count
} }
if title_lbl.text?.contains("代理商") == true {
return dls_centers.count
}
return centers.count return centers.count
} }
} }
...@@ -85,12 +99,19 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -85,12 +99,19 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
return cell return cell
}else{ }else{
if title_lbl.text == "新增供应商" { if title_lbl.text == "新增供应商" || title_lbl.text == "新增代理商"{
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSelectCell")! as! TitleAndSelectCell let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSelectCell")! as! TitleAndSelectCell
cell.is_center_select = true cell.is_center_select = true
cell.delegate = self cell.delegate = self
if dls_centers.count > 0 {
let model = dls_centers[indexPath.row]
cell.titleLbl.text = model.shop_name
}else{
let model = gys_centers[indexPath.row] let model = gys_centers[indexPath.row]
cell.titleLbl.text = model.shop_name cell.titleLbl.text = model.shop_name
}
let str = datas[idx] as! String let str = datas[idx] as! String
if str.count > 0{ if str.count > 0{
if cell.titleLbl.text == str { if cell.titleLbl.text == str {
...@@ -144,6 +165,9 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -144,6 +165,9 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
if title_lbl.text == "新增供应商" { if title_lbl.text == "新增供应商" {
let model = gys_centers[indexPath.row] let model = gys_centers[indexPath.row]
datas.insert(model.shop_name!, at: idx) datas.insert(model.shop_name!, at: idx)
}else if title_lbl.text == "新增代理商"{
let model = dls_centers[indexPath.row]
datas.insert(model.shop_name!, at: idx)
}else{ }else{
let model = centers[indexPath.row] let model = centers[indexPath.row]
datas.insert(model.shop_name!, at: idx) datas.insert(model.shop_name!, at: idx)
...@@ -198,6 +222,31 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -198,6 +222,31 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
} failture: { (err) in } failture: { (err) in
} }
return return
}else if title_lbl.text == "新增代理商" {
for i in 0 ..< d.count{
let str = d[i]
dls_centers.forEach { (item) in
if item.shop_name == str {
if i < d.count-1 {
shop_id += StringByInt(number: item.shop_id!) + ","
}else{
shop_id += StringByInt(number: item.shop_id!)
}
}
}
}
if shop_id.count == 0 {
HUD.flash(.label("商店不能为空"), delay: 1.2)
return
}
HUD.flash(.progress)
ageAddContract(["user_token":UserToken as Any,"agent_id":shop_id as Any]) { (data) in
self.removeFromSuperview()
HUD.hide()
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "dlsAdd"), object: nil)
} failture: { (err) in
}
return
} }
for i in 0 ..< d.count{ for i in 0 ..< d.count{
let str = d[i] let str = d[i]
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/> <device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<capability name="Named colors" minToolsVersion="9.0"/> <capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
</connections> </connections>
</button> </button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="请选择店铺" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9yi-HN-uNk"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="请选择店铺" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9yi-HN-uNk">
<rect key="frame" x="60" y="23" width="65.5" height="19"/> <rect key="frame" x="60" y="23" width="65" height="19"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="13"/> <fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="13"/>
<color key="textColor" name="灰色字体颜色"/> <color key="textColor" name="灰色字体颜色"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
......
...@@ -27,9 +27,10 @@ class SY_GYS_GL_VC: BaseViewController , UISearchBarDelegate, SearchBarViewDeleg ...@@ -27,9 +27,10 @@ class SY_GYS_GL_VC: BaseViewController , UISearchBarDelegate, SearchBarViewDeleg
} }
@IBOutlet weak var list_view: UITableView! @IBOutlet weak var list_view: UITableView!
@IBOutlet weak var contentV: UIView! @IBOutlet weak var contentV: UIView!
var titleStr = ""
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
navbar.title = "上游供应商管理" navbar.title = titleStr
self.view.addSubview(navbar) self.view.addSubview(navbar)
SetTopFrame(view: contentV, height: 45) SetTopFrame(view: contentV, height: 45)
let searchBr = SearchBarView.init() let searchBr = SearchBarView.init()
......
...@@ -8,19 +8,41 @@ ...@@ -8,19 +8,41 @@
import UIKit import UIKit
class SY_DLS_GL_VC: BaseViewController, UISearchBarDelegate, SearchBarViewDelegate,UITableViewDelegate,UITableViewDataSource,SY_SLS_GL_VC_Cell_Delegate,Cancel_Action_View_Delegate{ class SY_DLS_GL_VC: BaseViewController, UISearchBarDelegate, SearchBarViewDelegate,UITableViewDelegate,UITableViewDataSource,SY_SLS_GL_VC_Cell_Delegate,Cancel_Action_View_Delegate, GeliAlertViewDelegate{
func sureGeliAlertViewAction(sender: UIButton) {
ageAddContract(["user_token":UserToken as Any,"agent_id":sender.tag]) { (data) in
self.list_view.mj_header?.beginRefreshing()
} failture: { (err) in
}
}
func Cancel_Action_View_Action(view: Cancel_Action_View) { func Cancel_Action_View_Action(view: Cancel_Action_View) {
print(view.tag) stopAgentContract(["user_token":UserToken as Any,"age_id":view.tag]) { (data) in
self.list_view.mj_header?.beginRefreshing()
} failture: { (err) in
}
} }
func SY_SLS_GL_VC_Cell_Action(btn: UIButton, cell: SY_SLS_GL_VC_Cell) { func SY_SLS_GL_VC_Cell_Action(btn: UIButton, cell: SY_SLS_GL_VC_Cell) {
let model = dataArr[cell.tag]
if btn.titleLabel?.text == "终止合作" { if btn.titleLabel?.text == "终止合作" {
let view = Cancel_Action_View(frame: self.view.bounds) let view = Cancel_Action_View(frame: self.view.bounds)
view.delegate = self view.delegate = self
view.tag = cell.tag view.tag = model.age_id!
self.view.addSubview(view) self.view.addSubview(view)
}else{ }else{
let alertView = GeliAlertView(frame: self.view.window!.bounds)
alertView.delegate = self;
alertView.tishiLbl.text = ""
alertView.titileLbl.text = "是否确定重新合作?"
alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确定"), for: .normal)
let model = dataArr[cell.tag]
alertView.rightBtn.tag = model.age_id!
self.view.window?.addSubview(alertView)
} }
} }
...@@ -33,43 +55,72 @@ class SY_DLS_GL_VC: BaseViewController, UISearchBarDelegate, SearchBarViewDelega ...@@ -33,43 +55,72 @@ class SY_DLS_GL_VC: BaseViewController, UISearchBarDelegate, SearchBarViewDelega
return 165 return 165
} }
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3 return dataArr.count
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "SY_SLS_GL_VC_Cell") as! SY_SLS_GL_VC_Cell let cell = tableView.dequeueReusableCell(withIdentifier: "SY_SLS_GL_VC_Cell") as! SY_SLS_GL_VC_Cell
cell.delegate = self cell.delegate = self
let model = dataArr[indexPath.row]
cell.tag = indexPath.row cell.tag = indexPath.row
cell.icon.sd_setImage(with:URL(string:SERVERCE_ImageHost + model.shop_img_thumb!), placeholderImage: nil,options:.allowInvalidSSLCertificates)
cell.name.text = model.shop_name
cell.adress.text = model.address
cell.time.text = model.start_time
cell.status.text = model.status
cell.income.text = "\(model.sum_agent_commission_val!)"
if model.status?.contains("终止") == true {
cell.btn.setTitle("重新合作", for: .normal)
cell.btn.backgroundColor = UIColor(named: "按钮渐变色下,字体颜色")
cell.btn.setTitleColor(UIColor.white, for: .normal)
}else{
cell.btn.setTitle("终止合作", for: .normal)
cell.btn.backgroundColor = UIColor(named: "灰色分界线")
cell.btn.setTitleColor(UIColor(named: "#999999"), for: .normal)
}
return cell return cell
} }
var gys_centers:Array<getSupShopDataModel> = [] var gys_centers:Array<getAllAge_data_model> = []
func rightBtnClick() { func rightBtnClick() {
print("新增代理商") print("新增代理商")
getSupShop(["user_token":UserToken as Any]) { (data) in
let model = data as! getSupShopModel getAllAge(["user_token":UserToken as Any]) { (data) in
let model = data as! getAllAge_model
model.data?.forEach({ (item) in model.data?.forEach({ (item) in
self.gys_centers.append(item) self.gys_centers.append(item)
}) })
HUD.hide() HUD.hide()
let alertView = GLAlertTbAddView(frame: self.view.bounds) let alertView = GLAlertTbAddView(frame: self.view.bounds)
alertView.is_gys = true alertView.is_dls = true
alertView.bottom_tableview.isHidden = true alertView.bottom_tableview.isHidden = true
alertView.gys_centers = self.gys_centers alertView.dls_centers = self.gys_centers
self.view.addSubview(alertView) self.view.addSubview(alertView)
} failture: { (err) in } failture: { (err) in
} }
// getSupShop(["user_token":UserToken as Any]) { (data) in
// let model = data as! getSupShopModel
// model.data?.forEach({ (item) in
// self.gys_centers.append(item)
// })
//
//
// } failture: { (err) in
// }
} }
@IBOutlet weak var list_view: UITableView! @IBOutlet weak var list_view: UITableView!
@IBOutlet weak var contentV: UIView! @IBOutlet weak var contentV: UIView!
var titleStr = ""
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
navbar.title = "上游代理商管理" navbar.title = titleStr
navbar.rightTitle = "新增代理商" navbar.rightTitle = "新增代理商"
self.view.addSubview(navbar) self.view.addSubview(navbar)
SetTopFrame(view: contentV, height: 45) SetTopFrame(view: contentV, height: 45)
...@@ -97,11 +148,75 @@ class SY_DLS_GL_VC: BaseViewController, UISearchBarDelegate, SearchBarViewDelega ...@@ -97,11 +148,75 @@ class SY_DLS_GL_VC: BaseViewController, UISearchBarDelegate, SearchBarViewDelega
footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData)) footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData))
list_view.mj_footer = self.footerMJ list_view.mj_footer = self.footerMJ
NotificationCenter.default.addObserver(self, selector: #selector(getNoti(noti:)), name: NSNotification.Name(rawValue: "dlsAdd"), object: nil)
}
@objc func getNoti(noti:Notification){
list_view.mj_header?.beginRefreshing()
} }
@objc func loadData(){} deinit {
/// 移除通知
NotificationCenter.default.removeObserver(self)
}
var dataArr:Array<agentList_data_model> = []
var page = 0
@objc func loadData(){
page = 1
let dict = [
"user_token":UserToken as Any,
"agent_name":keyword as Any,
"page":page as Any
]
agentList(dict) { (data) in
let dataM = data as! agentList_model
self.dataArr.removeAll()
dataM.data?.forEach({ (model) in
self.dataArr.append(model)
})
self.list_view.mj_header?.endRefreshing()
self.list_view.reloadData()
if dataM.data?.count == 0 {
self.list_view.mj_footer?.endRefreshingWithNoMoreData()
}else{
self.list_view.mj_footer?.endRefreshing()
}
self.page = 2
@objc func loadMoreData(){} } failture: { (error) in
self.list_view.mj_header?.endRefreshing()
}
}
@objc func loadMoreData(){
let dict = [
"user_token":UserToken as Any,
"agent_name":keyword as Any,
"page":page as Any
]
agentList(dict) { (data) in
let dataM = data as! agentList_model
if dataM.data?.count == 0 {
self.list_view.mj_footer?.endRefreshingWithNoMoreData()
}else{
self.page += 1
dataM.data?.forEach({ (model) in
self.dataArr.append(model)
})
self.list_view.reloadData()
self.list_view.mj_footer?.endRefreshing()
}
} failture: { (error) in
self.list_view.mj_footer?.endRefreshing()
}
}
var blackBtnView:UIButton! = nil var blackBtnView:UIButton! = nil
@objc func removeBlackBtnView(){ @objc func removeBlackBtnView(){
......
...@@ -696,6 +696,7 @@ class WorkCViewController: BaseViewController, UITableViewDelegate, UITableViewD ...@@ -696,6 +696,7 @@ class WorkCViewController: BaseViewController, UITableViewDelegate, UITableViewD
// return // return
case 148://下游代理商管理 case 148://下游代理商管理
let vc = SY_DLS_GL_VC() let vc = SY_DLS_GL_VC()
vc.titleStr = "下游代理商管理"
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
return return
case 149://店长审核管理 case 149://店长审核管理
...@@ -737,6 +738,7 @@ class WorkCViewController: BaseViewController, UITableViewDelegate, UITableViewD ...@@ -737,6 +738,7 @@ class WorkCViewController: BaseViewController, UITableViewDelegate, UITableViewD
return return
case 159://上游供应商管理 case 159://上游供应商管理
let vc = SY_GYS_GL_VC() let vc = SY_GYS_GL_VC()
vc.titleStr = "下游代理商管理"
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
return return
case 160://下游店长管理 case 160://下游店长管理
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment