Commit 46a8dc6b authored by lujunye's avatar lujunye

地址选择调整完成(搜索待完成)

parent b51d374a
...@@ -26,7 +26,7 @@ class cityListModel: Mappable { ...@@ -26,7 +26,7 @@ class cityListModel: Mappable {
class cityListDataModel: Mappable { class cityListDataModel: Mappable {
var name : String? var name : String?
var lat_lon : Array<Double>? var lat_lon : citySearchDataPoiLocationModel?
var city_id : Int? var city_id : Int?
var name_en : String? var name_en : String?
......
...@@ -50,7 +50,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -50,7 +50,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
}else{ }else{
adrArr.append(dict as NSDictionary) adrArr.append(dict as NSDictionary)
} }
print(adrArr)
let view = hListView.footerView(forSection: 1) let view = hListView.footerView(forSection: 1)
view?.layoutIfNeeded() view?.layoutIfNeeded()
...@@ -60,10 +60,11 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -60,10 +60,11 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
var loc:cityListDataModel!
func CityListViewControllerLocSelect(loc: cityListDataModel) { func CityListViewControllerLocSelect(loc: cityListDataModel) {
selectLoc = loc.name! selectLoc = loc.name!
self.loc = loc
locBtn.setTitle(" " + loc.name!, for: .normal) locBtn.setTitle(" " + loc.name!, for: .normal)
locBtn.sizeToFit() locBtn.sizeToFit()
...@@ -73,6 +74,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -73,6 +74,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
make.height.equalTo(30) make.height.equalTo(30)
make.width.equalTo(self.locBtn.bounds.size.width) make.width.equalTo(self.locBtn.bounds.size.width)
}) })
} }
...@@ -780,6 +783,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -780,6 +783,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
let vc = ToAndFormSelectViewController() let vc = ToAndFormSelectViewController()
vc.idx = 10086 vc.idx = 10086
vc.adrDatas = adrDatas vc.adrDatas = adrDatas
vc.loc = loc
vc.delegate = self vc.delegate = self
if adrDatas.count > 0 { if adrDatas.count > 0 {
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
...@@ -903,6 +907,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -903,6 +907,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
let vc = ToAndFormSelectViewController() let vc = ToAndFormSelectViewController()
vc.idx = indexPath.row vc.idx = indexPath.row
vc.adrDatas = adrDatas vc.adrDatas = adrDatas
vc.loc = loc
vc.delegate = self vc.delegate = self
if adrArr.count > indexPath.row { if adrArr.count > indexPath.row {
let dict = adrArr[indexPath.row] as! NSDictionary let dict = adrArr[indexPath.row] as! NSDictionary
...@@ -912,6 +917,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -912,6 +917,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
vc.adrStr = (dict["menPai"] as! String) vc.adrStr = (dict["menPai"] as! String)
} }
} }
if adrDatas.count > 0 { if adrDatas.count > 0 {
self.navigationController?.pushViewController(vc, animated: true) self.navigationController?.pushViewController(vc, animated: true)
} }
......
...@@ -16,7 +16,19 @@ import IQKeyboardManagerSwift ...@@ -16,7 +16,19 @@ import IQKeyboardManagerSwift
protocol ToAndFormSelectViewControllerDelegate { protocol ToAndFormSelectViewControllerDelegate {
func ToAndFormSelectViewControllerSelectAdr(dict:Dictionary<String,Any>,idx:Int) func ToAndFormSelectViewControllerSelectAdr(dict:Dictionary<String,Any>,idx:Int)
} }
class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLocationManagerDelegate, AMapSearchDelegate, UISearchBarDelegate, SearchBarViewDelegate,UITableViewDelegate,UITableViewDataSource{ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLocationManagerDelegate, AMapSearchDelegate, UISearchBarDelegate, SearchBarViewDelegate,UITableViewDelegate,UITableViewDataSource,CityListViewControllerDelegate{
func CityListViewControllerLocSelect(loc: cityListDataModel) {
self.loc = loc
mapView.centerCoordinate = CLLocationCoordinate2DMake((loc.lat_lon?.lat)!,(loc.lat_lon?.lon)!)
}
@IBAction func citySelectClick(_ sender: UIButton) {
let vc = CityListViewController()
vc.adrDatas = adrDatas!
vc.locatStr = loc.name!
vc.delegate = self
self.navigationController?.pushViewController(vc, animated: true)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if tableView == searchList { if tableView == searchList {
return adrArr.count return adrArr.count
...@@ -26,7 +38,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -26,7 +38,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
var delegate:ToAndFormSelectViewControllerDelegate? var delegate:ToAndFormSelectViewControllerDelegate?
var dict:Dictionary<String,Any> = Dictionary() var dict:Dictionary<String,Any> = Dictionary()
var loc:cityListDataModel!
var nameStr = "" var nameStr = ""
var phoneNum = "" var phoneNum = ""
var adrStr = "" var adrStr = ""
...@@ -38,7 +50,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -38,7 +50,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "HuoLaLaDiZhiCell") as! HuoLaLaDiZhiCell let cell = tableView.dequeueReusableCell(withIdentifier: "HuoLaLaDiZhiCell") as! HuoLaLaDiZhiCell
cell.nameLbl.text = "1"
if tableView == searchList { if tableView == searchList {
let data = adrArr[indexPath.row] let data = adrArr[indexPath.row]
cell.nameLbl.text = data.name cell.nameLbl.text = data.name
...@@ -66,7 +78,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -66,7 +78,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
var search: AMapSearchAPI! var search: AMapSearchAPI!
var lat:CLLocationDegrees = 0 var lat:CLLocationDegrees = 0
var lng:CLLocationDegrees = 0 var lng:CLLocationDegrees = 0
var manger:CLLocationManager = CLLocationManager() // var manger:CLLocationManager = CLLocationManager()
@IBOutlet weak var lineX: NSLayoutConstraint! @IBOutlet weak var lineX: NSLayoutConstraint!
@IBOutlet weak var closeBtn: UIButton! @IBOutlet weak var closeBtn: UIButton!
...@@ -108,6 +120,8 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -108,6 +120,8 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
citySelectBtn.setTitle(loc.name, for: .normal)
let searchBr = SearchBarView.init() let searchBr = SearchBarView.init()
navBgView.addSubview(searchBr) navBgView.addSubview(searchBr)
searchBr.snp.makeConstraints { (make) in searchBr.snp.makeConstraints { (make) in
...@@ -121,6 +135,12 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -121,6 +135,12 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
searchBr.delegate = self searchBr.delegate = self
searchBr.delegateL = self searchBr.delegateL = self
if idx != 0 {
sureSelectLbl.text = "确认收货地"
toFormTitleLbl.text = "收货人信息(选填)"
nameTF.placeholder = "收货人姓名"
}
selectListV.register(UINib(nibName: "HuoLaLaDiZhiCell", bundle: nil), forCellReuseIdentifier: "HuoLaLaDiZhiCell") selectListV.register(UINib(nibName: "HuoLaLaDiZhiCell", bundle: nil), forCellReuseIdentifier: "HuoLaLaDiZhiCell")
selectListV.separatorStyle = .none selectListV.separatorStyle = .none
...@@ -129,10 +149,11 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -129,10 +149,11 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
initMapView() initMapView()
initSearch() initSearch()
manger.delegate = self
manger.requestAlwaysAuthorization() // manger.delegate = self
manger.requestWhenInUseAuthorization() // manger.requestAlwaysAuthorization()
manger.startUpdatingLocation() // manger.requestWhenInUseAuthorization()
// manger.startUpdatingLocation()
searchList.register(UINib(nibName: "HuoLaLaDiZhiCell", bundle: nil), forCellReuseIdentifier: "HuoLaLaDiZhiCell") searchList.register(UINib(nibName: "HuoLaLaDiZhiCell", bundle: nil), forCellReuseIdentifier: "HuoLaLaDiZhiCell")
...@@ -148,21 +169,22 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -148,21 +169,22 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
mapView.delegate = self mapView.delegate = self
mapView.zoomLevel = 16 mapView.zoomLevel = 16
mapView.isZoomEnabled = true mapView.isZoomEnabled = true
mapView.centerCoordinate = CLLocationCoordinate2DMake((loc.lat_lon?.lat)!,(loc.lat_lon?.lon)!)
MapBgView.addSubview(mapView!) MapBgView.addSubview(mapView!)
let tap = UITapGestureRecognizer(target: self, action: #selector(cancelKeyboard)) let tap = UITapGestureRecognizer(target: self, action: #selector(cancelKeyboard))
mapView.addGestureRecognizer(tap) mapView.addGestureRecognizer(tap)
} }
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { // func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
manger.stopUpdatingLocation() // manger.stopUpdatingLocation()
let location = locations.last // let location = locations.last
lat = location?.coordinate.latitude as! CLLocationDegrees // lat = location?.coordinate.latitude as! CLLocationDegrees
lng = location?.coordinate.longitude as! CLLocationDegrees // lng = location?.coordinate.longitude as! CLLocationDegrees
setMapCenter(lat: lat, lng: lng) //
} // }
func setMapCenter(lat:CLLocationDegrees,lng:CLLocationDegrees) { // func setMapCenter(lat:CLLocationDegrees,lng:CLLocationDegrees) {
mapView.setCenter(CLLocationCoordinate2D(latitude: lat, longitude: lng), animated: false) // mapView.setCenter(CLLocationCoordinate2D(latitude: lat, longitude: lng), animated: false)
} // }
@objc func cancelKeyboard(){ @objc func cancelKeyboard(){
IQKeyboardManager.shared.resignFirstResponder() IQKeyboardManager.shared.resignFirstResponder()
...@@ -181,7 +203,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -181,7 +203,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
var cityName:NSString = "" var cityName:NSString = ""
@IBAction func sureSelectAddressAction(_ sender: LGButton) { @IBAction func sureSelectAddressAction(_ sender: LGButton) {
print("sureSelectAddressAction") print("sureSelectAddressAction")
print(cityName)
if adrDatas!.count > 0 { if adrDatas!.count > 0 {
for item in adrDatas! { for item in adrDatas! {
if cityName.contains(item.name!) { if cityName.contains(item.name!) {
......
...@@ -69,6 +69,9 @@ ...@@ -69,6 +69,9 @@
<state key="normal" title="广州" image="xiala"> <state key="normal" title="广州" image="xiala">
<color key="titleColor" name="标题字颜色"/> <color key="titleColor" name="标题字颜色"/>
</state> </state>
<connections>
<action selector="citySelectClick:" destination="-1" eventType="touchUpInside" id="7no-DW-Cy8"/>
</connections>
</button> </button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="QHB-sv-BsU"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="QHB-sv-BsU">
<rect key="frame" x="0.0" y="44" width="414" height="1"/> <rect key="frame" x="0.0" y="44" width="414" height="1"/>
...@@ -167,7 +170,7 @@ ...@@ -167,7 +170,7 @@
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="13"/> <fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="13"/>
<textInputTraits key="textInputTraits"/> <textInputTraits key="textInputTraits"/>
</textField> </textField>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="货人姓名" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="tlN-2m-Au1"> <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="货人姓名" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="tlN-2m-Au1">
<rect key="frame" x="15" y="99" width="110" height="31"/> <rect key="frame" x="15" y="99" width="110" height="31"/>
<color key="textColor" name="灰色字体颜色"/> <color key="textColor" name="灰色字体颜色"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="13"/> <fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="13"/>
......
...@@ -59,7 +59,15 @@ ...@@ -59,7 +59,15 @@
</label> </label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JfY-Q9-10Q"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JfY-Q9-10Q">
<rect key="frame" x="46" y="29" width="232" height="42"/> <rect key="frame" x="46" y="29" width="232" height="42"/>
<attributedString key="attributedText"/> <attributedString key="attributedText">
<fragment content=" ">
<attributes>
<color key="NSColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<font key="NSFont" metaFont="system" size="12"/>
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
</attributes>
</fragment>
</attributedString>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="eV0-oM-vuy"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="eV0-oM-vuy">
......
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