Commit 0ceeeaff authored by 刘俊宏's avatar 刘俊宏

旧物流下单选择填写地址完成

parent 6f53c7b0
......@@ -220,5 +220,7 @@
<string>Order/confirmReceiving</string>
<key>商品上下/架</key>
<string>Goods/onOff</string>
<key>下运单收发地址信息</key>
<string>Logistics/getAddr</string>
</dict>
</plist>
......@@ -60,7 +60,7 @@ consignee 联系人
is_send_default 是否默发收货地址,1是0非
*/
func AddAddress(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) {
NetworkRequest.sharedInstance.postRequest("新增地址", params, { (rep:DataResponse<AddAddressDataModel>) in
NetworkRequest.sharedInstance.postRequest("新增地址", params, { (rep:DataResponse<AddAddressModel>) in
}, success: { (data) in
success(data)
}) { (error) in
......
......@@ -81,3 +81,16 @@ func logisticsOrderDetails(_ params:[String:Any],success:@escaping (_ res:Any)->
}
}
//MARK:-- 下运单收发地址信息
/*
user_token 验证token
*/
func getAddr(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) {
NetworkRequest.sharedInstance.postRequest("下运单收发地址信息", params, { (rep:DataResponse<GetAddrsInfoModel>) in
}, success: { (data) in
success(data)
}) { (error) in
failture(error)
}
}
......@@ -37,7 +37,8 @@ class GetAddrsInfoDataModel: Mappable {
var mobile:String? //联系方式
var is_default:Int?
var addr_cn:String? //联系人详细地址
var addr_name:String? ////完整地址信息(下单收发货才有)
required init?( map: Map) {
}
......@@ -53,5 +54,7 @@ class GetAddrsInfoDataModel: Mappable {
mobile <- map["mobile"]
is_default <- map["is_default"]
addr_cn <- map["addr_cn"]
addr_name <- map["addr_name"]
}
}
......@@ -11,39 +11,70 @@ import WebKit
class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,JiTuoWuXinXiViewDelegate,JiPaiFangShiViewControllerDelegate,ZengZhiServicesViewControllerDelegate,AdressSelectCellDelegate,DZGLViewControllerDelegate,XinZengDiZhiViewControllerDelegate{
var sender:String?
var sendPhone:String?
var sendAdr:String?
var sendAddressModel:AddAddressDataModel?
var sendAddressSelectModel:GetAddrsInfoDataModel?
var isSelectSendAddressModel = false
var receiver:String?
var receivePhone:String?
var receiveAdr:String?
func XinZengDiZhiViewControllerFinishAction(name: String, phone: String, adr: String) {
var receiveAddressModel:AddAddressDataModel?
var receiveAddressSelectModel:GetAddrsInfoDataModel?
var isSelectReceiveAddressModel = false
func XinZengDiZhiViewControllerFinishAction(name: String, phone: String, adr: String, data: AddAddressDataModel?) {
if isSend {
sender = name
sendPhone = phone
sendAdr = adr
sendAddressModel = data
isSelectSendAddressModel = false
}else{
receiver = name
receivePhone = phone
receiveAdr = adr
receiveAddressModel = data
isSelectReceiveAddressModel = false
}
listView.reloadData()
}
func DZGLViewControllerSelect(data: GetAddrsInfoDataModel) {
print("已选的收发货地址\(data.addr_name!)")
if isSend {
sender = data.consignee
sendPhone = data.mobile
sendAdr = data.addr_name
isSelectSendAddressModel = true
sendAddressSelectModel = data
}else{
receiver = data.consignee
receivePhone = data.mobile
receiveAdr = data.addr_name
receiveAddressSelectModel = data
isSelectReceiveAddressModel = true
}
listView.reloadData()
}
func AdressSelectCellBtnCLick(row: Int) {
let vc = DZGLViewController()
vc.cus_id = 365
vc.isSelectlogAddress = true
vc.isSelectMotion = true
vc.delegate = self
isSend = true
if row == 1 {
isSend = false
}
self.navigationController?.pushViewController(vc, animated: true )
}
var isSend = true
......@@ -108,58 +139,17 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
let vc = XiaDanChengGongViewController()
self.navigationController?.pushViewController(vc, animated: true)
}
@IBOutlet weak var topBtnView: UIView!
@IBOutlet weak var bottomView: UIView!
@IBOutlet weak var listView: UITableView!
var locBtn = UIButton()
@IBOutlet weak var hListView: UITableView!
@IBAction func selectAction(_ sender: UIButton) {
if rightBtn == sender {
rightBtn.isSelected = true
leftBtn.isSelected = false
lineV.frame.origin.x = fullScreenWidth * 0.5
hllView.isHidden = false
if fullScreenHeight > 736 {
hBtnViewH.constant = 83
}else{
hBtnViewH.constant = 49
}
}else{
rightBtn.isSelected = false
leftBtn.isSelected = true
lineV.frame.origin.x = 0
hllView.isHidden = true
}
}
@IBOutlet weak var lineV: UIView!
@IBOutlet weak var leftBtn: UIButton!
@IBOutlet weak var hBtnViewH: NSLayoutConstraint!
@IBOutlet weak var hllView: UIView!
@IBOutlet weak var rightBtn: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
navbar.title = "运单列表"
self.view.addSubview(navbar)
locBtn.backgroundColor = UIColor.red
self.view.addSubview(locBtn)
locBtn.snp_makeConstraints({ (make) in
make.right.equalTo(-15)
make.centerY.equalTo(navbar.snp_centerY).offset(10)
make.height.equalTo(30)
make.width.equalTo(100)
})
SetTopFrame(view: topBtnView, height: 44)
listView.snp.makeConstraints { (make) in
make.top.equalTo(NavCGRect.height)
make.left.right.equalTo(0)
make.bottom.equalTo(bottomView.snp_top)
}
listView.separatorStyle = .none
listView.register(UINib(nibName: "AdressSelectCell", bundle: nil), forCellReuseIdentifier: "AdressSelect")
listView.register(UINib(nibName: "PersonCenterCell", bundle: nil), forCellReuseIdentifier: "PersonCenter")
......@@ -308,79 +298,77 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
return 49
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// if tableView == listView {
switch indexPath.section {
case 0:
let cell = tableView.dequeueReusableCell(withIdentifier: "AdressSelect") as! AdressSelectCell
cell.titleLbl.text = "寄"
cell.tag = indexPath.row
cell.delegate = self
cell.contentLbl.isHidden = false
cell.contentV.isHidden = true
if indexPath.row == 0 {
if sender != nil {
cell.contentLbl.isHidden = true
cell.contentV.isHidden = false
cell.nameLbl.text = sender!
cell.phoneLbl.text = sendPhone!
cell.adrLbl.text = sendAdr!
}
switch indexPath.section {
case 0:
let cell = tableView.dequeueReusableCell(withIdentifier: "AdressSelect") as! AdressSelectCell
cell.titleLbl.text = "寄"
cell.tag = indexPath.row
cell.delegate = self
cell.contentLbl.isHidden = false
cell.contentV.isHidden = true
if indexPath.row == 0 {
if sender != nil {
cell.contentLbl.isHidden = true
cell.contentV.isHidden = false
cell.nameLbl.text = sender!
cell.phoneLbl.text = sendPhone!
cell.adrLbl.text = sendAdr!
}
if indexPath.row == 1 {
cell.titleLbl.backgroundColor = UIColor(named: "企业、预售字体")
cell.titleLbl.text = "收"
if receiver != nil {
cell.contentLbl.isHidden = true
cell.contentV.isHidden = false
cell.nameLbl.text = receiver!
cell.phoneLbl.text = receivePhone!
cell.adrLbl.text = receiveAdr!
}
}
if indexPath.row == 1 {
cell.titleLbl.backgroundColor = UIColor(named: "企业、预售字体")
cell.titleLbl.text = "收"
if receiver != nil {
cell.contentLbl.isHidden = true
cell.contentV.isHidden = false
cell.nameLbl.text = receiver!
cell.phoneLbl.text = receivePhone!
cell.adrLbl.text = receiveAdr!
}
return cell
case 1:
let cell = tableView.dequeueReusableCell(withIdentifier: "PersonCenter") as! PersonCenterCell
cell.titleLbl.text = titleArr[indexPath.row]
if indexPath.row == 0 {
cell.introLbl.text = "(必填)"
cell.introLbl.textColor = UIColor(named: "蓝色字体颜色")
cell.introLbl.isHidden = false
if isCheck != nil {
cell.contentStr = itemName + "; \(count!)箱; \(weight!)kg"
}
}
return cell
case 1:
let cell = tableView.dequeueReusableCell(withIdentifier: "PersonCenter") as! PersonCenterCell
cell.titleLbl.text = titleArr[indexPath.row]
if indexPath.row == 0 {
cell.introLbl.text = "(必填)"
cell.introLbl.textColor = UIColor(named: "蓝色字体颜色")
cell.introLbl.isHidden = false
if isCheck != nil {
cell.contentStr = itemName + "; \(count!)箱; \(weight!)kg"
}
if indexPath.row == 1 {
var sendStr = "上门提货"
if send != 0 {
sendStr = "自送到库"
}
var receiveStr = "送货上门"
if receive != 0 {
receiveStr = "到库自取"
}
cell.contentStr = sendStr + "; " + receiveStr
}
if indexPath.row == 1 {
var sendStr = "上门提货"
if send != 0 {
sendStr = "自送到库"
}
if indexPath.row == 2 {
cell.introLbl.isHidden = false
if price != nil {
cell.contentStr = "报价金额:\(price!)"
}
var receiveStr = "送货上门"
if receive != 0 {
receiveStr = "到库自取"
}
if indexPath.row == 3 {
let cell = tableView.dequeueReusableCell(withIdentifier: "WenDu") as! WenDuCell
cell.titleLbl.text = titleArr[indexPath.row]
return cell
cell.contentStr = sendStr + "; " + receiveStr
}
if indexPath.row == 2 {
cell.introLbl.isHidden = false
if price != nil {
cell.contentStr = "报价金额:\(price!)"
}
return cell
default:
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTFBtnCell") as! TitleAndTFBtnCell
cell.nameLbl.text = title2Arr[indexPath.row]
}
if indexPath.row == 3 {
let cell = tableView.dequeueReusableCell(withIdentifier: "WenDu") as! WenDuCell
cell.titleLbl.text = titleArr[indexPath.row]
return cell
}
// }
return cell
default:
let cell = tableView.dequeueReusableCell(withIdentifier: "TitleAndTFBtnCell") as! TitleAndTFBtnCell
cell.nameLbl.text = title2Arr[indexPath.row]
return cell
}
}
}
......@@ -13,12 +13,13 @@ protocol DZGLViewControllerDelegate {
func DZGLViewControllerSelect(data:GetAddrsInfoDataModel)
}
class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,SwipeTableViewCellDelegate,UISearchBarDelegate,SearchBarViewDelegate,XinZengDiZhiViewControllerDelegate,GeliAlertViewDelegate{
func XinZengDiZhiViewControllerFinishAction(name: String, phone: String, adr: String) {
listView.mj_header?.beginRefreshing()
func XinZengDiZhiViewControllerFinishAction(name: String, phone: String, adr: String, data: AddAddressDataModel?) {
listView.mj_header?.beginRefreshing()
}
func sureGeliAlertViewAction(sender: UIButton) {
let model = adrArrs[sender.tag]
AddressDel(["user_token":UserToken as Any,"address_id":model.address_id as Any], success: { (data) in
self.listView.mj_header?.beginRefreshing()
......@@ -27,8 +28,8 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
}
}
let UserToken = UserDefaults.standard.value(forKey: "user_token")
let UserToken = UserDefaults.standard.value(forKey: "user_token")
//MARK:--搜索模块
//MAKR:--调起搜索后添加个蒙版本
......@@ -85,7 +86,7 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
var isSelectMotion = false
var selectIdx:IndexPath?
var adrInfo:GetAddrsInfoModel?
var isSelectlogAddress = false
//列表
var adrArrs:Array<AddressListDataModel> = []
......@@ -109,11 +110,10 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
super.viewDidLoad()
navbar.title = "地址管理"
self.view.addSubview(navbar)
if cus_id != nil {
if isSelectlogAddress {
HUD.flash(.progress)
searchBgH.constant = 0
getAddrsInfo(["user_token":UserToken as Any,"cus_id":cus_id as Any], success: { (data) in
getAddr(["user_token":UserToken as Any], success: { (data) in
self.adrInfo = (data as! GetAddrsInfoModel)
self.listView.reloadData()
HUD.hide()
......@@ -121,28 +121,41 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
}
}else{
//searchbar
let searchBr = SearchBarView.init()
self.searchBg.addSubview(searchBr)
searchBr.snp.makeConstraints { (make) in
make.left.right.equalTo(0)
make.centerY.equalToSuperview()
make.height.equalTo(35)
if cus_id != nil {
HUD.flash(.progress)
searchBgH.constant = 0
getAddrsInfo(["user_token":UserToken as Any,"cus_id":cus_id as Any], success: { (data) in
self.adrInfo = (data as! GetAddrsInfoModel)
self.listView.reloadData()
HUD.hide()
}) { (error) in
}
}else{
//searchbar
let searchBr = SearchBarView.init()
self.searchBg.addSubview(searchBr)
searchBr.snp.makeConstraints { (make) in
make.left.right.equalTo(0)
make.centerY.equalToSuperview()
make.height.equalTo(35)
}
searchV = searchBr
searchBr.placeholderStr = "请输入收货人地址"
searchBr.cornerRadius = 35/2.0
searchBr.delegate = self
searchBr.delegateL = self
navbar.rightTitle = "新增"
searchBgH.constant = 45
//下拉刷新相关设置
headerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadData))
self.listView!.mj_header = headerMJ
self.listView.mj_header?.beginRefreshing()
}
searchV = searchBr
searchBr.placeholderStr = "请输入收货人地址"
searchBr.cornerRadius = 35/2.0
searchBr.delegate = self
searchBr.delegateL = self
navbar.rightTitle = "新增"
searchBgH.constant = 45
//下拉刷新相关设置
headerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadData))
self.listView!.mj_header = headerMJ
self.listView.mj_header?.beginRefreshing()
}
listView.separatorStyle = .none
// SetTopFrameView(view: listView, btmView: btmLbl)
SetTopFrame(view: searchBg, height: 45)
......@@ -170,7 +183,7 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
}
@objc func loadData(){
adrArrs.removeAll()
AddressList(["user_token":UserToken as Any,"key_word":keyWord], success: { (data) in
let model = data as! AddressListModel
......@@ -193,6 +206,11 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
self.navigationController?.pushViewController(vc, animated: true)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if isSelectlogAddress{
if adrInfo != nil {
return (adrInfo?.data!.count)!
}
}
if cus_id != nil {
if adrInfo != nil {
return (adrInfo?.data!.count)!
......@@ -200,15 +218,15 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
}
return adrArrs.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "DiZhiGuanLiCell") as! DiZhiGuanLiCell
cell.delegate = self
if cus_id != nil {//选择
if isSelectlogAddress {
let model = adrInfo?.data![indexPath.row]
cell.nameLbl.text = model?.consignee
cell.phoneLbl.text = model?.mobile
cell.adrLbl.text = model?.addr_cn
cell.adrLbl.text = model?.addr_name
if isSelectMotion == false {
cell.btnH.constant = 0
......@@ -218,40 +236,57 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
cell.btn.isSelected = true
}
}
}else{//列表
if adrArrs.count > 0 {
let model = adrArrs[indexPath.row]
cell.nameLbl.text = model.consignee
cell.phoneLbl.text = model.mobile
cell.adrLbl.text = model.province_cn! + model.address!
if model.city_cn != nil {
cell.adrLbl.text = model.province_cn! + model.city_cn! + model.address!
if model.district_cn != nil {
cell.adrLbl.text = model.province_cn! + model.city_cn! + model.district_cn! + model.address!
}else{
if cus_id != nil {//选择
let model = adrInfo?.data![indexPath.row]
cell.nameLbl.text = model?.consignee
cell.phoneLbl.text = model?.mobile
cell.adrLbl.text = model?.addr_cn
if isSelectMotion == false {
cell.btnH.constant = 0
cell.xValue.constant = 0
}else{
if indexPath == selectIdx {
cell.btn.isSelected = true
}
}
cell.btnH.constant = 0
cell.xValue.constant = 0
cell.blueLbl.isHidden = true
cell.yellowLbl.isHidden = true
if model.is_default == 1 {
cell.yellowLbl.isHidden = false
}else{//列表
if adrArrs.count > 0 {
let model = adrArrs[indexPath.row]
cell.nameLbl.text = model.consignee
cell.phoneLbl.text = model.mobile
cell.adrLbl.text = model.province_cn! + model.address!
if model.city_cn != nil {
cell.adrLbl.text = model.province_cn! + model.city_cn! + model.address!
if model.district_cn != nil {
cell.adrLbl.text = model.province_cn! + model.city_cn! + model.district_cn! + model.address!
}
}
cell.btnH.constant = 0
cell.xValue.constant = 0
cell.blueLbl.isHidden = true
cell.yellowLblLeft.constant = -18
}
if model.is_send_default == 1 {
cell.blueLbl.isHidden = false
cell.yellowLbl.isHidden = true
if model.is_default == 1 {
cell.yellowLbl.isHidden = false
cell.blueLbl.isHidden = true
cell.yellowLblLeft.constant = -18
}
if model.is_send_default == 1 {
cell.blueLbl.isHidden = false
cell.yellowLbl.isHidden = true
}
if (model.is_send_default == 1) && (model.is_default == 1) {
cell.yellowLbl.isHidden = false
cell.blueLbl.isHidden = false
cell.yellowLblLeft.constant = 10
}
}
if (model.is_send_default == 1) && (model.is_default == 1) {
cell.yellowLbl.isHidden = false
cell.blueLbl.isHidden = false
cell.yellowLblLeft.constant = 10
}
}
}
return cell
}
......
......@@ -9,7 +9,7 @@
import UIKit
import SwiftyJSON
protocol XinZengDiZhiViewControllerDelegate {
func XinZengDiZhiViewControllerFinishAction(name:String,phone:String,adr:String)
func XinZengDiZhiViewControllerFinishAction(name:String,phone:String,adr:String, data: AddAddressDataModel?)
}
class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,TitleAndTFAndBtnCellDelegate, UIPickerViewDelegate, UIPickerViewDataSource,SJMapViewControllerDelegate,UITextFieldDelegate,TitleAndSwitchCellDelegate,GeliAlertViewDelegate{
var address_id:Int?
......@@ -18,7 +18,7 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
if sender.tag == 999 {
AddressDel(["user_token":UserToken as Any,"address_id":address_id as Any], success: { (data) in
self.delegate?.XinZengDiZhiViewControllerFinishAction(name: self.nameStr, phone: self.phone, adr: self.adrStr)
self.delegate?.XinZengDiZhiViewControllerFinishAction(name: self.nameStr, phone: self.phone, adr: self.adrStr, data: nil)
self.navigationController?.popViewController(animated: true)
}) { (error) in
......@@ -64,7 +64,7 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
"is_send_default":send_default as Any,
]
EditAddress(dict, success: { (data) in
self.delegate?.XinZengDiZhiViewControllerFinishAction(name: self.nameStr, phone: self.phone, adr: self.adrStr)
self.delegate?.XinZengDiZhiViewControllerFinishAction(name: self.nameStr, phone: self.phone, adr: self.adrStr, data: nil)
self.navigationController?.popViewController(animated: true)
HUD.hide()
}) { (error) in
......@@ -87,7 +87,8 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
"is_send_default":send_default as Any,
]
AddAddress(dict, success: { (data) in
self.delegate?.XinZengDiZhiViewControllerFinishAction(name: self.nameStr, phone: self.phone, adr: self.adrStr)
let dataModel = data as! AddAddressModel
self.delegate?.XinZengDiZhiViewControllerFinishAction(name: self.nameStr, phone: self.phone, adr: self.adrStr, data: dataModel.data)
self.navigationController?.popViewController(animated: true)
HUD.hide()
}) { (error) in
......
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