Commit f988f954 authored by lujunye's avatar lujunye

33

parent 5caefc91
...@@ -27,10 +27,10 @@ let systemVersion = (UIDevice.current.systemVersion as String) ...@@ -27,10 +27,10 @@ let systemVersion = (UIDevice.current.systemVersion as String)
//接口地址 //接口地址
//test //test
//let SERVERCE_ImageHost = "https://z.gelifood.com/" let SERVERCE_ImageHost = "https://z.gelifood.com/"
//let SERVERCE_HOST = "https://z.gelifood.com/admin/" let SERVERCE_HOST = "https://z.gelifood.com/admin/"
let SERVERCE_ImageHost = "https://zx.gelifood.com/" //let SERVERCE_ImageHost = "https://zx.gelifood.com/"
let SERVERCE_HOST = "https://zx.gelifood.com/admin/" //let SERVERCE_HOST = "https://zx.gelifood.com/admin/"
//online //online
//视图常量 //视图常量
......
...@@ -420,5 +420,13 @@ ...@@ -420,5 +420,13 @@
<string>Distribution/delDbtListInfo</string> <string>Distribution/delDbtListInfo</string>
<key>设置商品参与分销</key> <key>设置商品参与分销</key>
<string>Distribution/dbtSetDbtGoods</string> <string>Distribution/dbtSetDbtGoods</string>
<key>修改客户收货地址</key>
<string>Customer/saveShippingAddress</string>
<key>新增客户收货地址</key>
<string>Customer/newShippingAddress</string>
<key>删除客户地址</key>
<string>Customer/deleteCusAdd</string>
<key>特殊客户地址查询</key>
<string>Customer/getAddrsInfoCaddr</string>
</dict> </dict>
</plist> </plist>
...@@ -52,7 +52,7 @@ cus_name 客户名 ...@@ -52,7 +52,7 @@ cus_name 客户名
phone 联系电话 phone 联系电话
user_id 绑定用户的用户id user_id 绑定用户的用户id
discounts_rate 优惠率,使用时除100 discounts_rate 优惠率,使用时除100
address_id 新增地址时返回的address_id,多个就用英文逗号隔开的字符串。新增客户时新增了地址就必传
*/ */
func cusAdd(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) { func cusAdd(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) {
NetworkRequest.sharedInstance.postRequest("新增客户", params, { (rep:DataResponse<UpDataModel>) in NetworkRequest.sharedInstance.postRequest("新增客户", params, { (rep:DataResponse<UpDataModel>) in
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import Foundation import Foundation
import ObjectMapper import ObjectMapper
//发送验证码,验证短信验证码,修改登录密码,绑定、更换绑定格利支付账号,简单通用操作接口,普通订单发货,预售订单发货,订单绑定/更换绑定客户,确认订单,订单取消,修改订单商品价格,订单退款,普通订单退货,预售订单退货,修改订单支付方式(状态),商家仓库添加,商家仓库修改,商家仓库删除,提交下单,商品入库申请,商品出库,商品申请出库,商品审核出库,出库入库审核不通过,编辑地址,删除地址,新增采购单,审核采购单,撤销入库,采购单修改支付状态,供应商编辑,新增供应商,编辑客户,新增客户,应收账款收款,设为未收,取消采购单,修改采购订单,新增品牌,拒绝退款,确认用户退款到账,拒绝接单,审核同意退货退款,取消订单审核,确认收到退货,审核同意退货或退款,订单确认收货,取消运单,支付运费,选定地址添加收发货历史,取消货拉拉订单,货拉拉二次支付,货拉拉格利支付,发票消息短信通知,修改电子发票链接地址,分销分账设置,供应商新增店铺,标记已人工结算,铺货与取消铺货,终止合作,分销商品管理,分销商新增供应商,审核操作(通过和不通过),删除客户,新增分销员,删除分销员,修改不二制油订单打印,店长审核通过、审核通过待补齐资料、不通过,保存店长审核信息(商家信息),拼拼货取消订单,供应商新增代理商(批量和单个新增代理商),终止与代理商合作,给代理商设置分销商品,商品上下架,供应商取消商品分销,上下架(设置分销商品给分销商),代理商终止与供应商合作,代理商的铺货或分销设置,取消分销,代理商设置分销商品上下架商品,代理商终止合作,分销商新增代理商,删除下游店长,新增店铺,上下架,上游商品上下架,上游取消分销,设置商品参与分销, //发送验证码,验证短信验证码,修改登录密码,绑定、更换绑定格利支付账号,简单通用操作接口,普通订单发货,预售订单发货,订单绑定/更换绑定客户,确认订单,订单取消,修改订单商品价格,订单退款,普通订单退货,预售订单退货,修改订单支付方式(状态),商家仓库添加,商家仓库修改,商家仓库删除,提交下单,商品入库申请,商品出库,商品申请出库,商品审核出库,出库入库审核不通过,编辑地址,删除地址,新增采购单,审核采购单,撤销入库,采购单修改支付状态,供应商编辑,新增供应商,编辑客户,新增客户,应收账款收款,设为未收,取消采购单,修改采购订单,新增品牌,拒绝退款,确认用户退款到账,拒绝接单,审核同意退货退款,取消订单审核,确认收到退货,审核同意退货或退款,订单确认收货,取消运单,支付运费,选定地址添加收发货历史,取消货拉拉订单,货拉拉二次支付,货拉拉格利支付,发票消息短信通知,修改电子发票链接地址,分销分账设置,供应商新增店铺,标记已人工结算,铺货与取消铺货,终止合作,分销商品管理,分销商新增供应商,审核操作(通过和不通过),删除客户,新增分销员,删除分销员,修改不二制油订单打印,店长审核通过、审核通过待补齐资料、不通过,保存店长审核信息(商家信息),拼拼货取消订单,供应商新增代理商(批量和单个新增代理商),终止与代理商合作,给代理商设置分销商品,商品上下架,供应商取消商品分销,上下架(设置分销商品给分销商),代理商终止与供应商合作,代理商的铺货或分销设置,取消分销,代理商设置分销商品上下架商品,代理商终止合作,分销商新增代理商,删除下游店长,新增店铺,上下架,上游商品上下架,上游取消分销,设置商品参与分销,修改客户收货地址,删除客户地址,
class UpDataModel: Mappable { class UpDataModel: Mappable {
......
...@@ -483,3 +483,75 @@ func dbtSetDbtGoods(_ params:[String:Any],success:@escaping (_ res:Any)->(),fail ...@@ -483,3 +483,75 @@ func dbtSetDbtGoods(_ params:[String:Any],success:@escaping (_ res:Any)->(),fail
failture(error) failture(error)
} }
} }
//MARK:-- 修改客户收货地址
/*
user_token 1 string 验证token 必填
cus_id 1 int 客户id 必填
consignee 1 string 收货人的名字 必填
province 1 int 省份 必填
city 1 int 城市 必填
district 1 int 地区 必填
street 0 int 街道 非必填
address 1 string 详细地址 必填
mobile 1 int 手机 必填
is_default 1 int 是否为默认收货地址:1默认 0非默认 必填
*/
func saveShippingAddress(_ 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)
}
}
//MARK:-- 删除客户地址
/*
user_token 1 string 验证token 必填
caddr_id 1 int 客户地址id(getAddrsInfo接口有返回) 必填
*/
func deleteCusAdd(_ 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)
}
}
//MARK:-- 新增客户收货地址
/*
user_token 1 string 验证token 必填
cus_id 0 int 客户id【注:只有在新增客户时先新增了地址才可以不传,新增客户时把返回的address_id英文逗号拼接返回。其他有客户的情况下必填】 非必填
consignee 1 string 收货人的名字 必填
province 1 int 省份 必填
city 1 int 城市 必填
district 1 int 地区 必填
street 0 int 街道 非必填
address 1 string 详细地址 必填
mobile 1 int 手机 必填
is_default 1 int 是否为默认收货地址:1默认 0非默认 必填
*/
func newShippingAddress(_ params:[String:Any],success:@escaping (_ res:Any)->(),failture:@escaping(_ error:Error)->()) {
NetworkRequest.sharedInstance.postRequest("新增客户收货地址", params, { (rep:DataResponse<newShippingAddress_model>) in
}, success: { (data) in
success(data)
}) { (error) in
failture(error)
}
}
//MARK:-- 特殊客户地址查询
/*
user_token 1 string 验证token 必填
caddr_id 1 string caddr_id就是接口【saveShippingAddress】返回的address_id,用英文逗号隔开 必填
*/
func getAddrsInfoCaddr(_ 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)
}
}
...@@ -8,7 +8,30 @@ ...@@ -8,7 +8,30 @@
import Foundation import Foundation
import ObjectMapper import ObjectMapper
//MARK: - 新增客户收货地址
class newShippingAddress_model: Mappable {
var code:Int?
var message : String?
var data :newShippingAddress_data_model?
required init?( map: Map) {
}
func mapping(map: Map) {
code <- map["code"]
message <- map["message"]
data <- map["data"]
}
}
class newShippingAddress_data_model: Mappable {
var address_id : String?
required init?( map: Map) {
}
func mapping(map: Map) {
address_id <- map["address_id"]
}
}
//MARK: - 代理商下拉框列表查询(查询合作着的代理商) //MARK: - 代理商下拉框列表查询(查询合作着的代理商)
class ageConList_model: Mappable { class ageConList_model: Mappable {
var code:Int? var code:Int?
......
...@@ -45,9 +45,7 @@ class HGImagePickerController: UIViewController { ...@@ -45,9 +45,7 @@ class HGImagePickerController: UIViewController {
//异步加载表格数据,需要在主线程中调用reloadData() 方法 //异步加载表格数据,需要在主线程中调用reloadData() 方法
DispatchQueue.main.async{ DispatchQueue.main.async{
self.tableView?.reloadData() self.tableView?.reloadData() //首次进来后直接进入第一个相册图片展示页面(相机胶卷)
//首次进来后直接进入第一个相册图片展示页面(相机胶卷)
if let imageCollectionVC = self.storyboard? if let imageCollectionVC = self.storyboard?
.instantiateViewController(withIdentifier: "hgImageCollectionVC") .instantiateViewController(withIdentifier: "hgImageCollectionVC")
as? HGImageCollectionViewController{ as? HGImageCollectionViewController{
......
...@@ -16,6 +16,14 @@ import IQKeyboardManagerSwift ...@@ -16,6 +16,14 @@ import IQKeyboardManagerSwift
class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,JiTuoWuXinXiViewDelegate,JiPaiFangShiViewControllerDelegate,ZengZhiServicesViewControllerDelegate,AdressSelectCellDelegate,DZGLViewControllerDelegate,XinZengDiZhiViewControllerDelegate,TitleAndTFBtnCellDelegate,WenDuCellDelegate,LogisticalSelectViewDelegate, UIPickerViewDataSource, UIPickerViewDelegate, GLAlertSelectViewDelegate,CLLocationManagerDelegate, CityListViewControllerDelegate,ToAndFormSelectViewControllerDelegate,WayBillAddressCanDelItemCellDelegate,HLLTopCellDelegate,OtherDemandViewControllerDelegate,OnlyViewCellDelegate, XiaDanUserInfoViewControllerDelegate, P_P_H_Time_Select_View_Delegate,P_P_H_Adr_VC_Delegate, Suc_LOG_Cell_Delegate,PaymentViewDelegate{ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,JiTuoWuXinXiViewDelegate,JiPaiFangShiViewControllerDelegate,ZengZhiServicesViewControllerDelegate,AdressSelectCellDelegate,DZGLViewControllerDelegate,XinZengDiZhiViewControllerDelegate,TitleAndTFBtnCellDelegate,WenDuCellDelegate,LogisticalSelectViewDelegate, UIPickerViewDataSource, UIPickerViewDelegate, GLAlertSelectViewDelegate,CLLocationManagerDelegate, CityListViewControllerDelegate,ToAndFormSelectViewControllerDelegate,WayBillAddressCanDelItemCellDelegate,HLLTopCellDelegate,OtherDemandViewControllerDelegate,OnlyViewCellDelegate, XiaDanUserInfoViewControllerDelegate, P_P_H_Time_Select_View_Delegate,P_P_H_Adr_VC_Delegate, Suc_LOG_Cell_Delegate,PaymentViewDelegate{
func DZGLViewController_adr(adr_id: String) {
//此处无用
}
func XinZengDiZhiViewControllerFinishAction_kehu(adr_id: String) {
//此处无用
}
func PaymentViewClose() { func PaymentViewClose() {
paymentView?.removeFromSuperview() paymentView?.removeFromSuperview()
paymentView = nil paymentView = nil
......
...@@ -10,6 +10,10 @@ import UIKit ...@@ -10,6 +10,10 @@ import UIKit
import IQKeyboardManagerSwift import IQKeyboardManagerSwift
class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,UITableViewDelegate,DaiKeXiaDanFooterViewDelegate,TitleAndBtnCellDelegate,GLAlertSelectViewDelegate,DZGLViewControllerDelegate,XuanZeShangPinViewControllerDelegate,DaiKeXiaDanGouWuCellDelegate,GuanLianKehuVCDelegate,XiuGaiYuShouJiaViewControllerDelegate,TitleAndTFCellDelegate, GeliAlertViewDelegate,UITextFieldDelegate{ class DaiKeXiaDanGouWuViewController: BaseViewController,UITableViewDataSource,UITableViewDelegate,DaiKeXiaDanFooterViewDelegate,TitleAndBtnCellDelegate,GLAlertSelectViewDelegate,DZGLViewControllerDelegate,XuanZeShangPinViewControllerDelegate,DaiKeXiaDanGouWuCellDelegate,GuanLianKehuVCDelegate,XiuGaiYuShouJiaViewControllerDelegate,TitleAndTFCellDelegate, GeliAlertViewDelegate,UITextFieldDelegate{
func DZGLViewController_adr(adr_id: String) {
//此处无用
}
func DaiKeXiaDanGouWuCell_select_pi_ci(cell: DaiKeXiaDanGouWuCell) { func DaiKeXiaDanGouWuCell_select_pi_ci(cell: DaiKeXiaDanGouWuCell) {
print("选择批次2") print("选择批次2")
} }
......
...@@ -11,8 +11,24 @@ import SwipeCellKit ...@@ -11,8 +11,24 @@ import SwipeCellKit
import LGButton import LGButton
protocol DZGLViewControllerDelegate { protocol DZGLViewControllerDelegate {
func DZGLViewControllerSelect(data:GetAddrsInfoDataModel) func DZGLViewControllerSelect(data:GetAddrsInfoDataModel)
func DZGLViewController_adr(adr_id:String)
} }
class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,SwipeTableViewCellDelegate,UISearchBarDelegate,SearchBarViewDelegate,XinZengDiZhiViewControllerDelegate,GeliAlertViewDelegate{ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,SwipeTableViewCellDelegate,UISearchBarDelegate,SearchBarViewDelegate,XinZengDiZhiViewControllerDelegate,GeliAlertViewDelegate{
func XinZengDiZhiViewControllerFinishAction_kehu(adr_id: String) {
if adr_id.count > 0 {
address_id_arr.append(adr_id)
if address_id_arr.count > 1 {
delegate?.DZGLViewController_adr(adr_id: address_id_arr.joined(separator: ","))
}else{
delegate?.DZGLViewController_adr(adr_id: adr_id)
}
}
listView.mj_header?.beginRefreshing()
}
@IBOutlet weak var holder_view: UIView! @IBOutlet weak var holder_view: UIView!
var is_keHu_list = false var is_keHu_list = false
var kehu_adrArr:Array<GetAddrsInfoDataModel> = [] var kehu_adrArr:Array<GetAddrsInfoDataModel> = []
...@@ -89,7 +105,7 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -89,7 +105,7 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
var selectIdx:IndexPath? var selectIdx:IndexPath?
var adrInfo:GetAddrsInfoModel? var adrInfo:GetAddrsInfoModel?
var isSelectlogAddress = false var isSelectlogAddress = false
var address_id_arr:Array<String> = []
//列表 //列表
var adrArrs:Array<AddressListDataModel> = [] var adrArrs:Array<AddressListDataModel> = []
@IBOutlet weak var searchBg: UIView! @IBOutlet weak var searchBg: UIView!
...@@ -127,21 +143,6 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -127,21 +143,6 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
HUD.hide() HUD.hide()
}) { (error) in }) { (error) in
}
}else{
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)
if self.adrInfo?.data?.count == 0 {
self.holder_view.isHidden = false
}
self.listView.reloadData()
HUD.hide()
}) { (error) in
} }
}else{ }else{
//searchbar //searchbar
...@@ -166,7 +167,6 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -166,7 +167,6 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
self.listView!.mj_header = headerMJ self.listView!.mj_header = headerMJ
self.listView.mj_header?.beginRefreshing() self.listView.mj_header?.beginRefreshing()
} }
}
listView.separatorStyle = .none listView.separatorStyle = .none
// SetTopFrameView(view: listView, btmView: btmLbl) // SetTopFrameView(view: listView, btmView: btmLbl)
...@@ -191,11 +191,48 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -191,11 +191,48 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
listView.estimatedRowHeight = 49 listView.estimatedRowHeight = 49
listView.rowHeight = UITableView.automaticDimension listView.rowHeight = UITableView.automaticDimension
// Do any additional setup after loading the view.
} }
@objc func loadData(){ @objc func loadData(){
if is_keHu_list {
if cus_id != nil {
getAddrsInfo(["user_token":UserToken as Any,"cus_id":cus_id as Any], success: { (data) in
self.adrInfo = (data as! GetAddrsInfoModel)
self.kehu_adrArr.removeAll()
if self.adrInfo?.data?.count == 0 {
self.holder_view.isHidden = false
}else{
self.holder_view.isHidden = true
self.adrInfo?.data?.forEach({ item in
self.kehu_adrArr.append(item)
})
}
self.listView.reloadData()
self.listView.mj_header?.endRefreshing()
}) { (error) in
self.listView.mj_header?.endRefreshing()
}
}else{
getAddrsInfoCaddr(["user_token":UserToken as Any,"caddr_id":address_id_arr.joined(separator: ",") as Any]) { data in
self.adrInfo = (data as! GetAddrsInfoModel)
self.kehu_adrArr.removeAll()
if self.adrInfo?.data?.count == 0 {
self.holder_view.isHidden = false
}else{
self.holder_view.isHidden = true
self.adrInfo?.data?.forEach({ item in
self.kehu_adrArr.append(item)
})
}
self.listView.reloadData()
self.listView.mj_header?.endRefreshing()
} failture: { err in
self.listView.mj_header?.endRefreshing()
}
}
return
}
adrArrs.removeAll() adrArrs.removeAll()
AddressList(["user_token":UserToken as Any,"key_word":keyWord], 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
...@@ -207,9 +244,7 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -207,9 +244,7 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
self.adrArrs.append(item) self.adrArrs.append(item)
}) })
} }
print("adrs == ",self.adrArrs.count)
self.listView.reloadData() self.listView.reloadData()
self.listView.mj_header?.endRefreshing() self.listView.mj_header?.endRefreshing()
}) { (data) in }) { (data) in
self.listView.mj_header?.endRefreshing() self.listView.mj_header?.endRefreshing()
...@@ -221,6 +256,10 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -221,6 +256,10 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
let vc = XinZengDiZhiViewController() let vc = XinZengDiZhiViewController()
vc.navTitle = "新增地址" vc.navTitle = "新增地址"
vc.delegate = self vc.delegate = self
vc.is_keHu_list = is_keHu_list
if cus_id != nil {
vc.cus_id = cus_id!
}
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
} }
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
...@@ -330,28 +369,31 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData ...@@ -330,28 +369,31 @@ class DZGLViewController: BaseViewController,UITableViewDelegate,UITableViewData
if kehu_adrArr.count > 0 { if kehu_adrArr.count > 0 {
let model = kehu_adrArr[indexPath.row] let model = kehu_adrArr[indexPath.row]
let vc = XinZengDiZhiViewController() let vc = XinZengDiZhiViewController()
vc.is_keHu_list = true
vc.cus_id = cus_id!
vc.caddr_id = model.caddr_id!
vc.delegate = self vc.delegate = self
vc.navTitle = "编辑地址" vc.navTitle = "编辑地址"
vc.provinceIndex = model.province! vc.provinceIndex = model.province!
vc.cityIndex = model.city! vc.cityIndex = model.city!
vc.areaIndex = model.district! vc.areaIndex = model.district!
// vc.address_id = model.address_id! // vc.address_id = model.address_id!
vc.adrStr = model.address! vc.adrStr = model.address!
vc.nameStr = model.consignee! vc.nameStr = model.consignee!
vc.phone = model.mobile! vc.phone = model.mobile!
// vc.tel = model.tel!
// vc.zip = model.zipcode!
vc.is_send_default = false vc.is_send_default = false
// vc.pcdStr = model.province_cn! if model.province_cn != nil {
// if model.city_cn != nil { vc.pcdStr = model.province_cn!
// vc.pcdStr = model.province_cn! + "-" + model.city_cn! if model.city_cn != nil {
// if model.district_cn != nil { vc.pcdStr = model.province_cn! + "-" + model.city_cn!
// vc.pcdStr = model.province_cn! + "-" + model.city_cn! + "-" + model.district_cn! if model.district_cn != nil {
// } vc.pcdStr = model.province_cn! + "-" + model.city_cn! + "-" + model.district_cn!
// } }
// if model.is_send_default == 1 { }
// vc.is_send_default = true }
// } //if model.is_send_default == 1 {
// vc.is_send_default = true
//}
vc.is_default = false vc.is_default = false
if model.is_default == 1 { if model.is_default == 1 {
vc.is_default = true vc.is_default = true
......
...@@ -10,18 +10,32 @@ import UIKit ...@@ -10,18 +10,32 @@ import UIKit
import SwiftyJSON import SwiftyJSON
protocol XinZengDiZhiViewControllerDelegate { protocol XinZengDiZhiViewControllerDelegate {
func XinZengDiZhiViewControllerFinishAction(name:String,phone:String,adr:String, data: AddAddressDataModel?,province_name:String,city_name:String,district_name:String) func XinZengDiZhiViewControllerFinishAction(name:String,phone:String,adr:String, data: AddAddressDataModel?,province_name:String,city_name:String,district_name:String)
func XinZengDiZhiViewControllerFinishAction_kehu(adr_id:String)
} }
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?
var is_keHu_list = false
var cus_id = 0
var caddr_id = -1
func sureGeliAlertViewAction(sender: UIButton) { func sureGeliAlertViewAction(sender: UIButton) {
let UserToken = UserDefaults.standard.value(forKey: "user_token") let UserToken = UserDefaults.standard.value(forKey: "user_token")
if sender.tag == 999 { if sender.tag == 999 {//删除地址
if is_keHu_list {
print("1")
deleteCusAdd(["user_token":UserToken as Any,"caddr_id":caddr_id as Any]) { data in
self.delegate?.XinZengDiZhiViewControllerFinishAction_kehu(adr_id: "")
self.navigationController?.popViewController(animated: true)
} failture: { err in
}
}else{
AddressDel(["user_token":UserToken as Any,"address_id":address_id as Any], success: { (data) in 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, data: nil,province_name:"",city_name:"",district_name:"") self.delegate?.XinZengDiZhiViewControllerFinishAction(name: self.nameStr, phone: self.phone, adr: self.adrStr, data: nil,province_name:"",city_name:"",district_name:"")
self.navigationController?.popViewController(animated: true) self.navigationController?.popViewController(animated: true)
}) { (error) in }) { (error) in
}
} }
return return
} }
...@@ -52,6 +66,28 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -52,6 +66,28 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
send_default = 1 send_default = 1
} }
if navTitle == "编辑地址"{ if navTitle == "编辑地址"{
if is_keHu_list {
print("2")
let dict = [
"user_token":UserToken as Any,
"caddr_id":caddr_id as Any,
"consignee":nameStr as Any,
"province":proDict["area_id"]! as Any,
"city":cityDict["area_id"]! as Any,
"district":areaDict["area_id"]! as Any,
"street":0 as Any,
"address":adrStr as Any,
"mobile":phone as Any,
"is_default":defalut as Any,
]
saveShippingAddress(dict) { data in
self.delegate?.XinZengDiZhiViewControllerFinishAction_kehu(adr_id: "")
self.navigationController?.popViewController(animated: true)
} failture: { err in
}
}else{
let dict = [ let dict = [
"user_token":UserToken as Any, "user_token":UserToken as Any,
"address_id":address_id as Any, "address_id":address_id as Any,
...@@ -73,8 +109,32 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -73,8 +109,32 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
}) { (error) in }) { (error) in
} }
}
}else{ }else{
if is_keHu_list {
print("3")
let dict = [
"user_token":UserToken as Any,
"cus_id":cus_id as Any,
"consignee":nameStr as Any,
"province":proDict["area_id"]! as Any,
"city":cityDict["area_id"]! as Any,
"district":areaDict["area_id"]! as Any,
"street":0 as Any,
"address":adrStr as Any,
"mobile":phone as Any,
"is_default":defalut as Any
]
newShippingAddress(dict) { data in
let dataModel = data as! newShippingAddress_model
self.delegate?.XinZengDiZhiViewControllerFinishAction_kehu(adr_id: (dataModel.data?.address_id)!)
self.navigationController?.popViewController(animated: true)
} failture: { err in
}
}else{
let dict = [ let dict = [
"user_token":UserToken as Any, "user_token":UserToken as Any,
"consignee":nameStr as Any, "consignee":nameStr as Any,
...@@ -98,6 +158,8 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -98,6 +158,8 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
} }
} }
}
} }
var delegate:XinZengDiZhiViewControllerDelegate? var delegate:XinZengDiZhiViewControllerDelegate?
...@@ -115,11 +177,11 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -115,11 +177,11 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
var is_send_default = false//默认发货 var is_send_default = false//默认发货
var is_default = false //默认收货 var is_default = false //默认收货
let titleArr = ["收货人:","地址:","详细地址:","手机号:","电话:","邮编:"]
var holderArr = ["请填写收货人姓名","请选择城市","请输入详细地址","请输入手机号","请输入电话","请输入邮编"] var holderArr = ["请填写收货人姓名","请选择城市","请输入详细地址","请输入手机号","请输入电话","请输入邮编"]
@IBOutlet weak var listView: UITableView! @IBOutlet weak var listView: UITableView!
@IBAction func saveAction(_ sender: Any) { @IBAction func saveAction(_ sender: Any) {
print("save ") print("save")
if nameStr.count == 0{ if nameStr.count == 0{
HUD.flash(.label("请填写收货人姓名"), delay: 1.2) HUD.flash(.label("请填写收货人姓名"), delay: 1.2)
return return
...@@ -151,6 +213,7 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -151,6 +213,7 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
var navTitle:String? var navTitle:String?
func getIndex(){ func getIndex(){
let path = Bundle.main.path(forResource: "address_new", ofType: "json") let path = Bundle.main.path(forResource: "address_new", ofType: "json")
let url = URL(fileURLWithPath: path!) let url = URL(fileURLWithPath: path!)
// 带throws的方法需要抛异常 // 带throws的方法需要抛异常
...@@ -160,47 +223,65 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -160,47 +223,65 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
print("地址文件数据",jsonData["data"]) print("地址文件数据",jsonData["data"])
self.addressArray = jsonData["data"].arrayObject! self.addressArray = jsonData["data"].arrayObject!
if navTitle == "编辑地址" { if navTitle == "编辑地址" {
for i in 0 ..< addressArray.count { for i in 0 ..< addressArray.count {
let item = addressArray[i] as! Dictionary<String,Any> let item = addressArray[i] as! Dictionary<String,Any>
if i == addressArray.count - 1 && item["area_id"] as! Int != provinceIndex{
provinceIndex = 0
cityIndex = 0
areaIndex = 0
}
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 { if citys.count == 0 {
provinceIndex = i provinceIndex = i
} cityIndex = 0
areaIndex = 0
break
}else{
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 { if districts.count == 0 {
provinceIndex = i
cityIndex = j cityIndex = j
} areaIndex = 0
break
}else{
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{
provinceIndex = i provinceIndex = i
cityIndex = j cityIndex = j
areaIndex = k areaIndex = k
break return
} }
} }
} }
} }
}else{
provinceIndex = 0
cityIndex = 0 }
areaIndex = 0
} }
} }
}
} }
print("provinceIndex = ",provinceIndex)
} catch let error as Error? { } catch let error as Error? {
print("读取本地数据出现错误!",error as Any) print("读取本地数据出现错误!",error as Any)
} }
} }
var titleArr:Array<String> = []
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
getIndex() if is_keHu_list {
titleArr = ["收货人:","地址:","详细地址:","手机号:"]
}else{
titleArr = ["收货人:","地址:","详细地址:","手机号:","电话:","邮编:"]
}
navbar.title = navTitle navbar.title = navTitle
if navTitle == "编辑地址" { if navTitle == "编辑地址" {
navbar.rightTitle = "删除" navbar.rightTitle = "删除"
...@@ -210,6 +291,9 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -210,6 +291,9 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
} }
} }
getIndex()
self.view.addSubview(navbar) self.view.addSubview(navbar)
listView.separatorStyle = .none listView.separatorStyle = .none
...@@ -364,7 +448,7 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable ...@@ -364,7 +448,7 @@ class XinZengDiZhiViewController: BaseViewController,UITableViewDelegate,UITable
} }
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == 0 { if section == 0 {
return 6 return titleArr.count
} }
return 1 return 1
} }
......
...@@ -236,7 +236,9 @@ class KeHuListViewController: BaseViewController,UITableViewDelegate,UITableView ...@@ -236,7 +236,9 @@ class KeHuListViewController: BaseViewController,UITableViewDelegate,UITableView
@IBAction func addAction(_ sender: Any) { @IBAction func addAction(_ sender: Any) {
let vc = XinZengAndBianJiKeHuViewController() let vc = XinZengAndBianJiKeHuViewController()
vc.titleStr = "新增客户" vc.titleStr = "新增客户"
vc.delegate = self vc.delegate = self
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
} }
//MARK: - 自定义delegate //MARK: - 自定义delegate
...@@ -246,6 +248,7 @@ class KeHuListViewController: BaseViewController,UITableViewDelegate,UITableView ...@@ -246,6 +248,7 @@ class KeHuListViewController: BaseViewController,UITableViewDelegate,UITableView
vc.titleStr = "编辑客户" vc.titleStr = "编辑客户"
vc.delegate = self vc.delegate = self
vc.cus_id = model.cus_id! vc.cus_id = model.cus_id!
if model.company != nil { if model.company != nil {
vc.companyName = model.company! vc.companyName = model.company!
} }
......
...@@ -11,11 +11,20 @@ import LGButton ...@@ -11,11 +11,20 @@ import LGButton
protocol XinZengAndBianJiKeHuViewControllerDelegate { protocol XinZengAndBianJiKeHuViewControllerDelegate {
func XinZengAndBianJiKeHuViewControllerFinish() func XinZengAndBianJiKeHuViewControllerFinish()
} }
class XinZengAndBianJiKeHuViewController: BaseViewController,UITableViewDataSource,UITableViewDelegate,BingDingKeHuViewControllerDelegate,GLAlertSelectViewDelegate,UITextFieldDelegate,GeliAlertViewDelegate{ class XinZengAndBianJiKeHuViewController: BaseViewController,UITableViewDataSource,UITableViewDelegate,BingDingKeHuViewControllerDelegate,GLAlertSelectViewDelegate,UITextFieldDelegate,GeliAlertViewDelegate, DZGLViewControllerDelegate{
func DZGLViewControllerSelect(data: GetAddrsInfoDataModel) {
//此处无用
}
func DZGLViewController_adr(adr_id: String) {
address_id = adr_id
print("abc = ",address_id)
}
var delegate:XinZengAndBianJiKeHuViewControllerDelegate? var delegate:XinZengAndBianJiKeHuViewControllerDelegate?
var cus_id:Int? var cus_id:Int?
var user_id:Int? var user_id:Int?
var address_id = ""
func rightBtnClick() { func rightBtnClick() {
let alertView = GeliAlertView(frame: self.view.window!.bounds) let alertView = GeliAlertView(frame: self.view.window!.bounds)
...@@ -55,6 +64,7 @@ class XinZengAndBianJiKeHuViewController: BaseViewController,UITableViewDataSour ...@@ -55,6 +64,7 @@ class XinZengAndBianJiKeHuViewController: BaseViewController,UITableViewDataSour
"discounts_rate":discount as Any "discounts_rate":discount as Any
] ]
if cus_id == nil { if cus_id == nil {
dict["address_id"] = address_id
cusAdd(dict, success: { (data) in cusAdd(dict, success: { (data) in
HUD.hide() HUD.hide()
HUD.flash(.labeledSubSuccess(subtitle: "提交成功"), delay: 1.2) HUD.flash(.labeledSubSuccess(subtitle: "提交成功"), delay: 1.2)
...@@ -63,10 +73,8 @@ class XinZengAndBianJiKeHuViewController: BaseViewController,UITableViewDataSour ...@@ -63,10 +73,8 @@ class XinZengAndBianJiKeHuViewController: BaseViewController,UITableViewDataSour
}) { (err) in }) { (err) in
} }
print("add == ",dict)
}else{ }else{
dict["cus_id"] = cus_id dict["cus_id"] = cus_id
print("edit == ",dict)
cusEdit(dict, success: { (data) in cusEdit(dict, success: { (data) in
HUD.hide() HUD.hide()
HUD.flash(.labeledSubSuccess(subtitle: "编辑成功"), delay: 1.2) HUD.flash(.labeledSubSuccess(subtitle: "编辑成功"), delay: 1.2)
...@@ -188,7 +196,10 @@ class XinZengAndBianJiKeHuViewController: BaseViewController,UITableViewDataSour ...@@ -188,7 +196,10 @@ class XinZengAndBianJiKeHuViewController: BaseViewController,UITableViewDataSour
if indexPath.row == 6 { if indexPath.row == 6 {
let vc = DZGLViewController() let vc = DZGLViewController()
vc.is_keHu_list = true vc.is_keHu_list = true
vc.kehu_adrArr = adrArr // vc.kehu_adrArr = adrArr
vc.cus_id = cus_id
print("vc.cus = ",vc.cus_id)
vc.delegate = self
self.navigationController?.pushViewController(vc, animated: true ) self.navigationController?.pushViewController(vc, animated: true )
} }
if indexPath.row == 3 { if indexPath.row == 3 {
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/> <device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
<capability name="Named colors" minToolsVersion="9.0"/> <capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/> <capability name="System colors in document resources" minToolsVersion="11.0"/>
......
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