Commit 28a70dce authored by lujunye's avatar lujunye

修复规格,商品详情bug

parent ccb1ec82
......@@ -43,15 +43,14 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, UITabBarControllerDeleg
//MARK:--loginVC
func addLoginVc (isAgain:Bool){
// let vc = LoginViewController()
// vc.delegate = self
// let contentView = vc
let vc = LoginViewController()
vc.delegate = self
let contentView = vc
//
let vc = ChuRuKuJiLuXQViewController()
vc.barTitle = "入库"
let contentView = vc
// let vc = ProductDetailViewController()
// let contentView = vc
if let windowScene = sceneC as? UIWindowScene {
......
......@@ -68,26 +68,10 @@ class GLAlertSelectView: UIView,UITableViewDelegate,UITableViewDataSource,TitleA
}
@IBAction func closeAction(_ sender: UIButton) {
print("close",tempArr,selectArray)
if tempNum == nil {
tempNum = 10086
}
delegate?.GLASClose(view: self, selectnum: tempNum!, selectArr: tempArr!)
// if isMultipleS == false {
// if selectNum == nil {
// HUD.flash(.label("\(titleLbl.text!)"), delay: 1.2)
// return
// }
// delegate?.GLAlertSelectViewClick?(selectNum: selectNum!,view: self)
// }else{
//
// if selectArray?.componentsJoined(by: "_") == "99_99_99_99" {
// HUD.flash(.label("\(titleLbl.text!)"), delay: 1.2)
// return
// }
// delegate?.GLAlertMoreSelectViewClick?(sender: selectArray!,view:self)
// }
}
//初始化时将xib中的view添加进来
@IBOutlet weak var btmView: UIView!
......@@ -224,7 +208,7 @@ class GLAlertSelectView: UIView,UITableViewDelegate,UITableViewDataSource,TitleA
HUD.flash(.label("\(titleLbl.text!)"), delay: 1.2)
return
}
print("abc == \(selectNum)")
delegate?.GLAlertSelectViewClick?(selectNum: selectNum!,view: self)
}else{
if selectArray == [99,99,99,99] {
......
......@@ -29,9 +29,6 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
shangPinStatus = selectnum
}
}
view.removeFromSuperview()
glSelectView = nil
}
......@@ -47,13 +44,14 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
let qtxxArr = ["关键字","物流费用","国家","商品状态","运输方式"]
let ysszArr = ["用户付款是否需要审核","预设预付定金时间段","预设预付尾款时间段","预设预付尾款发货时间"]
let ysszHolder = ["0","请选择时段","请选择时段","0"]
var shangPinStatusArr:Array<GeneralInfoGsModel>?
var shangPinStatusArr:Array<GeneralInfoGsModel>? = []
var yunShuTypeArr = ["冷链","常温","热链"]
var countryArr = ["中国"]
var layout = UICollectionViewFlowLayout()
var glSelectView:GLAlertSelectView?
var selectIdx:IndexPath?//多规格状态下点击collectionCell的row记录
var selectIdx:IndexPath? = IndexPath(item: 0, section: 0) //多规格状态下点击collectionCell的row记录
var isYuShouShangPin:Bool?//是否为预售商品
......@@ -77,11 +75,38 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
@IBAction func submitAction(_ sender: Any) {
print("保存按钮submitAction")
print(itemName)//商品名称
print(itemTypeArr)//商品类型
print(qiMaiShuLiang)//起卖数量
print(singleImgArr.count)//商品封面图
print(shiFouQZ)//是否清真
print(shiFouXJ)//是否询价
print(maxFiveImgsArr)//商品主图
print(shiFouSH)
print(guiGeArr)//商品规格
print(keyWord)//关键字
print(wuLiuPrice)//物流费用
print(shangPinStatus)//商品状态
print(yunShuType)//运输方式
print(countrySelect)//选择国家
if itemName.count == 0 {
HUD.flash(.label("请输入商品名称"), delay: 1.2)
return
}
if itemTypeArr == [] || itemTypeArr == [99,99,99,99] {
HUD.flash(.label("请选择商品类型"), delay: 1.2)
return
}
//待补充
if itemName.count == 0 {
HUD.flash(.label("请输入商品名称"), delay: 1.2)
return
}
//待补充
if itemName.count == 0 {
HUD.flash(.label("请输入商品名称"), delay: 1.2)
return
}
print(itemTypeArr)//商品类型
if itemTypeArr == [99,99,99,99] {
HUD.flash(.label("请选择商品类型"), delay: 1.2)
return
......@@ -90,20 +115,17 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
HUD.flash(.label("请输入起卖数量"), delay: 1.2)
return
}
print(qiMaiShuLiang)//起卖数量
print(shiFouQZ)//是否清真
print(shiFouXJ)//是否询价
if singleImgArr.count == 0 {
HUD.flash(.label("请选择商品封面图"), delay: 1.2)
return
}
print(singleImgArr.count)//商品封面图
if maxFiveImgsArr.count == 0 {
HUD.flash(.label("请选择商品主图"), delay: 1.2)
return
}
print(maxFiveImgsArr)//商品主图
if guiGeArr.count == 0 {
HUD.flash(.label("请填写商品规格"), delay: 1.2)
return
......@@ -113,7 +135,6 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
HUD.flash(.label("请输入发货时间"), delay: 1.2)
return
}
print(shiFouSH)
}
if keyWord.count == 0 {
HUD.flash(.label("请输入关键字"), delay: 1.2)
......@@ -123,24 +144,22 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
HUD.flash(.label("请输入物流费用"), delay: 1.2)
return
}
print(guiGeArr)//商品规格
print(keyWord)//关键字
print(wuLiuPrice)//物流费用
if countrySelect == nil {
HUD.flash(.label("请选择国家"), delay: 1.2)
return
}
if shangPinStatus == nil {
HUD.flash(.label("请选择商品状态"), delay: 1.2)
return
}
print(shangPinStatusArr![shangPinStatus!])//商品状态
if yunShuType == nil {
HUD.flash(.label("请选择运输方式"), delay: 1.2)
return
}
print(yunShuTypeArr[yunShuType!])//运输方式
if countrySelect == nil {
HUD.flash(.label("请选择国家"), delay: 1.2)
return
}
print(countryArr[countrySelect!])//选择国家
......@@ -160,6 +179,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
HUD.hide(animated: true)
self.generalInfoModel = (data as! GeneralInfoModel)
self.shangPinStatusArr = (self.generalInfoModel?.data!.gs)!
}) { (error) in
}
......@@ -548,9 +568,10 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
func GLAlertSelectViewClick(selectNum: Int, view: GLAlertSelectView) {
switch view.titleLbl.text {
case "请选择商品类型":
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
......@@ -564,6 +585,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
tishixxArr1.insert(countryArr[selectNum], at: view.tag)
tishixxArr1.remove(at: view.tag+1)
break
default:
break
}
......@@ -634,7 +656,6 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
let vc = CreatNewSpecsViewController()
vc.barTitle = "编辑规格"
vc.datasArr = guiGeArr
vc.danWeiArr = generalInfoModel?.data?.unit!
vc.isJieTiJiaSetting = true
let dataDict:GuiGeModel!
......@@ -654,12 +675,9 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
vc.yuShouPrice = dataDict.yuShouPrice
vc.specalArr = dataDict.specalArr
vc.jieTiArr = dataDict.jieTiArr
if selectIdx == nil {
vc.selectIdx = IndexPath(item: 0, section: 0)
}else{
vc.selectIdx = selectIdx
}
print(vc.selectIdx?.item)
vc.itemDanWeiSelect = dataDict.itemDanWeiSelect
vc.tempSelect = dataDict.tempSelect
vc.delegate = self
self.navigationController?.pushViewController(vc, animated: true)
}
......@@ -680,14 +698,17 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
vc.isYuShouSetting = isYuShou
vc.isNonYuShou = isYuShou
vc.datasArr = guiGeArr
vc.selectIdx = selectIdx
self.navigationController?.pushViewController(vc, animated: true)
}
//MARK: - 新增、编辑规格
func CreatNewSpecsViewControllerSaveAction(datas: Array<GuiGeModel>) {
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
......@@ -701,9 +722,7 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
as! ItemCell
cell.tag = indexPath.row
cell.nameLbl.text = "规格" + "\(indexPath.item+1)"
if selectIdx == nil {
selectIdx = IndexPath(item: 0, section: 0)
}
if indexPath == selectIdx {
cell.nameLbl.textColor = UIColor(named: "蓝色字体颜色")
cell.lineView.isHidden = false
......@@ -717,8 +736,8 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
selectIdx = indexPath
//刷新cell
listTbv.reloadData()
collectionView.reloadData()
listTbv.reloadRows(at: [IndexPath(row: 0, section: 2)], with:.none)
}
//MARK: - switchClick
func switchClick(content: UISwitch, cell: TitleAndSwitchCell) {
......@@ -814,7 +833,10 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
layout.scrollDirection = .horizontal
collectionView.collectionViewLayout = layout
collectionView.register(UINib(nibName: "ItemCell", bundle: nil), forCellWithReuseIdentifier: "ItemCell")
collectionView.selectItem(at:selectIdx, animated: false, scrollPosition: .left)
if guiGeArr.count > 0 {
collectionView.layoutIfNeeded()
collectionView.scrollToItem(at: selectIdx!, at: .centeredHorizontally, animated: false)
}
}
}
return view
......
......@@ -11,7 +11,7 @@ import LGButton
import IQKeyboardManagerSwift
protocol CreatNewSpecsViewControllerDelegate {
func CreatNewSpecsViewControllerSaveAction(datas:Array<GuiGeModel>)
func CreatNewSpecsViewControllerSaveAction(datas:Array<GuiGeModel>,selectIdx:IndexPath)
func CreatNewSpecsViewControllerDeleteAction(datas:Array<GuiGeModel>,selectIdx:IndexPath)
}
class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,TitleAndTFCellDelegate,TitleAndBtnCellDelegate,TitleAndSwitchCellDelegate,TitleAndSwitchHeaderViewDelegate,NewCreateHeaderDelegate,NewCreateFooterDelegate,YuShouCellDelegate,GLAlertSelectViewDelegate,PuTongJieTiCellDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,UITextFieldDelegate{
......@@ -28,12 +28,7 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
selectView = nil
}
var layout = UICollectionViewFlowLayout()
var delegate:CreatNewSpecsViewControllerDelegate?
var collectView:UICollectionView?
var datasArr:Array<GuiGeModel> = []
......@@ -43,12 +38,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
@IBOutlet weak var bottomBtn: LGButton!
@IBOutlet weak var listTbv: UITableView!
var selectIdx:IndexPath?
var isYuShouSetting: Bool = false{
willSet{
isYuShouSetting = newValue
}
}//打开预售
var isJieTiJiaSetting: Bool = false
var isYuShouSetting = false//打开预售
var isJieTiJiaSetting = false
var selectYuShou:Bool = false//是否选择设置预售价格
......@@ -58,54 +49,17 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
//选择页面
var selectView:GLAlertSelectView? = nil
var selectListArr:Array<String> = ["冷冻","冷藏","常温"]
var danWeiArr:Array<String>?{
willSet{
print(newValue)
danWeiArr = newValue
}
}
var price = ""{
willSet{
price = newValue
}
}
var guiGe = ""{
willSet{
guiGe = newValue
}
}
var weight = ""{
willSet{
weight = newValue
}
}
var wenDu = ""{
willSet{
wenDu = newValue
for i in 0 ..< selectListArr.count {
if newValue == selectListArr[i] {
tempSelect = i
}
}
}
}
var danWei = ""{
willSet{
danWei = newValue
if danWeiArr != nil {
for i in 0 ..< danWeiArr!.count {
if newValue == selectListArr[i] {
itemDanWeiSelect = i
}
}
}
}
}//规格
var danWeiArr:Array<String>?
var price = ""
var guiGe = ""
var weight = ""
var wenDu = ""
var danWei = ""
//规格
var specalArr:Array<Any> = []{
willSet{
specalArr.removeAll()
specalArr = newValue
}
}//预售
var jieTiArr:Array<Any> = []{
......@@ -231,6 +185,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
dataModel.isNonYuShou = isNonYuShou
dataModel.isYuShouSetting = isYuShouSetting
dataModel.yuShouPrice = yuShouPrice
dataModel.itemDanWeiSelect = itemDanWeiSelect
dataModel.tempSelect = tempSelect
if barTitle?.contains("编辑") == true {
datasArr.insert(dataModel, at: selectIdx!.item)
......@@ -238,8 +194,9 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
}else{
datasArr.append(dataModel)
selectIdx?.item = datasArr.count - 1
}
delegate?.CreatNewSpecsViewControllerSaveAction(datas:datasArr)
delegate?.CreatNewSpecsViewControllerSaveAction(datas:datasArr,selectIdx:selectIdx!)
self.navigationController?.popViewController(animated: true)
}
//MARK: - TEXTFIELD DELEGATE
......@@ -585,7 +542,6 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
isYuShouSetting = content.isOn
let idxPath = IndexPath(row: 0, section: 1)
if isYuShouSetting && isJieTiJiaSetting {//单独点击预售设置
listTbv.reloadData()
}else{//单独打开预售设置
listTbv.reloadRows(at: [idxPath], with: .none)
......@@ -649,8 +605,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ItemCell", for: indexPath)
as! ItemCell
cell.tag = indexPath.row
cell.tag = indexPath.item
cell.nameLbl.text = "规格" + "\(indexPath.item+1)"
if indexPath == selectIdx {
cell.nameLbl.textColor = UIColor(named: "蓝色字体颜色")
cell.lineView.isHidden = false
......
......@@ -29,5 +29,8 @@ class GuiGeModel: NSObject {
var jieTiArr : Array<Any> = []
///预售阶梯价
var specalArr : Array<Any> = []
///单位select
var itemDanWeiSelect:Int?
///温度select
var tempSelect:Int?
}
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