Commit 46a8dc6b authored by lujunye's avatar lujunye

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

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