Commit 0e534b5e authored by lujunye's avatar lujunye

2

parent c8c15dc5
......@@ -9,7 +9,13 @@
import UIKit
class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlertTbAddViewCellDelegate,TitleAndSelectCellDelegate{
var is_dls = false {
didSet{
if is_dls {
title_lbl.text = "新增代理商"
}
}
}
var is_gys = false {
didSet{
if is_gys{
......@@ -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> = []{
......@@ -58,6 +69,9 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
if title_lbl.text == "新增供应商" {
return gys_centers.count
}
if title_lbl.text?.contains("代理商") == true {
return dls_centers.count
}
return centers.count
}
}
......@@ -85,12 +99,19 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
return cell
}else{
if title_lbl.text == "新增供应商" {
if title_lbl.text == "新增供应商" || title_lbl.text == "新增代理商"{
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSelectCell")! as! TitleAndSelectCell
cell.is_center_select = true
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]
cell.titleLbl.text = model.shop_name
cell.titleLbl.text = model.shop_name
}
let str = datas[idx] as! String
if str.count > 0{
if cell.titleLbl.text == str {
......@@ -144,6 +165,9 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
if title_lbl.text == "新增供应商" {
let model = gys_centers[indexPath.row]
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{
let model = centers[indexPath.row]
datas.insert(model.shop_name!, at: idx)
......@@ -198,6 +222,31 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
} failture: { (err) in
}
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{
let str = d[i]
......
<?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"/>
<dependencies>
<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="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
......@@ -53,7 +53,7 @@
</connections>
</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">
<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"/>
<color key="textColor" name="灰色字体颜色"/>
<nil key="highlightedColor"/>
......
......@@ -27,9 +27,10 @@ class SY_GYS_GL_VC: BaseViewController , UISearchBarDelegate, SearchBarViewDeleg
}
@IBOutlet weak var list_view: UITableView!
@IBOutlet weak var contentV: UIView!
var titleStr = ""
override func viewDidLoad() {
super.viewDidLoad()
navbar.title = "上游供应商管理"
navbar.title = titleStr
self.view.addSubview(navbar)
SetTopFrame(view: contentV, height: 45)
let searchBr = SearchBarView.init()
......
......@@ -8,19 +8,41 @@
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) {
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) {
let model = dataArr[cell.tag]
if btn.titleLabel?.text == "终止合作" {
let view = Cancel_Action_View(frame: self.view.bounds)
view.delegate = self
view.tag = cell.tag
view.tag = model.age_id!
self.view.addSubview(view)
}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
return 165
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
return dataArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "SY_SLS_GL_VC_Cell") as! SY_SLS_GL_VC_Cell
cell.delegate = self
let model = dataArr[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
}
var gys_centers:Array<getSupShopDataModel> = []
var gys_centers:Array<getAllAge_data_model> = []
func rightBtnClick() {
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
self.gys_centers.append(item)
})
HUD.hide()
let alertView = GLAlertTbAddView(frame: self.view.bounds)
alertView.is_gys = true
alertView.is_dls = true
alertView.bottom_tableview.isHidden = true
alertView.gys_centers = self.gys_centers
alertView.dls_centers = self.gys_centers
self.view.addSubview(alertView)
} 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 contentV: UIView!
var titleStr = ""
override func viewDidLoad() {
super.viewDidLoad()
navbar.title = "上游代理商管理"
navbar.title = titleStr
navbar.rightTitle = "新增代理商"
self.view.addSubview(navbar)
SetTopFrame(view: contentV, height: 45)
......@@ -97,11 +148,75 @@ class SY_DLS_GL_VC: BaseViewController, UISearchBarDelegate, SearchBarViewDelega
footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData))
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
} failture: { (error) in
self.list_view.mj_header?.endRefreshing()
}
}
@objc func loadMoreData(){}
@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
@objc func removeBlackBtnView(){
......
......@@ -696,6 +696,7 @@ class WorkCViewController: BaseViewController, UITableViewDelegate, UITableViewD
// return
case 148://下游代理商管理
let vc = SY_DLS_GL_VC()
vc.titleStr = "下游代理商管理"
self.navigationController?.pushViewController(vc, animated: true)
return
case 149://店长审核管理
......@@ -737,6 +738,7 @@ class WorkCViewController: BaseViewController, UITableViewDelegate, UITableViewD
return
case 159://上游供应商管理
let vc = SY_GYS_GL_VC()
vc.titleStr = "下游代理商管理"
self.navigationController?.pushViewController(vc, animated: true)
return
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