Commit 910199a4 authored by lujunye's avatar lujunye

地址删除

parent f9e5a69e
...@@ -138,5 +138,7 @@ ...@@ -138,5 +138,7 @@
<string>Address/editAddress</string> <string>Address/editAddress</string>
<key>新增地址</key> <key>新增地址</key>
<string>Address/addAddress</string> <string>Address/addAddress</string>
<key>删除地址</key>
<string>Address/addressDel</string>
</dict> </dict>
</plist> </plist>
...@@ -67,3 +67,19 @@ func AddAddress(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture ...@@ -67,3 +67,19 @@ func AddAddress(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture
failture(error) failture(error)
} }
} }
/*
params-key(
user_token(用户token )
address_id 地址id
*/
func AddressDel(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) {
NetworkRequest.sharedInstance.postRequest("删除地址", params, { (rep:DataResponse<UpDataModel>) in
}, success: { (data) in
success(data)
}) { (error) in
failture(error)
}
}
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import Foundation import Foundation
import ObjectMapper import ObjectMapper
//发送验证码,验证短信验证码,修改登录密码,绑定、更换绑定格利支付账号,简单通用操作接口,普通订单发货,预售订单发货,订单绑定/更换绑定客户,确认订单,订单取消,修改订单商品价格,订单退款,普通订单退货,预售订单退货,修改订单支付方式(状态),商家仓库添加,商家仓库修改,商家仓库删除,提交下单,商品入库审核,商品入库,商品入库申请,商品出库,商品申请出库,商品审核出库,出库入库审核不通过,编辑地址 //发送验证码,验证短信验证码,修改登录密码,绑定、更换绑定格利支付账号,简单通用操作接口,普通订单发货,预售订单发货,订单绑定/更换绑定客户,确认订单,订单取消,修改订单商品价格,订单退款,普通订单退货,预售订单退货,修改订单支付方式(状态),商家仓库添加,商家仓库修改,商家仓库删除,提交下单,商品入库审核,商品入库,商品入库申请,商品出库,商品申请出库,商品审核出库,出库入库审核不通过,编辑地址,删除地址
class UpDataModel: Mappable { class UpDataModel: Mappable {
var code:Int? var code:Int?
......
...@@ -12,13 +12,70 @@ import LGButton ...@@ -12,13 +12,70 @@ import LGButton
protocol DZGLViewControllerDelegate { protocol DZGLViewControllerDelegate {
func DZGLViewControllerSelect(data:GetAddrsInfoDataModel) func DZGLViewControllerSelect(data:GetAddrsInfoDataModel)
} }
class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,SwipeTableViewCellDelegate,UISearchBarDelegate,SearchBarViewDelegate,XinZengDiZhiViewControllerDelegate{ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,SwipeTableViewCellDelegate,UISearchBarDelegate,SearchBarViewDelegate,XinZengDiZhiViewControllerDelegate,GeliAlertViewDelegate{
func sureGeliAlertViewAction(sender: UIButton) {
let UserToken = UserDefaults.standard.value(forKey: "user_token")
let model = adrArrs[sender.tag]
AddressDel(["user_token":UserToken as Any,"address_id":model.address_id as Any], success: { (data) in
self.loadData()
}) { (error) in
}
}
func XinZengDiZhiViewControllerFinishAction() { func XinZengDiZhiViewControllerFinishAction() {
loadData() loadData()
} }
func clearSearchAction() { //MARK:--搜索模块
//MAKR:--调起搜索后添加个蒙版本
var blackBtnView:UIButton! = nil
func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool {
print("调起搜索后添加个蒙版本")
blackBtnView = UIButton ()
blackBtnView.backgroundColor = UIColor.init(named: "提示视图背景色")
view.addSubview(blackBtnView)
blackBtnView.snp.makeConstraints { (make) in
make.left.right.bottom.equalToSuperview()
make.top.equalTo(searchBg.snp_bottom)
}
blackBtnView.addTarget(self, action: #selector(removeBlackBtnView), for: .touchUpInside)
return true
}
@objc func removeBlackBtnView(){
if blackBtnView != nil {
blackBtnView.removeFromSuperview()
searchV!.resignFirstResponder()
}
}
//MARK:--搜索按钮代理
func searchBarSearchButtonClicked(_ searchBar: UISearchBar) {
print("点击搜索关键字进行--\(searchBar.text)")
searchBar.resignFirstResponder()
if blackBtnView != nil {
blackBtnView.removeFromSuperview()
}
keyWord = searchBar.text!
loadData()
}
//MARK:--清空搜索代理
func clearSearchAction() {
}
//MARK:--编辑即将结束
func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
print("编辑即将结束了--")
removeBlackBtnView()
if keyWord.count > 0 {
keyWord = searchBar.text!
if keyWord.count == 0 {
loadData()
}
}
} }
var delegate:DZGLViewControllerDelegate? var delegate:DZGLViewControllerDelegate?
...@@ -48,8 +105,6 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -48,8 +105,6 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
self.view.addSubview(navbar) self.view.addSubview(navbar)
HUD.flash(.progress) HUD.flash(.progress)
let UserToken = UserDefaults.standard.value(forKey: "user_token") let UserToken = UserDefaults.standard.value(forKey: "user_token")
if cus_id != nil { if cus_id != nil {
searchBgH.constant = 0 searchBgH.constant = 0
...@@ -78,15 +133,7 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -78,15 +133,7 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
navbar.rightTitle = "新增" navbar.rightTitle = "新增"
searchBgH.constant = 45 searchBgH.constant = 45
AddressList(["user_token":UserToken as Any,"key_word":keyWord], success: { (data) in loadData()
let model = data as! AddressListModel
model.data?.forEach({ (item) in
self.adrArrs.append(item)
})
self.listView.reloadData()
}) { (error) in
}
} }
listView.separatorStyle = .none listView.separatorStyle = .none
// SetTopFrameView(view: listView, btmView: btmLbl) // SetTopFrameView(view: listView, btmView: btmLbl)
...@@ -108,12 +155,13 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -108,12 +155,13 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
@objc func loadData(){ @objc func loadData(){
let UserToken = UserDefaults.standard.value(forKey: "user_token") let UserToken = UserDefaults.standard.value(forKey: "user_token")
adrArrs.removeAll() adrArrs.removeAll()
AddressList(["user_token":UserToken as Any,"key_word":""], success: { (data) in AddressList(["user_token":UserToken as Any,"key_word":keyWord], success: { (data) in
let model = data as! AddressListModel let model = data as! AddressListModel
model.data?.forEach({ (item) in model.data?.forEach({ (item) in
self.adrArrs.append(item) self.adrArrs.append(item)
}) })
self.listView.reloadData() self.listView.reloadData()
HUD.hide()
}) { (error) in }) { (error) in
} }
...@@ -144,6 +192,7 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -144,6 +192,7 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
cell.nameLbl.text = model?.consignee cell.nameLbl.text = model?.consignee
cell.phoneLbl.text = model?.mobile cell.phoneLbl.text = model?.mobile
cell.adrLbl.text = model?.addr_cn cell.adrLbl.text = model?.addr_cn
if isSelectMotion == false { if isSelectMotion == false {
cell.btnH.constant = 0 cell.btnH.constant = 0
cell.xValue.constant = 0 cell.xValue.constant = 0
...@@ -160,6 +209,24 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -160,6 +209,24 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
cell.adrLbl.text = model.address cell.adrLbl.text = model.address
cell.btnH.constant = 0 cell.btnH.constant = 0
cell.xValue.constant = 0 cell.xValue.constant = 0
cell.blueLbl.isHidden = true
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
}
} }
} }
return cell return cell
...@@ -183,7 +250,13 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -183,7 +250,13 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
vc.tel = model.tel! vc.tel = model.tel!
vc.zip = model.zipcode! vc.zip = model.zipcode!
vc.is_send_default = false vc.is_send_default = false
vc.pcdStr = model.province_cn!+"-"+model.city_cn!+"-"+model.district_cn! vc.pcdStr = model.province_cn!
if model.city_cn != nil {
vc.pcdStr = model.province_cn! + "-" + model.city_cn!
if model.district_cn != nil {
vc.pcdStr = model.province_cn! + "-" + model.city_cn! + "-" + model.district_cn!
}
}
if model.is_send_default == 1 { if model.is_send_default == 1 {
vc.is_send_default = true vc.is_send_default = true
} }
...@@ -211,12 +284,20 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -211,12 +284,20 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
return options return options
} }
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]? { func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath, for orientation: SwipeActionsOrientation) -> [SwipeAction]? {
let tag = indexPath.row
//创建“删除”事件按钮 //创建“删除”事件按钮
let deleteAction = SwipeAction(style: .destructive, title: nil) { let deleteAction = SwipeAction(style: .destructive, title: nil) {
action, indexPath in action, indexPath in
//将对应条目的数据删除 //将对应条目的数据删除
tableView.reloadData() let alertView = GeliAlertView(frame: self.view.window!.bounds)
alertView.delegate = self
alertView.tishiLbl.text = ""
alertView.titileLbl.text = "是否删除地址?"
alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确定"), for: .normal)
alertView.rightBtn.tag = tag
self.view.window?.addSubview(alertView)
} }
deleteAction.image = UIImage(named: "shanchuWhite") deleteAction.image = UIImage(named: "shanchuWhite")
deleteAction.backgroundColor = UIColor(named: "#F57575") deleteAction.backgroundColor = UIColor(named: "#F57575")
......
...@@ -11,6 +11,7 @@ import SwipeCellKit ...@@ -11,6 +11,7 @@ import SwipeCellKit
class DiZhiGuanLiCell: SwipeTableViewCell { class DiZhiGuanLiCell: SwipeTableViewCell {
@IBOutlet weak var yellowLblLeft: NSLayoutConstraint!
@IBOutlet weak var btn: UIButton! @IBOutlet weak var btn: UIButton!
@IBOutlet weak var adrLbl: UILabel! @IBOutlet weak var adrLbl: UILabel!
@IBOutlet weak var yellowLbl: UILabel! @IBOutlet weak var yellowLbl: UILabel!
......
...@@ -137,6 +137,7 @@ ...@@ -137,6 +137,7 @@
<outlet property="phoneLbl" destination="0Zd-v3-Vtu" id="3CH-Ai-KUY"/> <outlet property="phoneLbl" destination="0Zd-v3-Vtu" id="3CH-Ai-KUY"/>
<outlet property="xValue" destination="4ok-AC-XWT" id="Lfk-u8-Fp8"/> <outlet property="xValue" destination="4ok-AC-XWT" id="Lfk-u8-Fp8"/>
<outlet property="yellowLbl" destination="mWp-V0-KaZ" id="La4-PQ-SDN"/> <outlet property="yellowLbl" destination="mWp-V0-KaZ" id="La4-PQ-SDN"/>
<outlet property="yellowLblLeft" destination="Q58-SO-drh" id="Rxw-kX-5Wm"/>
</connections> </connections>
<point key="canvasLocation" x="131.15942028985509" y="121.54017857142857"/> <point key="canvasLocation" x="131.15942028985509" y="121.54017857142857"/>
</tableViewCell> </tableViewCell>
......
...@@ -14,14 +14,32 @@ protocol XinZengDiZhiViewControllerDelegate { ...@@ -14,14 +14,32 @@ protocol XinZengDiZhiViewControllerDelegate {
class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,TitleAndTFAndBtnCellDelegate, UIPickerViewDelegate, UIPickerViewDataSource,SJMapViewControllerDelegate,UITextFieldDelegate,TitleAndSwitchCellDelegate,GeliAlertViewDelegate{ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,TitleAndTFAndBtnCellDelegate, UIPickerViewDelegate, UIPickerViewDataSource,SJMapViewControllerDelegate,UITextFieldDelegate,TitleAndSwitchCellDelegate,GeliAlertViewDelegate{
var address_id:Int? var address_id:Int?
func sureGeliAlertViewAction(sender: UIButton) { func sureGeliAlertViewAction(sender: UIButton) {
let UserToken = UserDefaults.standard.value(forKey: "user_token")
if sender.tag == 999 {
AddressDel(["user_token":UserToken as Any,"address_id":address_id as Any], success: { (data) in
self.delegate?.XinZengDiZhiViewControllerFinishAction()
self.navigationController?.popViewController(animated: true)
}) { (error) in
}
return
}
HUD.flash(.progress) HUD.flash(.progress)
print("adfb == ",provinceIndex)
let proDict = addressArray[provinceIndex] as! Dictionary<String,Any> let proDict = addressArray[provinceIndex] as! Dictionary<String,Any>
var cityDict:Dictionary<String,Any> = Dictionary()
var areaDict:Dictionary<String,Any> = Dictionary()
cityDict["area_id"] = ""
areaDict["area_id"] = ""
if (proDict["city_list"] as! NSArray).count > 0 {
cityDict = (proDict["city_list"] as! NSArray)[cityIndex] as! Dictionary<String, Any>
if (cityDict["district_list"] as! NSArray).count > 0 {
areaDict = (cityDict["district_list"] as! NSArray)[areaIndex] as! Dictionary<String,Any>
}
}
let cityDict = (proDict["city_list"] as! NSArray)[cityIndex] as! [String: AnyObject]
let areaDict = (cityDict["district_list"] as! NSArray)[areaIndex] as! Dictionary<String,Any>
let UserToken = UserDefaults.standard.value(forKey: "user_token")
var defalut = 0 var defalut = 0
if is_default { if is_default {
defalut = 1 defalut = 1
...@@ -127,10 +145,16 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -127,10 +145,16 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
let item = addressArray[i] as! Dictionary<String,Any> let item = addressArray[i] as! Dictionary<String,Any>
if item["area_id"] as! Int == provinceIndex { if item["area_id"] as! Int == provinceIndex {
let citys = item["city_list"] as! Array<Dictionary<String,Any>> let citys = item["city_list"] as! Array<Dictionary<String,Any>>
if citys.count == 0 {
provinceIndex = i
}
for j in 0 ..< citys.count { for j in 0 ..< citys.count {
let cItem = citys[j] let cItem = citys[j]
if cItem["area_id"] as! Int == cityIndex { if cItem["area_id"] as! Int == cityIndex {
let districts = cItem["district_list"] as! Array<Dictionary<String,Any>> let districts = cItem["district_list"] as! Array<Dictionary<String,Any>>
if districts.count == 0 {
cityIndex = j
}
for k in 0 ..< districts.count{ for k in 0 ..< districts.count{
let dItem = districts[k] let dItem = districts[k]
if dItem["area_id"] as! Int == areaIndex{ if dItem["area_id"] as! Int == areaIndex{
...@@ -152,12 +176,11 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -152,12 +176,11 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
} }
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
getIndex() getIndex()
navbar.title = navTitle navbar.title = navTitle
if navTitle == "编辑地址" { if navTitle == "编辑地址" {
// navbar.rightTitle = "删除" navbar.rightTitle = "删除"
if pcdStr != nil { if pcdStr != nil {
holderArr.insert(pcdStr!, at: 1) holderArr.insert(pcdStr!, at: 1)
holderArr.remove(at: 2) holderArr.remove(at: 2)
...@@ -183,12 +206,30 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -183,12 +206,30 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
} }
@objc func adrSelectFinish(sender:UIButton){ @objc func adrSelectFinish(sender:UIButton){
var proName = ""
var cityName = ""
var areaName = ""
let proDict = addressArray[provinceIndex] as! Dictionary<String,Any> let proDict = addressArray[provinceIndex] as! Dictionary<String,Any>
proName = proDict["area_name"] as! String
if (proDict["city_list"] as! NSArray).count > 0 {
let cityDict = (proDict["city_list"] as! NSArray)[cityIndex] as! [String: AnyObject]
cityName = cityDict["area_name"] as! String
if (cityDict["district_list"] as! NSArray).count > 0 {
let areaDict = (cityDict["district_list"] as! NSArray)[areaIndex] as! Dictionary<String,Any>
areaName = areaDict["area_name"] as! String
}
}
let cityDict = (proDict["city_list"] as! NSArray)[cityIndex] as! [String: AnyObject]
let areaDict = (cityDict["district_list"] as! NSArray)[areaIndex] as! Dictionary<String,Any>
let selectAdr = "\(proDict["area_name"]!)"+"-"+"\(cityDict["area_name"]!)"+"-"+"\(areaDict["area_name"]!)" var selectAdr = proName
if cityName.count > 0 {
selectAdr = proName + "-" + cityName
if areaName.count > 0 {
selectAdr = proName + "-" + cityName + "-" + areaName
}
}
holderArr.insert(selectAdr, at: 1) holderArr.insert(selectAdr, at: 1)
holderArr.remove(at: 2) holderArr.remove(at: 2)
bgBtn?.removeFromSuperview() bgBtn?.removeFromSuperview()
...@@ -268,7 +309,13 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -268,7 +309,13 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
} }
func rightBtnClick() { func rightBtnClick() {
print("删除") let alertView = GeliAlertView(frame: self.view.window!.bounds)
alertView.delegate = self
alertView.tishiLbl.text = ""
alertView.titileLbl.text = "是否删除地址?"
alertView.rightBtn.setAttributedTitle(NSAttributedString(string: "确定"), for: .normal)
alertView.rightBtn.tag = 999
self.view.window?.addSubview(alertView)
} }
//MARK: - cell delegate //MARK: - cell delegate
func TitleAndTFAndBtnCellBtnClick() { func TitleAndTFAndBtnCellBtnClick() {
...@@ -394,6 +441,7 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -394,6 +441,7 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
if component == 0 { if component == 0 {
return self.addressArray.count return self.addressArray.count
} else if component == 1 { } else if component == 1 {
print("alkjdflkasd == ",provinceIndex)
let province = self.addressArray[provinceIndex] as! Dictionary<String,Any> let province = self.addressArray[provinceIndex] as! Dictionary<String,Any>
return (province["city_list"]! as AnyObject).count return (province["city_list"]! as AnyObject).count
} else { } else {
...@@ -504,7 +552,8 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -504,7 +552,8 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
func switchClick(content: UISwitch, cell: TitleAndSwitchCell) { func switchClick(content: UISwitch, cell: TitleAndSwitchCell) {
if cell.tag == 1 {//寄件 if cell.tag == 1 {//寄件
is_send_default = content.isOn is_send_default = content.isOn
}else{//收件
is_default = content.isOn
} }
is_default = content.isOn
} }
} }
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