Commit 5a0507fd authored by lujunye's avatar lujunye

品牌列表,新增品牌

parent 0562db9c
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
E013D7912484D5AF0092DE46 /* NewCKCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E013D78F2484D5AF0092DE46 /* NewCKCell.xib */; }; E013D7912484D5AF0092DE46 /* NewCKCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E013D78F2484D5AF0092DE46 /* NewCKCell.xib */; };
E0190A2D2487696F00B1E067 /* NewSelectItemVc.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0190A2B2487696F00B1E067 /* NewSelectItemVc.swift */; }; E0190A2D2487696F00B1E067 /* NewSelectItemVc.swift in Sources */ = {isa = PBXBuildFile; fileRef = E0190A2B2487696F00B1E067 /* NewSelectItemVc.swift */; };
E0190A2E2487696F00B1E067 /* NewSelectItemVc.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0190A2C2487696F00B1E067 /* NewSelectItemVc.xib */; }; E0190A2E2487696F00B1E067 /* NewSelectItemVc.xib in Resources */ = {isa = PBXBuildFile; fileRef = E0190A2C2487696F00B1E067 /* NewSelectItemVc.xib */; };
E019E98124A975920086C565 /* brandListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E019E98024A975920086C565 /* brandListModel.swift */; };
E019E98324A9763A0086C565 /* BrandListInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = E019E98224A9763A0086C565 /* BrandListInterface.swift */; };
E01C26B12446989700ADCC70 /* Interface_Z.plist in Resources */ = {isa = PBXBuildFile; fileRef = E01C26B02446989700ADCC70 /* Interface_Z.plist */; }; E01C26B12446989700ADCC70 /* Interface_Z.plist in Resources */ = {isa = PBXBuildFile; fileRef = E01C26B02446989700ADCC70 /* Interface_Z.plist */; };
E01C26B62446AF3100ADCC70 /* DemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E01C26B42446AF3100ADCC70 /* DemoViewController.swift */; }; E01C26B62446AF3100ADCC70 /* DemoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E01C26B42446AF3100ADCC70 /* DemoViewController.swift */; };
E01C26B72446AF3100ADCC70 /* DemoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E01C26B52446AF3100ADCC70 /* DemoViewController.xib */; }; E01C26B72446AF3100ADCC70 /* DemoViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E01C26B52446AF3100ADCC70 /* DemoViewController.xib */; };
...@@ -595,6 +597,8 @@ ...@@ -595,6 +597,8 @@
E013D78F2484D5AF0092DE46 /* NewCKCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NewCKCell.xib; sourceTree = "<group>"; }; E013D78F2484D5AF0092DE46 /* NewCKCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NewCKCell.xib; sourceTree = "<group>"; };
E0190A2B2487696F00B1E067 /* NewSelectItemVc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewSelectItemVc.swift; sourceTree = "<group>"; }; E0190A2B2487696F00B1E067 /* NewSelectItemVc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewSelectItemVc.swift; sourceTree = "<group>"; };
E0190A2C2487696F00B1E067 /* NewSelectItemVc.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NewSelectItemVc.xib; sourceTree = "<group>"; }; E0190A2C2487696F00B1E067 /* NewSelectItemVc.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NewSelectItemVc.xib; sourceTree = "<group>"; };
E019E98024A975920086C565 /* brandListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = brandListModel.swift; sourceTree = "<group>"; };
E019E98224A9763A0086C565 /* BrandListInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrandListInterface.swift; sourceTree = "<group>"; };
E01C26B02446989700ADCC70 /* Interface_Z.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Interface_Z.plist; sourceTree = "<group>"; }; E01C26B02446989700ADCC70 /* Interface_Z.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Interface_Z.plist; sourceTree = "<group>"; };
E01C26B42446AF3100ADCC70 /* DemoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoViewController.swift; sourceTree = "<group>"; }; E01C26B42446AF3100ADCC70 /* DemoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DemoViewController.swift; sourceTree = "<group>"; };
E01C26B52446AF3100ADCC70 /* DemoViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DemoViewController.xib; sourceTree = "<group>"; }; E01C26B52446AF3100ADCC70 /* DemoViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DemoViewController.xib; sourceTree = "<group>"; };
...@@ -1352,6 +1356,14 @@ ...@@ -1352,6 +1356,14 @@
path = "出库"; path = "出库";
sourceTree = "<group>"; sourceTree = "<group>";
}; };
E019E97F24A975710086C565 /* pinPai */ = {
isa = PBXGroup;
children = (
E019E98024A975920086C565 /* brandListModel.swift */,
);
path = pinPai;
sourceTree = "<group>";
};
E01C26B32446AEF800ADCC70 /* DEMO */ = { E01C26B32446AEF800ADCC70 /* DEMO */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
...@@ -1711,6 +1723,7 @@ ...@@ -1711,6 +1723,7 @@
E09B03A92445B09200211A51 /* Model */ = { E09B03A92445B09200211A51 /* Model */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E019E97F24A975710086C565 /* pinPai */,
E05FAD282498A5E800D8C90D /* yfzkModel */, E05FAD282498A5E800D8C90D /* yfzkModel */,
F924B38E24971BB600A913CD /* CustomerModel */, F924B38E24971BB600A913CD /* CustomerModel */,
E0EFB9CC24931877005FB0CD /* PurchaseModel */, E0EFB9CC24931877005FB0CD /* PurchaseModel */,
...@@ -1724,6 +1737,7 @@ ...@@ -1724,6 +1737,7 @@
F956D5BD246A3629003FF510 /* PersonCenterModel */, F956D5BD246A3629003FF510 /* PersonCenterModel */,
F956D5BC246A35DB003FF510 /* GoodsManageMoel */, F956D5BC246A35DB003FF510 /* GoodsManageMoel */,
F9171EFB245128B200359C2B /* Interface.swift */, F9171EFB245128B200359C2B /* Interface.swift */,
E019E98224A9763A0086C565 /* BrandListInterface.swift */,
E05FAD262498A5E500D8C90D /* accountsPayableInterface.swift */, E05FAD262498A5E500D8C90D /* accountsPayableInterface.swift */,
E007B1DA248F8F57004D14CC /* PurchaseInterface.swift */, E007B1DA248F8F57004D14CC /* PurchaseInterface.swift */,
F9697243248F70C00010D39B /* VendorInterface.swift */, F9697243248F70C00010D39B /* VendorInterface.swift */,
...@@ -3136,6 +3150,7 @@ ...@@ -3136,6 +3150,7 @@
F95A9EDD24557CD500867849 /* GuanLianKehuVC.swift in Sources */, F95A9EDD24557CD500867849 /* GuanLianKehuVC.swift in Sources */,
E00D85DF244561FD00F5F816 /* AppDelegate.swift in Sources */, E00D85DF244561FD00F5F816 /* AppDelegate.swift in Sources */,
E0516F7F244806C500E373CE /* MsgCenterViewController.swift in Sources */, E0516F7F244806C500E373CE /* MsgCenterViewController.swift in Sources */,
E019E98124A975920086C565 /* brandListModel.swift in Sources */,
F94A315724628AC600FEC38E /* WorkItemCollectionViewCell.swift in Sources */, F94A315724628AC600FEC38E /* WorkItemCollectionViewCell.swift in Sources */,
F950FDA52451453A00C40530 /* ShopInfoModel.swift in Sources */, F950FDA52451453A00C40530 /* ShopInfoModel.swift in Sources */,
F96A585024790E300070A057 /* TFHpple.m in Sources */, F96A585024790E300070A057 /* TFHpple.m in Sources */,
...@@ -3283,6 +3298,7 @@ ...@@ -3283,6 +3298,7 @@
E06524FD24581BD900CA22E2 /* PiCiXuanZeViewController.swift in Sources */, E06524FD24581BD900CA22E2 /* PiCiXuanZeViewController.swift in Sources */,
E00B0B1B24629E99006DC846 /* SJMapCell.swift in Sources */, E00B0B1B24629E99006DC846 /* SJMapCell.swift in Sources */,
F956D5B0246A2D9C003FF510 /* LMNItem.m in Sources */, F956D5B0246A2D9C003FF510 /* LMNItem.m in Sources */,
E019E98324A9763A0086C565 /* BrandListInterface.swift in Sources */,
E013D78C2484CAFC0092DE46 /* CRKBtnCell.swift in Sources */, E013D78C2484CAFC0092DE46 /* CRKBtnCell.swift in Sources */,
F956D5B5246A2D9C003FF510 /* LMNStore.m in Sources */, F956D5B5246A2D9C003FF510 /* LMNStore.m in Sources */,
F956D5A7246A2D9C003FF510 /* LMNLineChain+Numbering.m in Sources */, F956D5A7246A2D9C003FF510 /* LMNLineChain+Numbering.m in Sources */,
......
...@@ -188,5 +188,9 @@ ...@@ -188,5 +188,9 @@
<string>Purchase/purchaseOrderEdit</string> <string>Purchase/purchaseOrderEdit</string>
<key>新增采购单初始化信息</key> <key>新增采购单初始化信息</key>
<string>Purchase/InitInfo</string> <string>Purchase/InitInfo</string>
<key>品牌列表</key>
<string>brand/brandList</string>
<key>新增品牌</key>
<string>Brand/brandAdd</string>
</dict> </dict>
</plist> </plist>
//
// BrandListInterface.swift
// GeliBusinessPlatform
//
// Created by junye lu on 2020/6/29.
// Copyright © 2020 junye lu. All rights reserved.
//
import Foundation
import Alamofire
import SwiftyJSON
import ObjectMapper
//MARK:--品牌列表
/*
params-key
user_name 用户名
keyword 搜索关键词
keyword 页数
*/
func brandList(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) {
NetworkRequest.sharedInstance.postRequest("品牌列表", params, { (rep:DataResponse<brandListModel>) in
}, success: { (data) in
success(data)
}) { (error) in
failture(error)
}
}
//MARK:--新增品牌
/*
params-key
user_name 用户名
keyword 搜索关键词
keyword 页数
*/
func brandAdd(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) {
NetworkRequest.sharedInstance.postRequest("新增品牌", params, { (rep:DataResponse<UpDataModel>) in
}, success: { (data) in
success(data)
}) { (error) in
failture(error)
}
}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import Foundation import Foundation
import ObjectMapper import ObjectMapper
//发送验证码,验证短信验证码,修改登录密码,绑定、更换绑定格利支付账号,简单通用操作接口,普通订单发货,预售订单发货,订单绑定/更换绑定客户,确认订单,订单取消,修改订单商品价格,订单退款,普通订单退货,预售订单退货,修改订单支付方式(状态),商家仓库添加,商家仓库修改,商家仓库删除,提交下单,商品入库审核,商品入库,商品入库申请,商品出库,商品申请出库,商品审核出库,出库入库审核不通过,编辑地址,删除地址,新增采购单,审核采购单,撤销入库,采购单修改支付状态,供应商编辑,新增供应商,编辑客户,新增客户,应收账款收款,设为未收,取消采购单,修改采购订单, //发送验证码,验证短信验证码,修改登录密码,绑定、更换绑定格利支付账号,简单通用操作接口,普通订单发货,预售订单发货,订单绑定/更换绑定客户,确认订单,订单取消,修改订单商品价格,订单退款,普通订单退货,预售订单退货,修改订单支付方式(状态),商家仓库添加,商家仓库修改,商家仓库删除,提交下单,商品入库审核,商品入库,商品入库申请,商品出库,商品申请出库,商品审核出库,出库入库审核不通过,编辑地址,删除地址,新增采购单,审核采购单,撤销入库,采购单修改支付状态,供应商编辑,新增供应商,编辑客户,新增客户,应收账款收款,设为未收,取消采购单,修改采购订单,新增品牌,
class UpDataModel: Mappable { class UpDataModel: Mappable {
var code:Int? var code:Int?
......
//
// brandListModel.swift
// GeliBusinessPlatform
//
// Created by junye lu on 2020/6/29.
// Copyright © 2020 junye lu. All rights reserved.
//
import Foundation
import ObjectMapper
//MARK: - 应付账款列表
class brandListModel: Mappable {
var code:Int?
var message : String?
var data :Array<brandListDataModel>?
required init?( map: Map) {
}
func mapping(map: Map) {
code <- map["code"]
message <- map["message"]
data <- map["data"]
}
}
class brandListDataModel: Mappable {
var brand_id:Int?
var brand_name : String?
var brand_logo :String?
var brand_desc:String?
var site_url : String?
var sort_order :Int?
var is_show:Int?
var brand_img : String?
var wap_brand_desc :String?
required init?( map: Map) {
}
func mapping(map: Map) {
brand_id <- map["brand_id"]
brand_name <- map["brand_name"]
brand_logo <- map["brand_logo"]
brand_desc <- map["brand_desc"]
site_url <- map["site_url"]
sort_order <- map["sort_order"]
is_show <- map["is_show"]
brand_img <- map["brand_img"]
wap_brand_desc <- map["wap_brand_desc"]
}
}
...@@ -425,10 +425,10 @@ class YingFuZhangKuanXQViewController:BaseViewController,UISearchBarDelegate,Sea ...@@ -425,10 +425,10 @@ class YingFuZhangKuanXQViewController:BaseViewController,UISearchBarDelegate,Sea
self.datas.append(item) self.datas.append(item)
}) })
self.listView.reloadData() self.listView.reloadData()
self.listView.mj_header?.endRefreshing() self.listView.mj_footer?.endRefreshing()
} }
}) { (err) in }) { (err) in
self.listView.mj_header?.endRefreshing() self.listView.mj_footer?.endRefreshing()
} }
} }
} }
......
...@@ -10,7 +10,11 @@ import UIKit ...@@ -10,7 +10,11 @@ import UIKit
protocol PinPaiListViewControllerDelegate { protocol PinPaiListViewControllerDelegate {
func blackSelectPinPaiData(sender:GeneralInfoBrandModel) func blackSelectPinPaiData(sender:GeneralInfoBrandModel)
} }
class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBarViewDelegate,UITableViewDelegate,UITableViewDataSource,TitleAndSelectCellDelegate{ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBarViewDelegate,UITableViewDelegate,UITableViewDataSource,TitleAndSelectCellDelegate,XinZengPinPaiViewControllerDelegate{
func XinZengPinPaiViewControllerFinsih() {
self.listView.mj_header?.beginRefreshing()
}
var dataModelArray : Array<GeneralInfoBrandModel>? = [] var dataModelArray : Array<GeneralInfoBrandModel>? = []
var isSelectData : Bool = false var isSelectData : Bool = false
var delegate : PinPaiListViewControllerDelegate? var delegate : PinPaiListViewControllerDelegate?
...@@ -20,6 +24,11 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar ...@@ -20,6 +24,11 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar
@IBOutlet weak var sureBtn: UIButton! @IBOutlet weak var sureBtn: UIButton!
@IBOutlet weak var topView: UIView! @IBOutlet weak var topView: UIView!
@IBOutlet weak var listView: UITableView! @IBOutlet weak var listView: UITableView!
let UserToken = UserDefaults.standard.value(forKey: "user_token")
var keyWord = ""
var page = 0
var tempArr:Array<GeneralInfoBrandModel>? = [] var tempArr:Array<GeneralInfoBrandModel>? = []
var searchV : SearchBarView? = nil var searchV : SearchBarView? = nil
override func viewDidLoad() { override func viewDidLoad() {
...@@ -32,6 +41,13 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar ...@@ -32,6 +41,13 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar
navbar.rightTitle = "新增" navbar.rightTitle = "新增"
sureBtn.isHidden = true sureBtn.isHidden = true
sureLbl.isHidden = true sureLbl.isHidden = true
//下拉刷新相关设置
headerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadData))
listView.mj_header = headerMJ
//上拉加载相关设置
footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData))
listView.mj_footer = footerMJ
listView.mj_header?.beginRefreshing()
} }
self.view.addSubview(navbar) self.view.addSubview(navbar)
...@@ -54,10 +70,13 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar ...@@ -54,10 +70,13 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar
tempArr = dataModelArray tempArr = dataModelArray
listView.register(UINib(nibName: "TitleAndSelectCell", bundle: nil), forCellReuseIdentifier: "TitleAndSelectCell") listView.register(UINib(nibName: "TitleAndSelectCell", bundle: nil), forCellReuseIdentifier: "TitleAndSelectCell")
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
} }
func rightBtnClick() { func rightBtnClick() {
let vc = XinZengPinPaiViewController() let vc = XinZengPinPaiViewController()
vc.navTitle = "新增品牌" vc.navTitle = "新增品牌"
vc.delegate = self
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
} }
...@@ -88,25 +107,40 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar ...@@ -88,25 +107,40 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar
return 49 return 49
} }
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataModelArray!.count if isSelectData{
return dataModelArray!.count
}else{
return datas.count
}
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSelectCell") as! TitleAndSelectCell let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSelectCell") as! TitleAndSelectCell
cell.delegate = self cell.delegate = self
cell.tag = indexPath.row cell.tag = indexPath.row
let rowModel = dataModelArray![indexPath.row]
cell.titleLbl.text = rowModel.brand_name
cell.titleLbl.textColor = UIColor(named: "标题字颜色") if isSelectData {
cell.selectBtn.isSelected = false let rowModel = dataModelArray![indexPath.row]
if selectModel != nil {
if rowModel.brand_id == selectModel?.brand_id { cell.titleLbl.text = rowModel.brand_name
cell.titleLbl.textColor = UIColor(named: "蓝色字体颜色") cell.titleLbl.textColor = UIColor(named: "标题字颜色")
cell.selectBtn.isSelected = true cell.selectBtn.isSelected = false
if selectModel != nil {
if rowModel.brand_id == selectModel?.brand_id {
cell.titleLbl.textColor = UIColor(named: "蓝色字体颜色")
cell.selectBtn.isSelected = true
}
}
}else{
cell.selectBtn.isHidden = true
if datas.count > 0 {
let rowModel = datas[indexPath.row]
cell.titleLbl.text = rowModel.brand_name
} }
} }
return cell return cell
} }
var selectModel : GeneralInfoBrandModel? = nil var selectModel : GeneralInfoBrandModel? = nil
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
...@@ -115,8 +149,14 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar ...@@ -115,8 +149,14 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar
selectModel = rowModel selectModel = rowModel
listView.reloadData() listView.reloadData()
}else{ }else{
let model = datas[indexPath.row]
let vc = XinZengPinPaiViewController() let vc = XinZengPinPaiViewController()
vc.navTitle = "编辑品牌" vc.navTitle = "品牌详情"
// vc.navTitle = "编辑品牌"
vc.iconUrl = model.brand_img!
vc.pinPaiUrl = model.site_url!
vc.commend = model.brand_desc!
vc.pinPaiName = model.brand_name!
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
} }
...@@ -140,5 +180,52 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar ...@@ -140,5 +180,52 @@ class PinPaiListViewController: BaseViewController,UISearchBarDelegate,SearchBar
listView.reloadData() listView.reloadData()
} }
var datas:Array<brandListDataModel> = []
//MARK:--加载数据
@objc func loadData(){
print("加载数据")
page = 1
let dic = ["user_token":UserToken as Any,"keyword":keyWord as Any,"page":page as Any]
brandList(dic, success: { (data) in
let model = data as! brandListModel
self.datas.removeAll()
model.data?.forEach({ (item) in
self.datas.append(item)
})
self.listView.reloadData()
self.listView.mj_header?.endRefreshing()
self.page = 2
if model.data?.count == 0 {
self.listView.mj_footer?.endRefreshingWithNoMoreData()
}else{
self.listView.mj_footer?.endRefreshing()
}
}) { (error) in
self.listView.mj_header?.endRefreshing()
}
}
//MARK:--加载更多数据
@objc func loadMoreData(){
print("加载更多数据")
let dic = ["user_token":UserToken as Any,"keyword":keyWord as Any,"page":page as Any]
brandList(dic, success: { (data) in
let model = data as! brandListModel
if model.data?.count == 0 {
self.listView.mj_footer?.endRefreshingWithNoMoreData()
}else{
self.page += 1
model.data?.forEach({ (item) in
self.datas.append(item)
})
self.listView.reloadData()
self.listView.mj_footer?.endRefreshing()
}
}) { (error) in
self.listView.mj_footer?.endRefreshing()
}
}
} }
...@@ -9,18 +9,24 @@ ...@@ -9,18 +9,24 @@
import UIKit import UIKit
import LGButton import LGButton
import Photos import Photos
protocol XinZengPinPaiViewControllerDelegate {
func XinZengPinPaiViewControllerFinsih()
}
class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITableViewDelegate,TitleAndBtnCellDelegate,TitleAndTFCellDelegate,TilteAndTextViewCellDelegate{ class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITableViewDelegate,TitleAndBtnCellDelegate,TitleAndTFCellDelegate,TilteAndTextViewCellDelegate{
var delegate:XinZengPinPaiViewControllerDelegate?
let titleArr = ["品牌名称","品牌图标","站点地址","品牌描述"] let titleArr = ["品牌名称","品牌图标","站点地址","品牌描述"]
let holderArr = ["请输入品牌名称","0","请输入站点地址如:www.gelifood.com","0"] let holderArr = ["请输入品牌名称","0","请输入站点地址如:www.gelifood.com","0"]
@IBOutlet weak var lgBtn: LGButton!
let UserToken = UserDefaults.standard.value(forKey: "user_token")
@IBOutlet weak var btnTitleLbl: UILabel! @IBOutlet weak var btnTitleLbl: UILabel!
@IBOutlet weak var listView: UITableView! @IBOutlet weak var listView: UITableView!
var logoIcon:UIImage?//图片
var pinPaiName:String?//品牌名字 @IBOutlet weak var btmLblH: NSLayoutConstraint!
var pinPaiUrl:String?//品牌连接 var iconUrl = ""
var commend:String?//品牌描述 var pinPaiName = ""//品牌名字
var pinPaiUrl = ""//品牌连接
var commend = ""//品牌描述
var navTitle:String? var navTitle:String?
override func viewDidLoad() { override func viewDidLoad() {
...@@ -29,6 +35,11 @@ class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITa ...@@ -29,6 +35,11 @@ class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITa
if navTitle == "编辑品牌" { if navTitle == "编辑品牌" {
navbar.rightTitle = "删除" navbar.rightTitle = "删除"
} }
if (navTitle?.contains("详情"))!{
lgBtn.isHidden = true
btnTitleLbl.isHidden = true
btmLblH.constant = 0
}
self.view.addSubview(navbar) self.view.addSubview(navbar)
SetTopFrameView(view: listView, btmView: btnTitleLbl) SetTopFrameView(view: listView, btmView: btnTitleLbl)
...@@ -46,54 +57,85 @@ class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITa ...@@ -46,54 +57,85 @@ class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITa
//MARK: - 提交 //MARK: - 提交
@IBAction func btnAction(_ sender: Any) { @IBAction func btnAction(_ sender: Any) {
print("提交") print("提交")
print(pinPaiName)//名字 if pinPaiName.count == 0 {
print(pinPaiUrl)//链接 HUD.flash(.label("请输入品牌名称"), delay: 1.2)
print(commend)//描述 return
print(logoIcon)//图片 }
if iconUrl.count == 0 {
HUD.flash(.label("请选择图片"), delay: 1.2)
return
}
if pinPaiUrl.count == 0 {
HUD.flash(.label("请输入品牌链接"), delay: 1.2)
return
}
if commend.count == 0 {
HUD.flash(.label("请填写品牌描述"), delay: 1.2)
return
}
let dict = [
"user_token":UserToken as Any,
"brand_name":pinPaiName as Any,
"brand_logo":iconUrl as Any,
"brand_desc":commend as Any,
"site_url":pinPaiUrl as Any
]
brandAdd(dict, success: { (data) in
self.delegate?.XinZengPinPaiViewControllerFinsih()
self.navigationController?.popViewController(animated: true)
}) { (err) in
}
} }
//MARK: - cell delegate //MARK: - cell delegate
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.row { switch indexPath.row {
case 0,2: case 0,2:
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTF") as! TitleAndTFCell let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTF") as! TitleAndTFCell
cell.nameLbl.text = titleArr[indexPath.row] cell.nameLbl.text = titleArr[indexPath.row]
cell.textTF.placeholder = holderArr[indexPath.row] cell.textTF.placeholder = holderArr[indexPath.row]
cell.delegate = self if (navTitle?.contains("详情"))!{
cell.tag = indexPath.row cell.textTF.isUserInteractionEnabled = false
switch indexPath.row { }
case 0: cell.delegate = self
cell.tag = indexPath.row
switch indexPath.row {
case 0:
cell.textTF.text = pinPaiName cell.textTF.text = pinPaiName
break break
case 2: case 2:
cell.textTF.text = pinPaiUrl cell.textTF.text = pinPaiUrl
break break
default: default:
break break
} }
return cell return cell
case 1: case 1:
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtn") as! TitleAndBtnCell let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtn") as! TitleAndBtnCell
cell.nameLbl.text = titleArr[indexPath.row] cell.nameLbl.text = titleArr[indexPath.row]
cell.contentLbl.text = "上传图片" cell.contentLbl.text = "上传图片"
cell.delegate = self cell.delegate = self
if logoIcon != nil { if iconUrl.count > 0 {
cell.imgView.image = logoIcon cell.imgView.sd_setImage(with: URL(string:SERVERCE_ImageHost + iconUrl), placeholderImage: UIImage.init(named: "worktest1"))
cell.imgView.isHidden = false cell.imgView.isHidden = false
cell.contentLbl.isHidden = true cell.contentLbl.isHidden = true
} }
return cell return cell
default: default:
let cell = tableView.dequeueReusableCell(withIdentifier: "TilteAndTextView") as! TilteAndTextViewCell let cell = tableView.dequeueReusableCell(withIdentifier: "TilteAndTextView") as! TilteAndTextViewCell
cell.titleLbl.text = titleArr[indexPath.row] cell.titleLbl.text = titleArr[indexPath.row]
cell.holderLbl.text = "简述品牌体征。" cell.holderLbl.text = "简述品牌体征。"
cell.textView.text = commend cell.textView.text = commend
cell.delegate = self cell.delegate = self
return cell if (navTitle?.contains("详情"))!{
} cell.textView.isUserInteractionEnabled = false
}
return cell
}
} }
func textFieldContent(content: String, cell: TitleAndTFCell) { func textFieldContent(content: String, cell: TitleAndTFCell) {
if cell.tag == 0 { if cell.tag == 0 {
pinPaiName = content pinPaiName = content
} }
pinPaiUrl = content pinPaiUrl = content
} }
...@@ -106,7 +148,7 @@ class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITa ...@@ -106,7 +148,7 @@ class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITa
return 173.5*glscale return 173.5*glscale
} }
if indexPath.row == 1 { if indexPath.row == 1 {
if logoIcon != nil { if iconUrl.count > 0 {
return 100 return 100
} }
} }
...@@ -116,6 +158,9 @@ class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITa ...@@ -116,6 +158,9 @@ class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITa
return titleArr.count return titleArr.count
} }
func btnClick(content: String, cell: TitleAndBtnCell) { func btnClick(content: String, cell: TitleAndBtnCell) {
if (navTitle?.contains("详情"))!{
return
}
_ = self.presentHGImagePicker(maxSelected:1) { (assets) in _ = self.presentHGImagePicker(maxSelected:1) { (assets) in
//结果处理 //结果处理
print("共选择了\(assets.count)张图片,分别如下:") print("共选择了\(assets.count)张图片,分别如下:")
...@@ -125,11 +170,29 @@ class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITa ...@@ -125,11 +170,29 @@ class XinZengPinPaiViewController: BaseViewController,UITableViewDataSource,UITa
for asset in assets { for asset in assets {
PHImageManager.default().requestImage(for: asset, targetSize: PHImageManagerMaximumSize , contentMode: .default , options: option, resultHandler: { (image, _: [AnyHashable : Any]?) in PHImageManager.default().requestImage(for: asset, targetSize: PHImageManagerMaximumSize , contentMode: .default , options: option, resultHandler: { (image, _: [AnyHashable : Any]?) in
// print("上传图片==\(image)") // print("上传图片==\(image)")
self.logoIcon = image self.uploadImg(imge: image!, isOriginal: true, tag: 0)
}) })
} }
self.listView.reloadData() self.listView.reloadData()
} }
} }
func uploadImg (imge:UIImage,isOriginal:Bool,tag:Int){
let upLoadImg = imge as! UIImage
HUD.show(.progress)
saveFile(image: upLoadImg, ["user_token":UserToken as Any], success: { (data) in
let dataM = data as! SaveFileModel
if dataM.code == 1 {
print("图片上传成功\(dataM.data?.url)")
self.iconUrl = dataM.data!.url!
self.listView.reloadData()
HUD.hide()
}
}) { (error) in
print("图片上传失败\(error)")
}
}
} }
<?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="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097" 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>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<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"/>
</dependencies> </dependencies>
<objects> <objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="XinZengPinPaiViewController" customModule="GeliBusinessPlatform" customModuleProvider="target"> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="XinZengPinPaiViewController" customModule="TestClass" customModuleProvider="target">
<connections> <connections>
<outlet property="btmLblH" destination="v8X-Ve-jdc" id="xQ6-lM-qi6"/>
<outlet property="btnTitleLbl" destination="Hmi-sA-ntB" id="N32-OK-XWt"/> <outlet property="btnTitleLbl" destination="Hmi-sA-ntB" id="N32-OK-XWt"/>
<outlet property="lgBtn" destination="bjw-OI-1k0" id="qMO-yi-QTg"/>
<outlet property="listView" destination="rtS-FJ-o0e" id="FDx-iO-Tzh"/> <outlet property="listView" destination="rtS-FJ-o0e" id="FDx-iO-Tzh"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections> </connections>
......
...@@ -409,7 +409,7 @@ class CGDListVC: BaseViewController , UITableViewDelegate, UITableViewDataSource ...@@ -409,7 +409,7 @@ class CGDListVC: BaseViewController , UITableViewDelegate, UITableViewDataSource
self.listView?.mj_footer?.endRefreshing() self.listView?.mj_footer?.endRefreshing()
} }
}) { (error) in }) { (error) in
self.listView?.mj_header?.endRefreshing() self.listView?.mj_footer?.endRefreshing()
} }
} }
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
......
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