Commit 346d3d08 authored by lujunye's avatar lujunye

补充规格填写售价,重量输入格式错误提醒

parent 680fd596
...@@ -22,9 +22,7 @@ class TitleAndTFCell: UITableViewCell { ...@@ -22,9 +22,7 @@ class TitleAndTFCell: UITableViewCell {
// Initialization code // Initialization code
} }
@objc func textEditing(sender:UITextField){ @objc func textEditing(sender:UITextField){
// if sender.text!.count > 0 {
delegate?.textFieldContent?(content: sender.text!, cell: self) delegate?.textFieldContent?(content: sender.text!, cell: self)
// }
} }
override func setSelected(_ selected: Bool, animated: Bool) { override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated) super.setSelected(selected, animated: animated)
......
...@@ -237,18 +237,31 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -237,18 +237,31 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
func textFieldDidEndEditing(_ textField: UITextField) { func textFieldDidEndEditing(_ textField: UITextField) {
switch textField.tag { switch textField.tag {
case 0: case 0:
if isPurnNumber(str: textField.text!) {
textField.text = formatShowNumber(value: textField.text!) textField.text = formatShowNumber(value: textField.text!)
price = textField.text! price = textField.text!
}else{
HUD.flash(.label("请输入正确的价格"), delay: 1.2)
textField.text = ""
price = textField.text!
}
break break
case 2: case 2:
if isPurnNumber(str: textField.text!) {
textField.text = formatShowNumber(value: textField.text!) textField.text = formatShowNumber(value: textField.text!)
weight = textField.text! weight = textField.text!
}else{
HUD.flash(.label("请输入正确的重量"), delay: 1.2)
textField.text = ""
price = textField.text!
}
break break
default: default:
break break
} }
} }
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
switch textField.tag { switch textField.tag {
case 1: case 1:
guiGe = textField.text! guiGe = textField.text!
...@@ -257,19 +270,19 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -257,19 +270,19 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
break break
} }
return true return true
} }
func PuTongJieTiClickDone() { func PuTongJieTiClickDone() {
IQKeyboardManager.shared.resignFirstResponder() IQKeyboardManager.shared.resignFirstResponder()
} }
//MARK: - cell delegate //MARK: - cell delegate
func numberOfSections(in tableView: UITableView) -> Int { func numberOfSections(in tableView: UITableView) -> Int {
if (navbar.title?.contains("编辑"))! { if (navbar.title?.contains("编辑"))! {
return 4 return 4
}else{ }else{
return 3 return 3
} }
} }
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == 0 { if section == 0 {
return titleArray.count return titleArray.count
...@@ -282,9 +295,9 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -282,9 +295,9 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
} }
} }
return 1 return 1
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.section == 0 { if indexPath.section == 0 {
if indexPath.row < 3 { if indexPath.row < 3 {
...@@ -419,8 +432,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -419,8 +432,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
} }
return cell return cell
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if isAllEditing == false { if isAllEditing == false {
return return
} }
...@@ -437,8 +450,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -437,8 +450,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
} }
} }
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if indexPath.section == 1 { if indexPath.section == 1 {
if isOpenYSSetting { if isOpenYSSetting {
return 184.5 return 184.5
...@@ -455,10 +468,10 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -455,10 +468,10 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
} }
return 49 return 49
} }
//header //header
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView() let view = UIView()
if section == 2 {//阶梯价设置 if section == 2 {//阶梯价设置
if isYuShouSetting {//预售阶梯价 if isYuShouSetting {//预售阶梯价
...@@ -482,8 +495,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -482,8 +495,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
} }
} }
return view return view
} }
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section != 0 { if section != 0 {
if section == 2 { if section == 2 {
if isYuShouSetting{ if isYuShouSetting{
...@@ -494,9 +507,9 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -494,9 +507,9 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
return 10 return 10
} }
return 0.01 return 0.01
} }
//footer //footer
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? { func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if section == 2 { if section == 2 {
if barTitle?.contains("查看") == false { if barTitle?.contains("查看") == false {
if isJieTiOpen && selectYuShou == false{ if isJieTiOpen && selectYuShou == false{
...@@ -513,8 +526,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -513,8 +526,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
} }
let view = UIView() let view = UIView()
return view return view
} }
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if section == 2 { if section == 2 {
if isJieTiOpen && selectYuShou == false { if isJieTiOpen && selectYuShou == false {
return 49 return 49
...@@ -524,16 +537,16 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -524,16 +537,16 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
} }
} }
return 0.01 return 0.01
} }
//MARK: - NEW CELL DELEGATE //MARK: - NEW CELL DELEGATE
func YuShouCellTFContent(Price: NSString) { func YuShouCellTFContent(Price: NSString) {
let arr = Price.components(separatedBy: "_") let arr = Price.components(separatedBy: "_")
yuShouPrice = arr[0] yuShouPrice = arr[0]
ysKuCun = arr[1] ysKuCun = arr[1]
DJBiLi = arr[2] DJBiLi = arr[2]
} }
func textFieldContent(content: String, cell: TitleAndTFCell) { func textFieldContent(content: String, cell: TitleAndTFCell) {
switch cell.tag { switch cell.tag {
case 0: case 0:
price = content price = content
...@@ -545,8 +558,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -545,8 +558,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
weight = content weight = content
break break
} }
} }
func GLAlertSelectViewClick(selectNum: Int, view: GLAlertSelectView) { func GLAlertSelectViewClick(selectNum: Int, view: GLAlertSelectView) {
let cell = listTbv.cellForRow(at: IndexPath(row: view.tag, section: 0)) as! TitleAndBtnCell let cell = listTbv.cellForRow(at: IndexPath(row: view.tag, section: 0)) as! TitleAndBtnCell
if view.tag == 3 { if view.tag == 3 {
tempSelect = selectNum tempSelect = selectNum
...@@ -561,15 +574,15 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -561,15 +574,15 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
selectView?.removeFromSuperview() selectView?.removeFromSuperview()
selectView = nil selectView = nil
} }
var tempSelect:Int? var tempSelect:Int?
var itemDanWeiSelect:Int? var itemDanWeiSelect:Int?
func btnClick(content: String, cell: TitleAndBtnCell) { func btnClick(content: String, cell: TitleAndBtnCell) {
if cell.tag == 3 { if cell.tag == 3 {
if selectView == nil { if selectView == nil {
let view = GLAlertSelectView(frame: self.view.bounds) let view = GLAlertSelectView(frame: self.view.bounds)
...@@ -602,18 +615,18 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -602,18 +615,18 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
} }
} }
} }
func switchStatus(sender: UISwitch) {//阶梯价设置 func switchStatus(sender: UISwitch) {//阶梯价设置
if sender.tag == 99 { if sender.tag == 99 {
isYsJieTiOpen = sender.isOn isYsJieTiOpen = sender.isOn
}else{ }else{
isJieTiOpen = sender.isOn isJieTiOpen = sender.isOn
} }
listTbv.reloadData() listTbv.reloadData()
} }
func switchClick(content: UISwitch, cell: TitleAndSwitchCell) { func switchClick(content: UISwitch, cell: TitleAndSwitchCell) {
//控制 //控制
if cell.tag == 5{ if cell.tag == 5{
let idxPath = IndexPath(row: 0, section: 1) let idxPath = IndexPath(row: 0, section: 1)
...@@ -624,15 +637,15 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -624,15 +637,15 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
} }
} }
} }
func newCreateSwitchStatus(sender: UISwitch) { func newCreateSwitchStatus(sender: UISwitch) {
//打开switch 阶梯价设置 //打开switch 阶梯价设置
// isJieTiJiaSetting = sender.isOn // isJieTiJiaSetting = sender.isOn
isJieTiOpen = sender.isOn isJieTiOpen = sender.isOn
listTbv.reloadData() listTbv.reloadData()
} }
func footerClickAction() { func footerClickAction() {
if isAllEditing == false { if isAllEditing == false {
return return
} }
...@@ -643,14 +656,14 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -643,14 +656,14 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
jieTiArr.append("") jieTiArr.append("")
} }
listTbv.reloadData() listTbv.reloadData()
} }
func YuShouCellSwitchStatus(sender: UISwitch) { func YuShouCellSwitchStatus(sender: UISwitch) {
//控制 //控制
// isYuShouSetting = sender.isOn // isYuShouSetting = sender.isOn
isOpenYSSetting = sender.isOn isOpenYSSetting = sender.isOn
listTbv.reloadData() listTbv.reloadData()
} }
func PuTongJieTiDelAction(sender: PuTongJieTiCell) { func PuTongJieTiDelAction(sender: PuTongJieTiCell) {
if selectYuShou { if selectYuShou {
specalArr.remove(at: sender.tag) specalArr.remove(at: sender.tag)
listTbv.reloadData() listTbv.reloadData()
...@@ -659,35 +672,35 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -659,35 +672,35 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
listTbv.reloadData() listTbv.reloadData()
} }
} }
func PuTongJieTiContentSp(price: String, count: String, cell: PuTongJieTiCell) { func PuTongJieTiContentSp(price: String, count: String, cell: PuTongJieTiCell) {
specalArr.insert("\(price)_\(count)", at: cell.tag) specalArr.insert("\(price)_\(count)", at: cell.tag)
specalArr.remove(at: cell.tag+1) specalArr.remove(at: cell.tag+1)
} }
func PuTongJieTiContent(price: String, count: String, cell: PuTongJieTiCell) { func PuTongJieTiContent(price: String, count: String, cell: PuTongJieTiCell) {
jieTiArr.insert("\(price)_\(count)", at: cell.tag) jieTiArr.insert("\(price)_\(count)", at: cell.tag)
jieTiArr.remove(at: cell.tag+1) jieTiArr.remove(at: cell.tag+1)
} }
func selectYuShou(sender: UIButton) { func selectYuShou(sender: UIButton) {
if sender.tag == 0 { if sender.tag == 0 {
selectYuShou = false selectYuShou = false
}else{ }else{
selectYuShou = true selectYuShou = true
} }
listTbv.reloadData() listTbv.reloadData()
} }
//MARK: - COLLECTIONVIEW DELEGATE //MARK: - COLLECTIONVIEW DELEGATE
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0 return 0
} }
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return datasArr.count return datasArr.count
} }
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ItemCell", for: indexPath) let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ItemCell", for: indexPath)
as! ItemCell as! ItemCell
cell.tag = indexPath.item cell.tag = indexPath.item
...@@ -701,8 +714,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -701,8 +714,8 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
} }
return cell return cell
} }
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
selectIdx = indexPath selectIdx = indexPath
//刷新cell //刷新cell
let dataDict = datasArr[selectIdx!.item] let dataDict = datasArr[selectIdx!.item]
...@@ -722,5 +735,5 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl ...@@ -722,5 +735,5 @@ class CreatNewSpecsViewController: BaseViewController,UITableViewDelegate,UITabl
selectYuShou = dataDict.selectYuShou selectYuShou = dataDict.selectYuShou
listTbv.reloadData() listTbv.reloadData()
collectionView.reloadData() collectionView.reloadData()
} }
} }
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