Commit d5f44a55 authored by lujunye's avatar lujunye

添加预售设置开关

parent d49ad703
......@@ -24,21 +24,5 @@
continueAfterRunningActions = "No">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "B223F50A-4F5B-423B-9F6D-A967E5BFB36E"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "GeliBusinessPlatform/ViewController/&#x65b0;&#x589e;&#x89c4;&#x683c;/CreatNewSpecsViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "575"
endingLineNumber = "575"
landmarkName = "YuShouCellSwitchStatus(sender:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
......@@ -25,14 +25,18 @@ class GoodsDetailModel: Mappable {
}
class GoodsDetailDataModel: Mappable {
var goods_res : Array<GoodsDetailGoodsResModel>? //商品数据
var goods_res : GoodsDetailGoodsResModel? //商品数据
var sku_res : Array<GoodsDetailSkuResModel>? //商品sku信息
var banner_res : Array<GoodsDetailBannerResModel>? //副图信息
required init?( map: Map) {
}
func mapping(map: Map) {
goods_res <- map["goods_res"]
sku_res <- map["sku_res"]
banner_res <- map["banner_res"]
}
}
......@@ -40,7 +44,9 @@ class GoodsDetailGoodsResModel: Mappable {
var goods_id : Int? //商品id
var goods_name : String? //商品名
var cat_id : Int? //分类id
var cat_name : String? //分类名
var brand_id : Int? //品牌id
var brand_name : String? //品牌名
var goods_sn : String? //商品sn
var market_price : String? //市场价
var shop_price : String? //(默认)售价(本店售价)
......@@ -106,6 +112,8 @@ class GoodsDetailGoodsResModel: Mappable {
set_time <- map["set_time"]
is_inquiry <- map["is_inquiry"]
is_qz <- map["is_qz"]
brand_name <- map["brand_name"]
cat_name <- map["cat_name"]
}
......
......@@ -13,7 +13,7 @@ import IQKeyboardManagerSwift
import Dollar
class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,TitleAndBtnCellDelegate,GLAlertSelectViewDelegate,GoodsClassViewControllerDelegate,PinPaiListViewControllerDelegate,AddImgCellDelegate,AddGuiGeCellDelegate,CreatNewSpecsViewControllerDelegate,ShangPinGguiGeCellDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,TitleAndSwitchCellDelegate,TitleAndTFCellDelegate,YuShouWeiKuanFaHuoCellDelegate,UITextFieldDelegate,ShowTimeSelectViewDelegate {
@IBOutlet weak var btmBtnViewH: NSLayoutConstraint!
@IBOutlet weak var tbvBGView: UIView!
@IBOutlet weak var btmBtnBGView: UIView!
......@@ -23,1008 +23,1078 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo
var goods_id:Int?
func GLASClose(view: GLAlertSelectView, selectnum: Int, selectArr: Array<Int>) {
if view.titleLbl.text == "请选择商品类型" {
print(itemTypeArr,selectArr)
itemTypeArr = selectArr
}
if selectnum != 10086 {
if view.titleLbl.text == "请选择国家" {
print(itemTypeArr,selectArr)
countrySelect = selectnum
}
if view.titleLbl.text == "请选择运输方式" {
yunShuType = selectnum
}
if view.titleLbl.text == "请选择商品状态" {
shangPinStatus = selectnum
}
}
view.removeFromSuperview()
glSelectView = nil
}
if view.titleLbl.text == "请选择商品类型" {
print(itemTypeArr,selectArr)
itemTypeArr = selectArr
}
if selectnum != 10086 {
if view.titleLbl.text == "请选择国家" {
print(itemTypeArr,selectArr)
countrySelect = selectnum
}
if view.titleLbl.text == "请选择运输方式" {
yunShuType = selectnum
}
if view.titleLbl.text == "请选择商品状态" {
shangPinStatus = selectnum
}
}
view.removeFromSuperview()
glSelectView = nil
}
let titleArr = ["商品信息","商品图片","商品规格","预售设置","其它信息","商品详情"]
let spxxArr = ["商品名称","商品类型","商品分类","品牌","起卖数量","是否清真","是否询价"]
var tishixxArr = ["请输入商品名称","请选择商品类型","请选择商品分类","请选择品牌","请输入起卖数量"]
var tishixxArr1 = ["请输入关键字","请输入物流费用","请选择国家","请选择商品状态","请选择运输方式"]
let sptpArr = ["商品封面图(限一张)","商品主图(限五张)"]
let qtxxArr = ["关键字","物流费用","国家","商品状态","运输方式"]
let ysszArr = ["用户付款是否需要审核","预设预付定金时间段","预设预付尾款时间段","预设预付尾款发货时间"]
var ysszHolder = ["0","请选择时段","请选择时段","0"]
var shangPinStatusArr:Array<GeneralInfoGsModel>? = []
var yunShuTypeArr = ["冷链","常温","热链"]
var countryArr = ["中国"]
var layout = UICollectionViewFlowLayout()
var glSelectView:GLAlertSelectView?
let titleArr = ["商品信息","商品图片","商品规格","预售设置","其它信息","商品详情"]
let spxxArr = ["商品名称","商品类型","商品分类","品牌","起卖数量","是否清真","是否询价"]
var tishixxArr = ["请输入商品名称","请选择商品类型","请选择商品分类","请选择品牌","请输入起卖数量"]
var tishixxArr1 = ["请输入关键字","请输入物流费用","请选择国家","请选择商品状态","请选择运输方式"]
let sptpArr = ["商品封面图(限一张)","商品主图(限五张)"]
let qtxxArr = ["关键字","物流费用","国家","商品状态","运输方式"]
let ysszArr = ["用户付款是否需要审核","预设预付定金时间段","预设预付尾款时间段","预设预付尾款发货时间"]
var ysszHolder = ["0","请选择时段","请选择时段","0"]
var shangPinStatusArr:Array<GeneralInfoGsModel>? = []
var yunShuTypeArr = ["冷链","常温","热链"]
var countryArr = ["中国"]
var layout = UICollectionViewFlowLayout()
var glSelectView:GLAlertSelectView?
var selectIdx:IndexPath? = IndexPath(item: 0, section: 0) //多规格状态下点击collectionCell的row记录
var isYuShouShangPin:Bool?//是否为预售商品
var itemTypeArr:Array<Int>? = []//多选
var isYuShou:Bool = false//是否预售
var shangPinStatus:Int? = 0//商品状态
var yunShuType:Int? = 0//运输类型
var maxFiveImgsArr:Array<UIImage> = []//多图
var singleImgArr:Array<UIImage> = []//单张图
var itemName = ""//商品名称
var qiMaiShuLiang = ""//起卖数量
var shiFouQZ = false//是否清真
var shiFouXJ = false//是否询价
var keyWord = ""//关键字
var wuLiuPrice = ""//物流费用
var countrySelect:Int?//选择国家
var guiGeArr:Array<GuiGeModel> = []//规格数组,根据规格资料数量控制右上角新增按钮是否显示
var shiFouSH = false //是否审核
var faHuoTime = ""//发货时间
//预售时间段
var dj_time_start:Int? = 0
var dj_time_end:Int? = 0
var wk_time_start:Int? = 0
var wk_time_end:Int? = 0
var selectIdx:IndexPath? = IndexPath(item: 0, section: 0) //多规格状态下点击collectionCell的row记录
var listTbv:UITableView!
override func viewDidLoad() {
super.viewDidLoad()
//MARK:--获取新增商品的基本信息(品牌和分类等)
HUD.flash(.progress)
//MARK:--新增商品和编辑商品所需要的基本信息(无)就页面不正常显示
// let UserToken = UserDefaults.standard.value(forKey: "user_token")
// GeneralInfo(["user_token":UserToken as Any], success: { (data) in
// HUD.hide(animated: true)
// self.generalInfoModel = (data as! GeneralInfoModel)
// self.shangPinStatusArr = (self.generalInfoModel?.data!.gs)!
//
// }) { (error) in
//
// }
//是否为预售商品
isYuShouShangPin = false
navbar.title = "商品详情"
self.view.addSubview(navbar)
if listTbv == nil {
let tbv = UITableView()
tbvBGView.addSubview(tbv)
tbv.snp.makeConstraints { (make) in
make.top.left.bottom.right.equalTo(0)
var isYuShouShangPin:Bool?//是否为预售商品
var itemTypeArr:Array<Int>? = []//多选
var shangPinStatus:Int? = 0//商品状态
var yunShuType:Int? = 0//运输类型
var maxFiveImgsArr:Array<UIImage> = []//多图
var singleImgArr:Array<UIImage> = []//单张图
var itemName = ""//商品名称
var qiMaiShuLiang = ""//起卖数量
var shiFouQZ = false//是否清真
var shiFouXJ = false//是否询价
var keyWord = ""//关键字
var wuLiuPrice = ""//物流费用
var countrySelect:Int?//选择国家
var guiGeArr:Array<GuiGeModel> = []//规格数组,根据规格资料数量控制右上角新增按钮是否显示
var shiFouSH = false //是否审核
var faHuoTime = ""//发货时间
//预售时间段
var dj_time_start:Int? = 0
var dj_time_end:Int? = 0
var wk_time_start:Int? = 0
var wk_time_end:Int? = 0
var listTbv:UITableView!
override func viewDidLoad() {
super.viewDidLoad()
//MARK:--获取新增商品的基本信息(品牌和分类等)
HUD.flash(.progress)
//是否为预售商品
isYuShouShangPin = false
navbar.title = "商品详情"
self.view.addSubview(navbar)
//MARK:--新增商品和编辑商品所需要的基本信息(无)就页面不正常显示
let UserToken = UserDefaults.standard.value(forKey: "user_token")
goodsDetail(["user_token":UserToken,"goods_id":goods_id], success: { (data) in
let model = data as! GoodsDetailModel
//商品名
self.itemName = (model.data?.goods_res!.goods_name)!
//商品类型
if model.data?.goods_res!.is_adsale == 0{
self.itemTypeArr = [99,99,99,99]
}else{
self.itemTypeArr = [1,99,99,99]
}
if (model.data?.goods_res!.goods_type)! == 1 || (model.data?.goods_res!.goods_type)! == 2 {
self.itemTypeArr?.insert(1, at: 1)
self.itemTypeArr?.remove(at: 2)
}else{
self.itemTypeArr?.insert((model.data?.goods_res!.goods_type)!, at: (model.data?.goods_res!.goods_type)!-1)
self.itemTypeArr?.remove(at: (model.data?.goods_res!.goods_type)!)
}
let contentArr = ["预售","普通","期货","团购"]
let titles = NSMutableArray()
titles.removeAllObjects()
for num in self.itemTypeArr! {
if num != 99{
titles.add(contentArr[num])
}
}
if titles.componentsJoined(by: ",").contains("预售") {
self.isYuShouShangPin = true
}else{
self.isYuShouShangPin = false
}
self.tishixxArr.insert(titles.componentsJoined(by: ","), at: 1)
self.tishixxArr.remove(at: 2)
//商品分类
print("abc == ",model.data?.goods_res!.cat_name)
self.tishixxArr.insert((model.data?.goods_res!.cat_name)!, at: 2)
self.tishixxArr.remove(at: 3)
//品牌名
self.tishixxArr.insert((model.data?.goods_res!.brand_name)!, at: 3)
self.tishixxArr.remove(at: 4)
//起卖数量
self.qiMaiShuLiang = "\(model.data!.goods_res!.origin_number!)"
//是否清真
self.shiFouQZ = true
if model.data?.goods_res!.is_qz == 0 {
self.shiFouQZ = false
}
//是否询价
self.shiFouXJ = true
if model.data?.goods_res!.is_inquiry == 0 {
self.shiFouXJ = false
}
listTbv = tbv
//是否有封面图
// if model.data?.goods_res?.original_img?.count > 0 {
//
// }
//商品主图
//商品规格
if (model.data?.sku_res?.count)! > 0{
self.guiGeArr.removeAll()
for item in model.data!.sku_res! {
let dataSource = item as! GoodsDetailSkuResModel
let data = GuiGeModel()
data.DJBiLi = dataSource.pct!
data.danWei = dataSource.unit!
data.sku_id = dataSource.sku_id!
data.guiGe = dataSource.spec_str!
data.isOpenYSSetting = false
if dataSource.is_open_adsale! == 1 {
data.isOpenYSSetting = true
}
data.isJieTiOpen = false
if dataSource.is_tiered == 1 {
data.isJieTiOpen = true
}
}
}
if self.listTbv == nil {
let tbv = UITableView()
self.tbvBGView.addSubview(tbv)
tbv.snp.makeConstraints { (make) in
make.top.left.bottom.right.equalTo(0)
}
self.listTbv = tbv
self.listTbv.separatorStyle = .none
self.listTbv.delegate = self
self.listTbv.dataSource = self
self.listTbv.register(UINib(nibName: "TitleAndTFCell", bundle: nil), forCellReuseIdentifier: "TitleAndTF")
self.listTbv.register(UINib(nibName: "TitleAndSwitchCell", bundle: nil), forCellReuseIdentifier: "TitleAndSwitch")
self.listTbv.register(UINib(nibName: "TitleAndBtnCell", bundle: nil), forCellReuseIdentifier: "TitleAndBtn")
self.listTbv.register(UINib(nibName: "AddImgCell", bundle: nil), forCellReuseIdentifier: "AddImg")
self.listTbv.register(UINib(nibName: "AddGuiGeCell", bundle: nil), forCellReuseIdentifier: "AddGuiGe")
self.listTbv.register(UINib(nibName: "YuShouWeiKuanFaHuoCell", bundle: nil), forCellReuseIdentifier: "YuShouWeiKuanFaHuoCell")
self.listTbv.register(UINib(nibName: "ShangPinGguiGeCell", bundle: nil), forCellReuseIdentifier: "ShangPinGguiGeCell")
}
}) { (error) in
}
listTbv.separatorStyle = .none
listTbv.delegate = self
listTbv.dataSource = self
SetTopFrameView(view: tbvBGView, btmView: btmBtnBGView)
listTbv.register(UINib(nibName: "TitleAndTFCell", bundle: nil), forCellReuseIdentifier: "TitleAndTF")
listTbv.register(UINib(nibName: "TitleAndSwitchCell", bundle: nil), forCellReuseIdentifier: "TitleAndSwitch")
listTbv.register(UINib(nibName: "TitleAndBtnCell", bundle: nil), forCellReuseIdentifier: "TitleAndBtn")
listTbv.register(UINib(nibName: "AddImgCell", bundle: nil), forCellReuseIdentifier: "AddImg")
listTbv.register(UINib(nibName: "AddGuiGeCell", bundle: nil), forCellReuseIdentifier: "AddGuiGe")
listTbv.register(UINib(nibName: "YuShouWeiKuanFaHuoCell", bundle: nil), forCellReuseIdentifier: "YuShouWeiKuanFaHuoCell")
listTbv.register(UINib(nibName: "ShangPinGguiGeCell", bundle: nil), forCellReuseIdentifier: "ShangPinGguiGeCell")
// Do any additional setup after loading the view.
}
//MARK: - cell delegate
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.section {
case 0:
if indexPath.row == 0 || indexPath.row == 4 {
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTF") as! TitleAndTFCell
cell.textTF.delegate = self
cell.nameLbl.text = spxxArr[indexPath.row]
//商家名称
switch cell.nameLbl.text {
case "商品名称":
cell.textTF.text = itemName
cell.textTF.returnKeyType = .done
break
case "起卖数量":
cell.textTF.text = qiMaiShuLiang
cell.textTF.keyboardType = .numberPad
break
default:
break
}
cell.textTF.placeholder = tishixxArr[indexPath.row] as! String
cell.delegate = self
return cell
}
if indexPath.row > 4{
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSwitch") as! TitleAndSwitchCell
cell.namelbl.text = spxxArr[indexPath.row]
cell.delegate = self
switch cell.namelbl.text {
case "是否清真":
cell.infoSw.isOn = shiFouQZ
break
case "是否询价":
cell.infoSw.isOn = shiFouXJ
break
default:
break
}
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtn") as! TitleAndBtnCell
cell.nameLbl.text = spxxArr[indexPath.row]
cell.contentLbl.text = tishixxArr[indexPath.row] as! String
cell.tag = indexPath.row
cell.delegate = self
return cell
case 1:
let cell = tableView.dequeueReusableCell(withIdentifier: "AddImg") as! AddImgCell
cell.nameLbl.text = sptpArr[indexPath.row]
if indexPath.row == 0 {
cell.isSingle = true
if singleImgArr.count > 0{
cell.imgs = singleImgArr
cell.addBtn.isHidden = true
}else{
cell.scrollView?.isHidden = true
cell.addBtn.isHidden = false
}
}else{
cell.isSingle = false
if maxFiveImgsArr.count > 0{
cell.imgs = maxFiveImgsArr
}else{
cell.scrollView?.isHidden = true
cell.addBtnX.constant = 15
}
}
cell.delegate = self
cell.addBtn.tag = indexPath.row
cell.isEdit = true
return cell
case 2:
if guiGeArr.count > 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "ShangPinGguiGeCell") as! ShangPinGguiGeCell
cell.delegate = self
var dict:GuiGeModel!
if selectIdx != nil{
print(selectIdx?.item)
dict = guiGeArr[selectIdx!.item]
}else{
dict = guiGeArr.first
}
cell.tempLbl.text = "冷藏:\(dict.wenDu)℃"
cell.weightLbl.text = "重量(kg):\(dict.weight)kg"
cell.guiGeLbl.text = "规格:\(dict.guiGe)kg/件"
cell.danWeiLbl.text = "单位:\(dict.danWei)"
cell.sellPriceLbl.text = "售价:¥\(dict.price)"
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AddGuiGe") as! AddGuiGeCell
cell.imgBtn.addTarget(self, action: #selector(addGuiGe), for: .touchUpInside)
cell.imgBtn.setImage(UIImage(named: "xinzeng"), for: .normal)
return cell
case 3:
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSwitch") as! TitleAndSwitchCell
cell.namelbl.text = ysszArr[indexPath.row]
cell.delegate = self
cell.infoSw.isOn = shiFouSH
return cell
}
if indexPath.row == 3 {
let cell = tableView.dequeueReusableCell(withIdentifier: "YuShouWeiKuanFaHuoCell") as! YuShouWeiKuanFaHuoCell
cell.nameLbl.text = ysszArr[indexPath.row]
cell.textTF.keyboardType = .numberPad
cell.delegate = self
cell.textTF.text = faHuoTime
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtn") as! TitleAndBtnCell
cell.nameLbl.text = ysszArr[indexPath.row]
cell.delegate = self
cell.contentLbl.text = ysszHolder[indexPath.row]
return cell
case 4:
if indexPath.row < 2 {
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTF") as! TitleAndTFCell
cell.nameLbl.text = qtxxArr[indexPath.row]
cell.textTF.delegate = self
cell.textTF.returnKeyType = .done
switch cell.nameLbl.text {
case "关键字":
cell.textTF.text = keyWord
break
case "物流费用":
cell.textTF.text = wuLiuPrice
cell.textTF.keyboardType = .numbersAndPunctuation
break
default:
break
}
cell.textTF.placeholder = tishixxArr1[indexPath.row] as! String
cell.tag = indexPath.row
cell.delegate = self
return cell
}else{
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtn") as! TitleAndBtnCell
cell.nameLbl.text = qtxxArr[indexPath.row]
cell.tag = indexPath.row
cell.contentLbl.text = tishixxArr1[indexPath.row] as! String
cell.delegate = self
return cell
}
default:
let cell = tableView.dequeueReusableCell(withIdentifier: "AddGuiGe") as! AddGuiGeCell
cell.imgBtn.setImage(UIImage(named: "XiaYunDanViewController"), for: .normal)
cell.delegate = self
cell.imgBtn.tag = indexPath.row
cell.imgBtn.setImage(UIImage(named: "tjxq"), for: .normal)
cell.btmH.constant = 25
return cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
//MARK: - 底部广告软文跳转
func AddGuiGeCellClick(cell: AddGuiGeCell) {
print("底部广告软文跳转")
let vc = LMNoteViewController()
self.navigationController?.pushViewController(vc, animated: true)
}
//MARK: -- 点击按钮事件,跳转或者展示选择界面
func btnClick(content: String, cell: TitleAndBtnCell) {
if cell.nameLbl.text == "商品类型" {
if glSelectView == nil {
let view = GLAlertSelectView(frame: self.view.bounds)
view.tag = cell.tag
view.isMultipleS = true
view.isShangPinType = true
view.titleLbl.text = "请选择商品类型"
view.delegate = self
view.dataArr = ["预售","普通","期货","团购"]
if itemTypeArr?.count == 0 {
for _ in view.dataArr {
itemTypeArr?.append(99)
}
}
view.selectArray = itemTypeArr
view.tempArr = itemTypeArr
self.view.addSubview(view)
glSelectView = view
}
}
if cell.nameLbl.text == "商品分类" {
let vc = GoodsClassViewController()
vc.delegate = self
vc.selectModel = selectGoodsClassModel
vc.dataModelArray = generalInfoModel?.data?.cats
self.navigationController?.pushViewController(vc, animated: true)
}
if cell.nameLbl.text == "品牌" {
let vc = PinPaiListViewController()
vc.isSelectData = true
vc.delegate = self
vc.selectModel = selectPinPaiData
vc.dataModelArray = generalInfoModel?.data?.brand
self.navigationController?.pushViewController(vc, animated: true)
}
if cell.nameLbl.text == "国家" {
if glSelectView == nil {
let view = GLAlertSelectView(frame: self.view.bounds)
view.tag = cell.tag
view.titleLbl.text = "请选择国家"
view.delegate = self
view.dataArr = countryArr
if countrySelect != nil {
view.selectNum = countrySelect!
}
self.view.addSubview(view)
glSelectView = view
}
}
if cell.nameLbl.text == "商品状态" {
let view = GLAlertSelectView(frame: self.view.bounds)
view.tag = cell.tag
view.titleLbl.text = "请选择商品状态"
view.delegate = self
if shangPinStatusArr != nil {
var arr:Array<String>? = []
for item in shangPinStatusArr! {
arr?.append(item.gs_name!)
}
view.dataArr = arr!
}
if shangPinStatus != nil {
view.selectNum = shangPinStatus!
}
self.view.addSubview(view)
glSelectView = view
}
if cell.nameLbl.text == "运输方式" {
let view = GLAlertSelectView(frame: self.view.bounds)
view.tag = cell.tag
view.titleLbl.text = "请选择运输方式"
view.delegate = self
view.dataArr = yunShuTypeArr
if yunShuType != nil{
view.selectNum = yunShuType!
}
self.view.addSubview(view)
glSelectView = view
}
if cell.nameLbl.text == "预设预付定金时间段" {
print("定金时间段")
let timeSelectV = ShowTimeSelectView(frame: self.view.window!.bounds)
timeSelectV.titleLbl.text = "预设预付定金时间段"
timeSelectV.delegate = self
self.view.window?.addSubview(timeSelectV)
isWeiTime = false
}
if cell.nameLbl.text == "预设预付尾款时间段" {
print("预付尾款时")
let timeSelectV = ShowTimeSelectView(frame: self.view.window!.bounds)
timeSelectV.titleLbl.text = "预设预付尾款时间段"
timeSelectV.delegate = self
self.view.window?.addSubview(timeSelectV)
isWeiTime = true
}
}
//MARK:--选择预售时间回调数据
var isWeiTime : Bool = false
func showTimeSelectByData(timeStr: String, beginDate: Date, endginDate: Date) {
let timeInterval:TimeInterval = beginDate.timeIntervalSince1970
let timeIntervalEnd:TimeInterval = endginDate.timeIntervalSince1970
if isWeiTime {
ysszHolder.insert(timeStr, at: 2)
ysszHolder.remove(at: 3)
wk_time_start = Int(timeInterval)
wk_time_end = Int(timeIntervalEnd)
}else{
ysszHolder.insert(timeStr, at: 1)
ysszHolder.remove(at: 2)
dj_time_start = Int(timeInterval)
dj_time_end = Int(timeIntervalEnd)
}
listTbv.reloadData()
}
//MARK:---选择商品分类返回数据
var selectGoodsClassModel:GoodsClassModel? = nil
func blackGoodsClass(sender: GoodsClassModel) {
print("选择商品分类返回数据=\(sender)")
selectGoodsClassModel = sender
tishixxArr.insert(sender.cat_name!, at: 2)
tishixxArr.remove(at: 3)
listTbv.reloadData()
}
//MARK:--选择品牌返回的数据
var selectPinPaiData:GeneralInfoBrandModel? = nil
func blackSelectPinPaiData(sender: GeneralInfoBrandModel) {
print("选择品牌返回的数据=\(sender)")
selectPinPaiData = sender
tishixxArr.insert(sender.brand_name!, at: 3)
tishixxArr.remove(at: 4)
listTbv.reloadData()
}
//MARK:--图片选择处理
func AddImgCellBtnClick(cell: AddImgCell) {
if cell.addBtn.tag == 0 {//仅一张
_ = 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.singleImgArr.append(image!)
self.uploadImg(imge: image!, isOriginal: true, tag: 0)
})
}
self.listTbv.reloadData()
}
}else{//可多张
let num = 5 - maxFiveImgsArr.count
_ = self.presentHGImagePicker(maxSelected:num) { (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.maxFiveImgsArr.append(image!)
let index = Dollar.indexOf(self.maxFiveImgsArr, value: image!)
self.uploadImg(imge: image!, isOriginal: false, tag: index!)
})
}
self.listTbv.reloadData()
}
}
}
//MARK: - 修改图片
func ChangeCellBtnClick(sender: UIButton, cell: AddImgCell) {
print(sender.tag)
if cell.addBtn.tag == 0 {//仅一张
_ = 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.singleImgArr.removeAll()
self.singleImgArr.append(image!)
self.uploadImg(imge: image!, isOriginal: true, tag: 0)
})
}
self.listTbv.reloadData()
}
}else{//可多张
_ = 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.maxFiveImgsArr.insert(image!, at: sender.tag)
self.maxFiveImgsArr.remove(at: sender.tag+1)
self.uploadImg(imge: image!, isOriginal: false, tag: sender.tag)
})
}
self.listTbv.reloadData()
}
}
}
//MARK:--图片上传功能
var original_img:String? = "" //商品封面图
var goods_banner:Array<String>? = ["","","","",""] //商品副图,多张,最多5张,使用一维数组转json格式
func uploadImg (imge:UIImage,isOriginal:Bool,tag:Int){
let UserToken = UserDefaults.standard.value(forKey: "user_token")
let upLoadImg = imge as! UIImage
saveFile(image: upLoadImg, ["user_token":UserToken as Any], success: { (data) in
let dataM = data as! SaveFileModel
if dataM.code == 1 {
print("图片上传成功\(dataM.data?.url)")
if isOriginal {
self.original_img = dataM.data?.url!
}else{
self.goods_banner?.insert((dataM.data?.url!)!, at: tag)
self.goods_banner?.remove(at: tag + 1)
}
}
}) { (error) in
print("图片上传失败\(error)")
}
}
//MARK: - 删除图片处理
func DelImgCellBtnClick(sender:UIButton, cell: AddImgCell) {
if cell.isSingle == true {
singleImgArr.remove(at:sender.tag)
self.original_img = ""
listTbv.reloadData()
}else{
maxFiveImgsArr.remove(at:sender.tag)
self.goods_banner?.insert("", at: 5)
self.goods_banner?.remove(at: sender.tag)
listTbv.reloadData()
}
}
//MARK: - GLAlertView(单选)下的页面
func GLAlertSelectViewClick(selectNum: Int, view: GLAlertSelectView) {
switch view.titleLbl.text {
case "请选择商品状态":
shangPinStatus = selectNum
let item = shangPinStatusArr![selectNum]
print(item.gs_name!)
tishixxArr1.insert(item.gs_name!, at: view.tag)
tishixxArr1.remove(at: view.tag+1)
break
case "请选择运输方式":
yunShuType = selectNum
tishixxArr1.insert(yunShuTypeArr[selectNum], at: view.tag)
tishixxArr1.remove(at: view.tag+1)
break
case "请选择国家":
countrySelect = selectNum
tishixxArr1.insert(countryArr[selectNum], at: view.tag)
tishixxArr1.remove(at: view.tag+1)
break
default:
break
}
glSelectView?.removeFromSuperview()
glSelectView = nil
listTbv.reloadData()
}
//MARK: - GLAlertView(多选)下的页面
func GLAlertMoreSelectViewClick(sender: Array<Int>, view:UIView) {
itemTypeArr = sender
let str = "\(sender.first!)"
if str != "99" {
isYuShou = true
}else{
isYuShou = false
}
let contentArr = ["预售","普通","期货","团购"]
let titles = NSMutableArray()
titles.removeAllObjects()
for num in itemTypeArr! {
if num != 99{
titles.add(contentArr[num])
}
}
if titles.componentsJoined(by: ",").contains("预售") {
isYuShouShangPin = true
}else{
isYuShouShangPin = false
}
print("isYuShouShangPin == ",isYuShouShangPin)
tishixxArr.insert(titles.componentsJoined(by: ","), at: view.tag)
tishixxArr.remove(at: view.tag+1)
if itemTypeArr == [99,99,99,99] {
tishixxArr.insert("请选择商品类型", at: view.tag)
tishixxArr.remove(at: view.tag+1)
}
glSelectView?.removeFromSuperview()
glSelectView = nil
listTbv.reloadData()
}
//MARK: - titleAndTFdelegate
func textFieldContent(content: String, cell: TitleAndTFCell) {
switch cell.nameLbl.text {
case "商品名称":
itemName = content
break
case "起卖数量":
qiMaiShuLiang = content
break
case "关键字":
keyWord = content
break
case "物流费用":
wuLiuPrice = content
break
default:
break
}
}
//MARK: - 编辑规格
func ShangPinGguiGeCellEditAction(cell: ShangPinGguiGeCell) {
let vc = CreatNewSpecsViewController()
vc.barTitle = "编辑规格"
vc.datasArr = guiGeArr
vc.danWeiArr = generalInfoModel?.data?.unit!
let dataDict:GuiGeModel!
if selectIdx?.item != nil {
dataDict = guiGeArr[selectIdx!.item]
}else{
dataDict = guiGeArr.first
}
vc.price = dataDict.price
vc.guiGe = dataDict.guiGe
vc.weight = dataDict.weight
vc.wenDu = dataDict.wenDu
vc.danWei = dataDict.danWei
vc.isJieTiOpen = dataDict.isJieTiOpen
vc.isYuShouSetting = isYuShouShangPin!
vc.yuShouPrice = dataDict.yuShouPrice
vc.specalArr = dataDict.specalArr
vc.jieTiArr = dataDict.jieTiArr
vc.isOpenYSSetting = dataDict.isOpenYSSetting
vc.selectIdx = selectIdx
vc.itemDanWeiSelect = dataDict.itemDanWeiSelect
vc.tempSelect = dataDict.tempSelect
vc.delegate = self
vc.DJBiLi = dataDict.DJBiLi
vc.ysKuCun = dataDict.ysKuCun
self.navigationController?.pushViewController(vc, animated: true)
}
// //MARK: - 删除规格
func CreatNewSpecsViewControllerDeleteAction(datas: Array<GuiGeModel>,selectIdx:IndexPath) {
guiGeArr = datas
self.selectIdx = selectIdx
listTbv.reloadData()
}
//MARK: - 新增规格
@objc func addGuiGe(){
print("新增规格")
let vc = CreatNewSpecsViewController()
vc.barTitle = "新增规格"
vc.delegate = self
vc.danWeiArr = generalInfoModel?.data!.unit
vc.isYuShouSetting = isYuShouShangPin!
vc.datasArr = guiGeArr
vc.selectIdx = selectIdx
self.navigationController?.pushViewController(vc, animated: true)
}
//MARK: - 新增、编辑规格数据返回
func CreatNewSpecsViewControllerSaveAction(datas: Array<GuiGeModel>,selectIdx:IndexPath) {
guiGeArr = datas
self.selectIdx = selectIdx
listTbv.reloadData()
}
//MARK: - COLLECTIONVIEW DELEGATE
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return guiGeArr.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ItemCell", for: indexPath)
as! ItemCell
cell.tag = indexPath.row
cell.nameLbl.text = "规格" + "\(indexPath.item+1)"
if indexPath == selectIdx {
cell.nameLbl.textColor = UIColor(named: "蓝色字体颜色")
cell.lineView.isHidden = false
}else{
cell.nameLbl.textColor = UIColor(named: "标题字颜色")
cell.lineView.isHidden = true
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
selectIdx = indexPath
//刷新cell
collectionView.reloadData()
listTbv.reloadRows(at: [IndexPath(row: 0, section: 2)], with:.none)
}
//MARK: - switchClick
func switchClick(content: UISwitch, cell: TitleAndSwitchCell) {
switch cell.namelbl.text {
case "是否清真":
shiFouQZ = content.isOn
break
case "是否询价":
shiFouXJ = content.isOn
break
case "用户付款是否需要审核":
shiFouSH = content.isOn
break
default:
break
}
}
func numberOfSections(in tableView: UITableView) -> Int {
return 6
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0: return 7
case 1:return 2
case 2:return 1
case 3:return 4
case 4:return 5
default:return 1
}
}
//MARK: - tableview footer
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 10))
view.backgroundColor = UIColor(named: "app底色")
return view
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if section == 3 {
if isYuShouShangPin == false {
return 0.001
}
}
return 10
}
//MARK: - tableview header
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 3 {
if isYuShouShangPin == false {
return UIView()
}
}
let view = UIView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 39))
let lbl = UILabel(frame: CGRect(x: 15, y: 15, width: fullScreenWidth, height: 21))
lbl.text = titleArr[section]
lbl.textColor = UIColor(named: "标题字颜色")
lbl.font = UIFont.boldSystemFont(ofSize: 15)
view.addSubview(lbl)
if section == 2 && guiGeArr.count > 0{
let btn = UIButton()
btn.setTitle(" 新增", for: .normal)
btn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
btn.setTitleColor(UIColor(named: "蓝色字体颜色"), for: .normal)
btn.setImage(UIImage(named: "jiahaoXG"), for: .normal)
view.addSubview(btn)
btn.sizeToFit()
btn.snp.makeConstraints { (make) in
make.centerY.equalTo(lbl.snp_centerY)
make.right.equalTo(-15)
make.height.equalTo(btn.frame.size.height)
make.width.equalTo(btn.frame.size.width)
}
let btn2 = UIButton()
view.addSubview(btn2)
btn2.snp.makeConstraints { (make) in
make.top.right.bottom.equalTo(0)
make.width.equalTo(80)
}
btn2.addTarget(self, action: #selector(addGuiGe), for: .touchUpInside)
if guiGeArr.count > 1 {
view.frame = CGRect(x: 0, y: 0, width: fullScreenWidth, height: 80)
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 0, height: 0), collectionViewLayout: layout)
collectionView.backgroundColor = UIColor.white
collectionView.delegate = self
collectionView.dataSource = self
view.addSubview(collectionView)
collectionView.snp.makeConstraints { (make) in
make.bottom.left.right.equalTo(0)
make.height.equalTo(41)
}
collectionView.showsHorizontalScrollIndicator = false
collectionView.isPagingEnabled = true
layout.itemSize = CGSize(width: fullScreenWidth*0.5, height: 41)
layout.scrollDirection = .horizontal
collectionView.collectionViewLayout = layout
collectionView.register(UINib(nibName: "ItemCell", bundle: nil), forCellWithReuseIdentifier: "ItemCell")
if guiGeArr.count > 0 {
collectionView.layoutIfNeeded()
collectionView.scrollToItem(at: selectIdx!, at: .centeredHorizontally, animated: false)
}
}
}
return view
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 3 {
if isYuShouShangPin == false {
return 0.001
}
}
if section == 2 {
if guiGeArr.count > 1 {
return 80
}
}
return 39
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
switch indexPath.section {
case 0: return 49
case 1:return 148.5
case 2:
if guiGeArr.count > 0 {
return 146
}
return 123.5
case 3:
if isYuShouShangPin == false {
return 0.01
}else{
return 49
}
case 4:return 49
default:
return 98
}
}
func YuShouWeiKuanFaHuoCellString(str: String) {
faHuoTime = str
print(faHuoTime)
}
override func backAction() {
self.navigationController?.popViewController(animated: true)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
IQKeyboardManager.shared.resignFirstResponder()
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
IQKeyboardManager.shared.resignFirstResponder()
}
//MARK:--处理规格数据
var specifications = ""
var shop_price: Float = 0.0
var goods_unit = ""
var sku_info = ""
func getUpSkuInfoByData(dataArr:Array<GuiGeModel>) {
var price: Float = 0.0
var isgetP :Bool = false
var model : GuiGeModel? = nil
var skuArr:Array<Any> = []
dataArr.forEach { (md) in
if isPurnNumber(str: md.price) {
if isgetP {
let peiceP = Float(md.price)! //第n个售价(n > 1)
if peiceP < price {
price = peiceP
model = md
}
}else {
price = Float(md.price)! //第一个售价
model = md
isgetP = true
}
}
//普通阶梯价
var is_tiered = 0
var tiered_pri:Dictionary<String, String> = [:]
if md.isJieTiOpen {
is_tiered = 1
md.jieTiArr.forEach { (obj) in
let str = obj as! String
let arr = str.components(separatedBy: "_")
let priceStr = arr[0]
let coutStr = arr[1]
if isPurnNumber(str: priceStr) {
let specaP = Float(priceStr)!
if specaP < price {
price = specaP
model = md
}
}
tiered_pri.updateValue(priceStr, forKey: coutStr)
}
}
//预售价
var is_adsale_tiered = 0
var adsale_tiered_pri:Dictionary<String, String> = [:]
if md.isOpenYSSetting {
if isPurnNumber(str: md.yuShouPrice) {
let yushoup = Float(md.yuShouPrice)!
if yushoup < price {
price = yushoup
model = md
}
}
if md.isJieTiOpen {
is_adsale_tiered = 1
//每一个预售阶梯价
md.specalArr.forEach { (obj) in
let str = obj as! String
let arr = str.components(separatedBy: "_")
let priceStr = arr[0]
let coutStr = arr[1]
if isPurnNumber(str: priceStr) {
let specaP = Float(priceStr)!
if specaP < price {
price = specaP
model = md
}
}
adsale_tiered_pri.updateValue(priceStr, forKey: coutStr)
// Do any additional setup after loading the view.
}
//MARK: - cell delegate
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
switch indexPath.section {
case 0:
if indexPath.row == 0 || indexPath.row == 4 {
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTF") as! TitleAndTFCell
cell.textTF.delegate = self
cell.nameLbl.text = spxxArr[indexPath.row]
//商家名称
switch cell.nameLbl.text {
case "商品名称":
cell.textTF.text = itemName
cell.textTF.returnKeyType = .done
break
case "起卖数量":
cell.textTF.text = qiMaiShuLiang
cell.textTF.keyboardType = .numberPad
break
default:
break
}
cell.textTF.placeholder = tishixxArr[indexPath.row] as! String
cell.delegate = self
return cell
}
if indexPath.row > 4{
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSwitch") as! TitleAndSwitchCell
cell.namelbl.text = spxxArr[indexPath.row]
cell.delegate = self
switch cell.namelbl.text {
case "是否清真":
cell.infoSw.isOn = shiFouQZ
break
case "是否询价":
cell.infoSw.isOn = shiFouXJ
break
default:
break
}
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtn") as! TitleAndBtnCell
cell.nameLbl.text = spxxArr[indexPath.row]
cell.contentLbl.text = tishixxArr[indexPath.row] as! String
cell.tag = indexPath.row
cell.delegate = self
return cell
case 1:
let cell = tableView.dequeueReusableCell(withIdentifier: "AddImg") as! AddImgCell
cell.nameLbl.text = sptpArr[indexPath.row]
if indexPath.row == 0 {
cell.isSingle = true
if singleImgArr.count > 0{
cell.imgs = singleImgArr
cell.addBtn.isHidden = true
}else{
cell.scrollView?.isHidden = true
cell.addBtn.isHidden = false
}
}else{
cell.isSingle = false
if maxFiveImgsArr.count > 0{
cell.imgs = maxFiveImgsArr
}else{
cell.scrollView?.isHidden = true
cell.addBtnX.constant = 15
}
}
cell.delegate = self
cell.addBtn.tag = indexPath.row
cell.isEdit = true
return cell
case 2:
if guiGeArr.count > 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "ShangPinGguiGeCell") as! ShangPinGguiGeCell
cell.delegate = self
var dict:GuiGeModel!
if selectIdx != nil{
print(selectIdx?.item)
dict = guiGeArr[selectIdx!.item]
}else{
dict = guiGeArr.first
}
cell.tempLbl.text = "冷藏:\(dict.wenDu)℃"
cell.weightLbl.text = "重量(kg):\(dict.weight)kg"
cell.guiGeLbl.text = "规格:\(dict.guiGe)kg/件"
cell.danWeiLbl.text = "单位:\(dict.danWei)"
cell.sellPriceLbl.text = "售价:¥\(dict.price)"
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AddGuiGe") as! AddGuiGeCell
cell.imgBtn.addTarget(self, action: #selector(addGuiGe), for: .touchUpInside)
cell.imgBtn.setImage(UIImage(named: "xinzeng"), for: .normal)
return cell
case 3:
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndSwitch") as! TitleAndSwitchCell
cell.namelbl.text = ysszArr[indexPath.row]
cell.delegate = self
cell.infoSw.isOn = shiFouSH
return cell
}
if indexPath.row == 3 {
let cell = tableView.dequeueReusableCell(withIdentifier: "YuShouWeiKuanFaHuoCell") as! YuShouWeiKuanFaHuoCell
cell.nameLbl.text = ysszArr[indexPath.row]
cell.textTF.keyboardType = .numberPad
cell.delegate = self
cell.textTF.text = faHuoTime
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtn") as! TitleAndBtnCell
cell.nameLbl.text = ysszArr[indexPath.row]
cell.delegate = self
cell.contentLbl.text = ysszHolder[indexPath.row]
return cell
case 4:
if indexPath.row < 2 {
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTF") as! TitleAndTFCell
cell.nameLbl.text = qtxxArr[indexPath.row]
cell.textTF.delegate = self
cell.textTF.returnKeyType = .done
switch cell.nameLbl.text {
case "关键字":
cell.textTF.text = keyWord
break
case "物流费用":
cell.textTF.text = wuLiuPrice
cell.textTF.keyboardType = .numbersAndPunctuation
break
default:
break
}
cell.textTF.placeholder = tishixxArr1[indexPath.row] as! String
cell.tag = indexPath.row
cell.delegate = self
return cell
}else{
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndBtn") as! TitleAndBtnCell
cell.nameLbl.text = qtxxArr[indexPath.row]
cell.tag = indexPath.row
cell.contentLbl.text = tishixxArr1[indexPath.row] as! String
cell.delegate = self
return cell
}
default:
let cell = tableView.dequeueReusableCell(withIdentifier: "AddGuiGe") as! AddGuiGeCell
cell.imgBtn.setImage(UIImage(named: "XiaYunDanViewController"), for: .normal)
cell.delegate = self
cell.imgBtn.tag = indexPath.row
cell.imgBtn.setImage(UIImage(named: "tjxq"), for: .normal)
cell.btmH.constant = 25
return cell
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
//MARK: - 底部广告软文跳转
func AddGuiGeCellClick(cell: AddGuiGeCell) {
print("底部广告软文跳转")
let vc = LMNoteViewController()
self.navigationController?.pushViewController(vc, animated: true)
}
//MARK: -- 点击按钮事件,跳转或者展示选择界面
func btnClick(content: String, cell: TitleAndBtnCell) {
if cell.nameLbl.text == "商品类型" {
if glSelectView == nil {
let view = GLAlertSelectView(frame: self.view.bounds)
view.tag = cell.tag
view.isMultipleS = true
view.isShangPinType = true
view.titleLbl.text = "请选择商品类型"
view.delegate = self
view.dataArr = ["预售","普通","期货","团购"]
if itemTypeArr?.count == 0 {
for _ in view.dataArr {
itemTypeArr?.append(99)
}
}
view.selectArray = itemTypeArr
view.tempArr = itemTypeArr
self.view.addSubview(view)
glSelectView = view
}
}
if cell.nameLbl.text == "商品分类" {
let vc = GoodsClassViewController()
vc.delegate = self
vc.selectModel = selectGoodsClassModel
vc.dataModelArray = generalInfoModel?.data?.cats
self.navigationController?.pushViewController(vc, animated: true)
}
if cell.nameLbl.text == "品牌" {
let vc = PinPaiListViewController()
vc.isSelectData = true
vc.delegate = self
vc.selectModel = selectPinPaiData
vc.dataModelArray = generalInfoModel?.data?.brand
self.navigationController?.pushViewController(vc, animated: true)
}
if cell.nameLbl.text == "国家" {
if glSelectView == nil {
let view = GLAlertSelectView(frame: self.view.bounds)
view.tag = cell.tag
view.titleLbl.text = "请选择国家"
view.delegate = self
view.dataArr = countryArr
if countrySelect != nil {
view.selectNum = countrySelect!
}
self.view.addSubview(view)
glSelectView = view
}
}
if cell.nameLbl.text == "商品状态" {
let view = GLAlertSelectView(frame: self.view.bounds)
view.tag = cell.tag
view.titleLbl.text = "请选择商品状态"
view.delegate = self
if shangPinStatusArr != nil {
var arr:Array<String>? = []
for item in shangPinStatusArr! {
arr?.append(item.gs_name!)
}
view.dataArr = arr!
}
if shangPinStatus != nil {
view.selectNum = shangPinStatus!
}
self.view.addSubview(view)
glSelectView = view
}
if cell.nameLbl.text == "运输方式" {
let view = GLAlertSelectView(frame: self.view.bounds)
view.tag = cell.tag
view.titleLbl.text = "请选择运输方式"
view.delegate = self
view.dataArr = yunShuTypeArr
if yunShuType != nil{
view.selectNum = yunShuType!
}
self.view.addSubview(view)
glSelectView = view
}
if cell.nameLbl.text == "预设预付定金时间段" {
print("定金时间段")
let timeSelectV = ShowTimeSelectView(frame: self.view.window!.bounds)
timeSelectV.titleLbl.text = "预设预付定金时间段"
timeSelectV.delegate = self
self.view.window?.addSubview(timeSelectV)
isWeiTime = false
}
if cell.nameLbl.text == "预设预付尾款时间段" {
print("预付尾款时")
let timeSelectV = ShowTimeSelectView(frame: self.view.window!.bounds)
timeSelectV.titleLbl.text = "预设预付尾款时间段"
timeSelectV.delegate = self
self.view.window?.addSubview(timeSelectV)
isWeiTime = true
}
}
//MARK:--选择预售时间回调数据
var isWeiTime : Bool = false
func showTimeSelectByData(timeStr: String, beginDate: Date, endginDate: Date) {
let timeInterval:TimeInterval = beginDate.timeIntervalSince1970
let timeIntervalEnd:TimeInterval = endginDate.timeIntervalSince1970
if isWeiTime {
ysszHolder.insert(timeStr, at: 2)
ysszHolder.remove(at: 3)
wk_time_start = Int(timeInterval)
wk_time_end = Int(timeIntervalEnd)
}else{
ysszHolder.insert(timeStr, at: 1)
ysszHolder.remove(at: 2)
dj_time_start = Int(timeInterval)
dj_time_end = Int(timeIntervalEnd)
}
listTbv.reloadData()
}
//MARK:---选择商品分类返回数据
var selectGoodsClassModel:GoodsClassModel? = nil
func blackGoodsClass(sender: GoodsClassModel) {
print("选择商品分类返回数据=\(sender)")
selectGoodsClassModel = sender
tishixxArr.insert(sender.cat_name!, at: 2)
tishixxArr.remove(at: 3)
listTbv.reloadData()
}
//MARK:--选择品牌返回的数据
var selectPinPaiData:GeneralInfoBrandModel? = nil
func blackSelectPinPaiData(sender: GeneralInfoBrandModel) {
print("选择品牌返回的数据=\(sender)")
selectPinPaiData = sender
tishixxArr.insert(sender.brand_name!, at: 3)
tishixxArr.remove(at: 4)
listTbv.reloadData()
}
//MARK:--图片选择处理
func AddImgCellBtnClick(cell: AddImgCell) {
if cell.addBtn.tag == 0 {//仅一张
_ = 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.singleImgArr.append(image!)
self.uploadImg(imge: image!, isOriginal: true, tag: 0)
})
}
self.listTbv.reloadData()
}
}else{//可多张
let num = 5 - maxFiveImgsArr.count
_ = self.presentHGImagePicker(maxSelected:num) { (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.maxFiveImgsArr.append(image!)
let index = Dollar.indexOf(self.maxFiveImgsArr, value: image!)
self.uploadImg(imge: image!, isOriginal: false, tag: index!)
})
}
self.listTbv.reloadData()
}
}
}
//MARK: - 修改图片
func ChangeCellBtnClick(sender: UIButton, cell: AddImgCell) {
print(sender.tag)
if cell.addBtn.tag == 0 {//仅一张
_ = 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.singleImgArr.removeAll()
self.singleImgArr.append(image!)
self.uploadImg(imge: image!, isOriginal: true, tag: 0)
})
}
self.listTbv.reloadData()
}
}else{//可多张
_ = 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.maxFiveImgsArr.insert(image!, at: sender.tag)
self.maxFiveImgsArr.remove(at: sender.tag+1)
self.uploadImg(imge: image!, isOriginal: false, tag: sender.tag)
})
}
self.listTbv.reloadData()
}
}
}
//MARK:--图片上传功能
var original_img:String? = "" //商品封面图
var goods_banner:Array<String>? = ["","","","",""] //商品副图,多张,最多5张,使用一维数组转json格式
func uploadImg (imge:UIImage,isOriginal:Bool,tag:Int){
let UserToken = UserDefaults.standard.value(forKey: "user_token")
let upLoadImg = imge as! UIImage
saveFile(image: upLoadImg, ["user_token":UserToken as Any], success: { (data) in
let dataM = data as! SaveFileModel
if dataM.code == 1 {
print("图片上传成功\(dataM.data?.url)")
if isOriginal {
self.original_img = dataM.data?.url!
}else{
self.goods_banner?.insert((dataM.data?.url!)!, at: tag)
self.goods_banner?.remove(at: tag + 1)
}
}
}) { (error) in
print("图片上传失败\(error)")
}
}
//MARK: - 删除图片处理
func DelImgCellBtnClick(sender:UIButton, cell: AddImgCell) {
if cell.isSingle == true {
singleImgArr.remove(at:sender.tag)
self.original_img = ""
listTbv.reloadData()
}else{
maxFiveImgsArr.remove(at:sender.tag)
self.goods_banner?.insert("", at: 5)
self.goods_banner?.remove(at: sender.tag)
listTbv.reloadData()
}
}
//MARK: - GLAlertView(单选)下的页面
func GLAlertSelectViewClick(selectNum: Int, view: GLAlertSelectView) {
switch view.titleLbl.text {
case "请选择商品状态":
shangPinStatus = selectNum
let item = shangPinStatusArr![selectNum]
print(item.gs_name!)
tishixxArr1.insert(item.gs_name!, at: view.tag)
tishixxArr1.remove(at: view.tag+1)
break
case "请选择运输方式":
yunShuType = selectNum
tishixxArr1.insert(yunShuTypeArr[selectNum], at: view.tag)
tishixxArr1.remove(at: view.tag+1)
break
case "请选择国家":
countrySelect = selectNum
tishixxArr1.insert(countryArr[selectNum], at: view.tag)
tishixxArr1.remove(at: view.tag+1)
break
default:
break
}
glSelectView?.removeFromSuperview()
glSelectView = nil
listTbv.reloadData()
}
//MARK: - GLAlertView(多选)下的页面
func GLAlertMoreSelectViewClick(sender: Array<Int>, view:UIView) {
itemTypeArr = sender
let contentArr = ["预售","普通","期货","团购"]
let titles = NSMutableArray()
titles.removeAllObjects()
for num in itemTypeArr! {
if num != 99{
titles.add(contentArr[num])
}
}
if titles.componentsJoined(by: ",").contains("预售") {
isYuShouShangPin = true
}else{
isYuShouShangPin = false
}
print("isYuShouShangPin == ",isYuShouShangPin)
tishixxArr.insert(titles.componentsJoined(by: ","), at: view.tag)
tishixxArr.remove(at: view.tag+1)
if itemTypeArr == [99,99,99,99] {
tishixxArr.insert("请选择商品类型", at: view.tag)
tishixxArr.remove(at: view.tag+1)
}
glSelectView?.removeFromSuperview()
glSelectView = nil
listTbv.reloadData()
}
//MARK: - titleAndTFdelegate
func textFieldContent(content: String, cell: TitleAndTFCell) {
switch cell.nameLbl.text {
case "商品名称":
itemName = content
break
case "起卖数量":
qiMaiShuLiang = content
break
case "关键字":
keyWord = content
break
case "物流费用":
wuLiuPrice = content
break
default:
break
}
}
//MARK: - 编辑规格
func ShangPinGguiGeCellEditAction(cell: ShangPinGguiGeCell) {
let vc = CreatNewSpecsViewController()
vc.barTitle = "编辑规格"
vc.datasArr = guiGeArr
vc.danWeiArr = generalInfoModel?.data?.unit!
let dataDict:GuiGeModel!
if selectIdx?.item != nil {
dataDict = guiGeArr[selectIdx!.item]
}else{
dataDict = guiGeArr.first
}
vc.price = dataDict.price
vc.guiGe = dataDict.guiGe
vc.weight = dataDict.weight
vc.wenDu = dataDict.wenDu
vc.danWei = dataDict.danWei
vc.isJieTiOpen = dataDict.isJieTiOpen
vc.isYuShouSetting = isYuShouShangPin!
vc.yuShouPrice = dataDict.yuShouPrice
vc.specalArr = dataDict.specalArr
vc.jieTiArr = dataDict.jieTiArr
vc.isOpenYSSetting = dataDict.isOpenYSSetting
vc.selectIdx = selectIdx
vc.itemDanWeiSelect = dataDict.itemDanWeiSelect
vc.tempSelect = dataDict.tempSelect
vc.delegate = self
vc.DJBiLi = dataDict.DJBiLi
vc.ysKuCun = dataDict.ysKuCun
self.navigationController?.pushViewController(vc, animated: true)
}
// //MARK: - 删除规格
func CreatNewSpecsViewControllerDeleteAction(datas: Array<GuiGeModel>,selectIdx:IndexPath) {
guiGeArr = datas
self.selectIdx = selectIdx
listTbv.reloadData()
}
//MARK: - 新增规格
@objc func addGuiGe(){
print("新增规格")
let vc = CreatNewSpecsViewController()
vc.barTitle = "新增规格"
vc.delegate = self
vc.danWeiArr = generalInfoModel?.data!.unit
vc.isYuShouSetting = isYuShouShangPin!
vc.datasArr = guiGeArr
vc.selectIdx = selectIdx
self.navigationController?.pushViewController(vc, animated: true)
}
//MARK: - 新增、编辑规格数据返回
func CreatNewSpecsViewControllerSaveAction(datas: Array<GuiGeModel>,selectIdx:IndexPath) {
guiGeArr = datas
self.selectIdx = selectIdx
listTbv.reloadData()
}
//MARK: - COLLECTIONVIEW DELEGATE
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return guiGeArr.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ItemCell", for: indexPath)
as! ItemCell
cell.tag = indexPath.row
cell.nameLbl.text = "规格" + "\(indexPath.item+1)"
if indexPath == selectIdx {
cell.nameLbl.textColor = UIColor(named: "蓝色字体颜色")
cell.lineView.isHidden = false
}else{
cell.nameLbl.textColor = UIColor(named: "标题字颜色")
cell.lineView.isHidden = true
}
return cell
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
selectIdx = indexPath
//刷新cell
collectionView.reloadData()
listTbv.reloadRows(at: [IndexPath(row: 0, section: 2)], with:.none)
}
//MARK: - switchClick
func switchClick(content: UISwitch, cell: TitleAndSwitchCell) {
switch cell.namelbl.text {
case "是否清真":
shiFouQZ = content.isOn
break
case "是否询价":
shiFouXJ = content.isOn
break
case "用户付款是否需要审核":
shiFouSH = content.isOn
break
default:
break
}
}
func numberOfSections(in tableView: UITableView) -> Int {
return 6
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
switch section {
case 0: return 7
case 1:return 2
case 2:return 1
case 3:return 4
case 4:return 5
default:return 1
}
}
//MARK: - tableview footer
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 10))
view.backgroundColor = UIColor(named: "app底色")
return view
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if section == 3 {
if isYuShouShangPin == false {
return 0.001
}
}
return 10
}
//MARK: - tableview header
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if section == 3 {
if isYuShouShangPin == false {
return UIView()
}
}
let view = UIView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 39))
let lbl = UILabel(frame: CGRect(x: 15, y: 15, width: fullScreenWidth, height: 21))
lbl.text = titleArr[section]
lbl.textColor = UIColor(named: "标题字颜色")
lbl.font = UIFont.boldSystemFont(ofSize: 15)
view.addSubview(lbl)
if section == 2 && guiGeArr.count > 0{
let btn = UIButton()
btn.setTitle(" 新增", for: .normal)
btn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
btn.setTitleColor(UIColor(named: "蓝色字体颜色"), for: .normal)
btn.setImage(UIImage(named: "jiahaoXG"), for: .normal)
view.addSubview(btn)
btn.sizeToFit()
btn.snp.makeConstraints { (make) in
make.centerY.equalTo(lbl.snp_centerY)
make.right.equalTo(-15)
make.height.equalTo(btn.frame.size.height)
make.width.equalTo(btn.frame.size.width)
}
let btn2 = UIButton()
view.addSubview(btn2)
btn2.snp.makeConstraints { (make) in
make.top.right.bottom.equalTo(0)
make.width.equalTo(80)
}
btn2.addTarget(self, action: #selector(addGuiGe), for: .touchUpInside)
if guiGeArr.count > 1 {
view.frame = CGRect(x: 0, y: 0, width: fullScreenWidth, height: 80)
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 0, height: 0), collectionViewLayout: layout)
collectionView.backgroundColor = UIColor.white
collectionView.delegate = self
collectionView.dataSource = self
view.addSubview(collectionView)
collectionView.snp.makeConstraints { (make) in
make.bottom.left.right.equalTo(0)
make.height.equalTo(41)
}
collectionView.showsHorizontalScrollIndicator = false
collectionView.isPagingEnabled = true
layout.itemSize = CGSize(width: fullScreenWidth*0.5, height: 41)
layout.scrollDirection = .horizontal
collectionView.collectionViewLayout = layout
collectionView.register(UINib(nibName: "ItemCell", bundle: nil), forCellWithReuseIdentifier: "ItemCell")
if guiGeArr.count > 0 {
collectionView.layoutIfNeeded()
collectionView.scrollToItem(at: selectIdx!, at: .centeredHorizontally, animated: false)
}
}
}
return view
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 3 {
if isYuShouShangPin == false {
return 0.001
}
}
if section == 2 {
if guiGeArr.count > 1 {
return 80
}
}
return 39
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
switch indexPath.section {
case 0: return 49
case 1:return 148.5
case 2:
if guiGeArr.count > 0 {
return 146
}
return 123.5
case 3:
if isYuShouShangPin == false {
return 0.01
}else{
return 49
}
case 4:return 49
default:
return 98
}
}
func YuShouWeiKuanFaHuoCellString(str: String) {
faHuoTime = str
print(faHuoTime)
}
override func backAction() {
self.navigationController?.popViewController(animated: true)
}
//MARK:--处理规格数据
var specifications = ""
var shop_price: Float = 0.0
var goods_unit = ""
var sku_info = ""
func getUpSkuInfoByData(dataArr:Array<GuiGeModel>) {
var price: Float = 0.0
var isgetP :Bool = false
var model : GuiGeModel? = nil
var skuArr:Array<Any> = []
dataArr.forEach { (md) in
if isPurnNumber(str: md.price) {
if isgetP {
let peiceP = Float(md.price)! //第n个售价(n > 1)
if peiceP < price {
price = peiceP
model = md
}
}else {
price = Float(md.price)! //第一个售价
model = md
isgetP = true
}
}
//普通阶梯价
var is_tiered = 0
var tiered_pri:Dictionary<String, String> = [:]
if md.isJieTiOpen {
is_tiered = 1
md.jieTiArr.forEach { (obj) in
let str = obj as! String
let arr = str.components(separatedBy: "_")
let priceStr = arr[0]
let coutStr = arr[1]
if isPurnNumber(str: priceStr) {
let specaP = Float(priceStr)!
if specaP < price {
price = specaP
model = md
}
}
}
let pack_attr = ["l":"0","w":"0","h":"0","wg":md.weight,"v":"0"]
var is_open_adsale = 0
var adsale_pri = ""
var adsale_inventory = ""
var pct = ""
if md.isOpenYSSetting {
is_open_adsale = 1
adsale_pri = md.yuShouPrice
adsale_inventory = md.ysKuCun
pct = md.DJBiLi
}
tiered_pri.updateValue(priceStr, forKey: coutStr)
}
var sku = ["sku_sn":"",
"spec_id":"1",
"attr":md.guiGe,
"pack_attr":pack_attr,
"refrigerate":md.wenDu,
"unit":md.danWei,
"price":md.price,
"is_tiered":is_tiered,
"is_open_adsale":is_open_adsale,
"adsale_pri":adsale_pri,
"adsale_inventory":adsale_inventory,
"pct":pct,
"is_adsale_tiered":is_adsale_tiered] as [String : Any]
if tiered_pri.keys.count > 0{
sku.updateValue(tiered_pri, forKey: "tiered_pri")
}else{
sku.updateValue("", forKey: "tiered_pri")
}
if adsale_tiered_pri.keys.count > 0 {
sku.updateValue(adsale_tiered_pri, forKey: "adsale_tiered_pri")
}else{
sku.updateValue("", forKey: "adsale_tiered_pri")
}
skuArr.append(sku)
}
if skuArr.count > 0 {
sku_info = dataChangeString(sender: skuArr)
}
shop_price = price
if model != nil {
specifications = model!.guiGe
goods_unit = model!.danWei
}
}
//预售价
var is_adsale_tiered = 0
var adsale_tiered_pri:Dictionary<String, String> = [:]
if md.isOpenYSSetting {
if isPurnNumber(str: md.yuShouPrice) {
let yushoup = Float(md.yuShouPrice)!
if yushoup < price {
price = yushoup
model = md
}
}
if md.isJieTiOpen {
is_adsale_tiered = 1
//每一个预售阶梯价
md.specalArr.forEach { (obj) in
let str = obj as! String
let arr = str.components(separatedBy: "_")
let priceStr = arr[0]
let coutStr = arr[1]
if isPurnNumber(str: priceStr) {
let specaP = Float(priceStr)!
if specaP < price {
price = specaP
model = md
}
}
adsale_tiered_pri.updateValue(priceStr, forKey: coutStr)
}
}
}
let pack_attr = ["l":"0","w":"0","h":"0","wg":md.weight,"v":"0"]
var is_open_adsale = 0
var adsale_pri = ""
var adsale_inventory = ""
var pct = ""
if md.isOpenYSSetting {
is_open_adsale = 1
adsale_pri = md.yuShouPrice
adsale_inventory = md.ysKuCun
pct = md.DJBiLi
}
var sku = ["sku_sn":"",
"spec_id":"1",
"attr":md.guiGe,
"pack_attr":pack_attr,
"refrigerate":md.wenDu,
"unit":md.danWei,
"price":md.price,
"is_tiered":is_tiered,
"is_open_adsale":is_open_adsale,
"adsale_pri":adsale_pri,
"adsale_inventory":adsale_inventory,
"pct":pct,
"is_adsale_tiered":is_adsale_tiered] as [String : Any]
if tiered_pri.keys.count > 0{
sku.updateValue(tiered_pri, forKey: "tiered_pri")
}else{
sku.updateValue("", forKey: "tiered_pri")
}
if adsale_tiered_pri.keys.count > 0 {
sku.updateValue(adsale_tiered_pri, forKey: "adsale_tiered_pri")
}else{
sku.updateValue("", forKey: "adsale_tiered_pri")
}
skuArr.append(sku)
}
if skuArr.count > 0 {
sku_info = dataChangeString(sender: skuArr)
}
shop_price = price
if model != nil {
specifications = model!.guiGe
goods_unit = model!.danWei
}
}
}
}
......@@ -60,7 +60,6 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
var isYuShouShangPin:Bool?//是否为预售商品
var itemTypeArr:Array<Int>? = []//多选
var isYuShou:Bool = false//是否预售
var shangPinStatus:Int? = 0//商品状态
var yunShuType:Int? = 0//运输类型
var maxFiveImgsArr:Array<UIImage> = []//多图
......@@ -770,14 +769,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
//MARK: - GLAlertView(多选)下的页面
func GLAlertMoreSelectViewClick(sender: Array<Int>, view:UIView) {
itemTypeArr = sender
let str = "\(sender.first!)"
if str != "99" {
isYuShou = true
}else{
isYuShou = false
}
let contentArr = ["预售","普通","期货","团购"]
let titles = NSMutableArray()
titles.removeAllObjects()
......@@ -838,7 +830,6 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
}else{
dataDict = guiGeArr.first
}
vc.price = dataDict.price
vc.guiGe = dataDict.guiGe
vc.weight = dataDict.weight
......@@ -856,6 +847,8 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
vc.delegate = self
vc.DJBiLi = dataDict.DJBiLi
vc.ysKuCun = dataDict.ysKuCun
vc.isYsJieTiOpen = dataDict.isYsJieTiOpen
vc.selectYuShou = dataDict.selectYuShou
self.navigationController?.pushViewController(vc, animated: true)
}
// //MARK: - 删除规格
......@@ -1058,13 +1051,8 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
override func backAction() {
self.navigationController?.popViewController(animated: true)
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
IQKeyboardManager.shared.resignFirstResponder()
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
IQKeyboardManager.shared.resignFirstResponder()
}
//MARK:--处理规格数据
var specifications = ""
var shop_price: Float = 0.0
......
......@@ -35,16 +35,19 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
var collectView:UICollectionView?
var datasArr:Array<GuiGeModel> = []
var dataModel = GuiGeModel()
let titleArray = ["售价:","规格:","重量:","温藏:","单位:"]
let pliceHolderArr = ["请输入商品售价","请输入商品规格","请输入商品重量","请选择商品温藏","请选择商品单位"]
@IBOutlet weak var bottomBtn: LGButton!
@IBOutlet weak var listTbv: UITableView!
var selectIdx:IndexPath?
var isYuShouSetting = false//打开预售
// var isJieTiJiaSetting = false
var isJieTiOpen = false//控制阶梯价是否打开
var isYsJieTiOpen = false//控制预售阶梯是否打开
var isOpenYSSetting = false//是否打开预售设置
var selectYuShou:Bool = false//是否选择设置预售价格
var selectYuShou = false//是否选择设置预售价格
//选择页面
var selectView:GLAlertSelectView? = nil
......@@ -180,9 +183,12 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
dataModel.weight = weight
dataModel.wenDu = wenDu
dataModel.danWei = danWei
dataModel.isYsJieTiOpen = isYsJieTiOpen
dataModel.jieTiArr = jieTiArr as! Array<Any>
dataModel.specalArr = specalArr as! Array<Any>
dataModel.yuShouPrice = yuShouPrice
print("save == ",selectYuShou)
dataModel.selectYuShou = selectYuShou
dataModel.itemDanWeiSelect = itemDanWeiSelect
dataModel.tempSelect = tempSelect
dataModel.isJieTiOpen = isJieTiOpen
......@@ -190,10 +196,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
dataModel.DJBiLi = DJBiLi
dataModel.ysKuCun = ysKuCun
if barTitle?.contains("编辑") == true {
datasArr.insert(dataModel, at: selectIdx!.item)
datasArr.remove(at: selectIdx!.item+1)
}else{
datasArr.append(dataModel)
selectIdx?.item = datasArr.count - 1
......@@ -240,9 +244,7 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
}
if section == 2 {
if selectYuShou {//预售
return specalArr.count
}else{//非预售
return jieTiArr.count
}
......@@ -392,11 +394,14 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
}
}
if indexPath.section == 2 {
if isJieTiOpen {
if isJieTiOpen && selectYuShou == false {
return 49
}
if isYsJieTiOpen && selectYuShou {
return 49
}else{
return 0.001
}
return 0.001
}
return 49
}
......@@ -405,30 +410,30 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView()
if section == 2 {//阶梯价设置
let view = NewCreateHeader(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 49))
view.delegate = self
view.infoSw.isOn = isJieTiOpen
if isJieTiOpen == false{
return view
}
if isYuShouSetting {//阶梯价
if isYuShouSetting {//预售阶梯价
let view = TitleAndSwitchHeaderView(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 90))
view.delegate = self
print("selectYuShou == ",selectYuShou)
view.selectYuShou = selectYuShou
view.infoSW.isOn = isJieTiOpen
view.infoSW.isOn = isJieTiOpen//普通
view.ysInfoSw.isOn = isYsJieTiOpen//预售
return view
}else{//普通
let view = NewCreateHeader(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 49))
view.delegate = self
view.infoSw.isOn = isJieTiOpen
if isJieTiOpen == false{
return view
}
return view
}
return view
}
return view
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section != 0 {
if section == 2 {
if isYuShouSetting && isJieTiOpen {
if isYuShouSetting{
return 90
}
return 59
......@@ -440,7 +445,12 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
//footer
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if section == 2 {
if isJieTiOpen {
if isJieTiOpen && selectYuShou == false{
let view = NewCreateFooter(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 49))
view.delegate = self
return view
}
if isYsJieTiOpen && selectYuShou{
let view = NewCreateFooter(frame: CGRect(x: 0, y: 0, width: fullScreenWidth, height: 49))
view.delegate = self
return view
......@@ -451,7 +461,10 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if section == 2 {
if isJieTiOpen {
if isJieTiOpen && selectYuShou == false {
return 49
}
if isYsJieTiOpen && selectYuShou{
return 49
}
}
......@@ -537,8 +550,11 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
}
func switchStatus(sender: UISwitch) {//阶梯价设置
isJieTiOpen = sender.isOn
// isJieTiJiaSetting = sender.isOn
if sender.tag == 99 {
isYsJieTiOpen = sender.isOn
}else{
isJieTiOpen = sender.isOn
}
listTbv.reloadData()
}
......@@ -583,11 +599,9 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
func PuTongJieTiContent(price: String, count: String, cell: PuTongJieTiCell) {
if selectYuShou {
specalArr.insert("\(price)_\(count)", at: cell.tag)
print(specalArr)
specalArr.remove(at: cell.tag+1)
}else{
jieTiArr.insert("\(price)_\(count)", at: cell.tag)
print(jieTiArr)
jieTiArr.remove(at: cell.tag+1)
}
}
......@@ -638,7 +652,9 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
isJieTiOpen = dataDict.isJieTiOpen
isOpenYSSetting = dataDict.isOpenYSSetting
DJBiLi = dataDict.DJBiLi
isYsJieTiOpen = dataDict.isYsJieTiOpen
ysKuCun = dataDict.ysKuCun
selectYuShou = dataDict.selectYuShou
listTbv.reloadData()
collectionView.reloadData()
}
......
......@@ -9,6 +9,8 @@
import Foundation
class GuiGeModel: NSObject {
///sku_id
var sku_id :Int?
///售价
var price : String = ""
///规格
......@@ -39,4 +41,8 @@ class GuiGeModel: NSObject {
var isJieTiOpen:Bool = false
///是否打开预售设置
var isOpenYSSetting:Bool = false
///是否打开预售阶梯价
var isYsJieTiOpen:Bool = false
///是否选择预售阶梯
var selectYuShou:Bool = false
}
......@@ -17,15 +17,17 @@ class TitleAndSwitchHeaderView: UIView {
@IBOutlet weak var bottomLine: UIView!
var selectYuShou:Bool = false{
didSet{
print("abababababab === ",selectYuShou)
var sender = 0
if selectYuShou {
sender = 1
leftBtn.setTitleColor(UIColor(named: "标题字颜色"), for: .normal)
rightBtn.setTitleColor(UIColor(named: "按钮渐变色下,字体颜色"), for: .normal)
ysSettingView.isHidden = false
}else{
leftBtn.setTitleColor(UIColor(named: "按钮渐变色下,字体颜色"), for: .normal)
rightBtn.setTitleColor(UIColor(named: "标题字颜色"), for: .normal)
ysSettingView.isHidden = true
}
let x = CGFloat(sender)*fullScreenWidth*0.5
bottomLine.snp.updateConstraints { (make) in
......@@ -38,6 +40,8 @@ class TitleAndSwitchHeaderView: UIView {
}
var contentView:UIView!
var delegate:TitleAndSwitchHeaderViewDelegate?
@IBOutlet weak var ysSettingView: UIView!
@IBOutlet weak var ysInfoSw: UISwitch!
@IBOutlet weak var infoSW: UISwitch!
//初始化时将xib中的view添加进来
override init(frame: CGRect) {
......@@ -45,6 +49,14 @@ class TitleAndSwitchHeaderView: UIView {
contentView = loadViewFromNib()
addSubview(contentView)
ysInfoSw.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
ysInfoSw.tag = 99
ysInfoSw.addTarget(self, action: #selector(switchChange(sender:)), for: .valueChanged)
contentView.snp.makeConstraints { (make) in
make.left.top.right.bottom.equalToSuperview()
}
infoSW.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
infoSW.addTarget(self, action: #selector(switchChange(sender:)), for: .valueChanged)
contentView.snp.makeConstraints { (make) in
......
......@@ -13,6 +13,8 @@
<outlet property="infoSW" destination="CB7-5d-TkX" id="NR3-4A-D6i"/>
<outlet property="leftBtn" destination="Foa-mx-5Yx" id="T72-dm-y5o"/>
<outlet property="rightBtn" destination="ybR-u7-XP4" id="Dk3-d2-gbZ"/>
<outlet property="ysInfoSw" destination="GMQ-8b-xpg" id="Qqe-Na-SeV"/>
<outlet property="ysSettingView" destination="II7-GR-59T" id="7M4-1t-9N5"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
......@@ -77,12 +79,44 @@
</constraints>
<color key="onTintColor" name="蓝色字体颜色"/>
</switch>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="II7-GR-59T">
<rect key="frame" x="0.0" y="10" width="375" height="52"/>
<subviews>
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GMQ-8b-xpg">
<rect key="frame" x="311" y="10" width="51" height="31"/>
<color key="onTintColor" name="蓝色字体颜色"/>
</switch>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="fzO-2v-R5h">
<rect key="frame" x="15" y="15" width="105" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="dAn-sg-2eN"/>
</constraints>
<attributedString key="attributedText">
<fragment content="预售阶梯价设置">
<attributes>
<color key="NSColor" name="标题字颜色"/>
<font key="NSFont" size="15" name="PingFangSC-Medium"/>
</attributes>
</fragment>
</attributedString>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="fzO-2v-R5h" firstAttribute="top" secondItem="II7-GR-59T" secondAttribute="top" constant="15" id="Tr9-yg-lIC"/>
<constraint firstAttribute="trailing" secondItem="GMQ-8b-xpg" secondAttribute="trailing" constant="15" id="ZH7-e5-ZP3"/>
<constraint firstItem="GMQ-8b-xpg" firstAttribute="centerY" secondItem="fzO-2v-R5h" secondAttribute="centerY" id="ipq-Mm-XOP"/>
<constraint firstItem="fzO-2v-R5h" firstAttribute="leading" secondItem="II7-GR-59T" secondAttribute="leading" constant="15" id="ytg-81-7V9"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="76R-R0-pCI" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="4o5-ak-hVE"/>
<constraint firstItem="FFu-OD-rc8" firstAttribute="top" secondItem="76R-R0-pCI" secondAttribute="bottom" constant="15" id="HvO-2g-yPj"/>
<constraint firstAttribute="trailing" secondItem="FFu-OD-rc8" secondAttribute="trailing" id="JhF-wO-qGP"/>
<constraint firstItem="Foa-mx-5Yx" firstAttribute="top" secondItem="II7-GR-59T" secondAttribute="bottom" id="KFe-TD-fPY"/>
<constraint firstAttribute="bottom" secondItem="Foa-mx-5Yx" secondAttribute="bottom" id="LS2-nW-eWp"/>
<constraint firstItem="76R-R0-pCI" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="LrY-UI-RcR"/>
<constraint firstAttribute="trailing" secondItem="ybR-u7-XP4" secondAttribute="trailing" id="NLC-no-i4E"/>
......@@ -91,12 +125,15 @@
<constraint firstItem="ybR-u7-XP4" firstAttribute="leading" secondItem="Foa-mx-5Yx" secondAttribute="trailing" id="S3X-IS-ztd"/>
<constraint firstAttribute="trailing" secondItem="76R-R0-pCI" secondAttribute="trailing" id="Uth-qd-FUC"/>
<constraint firstAttribute="bottom" secondItem="iUg-fe-DMN" secondAttribute="bottom" id="UyW-VQ-lzx"/>
<constraint firstAttribute="trailing" secondItem="II7-GR-59T" secondAttribute="trailing" id="Wsj-kO-7V7"/>
<constraint firstItem="ybR-u7-XP4" firstAttribute="height" secondItem="Foa-mx-5Yx" secondAttribute="height" id="X7T-nQ-A6m"/>
<constraint firstItem="CB7-5d-TkX" firstAttribute="centerY" secondItem="FFu-OD-rc8" secondAttribute="centerY" id="e18-MP-pNs"/>
<constraint firstItem="II7-GR-59T" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="10" id="eQr-UG-t4i"/>
<constraint firstItem="FFu-OD-rc8" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="15" id="kCT-vS-1St"/>
<constraint firstAttribute="trailing" secondItem="CB7-5d-TkX" secondAttribute="trailing" constant="15" id="ktE-YY-c70"/>
<constraint firstItem="Foa-mx-5Yx" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="lve-Dd-EFp"/>
<constraint firstAttribute="bottom" secondItem="ybR-u7-XP4" secondAttribute="bottom" id="ras-iE-35P"/>
<constraint firstItem="II7-GR-59T" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="sgG-cQ-N2v"/>
<constraint firstItem="iUg-fe-DMN" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="u3M-i0-jPq"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
......@@ -113,6 +150,9 @@
<namedColor name="标题字颜色">
<color red="0.1803921568627451" green="0.1803921568627451" blue="0.1803921568627451" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="标题字颜色">
<color red="0.18000000715255737" green="0.18000000715255737" blue="0.18000000715255737" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="灰色字体颜色">
<color red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
......
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