Commit 768f0820 authored by 刘俊宏's avatar 刘俊宏

完成预售订单的定金和尾款修改

parent 05156e59
...@@ -94,7 +94,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, UITabBarControllerDeleg ...@@ -94,7 +94,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, UITabBarControllerDeleg
// Create the SwiftUI view that provides the window contents. // Create the SwiftUI view that provides the window contents.
tabBarController.viewControllers = [v1, v2, v3, v4, v5] tabBarController.viewControllers = [v1, v2, v3, v4, v5]
tabBarController.selectedIndex = 1 tabBarController.selectedIndex = 2
let contentView = tabBarController let contentView = tabBarController
......
...@@ -22,9 +22,9 @@ class TitleAndTFCell: UITableViewCell { ...@@ -22,9 +22,9 @@ class TitleAndTFCell: UITableViewCell {
// Initialization code // Initialization code
} }
@objc func textEditing(sender:UITextField){ @objc func textEditing(sender:UITextField){
if sender.text!.count > 0 { // 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)
......
...@@ -32,7 +32,7 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U ...@@ -32,7 +32,7 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U
var logistics_price = ""//运费 var logistics_price = ""//运费
var other_price = ""//其他费用 var other_price = ""//其他费用
var orderType:Int? //订单类型 var orderType:Int? = 0//订单类型默认进入系统自动选择普通订单
var adrData:GetAddrsInfoDataModel?//地址数据 var adrData:GetAddrsInfoDataModel?//地址数据
var glSelectView:GLAlertSelectView? = nil var glSelectView:GLAlertSelectView? = nil
...@@ -61,7 +61,22 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U ...@@ -61,7 +61,22 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U
HUD.flash(.label("请选择地址"), delay: 1.2) HUD.flash(.label("请选择地址"), delay: 1.2)
return return
} }
print(logistics_price)
print(other_price)
if logistics_price.count > 0 {
if !isPurnNumber(str: logistics_price) {
HUD.flash(.label("请填写正确的运费价格"), delay: 1.2)
return;
}
}
if other_price.count > 0 {
if !isPurnNumber(str: other_price) {
HUD.flash(.label("请填写正确的费用价格"), delay: 1.2)
return;
}
}
let goods_info = getGoodsInfo() let goods_info = getGoodsInfo()
let order_info = getOrderInfo() let order_info = getOrderInfo()
var is_adsale = 0 var is_adsale = 0
...@@ -74,17 +89,17 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U ...@@ -74,17 +89,17 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U
"goods_info":goods_info as Any, "goods_info":goods_info as Any,
"order_info":order_info as Any] as [String : Any] "order_info":order_info as Any] as [String : Any]
print(order) print(order)
HUD.flash(.progress) // HUD.flash(.progress)
addOrder(order, success: { (data) in // addOrder(order, success: { (data) in
let dataM = data as! UpDataModel // let dataM = data as! UpDataModel
if dataM.code == 1 { // if dataM.code == 1 {
HUD.flash(.labeledSubSuccess(subtitle:"提交成功"),delay: 1.2) // HUD.flash(.label("提交成功"), delay: 1.2)
}else{ // }else{
HUD.hide() // HUD.hide()
} // }
}) { (error) in // }) { (error) in
//
} // }
} }
override func viewDidLoad() { override func viewDidLoad() {
...@@ -355,6 +370,11 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U ...@@ -355,6 +370,11 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U
vc.inputData = cellDataArr vc.inputData = cellDataArr
vc.djTFstr = djTFstr vc.djTFstr = djTFstr
vc.wkTFstr = wkTFstr vc.wkTFstr = wkTFstr
let item = cellDataArr[0];
let price = item.priceTF.text as! NSString
let count = item.countTF.text as! NSString
let tp = price.floatValue * count.floatValue
vc.totalPrice = tp
vc.delegate = self vc.delegate = self
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
}else{//普通 }else{//普通
...@@ -515,7 +535,9 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U ...@@ -515,7 +535,9 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U
for item in pArr { for item in pArr {
tp = tp + item tp = tp + item
} }
view.totalPriceLbl.text = \(tp)" let tpStr = String(format: "%.2f", tp)
view.totalPriceLbl.text = "¥" + tpStr
if cellDataArr.count == 0 { if cellDataArr.count == 0 {
view.topView.isHidden = true view.topView.isHidden = true
view.topViewHeight.constant = 0.01 view.topViewHeight.constant = 0.01
...@@ -695,6 +717,7 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U ...@@ -695,6 +717,7 @@ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,U
} }
//MARK:--处理提交数据OrderInfo //MARK:--处理提交数据OrderInfo
func getOrderInfo() -> String { func getOrderInfo() -> String {
var orderInfo:String = "" var orderInfo:String = ""
var payType = 0 var payType = 0
if zhiFuWay == 0 { if zhiFuWay == 0 {
......
...@@ -172,10 +172,11 @@ class XuanZeShangPinViewController: BaseViewController,UITableViewDelegate,UITab ...@@ -172,10 +172,11 @@ class XuanZeShangPinViewController: BaseViewController,UITableViewDelegate,UITab
cell.idx = indexPath cell.idx = indexPath
cell.countTF.tag = indexPath.row cell.countTF.tag = indexPath.row
cell.priceTF.tag = indexPath.row cell.priceTF.tag = indexPath.row
cell.priceTF.keyboardType = .numbersAndPunctuation cell.countTF.keyboardType = .numberPad
cell.priceTF.keyboardType = .decimalPad
cell.priceTF.returnKeyType = .done cell.priceTF.returnKeyType = .done
cell.countTF.returnKeyType = .done cell.countTF.returnKeyType = .done
cell.countTF.tag = indexPath.row
if barTitle == "修改价格"{ if barTitle == "修改价格"{
let cell1 = inputData[indexPath.row] let cell1 = inputData[indexPath.row]
cell.sku_id = cell1.sku_id cell.sku_id = cell1.sku_id
...@@ -197,10 +198,14 @@ class XuanZeShangPinViewController: BaseViewController,UITableViewDelegate,UITab ...@@ -197,10 +198,14 @@ class XuanZeShangPinViewController: BaseViewController,UITableViewDelegate,UITab
cell.nameLbl.text = model.goods_name cell.nameLbl.text = model.goods_name
cell.cellModel = model cell.cellModel = model
cell.detailLbl.text = "\(model.spec_str!)/\(model.unit!)" cell.detailLbl.text = "\(model.spec_str!)/\(model.unit!)"
cell.detailLbl2.text = "存储\(model.inventory!)" cell.detailLbl2.text = "库存\(model.inventory!)"
cell.iconImg.sd_setImage(with: URL(string: SERVERCE_ImageHost + model.goods_img!)) cell.iconImg.sd_setImage(with: URL(string: SERVERCE_ImageHost + model.goods_img!))
cell.imgUrlPath = SERVERCE_ImageHost + model.goods_img! cell.imgUrlPath = SERVERCE_ImageHost + model.goods_img!
cell.sku_id = model.sku_id cell.sku_id = model.sku_id
cell.countTF.text = StringByInt(number: model.origin_number!)
cell.priceTF.text = model.price!
if isYuShou {//预售 if isYuShou {//预售
if idx == indexPath { if idx == indexPath {
cell.selectBtn.isSelected = true cell.selectBtn.isSelected = true
......
...@@ -12,13 +12,14 @@ protocol XiuGaiYuShouJiaViewControllerDelegate { ...@@ -12,13 +12,14 @@ protocol XiuGaiYuShouJiaViewControllerDelegate {
func changeYuShouGoodsByData(sender:EditOGPAdDataModel?,djText:String,wkText:String) func changeYuShouGoodsByData(sender:EditOGPAdDataModel?,djText:String,wkText:String)
} }
class XiuGaiYuShouJiaViewController: BaseViewController { class XiuGaiYuShouJiaViewController: BaseViewController, UITextFieldDelegate {
var dataModel : OrderDetailDataModel? var dataModel : OrderDetailDataModel?
var orderID:Int? = 0 var orderID:Int? = 0
var delegate : XiuGaiYuShouJiaViewControllerDelegate? var delegate : XiuGaiYuShouJiaViewControllerDelegate?
var inputData:Array<XuanZeShangPinCell> = [] var inputData:Array<XuanZeShangPinCell> = []
var djTFstr:String = ""; var djTFstr:String = "";
var wkTFstr:String = ""; var wkTFstr:String = "";
var totalPrice: Float? = 0
@IBOutlet weak var firstView: UIView! @IBOutlet weak var firstView: UIView!
@IBOutlet weak var weiKuanTF: UITextField! @IBOutlet weak var weiKuanTF: UITextField!
...@@ -65,13 +66,69 @@ class XiuGaiYuShouJiaViewController: BaseViewController { ...@@ -65,13 +66,69 @@ class XiuGaiYuShouJiaViewController: BaseViewController {
} }
} }
//MARK:--输入框代理
dingJinTF.delegate = self
dingJinTF.tag = 1001
weiKuanTF.delegate = self
weiKuanTF.tag = 1002
dingJinTF.keyboardType = .decimalPad
weiKuanTF.keyboardType = .decimalPad
}
func textFieldDidEndEditing(_ textField: UITextField) {
if textField.tag == 1001 {
print(dingJinTF.text)
let dingj = dingJinTF.text! as NSString
if isPurnNumber(str: dingJinTF.text!) {
if dingj.floatValue > (totalPrice! * 0.2) {
HUD.flash(.label("定金不得高于总价20%"),delay: 1.2)
dingJinTF.text = String(format: "%.2f", (totalPrice! * 0.2))
}else{
dingJinTF.text = String(format: "%.2f", dingj.floatValue)
}
let lastDj = dingJinTF.text! as NSString
let weiku = totalPrice! - lastDj.floatValue
weiKuanTF.text = String(format: "%.2f",weiku)
}else{
HUD.flash(.label("请填写正确的定金数值"),delay: 1.2)
dingJinTF.text = ""
}
}else if textField.tag == 1002{
print(weiKuanTF.text)
let weiku = weiKuanTF.text! as NSString
if isPurnNumber(str: weiKuanTF.text!) {
if weiku.floatValue > totalPrice! {
HUD.flash(.label("尾款不得高于总价"),delay: 1.2)
weiKuanTF.text = String(format: "%.2f", totalPrice!)
}else if weiku.floatValue < (totalPrice! * 0.8){
HUD.flash(.label("尾款不得低于总价的80%"),delay: 1.2)
weiKuanTF.text = String(format: "%.2f", (totalPrice! * 0.8))
}else{
weiKuanTF.text = String(format: "%.2f", weiku.floatValue)
}
let lastWeiku = weiKuanTF.text! as NSString
let dingj = totalPrice! - lastWeiku.floatValue
dingJinTF.text = String(format: "%.2f",dingj)
}else{
HUD.flash(.label("请填写正确的尾款数值"),delay: 1.2)
weiKuanTF.text = ""
}
}
} }
@IBAction func submitACTION(_ sender: Any) { @IBAction func submitACTION(_ sender: Any) {
print("预售返回上一级且提交了数据") print("预售返回上一级且提交了数据")
let weiku = weiKuanTF.text! as NSString
let dingj = dingJinTF.text! as NSString
if (weiku.floatValue + dingj.floatValue)
!= totalPrice {
let total = String(format: "%.2f", totalPrice!)
HUD.flash(.label("填写的定金和尾款总价应为" + total),delay: 1.2)
return;
}
if orderID != 0 { if orderID != 0 {
//MARK:--需要对输入是否为金额判断 //MARK:--需要对输入是否为金额判断
let UserToken = UserDefaults.standard.value(forKey: "user_token") let UserToken = UserDefaults.standard.value(forKey: "user_token")
......
...@@ -145,7 +145,8 @@ class OrderDViewController: BaseViewController,UITableViewDelegate,UITableViewDa ...@@ -145,7 +145,8 @@ class OrderDViewController: BaseViewController,UITableViewDelegate,UITableViewDa
vc.delegate = self vc.delegate = self
vc.dataModel = self.dataMdoel vc.dataModel = self.dataMdoel
vc.orderID = self.orderId vc.orderID = self.orderId
let goodsAmount = (self.dataMdoel?.order_res?.goods_amount!)! as NSString
vc.totalPrice = goodsAmount.floatValue
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
}else{ }else{
let vc = ChangeGoodsPriceVC() let vc = ChangeGoodsPriceVC()
......
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