Commit 965aa5b4 authored by lujunye's avatar lujunye

分销商品设置bug修复

parent 1e2626ff
...@@ -15,6 +15,7 @@ class DistributorSettingAlertView: UIView { ...@@ -15,6 +15,7 @@ class DistributorSettingAlertView: UIView {
@IBOutlet weak var percent_price_lbl: UILabel! @IBOutlet weak var percent_price_lbl: UILabel!
var temp_commission_per = "" var temp_commission_per = ""
var temp_commission_val = "" var temp_commission_val = ""
var temp_commission_price = ""
var temp_commission_type = 1 var temp_commission_type = 1
var is_all_select_mode = false var is_all_select_mode = false
var data:supGoodsListResDataModel?{ var data:supGoodsListResDataModel?{
...@@ -46,11 +47,14 @@ class DistributorSettingAlertView: UIView { ...@@ -46,11 +47,14 @@ class DistributorSettingAlertView: UIView {
payNumTypelbl.text = "%" payNumTypelbl.text = "%"
payTF.text = StringByInt(number: (data?.commission_per)!) payTF.text = StringByInt(number: (data?.commission_per)!)
temp_commission_per = StringByInt(number: (data?.commission_per)!) temp_commission_per = StringByInt(number: (data?.commission_per)!)
let price = data?.dbt_price as! NSString if data?.dbt_price != nil {
let percent = temp_commission_per as! NSString temp_commission_price = (data?.dbt_price)!
let c_price = price.floatValue * 0.01 * percent.floatValue let price = Float(temp_commission_price)
let percent = Float(temp_commission_per)
let c_price = price! * 0.01 * percent!
percent_price_lbl.text = "(" + String(format: "%.2f", c_price) + "元)" percent_price_lbl.text = "(" + String(format: "%.2f", c_price) + "元)"
percent_price_lbl.isHidden = false percent_price_lbl.isHidden = false
}
}else{ }else{
payBiBtn .setImage(UIImage.init(named: "daixuan"), for: .normal) payBiBtn .setImage(UIImage.init(named: "daixuan"), for: .normal)
payJueBtn .setImage(UIImage.init(named: "yuxuan"), for: .normal) payJueBtn .setImage(UIImage.init(named: "yuxuan"), for: .normal)
...@@ -131,21 +135,45 @@ class DistributorSettingAlertView: UIView { ...@@ -131,21 +135,45 @@ class DistributorSettingAlertView: UIView {
@objc func textChange(textField:UITextField){ @objc func textChange(textField:UITextField){
if textField == moneyTx { if textField == moneyTx {
let price = textField.text as! NSString if temp_commission_per != "" {
let percent = temp_commission_per as! NSString let price = Float(textField.text!)!
let c_price = price.floatValue * 0.01 * percent.floatValue let percent = Float(temp_commission_per)!
let c_price = price * 0.01 * percent
percent_price_lbl.text = "(" + String(format: "%.2f", c_price) + "元)" percent_price_lbl.text = "(" + String(format: "%.2f", c_price) + "元)"
}
temp_commission_price = moneyTx.text!
}else{ }else{
if temp_commission_type == 1 { if temp_commission_price != "" {
temp_commission_per = textField.text! let fx_price = Float(temp_commission_price)
let price = data?.dbt_price as! NSString let input_value = Float(textField.text!)
let percent = temp_commission_per as! NSString if temp_commission_type == 1 {//比例
let c_price = price.floatValue * 0.01 * percent.floatValue if textField.text == "" {
return
}
if input_value! > 100 {
HUD.flash(.label("佣金不大于100%~"), delay: 1.2)
textField.text! = ""
return
}else{
let c_price = input_value! * 0.01 * fx_price!
percent_price_lbl.text = "(" + String(format: "%.2f", c_price) + "元)" percent_price_lbl.text = "(" + String(format: "%.2f", c_price) + "元)"
temp_commission_per = textField.text!
}
}else{ }else{
if textField.text == "" {
return
}
if input_value! > fx_price! {
HUD.flash(.label("佣金大于分销价~"), delay: 1.2)
textField.text! = ""
return
}
temp_commission_val = textField.text! temp_commission_val = textField.text!
} }
}else{
HUD.flash(.label("请输入分销价"), delay: 1.2)
textField.text = ""
}
} }
} }
...@@ -183,17 +211,19 @@ class DistributorSettingAlertView: UIView { ...@@ -183,17 +211,19 @@ class DistributorSettingAlertView: UIView {
var commission_type = 1 var commission_type = 1
var commission_per = "" var commission_per = ""
var commission_val = "" var commission_val = ""
let fx_price = moneyTx.text
if payJueBtn.isSelected { if payJueBtn.isSelected {
commission_type = 2 commission_type = 2
commission_val = payTF.text! commission_val = payTF.text!
if (commission_val as! NSString).floatValue > (moneyTx.text as! NSString).floatValue{
if Float(commission_val)! > Float(fx_price!)! {
HUD.flash(.label("佣金大于分销价~"), delay: 1.2) HUD.flash(.label("佣金大于分销价~"), delay: 1.2)
payTF.text! = "" payTF.text! = ""
return return
} }
}else{ }else{
commission_per = payTF.text! commission_per = payTF.text!
if (commission_per as! NSString).floatValue > 100 { if Float(commission_per)! > 100 {
HUD.flash(.label("佣金不大于100%~"), delay: 1.2) HUD.flash(.label("佣金不大于100%~"), delay: 1.2)
payTF.text! = "" payTF.text! = ""
return return
......
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