Commit 7374c551 authored by lujunye's avatar lujunye

车型显示,选择完成

parent 5a944b55
{
"images" : [
{
"filename" : "dot.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dot@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dot@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ll.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ll@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ll@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "rr.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "rr@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "rr@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "xx.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "xx@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "xx@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -11,8 +11,49 @@ import WebKit ...@@ -11,8 +11,49 @@ import WebKit
import MAMapKit import MAMapKit
import SwiftyJSON import SwiftyJSON
import SwiftDate import SwiftDate
import SDWebImage
class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,JiTuoWuXinXiViewDelegate,JiPaiFangShiViewControllerDelegate,ZengZhiServicesViewControllerDelegate,AdressSelectCellDelegate,DZGLViewControllerDelegate,XinZengDiZhiViewControllerDelegate,TitleAndTFBtnCellDelegate,WenDuCellDelegate,LogisticalSelectViewDelegate, UIPickerViewDataSource, UIPickerViewDelegate, GLAlertSelectViewDelegate,CLLocationManagerDelegate, CityListViewControllerDelegate,ToAndFormSelectViewControllerDelegate,WayBillAddressCanDelItemCellDelegate,HLLTopCellDelegate{
func showScrollUI(){
for item in lineArr{
if item.tag == selectCarType {
item.isHidden = false
}else{
item.isHidden = true
}
}
for item in btnArr {
if item.tag == selectCarType {
item.isSelected = true
item.setTitleColor(UIColor(named: "蓝色字体颜色"), for: .normal)
}else{
item.isSelected = false
item.setTitleColor(UIColor(named: "提示语字体颜色"), for: .normal)
}
}
let btn = btnArr[selectCarType]
let idx = IndexPath(row: 0, section: 0)
let cell = hListView.cellForRow(at:idx) as! HLLTopCell
let w = cell.scViewBg.bounds.size.width
cell.scrollView?.setContentOffset(CGPoint(x: selectCarType * Int(w), y: 0), animated: true)
cell.idx = selectCarType
let x = btn.frame.minX
let rect = CGRect(x: Int(x), y: 0, width: Int(w), height: 1)
topBtnScv.scrollRectToVisible(rect, animated: true)
}
func HLLTopCellScrollIdx(idx: Int) {
selectCarType = idx
showScrollUI()
}
func HLLTopCellBtnClick(idx: Int) {
selectCarType = idx
showScrollUI()
}
class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,JiTuoWuXinXiViewDelegate,JiPaiFangShiViewControllerDelegate,ZengZhiServicesViewControllerDelegate,AdressSelectCellDelegate,DZGLViewControllerDelegate,XinZengDiZhiViewControllerDelegate,TitleAndTFBtnCellDelegate,WenDuCellDelegate,LogisticalSelectViewDelegate, UIPickerViewDataSource, UIPickerViewDelegate, GLAlertSelectViewDelegate,CLLocationManagerDelegate, CityListViewControllerDelegate,ToAndFormSelectViewControllerDelegate,WayBillAddressCanDelItemCellDelegate{
func WayBillAddressCanDelItemCellDelAc(idx: Int) { func WayBillAddressCanDelItemCellDelAc(idx: Int) {
adrArr.remove(at: idx) adrArr.remove(at: idx)
let view = hListView.footerView(forSection: 1) let view = hListView.footerView(forSection: 1)
...@@ -20,8 +61,35 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -20,8 +61,35 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
hListView.reloadData() hListView.reloadData()
} }
fileprivate func extractedFunc() {
cityCart(["user_token":UserToken as Any,"nonce_str":String.randomStr(len: 30) as Any,"city_id":city_id as Any], success: { (data) in
let model = data as! cityCartModel
self.carTypesArr.removeAll()
for item in model.data!.vehicle_arr! {
self.carTypesArr.append(item)
}
self.setBtnUI(carTypesArr: self.carTypesArr,view: self.topCarBtnSelectView)
self.hListView.reloadData()
}) { (err) in
}
}
func ToAndFormSelectViewControllerSelectAdr(dict: Dictionary<String, Any>, idx: Int) { func ToAndFormSelectViewControllerSelectAdr(dict: Dictionary<String, Any>, idx: Int) {
let adrModel = dict["adr"] as! cityListDataModel
if idx == 0 {
if city_id != adrModel.city_id {
city_id = adrModel.city_id!
selectCarType = 0
let cell = hListView.cellForRow(at: IndexPath(row: 0, section: 0)) as! HLLTopCell
cell.scrollView?.setContentOffset(CGPoint(x: selectCarType * Int(CGFloat(cell.scViewBg.bounds.size.width)), y: 0), animated: true)
cell.idx = selectCarType
locBtn.setTitle(" " + adrModel.name!, for: .normal)
extractedFunc()
}
}
if idx != 10086 { if idx != 10086 {
if idx != 0 { if idx != 0 {
if idx == 1 && adrArr.count == 0{ if idx == 1 && adrArr.count == 0{
...@@ -40,7 +108,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -40,7 +108,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
} }
} }
}else{ }else{
if idx == 0 && adrArr.count > 1 {
if idx == 0 && adrArr.count > 0 {
adrArr.insert(dict as NSDictionary, at: 0) adrArr.insert(dict as NSDictionary, at: 0)
adrArr.remove(at:1) adrArr.remove(at:1)
}else{ }else{
...@@ -316,7 +385,10 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -316,7 +385,10 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
@IBOutlet weak var hListView: UITableView! @IBOutlet weak var hListView: UITableView!
var isAlready = true var isAlready = true
var city_id = 0
var selectCarType = 0
var carTypesArr:Array<vehicle_arr_data> = []
@IBAction func selectAction(_ sender: UIButton) { @IBAction func selectAction(_ sender: UIButton) {
if rightBtn == sender { if rightBtn == sender {
...@@ -331,21 +403,15 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -331,21 +403,15 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
hBtnViewH.constant = 49 hBtnViewH.constant = 49
} }
if isAlready { if isAlready {
var city_id = 0
for item in adrDatas { for item in adrDatas {
if item.name == selectLoc { if item.name == selectLoc {
city_id = item.city_id! city_id = item.city_id!
} }
} }
cityCart(["user_token":UserToken as Any,"nonce_str":String.randomStr(len: 30) as Any,"city_id":city_id as Any], success: { (data) in extractedFunc()
}) { (err) in
}
setBtnUI(carTypesArr: carTypesArr,view: topCarBtnSelectView)
let line = UIView() let line = UIView()
line.backgroundColor = UIColor(named: "灰色分界线") line.backgroundColor = UIColor(named: "灰色分界线")
...@@ -361,6 +427,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -361,6 +427,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
leftBtn.isSelected = true leftBtn.isSelected = true
lineV.frame.origin.x = 0 lineV.frame.origin.x = 0
hllView.isHidden = true hllView.isHidden = true
closeCarList()
} }
} }
@IBOutlet weak var lineV: UIView! @IBOutlet weak var lineV: UIView!
...@@ -1005,6 +1072,9 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1005,6 +1072,9 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
vc.nameStr = (dict["shouHuoRen"] as! String) vc.nameStr = (dict["shouHuoRen"] as! String)
vc.phoneNum = (dict["phoneNum"] as! String) vc.phoneNum = (dict["phoneNum"] as! String)
vc.adrStr = (dict["menPai"] as! String) vc.adrStr = (dict["menPai"] as! String)
let adr = dict["adr"] as! cityListDataModel
vc.lat = adr.lat_lon!.lat!
vc.lng = adr.lat_lon!.lon!
} }
} }
...@@ -1025,6 +1095,9 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1025,6 +1095,9 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
vc.nameStr = (dict["shouHuoRen"] as! String) vc.nameStr = (dict["shouHuoRen"] as! String)
vc.phoneNum = (dict["phoneNum"] as! String) vc.phoneNum = (dict["phoneNum"] as! String)
vc.adrStr = (dict["menPai"] as! String) vc.adrStr = (dict["menPai"] as! String)
let adr = dict["adr"] as! cityListDataModel
vc.lat = adr.lat_lon!.lat!
vc.lng = adr.lat_lon!.lon!
} }
} }
...@@ -1228,6 +1301,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1228,6 +1301,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
if indexPath.section == 0 { if indexPath.section == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "HLLTopCell") as! HLLTopCell let cell = tableView.dequeueReusableCell(withIdentifier: "HLLTopCell") as! HLLTopCell
cell.datas = carTypesArr cell.datas = carTypesArr
cell.delegate = self
cell.idx = selectCarType
return cell return cell
} }
if indexPath.section == 1 { if indexPath.section == 1 {
...@@ -1353,39 +1428,28 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1353,39 +1428,28 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
} }
@objc func topBtnClick(btn:UIButton){ @objc func topBtnClick(btn:UIButton){
// topBtnScv.setContentOffset(CGPoint(x: btn.frame.minX, y: 0), animated: true) // topBtnScv.setContentOffset(CGPoint(x: btn.frame.minX, y: 0), animated: true)
selectCarType = btn.tag
for item in lineArr{ showScrollUI()
if item.tag == btn.tag {
item.isHidden = false
}else{
item.isHidden = true
}
}
for item in btnArr {
if item == btn {
item.isSelected = true
item.setTitleColor(UIColor(named: "蓝色字体颜色"), for: .normal)
}else{
item.isSelected = false
item.setTitleColor(UIColor(named: "提示语字体颜色"), for: .normal)
}
}
}
@objc func scrollToPage(sender:UIButton){
let idx = IndexPath(row: 0, section: 0) let idx = IndexPath(row: 0, section: 0)
let cell = hListView.cellForRow(at:idx) as! HLLTopCell let cell = hListView.cellForRow(at:idx) as! HLLTopCell
cell.scrollView?.setContentOffset(CGPoint(x: sender.tag * Int(CGFloat(cell.scViewBg.bounds.size.width)), y: 0), animated: true) cell.scrollView?.setContentOffset(CGPoint(x: selectCarType * Int(CGFloat(cell.scViewBg.bounds.size.width)), y: 0), animated: true)
cell.idx = sender.tag
} }
var btnArr:Array<UIButton> = [] var btnArr:Array<UIButton> = []
var lineArr:Array<UIView> = [] var lineArr:Array<UIView> = []
var topBtnScv:UIScrollView! var topBtnScv:UIScrollView!
func setBtnUI(carTypesArr:Array<String>,view:UIView){ func setBtnUI(carTypesArr:Array<vehicle_arr_data>,view:UIView){
isAlready = false isAlready = false
btnArr.removeAll() btnArr.removeAll()
lineArr.removeAll()
for item in view.subviews {
item.removeFromSuperview()
}
print("carCount = ",carTypesArr.count)
let scv = UIScrollView(frame: view.bounds) let scv = UIScrollView(frame: view.bounds)
view.addSubview(scv) view.addSubview(scv)
topBtnScv = scv topBtnScv = scv
...@@ -1394,7 +1458,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1394,7 +1458,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
scv.tag = 99 scv.tag = 99
for i in 0 ..< carTypesArr.count { for i in 0 ..< carTypesArr.count {
let btn = UIButton() let btn = UIButton()
btn.setTitle(carTypesArr[i], for: .normal) let model = carTypesArr[i]
btn.setTitle(model.name, for: .normal)
btn.tag = i btn.tag = i
scv.addSubview(btn) scv.addSubview(btn)
btn.sizeToFit() btn.sizeToFit()
...@@ -1403,7 +1468,6 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1403,7 +1468,6 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
let button = btnArr[i-1] let button = btnArr[i-1]
x = button.frame.maxX x = button.frame.maxX
} }
btn.addTarget(self, action: #selector(scrollToPage(sender:)), for: .touchUpInside)
btn.frame = CGRect(x:x, y: 0, width: btn.bounds.size.width + 6, height: 44) btn.frame = CGRect(x:x, y: 0, width: btn.bounds.size.width + 6, height: 44)
btn.titleLabel?.font = UIFont.systemFont(ofSize: 13) btn.titleLabel?.font = UIFont.systemFont(ofSize: 13)
btn.setTitleColor(UIColor(named: "提示语字体颜色"), for: .normal) btn.setTitleColor(UIColor(named: "提示语字体颜色"), for: .normal)
...@@ -1431,7 +1495,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1431,7 +1495,7 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
if carTypesArr.count > 5 { if carTypesArr.count > 5 {
let button = UIButton(frame: CGRect(x: fullScreenWidth-44, y: 0, width: 44, height: 44)) let button = UIButton(frame: CGRect(x: fullScreenWidth-44, y: 0, width: 44, height: 44))
button.backgroundColor = UIColor.white button.backgroundColor = UIColor.white
// button.setImage(UIImage(named: ""), for: .normal) button.setImage(UIImage(named: "dot"), for: .normal)
view.addSubview(button) view.addSubview(button)
button.addTarget(self, action: #selector(selectAllCars), for: .touchUpInside) button.addTarget(self, action: #selector(selectAllCars), for: .touchUpInside)
let line = UIView() let line = UIView()
...@@ -1450,16 +1514,17 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1450,16 +1514,17 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
} }
} }
if btnArr.count > 0 {
let btn = btnArr.first let btn = btnArr.first
btn!.isSelected = true btn!.isSelected = true
btn!.setTitleColor(UIColor(named: "蓝色字体颜色"), for: .normal) btn!.setTitleColor(UIColor(named: "蓝色字体颜色"), for: .normal)
let line = lineArr.first let line = lineArr.first
line!.isHidden = false line!.isHidden = false
} }
}
//MARK: - 选择所有车型 //MARK: - 选择所有车型
var carTypesArr:Array<String> = ["标题字颜1","标题字颜2","标题字颜3","标题字颜4","标题字5","标题字6"]
var carListView:UIView? var carListView:UIView?
var cBtn:UIButton? var cBtn:UIButton?
@objc func closeCarList(){ @objc func closeCarList(){
...@@ -1492,7 +1557,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1492,7 +1557,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
carListView!.addSubview(lbl) carListView!.addSubview(lbl)
let closeBtn = UIButton(frame: CGRect(x: fullScreenWidth-44, y: 0, width: 44, height: 44)) let closeBtn = UIButton(frame: CGRect(x: fullScreenWidth-44, y: 0, width: 44, height: 44))
closeBtn.backgroundColor = UIColor.red // closeBtn.backgroundColor = UIColor.red
closeBtn.setImage(UIImage(named: "xx"), for: .normal)
closeBtn.addTarget(self, action: #selector(closeCarList), for: .touchUpInside) closeBtn.addTarget(self, action: #selector(closeCarList), for: .touchUpInside)
carListView!.addSubview(closeBtn) carListView!.addSubview(closeBtn)
...@@ -1541,14 +1607,31 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1541,14 +1607,31 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
btn.tag = index btn.tag = index
btn.layer.borderColor = UIColor(named: "灰色分界线")?.cgColor btn.layer.borderColor = UIColor(named: "灰色分界线")?.cgColor
btn.layer.borderWidth = 0.5 btn.layer.borderWidth = 0.5
btn.setTitle("\(index)", for: .normal) let model = carTypesArr[index]
let imgV = UIImageView()
SDWebImageDownloader.shared.downloadImage(with: URL(string:model.img_url_high_light!), options: .continueInBackground, progress: { (a, b, nil) in
}) { (img, data, err, true) in
imgV.image = img
let p = w / (imgV.image?.size.width)!
imgV.frame = CGRect(x: btn.frame.origin.x, y: btn.frame.origin.y + 15, width: w, height: w * p * 1.8)
let lbl = UILabel(frame: CGRect(x: btn.frame.origin.x, y: btn.frame.origin.y + 10 + imgV.bounds.size.height, width: w, height: w - (w * p * 2.5)))
lbl.textColor = UIColor(named: "灰色字体颜色")
lbl.font = UIFont.systemFont(ofSize: 13)
lbl.textAlignment = .center
lbl.text = model.name
bg.addSubview(lbl)
}
bg.addSubview(imgV)
btn.setTitleColor(UIColor.black, for: .normal) btn.setTitleColor(UIColor.black, for: .normal)
bg.addSubview(btn) bg.addSubview(btn)
} }
@objc func carSelect(sender:UIButton){ @objc func carSelect(sender:UIButton){
print(sender.tag)
let btn = btnArr[sender.tag] let btn = btnArr[sender.tag]
topBtnClick(btn: btn) topBtnClick(btn: btn)
closeCarList() closeCarList()
...@@ -1561,7 +1644,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie ...@@ -1561,7 +1644,8 @@ class XiaYunDanViewController: BaseViewController,UITableViewDelegate,UITableVie
let x = btn.frame.minX let x = btn.frame.minX
let rect = CGRect(x: Int(x), y: 0, width: Int(w), height: 1) let rect = CGRect(x: Int(x), y: 0, width: Int(w), height: 1)
topBtnScv.scrollRectToVisible(rect, animated: true) topBtnScv.scrollRectToVisible(rect, animated: true)
print(rect.minX)
selectCarType = sender.tag
} }
//MARK:---预估费用操作 //MARK:---预估费用操作
......
...@@ -185,8 +185,6 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -185,8 +185,6 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
print("aksldf == ",adrDatas?.count)
let searchBr = SearchBarView.init() let searchBr = SearchBarView.init()
navBgView.addSubview(searchBr) navBgView.addSubview(searchBr)
searchBr.snp.makeConstraints { (make) in searchBr.snp.makeConstraints { (make) in
...@@ -212,18 +210,15 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -212,18 +210,15 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
AMapServices.shared().apiKey = "ca417b43e3d031db9c29382cc09a174a" AMapServices.shared().apiKey = "ca417b43e3d031db9c29382cc09a174a"
if lat == 0 && lng == 0 {
manger.delegate = self manger.delegate = self
manger.requestAlwaysAuthorization() manger.requestAlwaysAuthorization()
manger.requestWhenInUseAuthorization() manger.requestWhenInUseAuthorization()
manger.startUpdatingLocation() manger.startUpdatingLocation()
}
initMapView() initMapView()
initSearch() initSearch()
searchList.layer.cornerRadius = 5 searchList.layer.cornerRadius = 5
searchList.layer.maskedCorners = [CACornerMask.layerMinXMinYCorner,CACornerMask.layerMaxXMinYCorner] searchList.layer.maskedCorners = [CACornerMask.layerMinXMinYCorner,CACornerMask.layerMaxXMinYCorner]
searchList.register(UINib(nibName: "HuoLaLaDiZhiCell", bundle: nil), forCellReuseIdentifier: "HuoLaLaDiZhiCell") searchList.register(UINib(nibName: "HuoLaLaDiZhiCell", bundle: nil), forCellReuseIdentifier: "HuoLaLaDiZhiCell")
...@@ -231,7 +226,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -231,7 +226,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
nameTF.text = nameStr nameTF.text = nameStr
phoneTF.text = phoneNum phoneTF.text = phoneNum
addressDetailTF.text = adrStr addressDetailTF.text = adrStr
print("8")
} }
func initMapView(){ func initMapView(){
...@@ -243,11 +238,11 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -243,11 +238,11 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
self.mapView.centerCoordinate = CLLocationCoordinate2DMake(lat,lng) self.mapView.centerCoordinate = CLLocationCoordinate2DMake(lat,lng)
print("==",lat,lng)
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)
print("4")
} }
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
...@@ -271,7 +266,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -271,7 +266,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
search.delegate = self search.delegate = self
let request = AMapPOIAroundSearchRequest() let request = AMapPOIAroundSearchRequest()
//地址 //地址
print("5")
request.location = AMapGeoPoint.location(withLatitude: CGFloat(mapView.centerCoordinate.latitude), longitude: CGFloat(mapView.centerCoordinate.longitude)) request.location = AMapGeoPoint.location(withLatitude: CGFloat(mapView.centerCoordinate.latitude), longitude: CGFloat(mapView.centerCoordinate.longitude))
request.requireExtension = true request.requireExtension = true
search.aMapPOIAroundSearch(request) search.aMapPOIAroundSearch(request)
...@@ -319,7 +314,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -319,7 +314,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
// response.pois.forEach { (poi) in // response.pois.forEach { (poi) in
// adrArr.append(poi) // adrArr.append(poi)
// } // }
print("run",response.pois.first?.location.latitude)
if introView == nil { if introView == nil {
introView = UIView() introView = UIView()
MapBgView.addSubview(introView!) MapBgView.addSubview(introView!)
...@@ -353,9 +348,9 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -353,9 +348,9 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
paraph.lineSpacing = 3 paraph.lineSpacing = 3
var str = "\(String(describing: response.pois.first!.province!))\(String(describing: response.pois.first!.city!))\(String(describing: response.pois.first!.district!))\( String(describing: response.pois.first!.address!))" var str = "\(String(describing: response.pois.first!.province!))\(String(describing: response.pois.first!.city!))\(String(describing: response.pois.first!.district!))\( String(describing: response.pois.first!.address!))"
print("test11")
if adrName.count > 0 { if adrName.count > 0 {
print("test12")
isMove = true isMove = true
titleLbl!.text = adrName titleLbl!.text = adrName
str = detailAdr str = detailAdr
...@@ -435,11 +430,11 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -435,11 +430,11 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
adrName = "" adrName = ""
detailAdr = "" detailAdr = ""
} }
print("CLLocationDegrees = ",mapView.centerCoordinate.latitude,lat,CGFloat(mapView.centerCoordinate.latitude))
req.location = AMapGeoPoint.location(withLatitude: CGFloat(mapView.centerCoordinate.latitude), longitude: CGFloat(mapView.centerCoordinate.longitude)) req.location = AMapGeoPoint.location(withLatitude: CGFloat(mapView.centerCoordinate.latitude), longitude: CGFloat(mapView.centerCoordinate.longitude))
req.requireExtension = true req.requireExtension = true
search.aMapPOIAroundSearch(req) search.aMapPOIAroundSearch(req)
print("6")
} }
...@@ -449,7 +444,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo ...@@ -449,7 +444,7 @@ class ToAndFormSelectViewController: BaseViewController, MAMapViewDelegate, CLLo
let request = AMapReGeocodeSearchRequest() let request = AMapReGeocodeSearchRequest()
request.location = AMapGeoPoint.location(withLatitude: CGFloat(mapView.centerCoordinate.latitude), longitude: CGFloat(mapView.centerCoordinate.longitude)) request.location = AMapGeoPoint.location(withLatitude: CGFloat(mapView.centerCoordinate.latitude), longitude: CGFloat(mapView.centerCoordinate.longitude))
print("7",mapView.centerCoordinate.latitude)
search.aMapReGoecodeSearch(request) search.aMapReGoecodeSearch(request)
request.requireExtension = true request.requireExtension = true
......
...@@ -7,9 +7,15 @@ ...@@ -7,9 +7,15 @@
// //
import UIKit import UIKit
import SDWebImage
protocol HLLTopCellDelegate {
func HLLTopCellBtnClick(idx:Int)
func HLLTopCellScrollIdx(idx:Int)
}
class HLLTopCell: UITableViewCell,UIScrollViewDelegate { class HLLTopCell: UITableViewCell,UIScrollViewDelegate {
var idx = 0 var idx = 0
var delegate:HLLTopCellDelegate?
@IBAction func btnClick(_ sender: UIButton) { @IBAction func btnClick(_ sender: UIButton) {
leftBtn.isHidden = false leftBtn.isHidden = false
rightBtn.isHidden = false rightBtn.isHidden = false
...@@ -31,13 +37,26 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate { ...@@ -31,13 +37,26 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate {
} }
scrollView?.setContentOffset(CGPoint(x: scViewBg.bounds.size.width * CGFloat(idx), y: (scrollView?.frame.origin.y)!), animated: true) scrollView?.setContentOffset(CGPoint(x: scViewBg.bounds.size.width * CGFloat(idx), y: (scrollView?.frame.origin.y)!), animated: true)
delegate?.HLLTopCellBtnClick(idx: idx)
}
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let isStop = !scrollView.isTracking && !scrollView.isDragging && !scrollView.isDecelerating
if isStop {
var idx:Int = Int(scrollView.contentOffset.x/scViewBg.bounds.size.width)
if idx < 0 {
idx = 0
}
if idx > datas.count - 1 {
idx = datas.count - 1
}
delegate?.HLLTopCellScrollIdx(idx:idx)
}
} }
func scrollViewDidScroll(_ scrollView: UIScrollView) { func scrollViewDidScroll(_ scrollView: UIScrollView) {
leftBtn.isHidden = false leftBtn.isHidden = false
rightBtn.isHidden = false rightBtn.isHidden = false
if scrollView.contentOffset.x/scViewBg.bounds.size.width <= 0 { if scrollView.contentOffset.x/scViewBg.bounds.size.width < 1 {
leftBtn.isHidden = true leftBtn.isHidden = true
} }
let num = datas.count - 1 let num = datas.count - 1
...@@ -46,7 +65,17 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate { ...@@ -46,7 +65,17 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate {
rightBtn.isHidden = true rightBtn.isHidden = true
} }
var numIdx = Int(scrollView.contentOffset.x/scViewBg.bounds.size.width - 1)
if numIdx < 0 {
numIdx = 0
}
if numIdx > num {
numIdx = num
}
let model = datas[numIdx]
weightLbl.text = model.vehicle_price_text_item?.text_weight
sizeLbl.text = model.vehicle_price_text_item?.text_size
tjLbl.text = model.vehicle_price_text_item?.text_volume
} }
@IBOutlet weak var rightBtn: UIButton! @IBOutlet weak var rightBtn: UIButton!
...@@ -56,7 +85,21 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate { ...@@ -56,7 +85,21 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate {
@IBOutlet weak var sizeLbl: UILabel! @IBOutlet weak var sizeLbl: UILabel!
@IBOutlet weak var weightLbl: UILabel! @IBOutlet weak var weightLbl: UILabel!
var datas:Array<String> = [] var datas:Array<vehicle_arr_data> = []{
didSet{
if datas.count < 2 {
rightBtn.isHidden = true
}else{
rightBtn.isHidden = false
}
if datas.count > 0 {
let model = datas[idx]
weightLbl.text = model.vehicle_price_text_item?.text_weight
sizeLbl.text = model.vehicle_price_text_item?.text_size
tjLbl.text = model.vehicle_price_text_item?.text_volume
}
}
}
var scrollView:UIScrollView? var scrollView:UIScrollView?
override func awakeFromNib() { override func awakeFromNib() {
...@@ -65,33 +108,51 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate { ...@@ -65,33 +108,51 @@ class HLLTopCell: UITableViewCell,UIScrollViewDelegate {
leftBtn.isHidden = true leftBtn.isHidden = true
self.selectionStyle = .none self.selectionStyle = .none
}
}
override func layoutIfNeeded() { override func layoutIfNeeded() {
super.layoutIfNeeded() super.layoutIfNeeded()
if scrollView == nil {
scrollView = UIScrollView(frame: scViewBg.bounds) scrollView = UIScrollView(frame: scViewBg.bounds)
scViewBg.addSubview(scrollView!) scViewBg.addSubview(scrollView!)
scrollView?.isPagingEnabled = true scrollView?.isPagingEnabled = true
scrollView?.showsHorizontalScrollIndicator = false scrollView?.showsHorizontalScrollIndicator = false
scrollView?.delegate = self scrollView?.delegate = self
}
if (scrollView?.subviews.count)! > 0 && scrollView != nil {
for item in scrollView!.subviews {
item.removeFromSuperview()
}
}
let num = datas.count
var num = datas.count
scrollView?.contentSize = CGSize(width: (scViewBg.bounds.size.width) * CGFloat(num), height: (scViewBg.bounds.size.height)) scrollView?.contentSize = CGSize(width: (scViewBg.bounds.size.width) * CGFloat(num), height: (scViewBg.bounds.size.height))
for i in 0 ..< num{ for i in 0 ..< num{
let view = UIView(frame: CGRect(x: CGFloat(i) * (scViewBg.bounds.size.width), y:0, width: scViewBg.bounds.size.width, height: scViewBg.bounds.size.height)) let view = UIView(frame: CGRect(x: CGFloat(i) * (scViewBg.bounds.size.width), y:0, width: scViewBg.bounds.size.width, height: scViewBg.bounds.size.height))
if i % 2 == 0 { let model = datas[i]
view.backgroundColor = UIColor.blue let imgV = UIImageView()
}else{ view.addSubview(imgV)
view.backgroundColor = UIColor.red SDWebImageDownloader.shared.downloadImage(with: URL(string:model.img_url_high_light!), options: .continueInBackground, progress: { (a, b, nil) in
}) { (img, data, err, true) in
imgV.image = img
if img != nil {
let p = self.scViewBg.bounds.size.width / (img!.size.width)
imgV.snp.makeConstraints { (make) in
make.width.equalTo((imgV.image?.size.width)! * p * 0.6)
make.height.equalTo((imgV.image?.size.height)! * p * 0.5)
make.centerX.equalTo(view.snp.centerX)
make.centerY.equalTo(view.snp.centerY)
}
}
} }
scrollView?.addSubview(view) scrollView?.addSubview(view)
} }
} }
override func setSelected(_ selected: Bool, animated: Bool) { override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated) super.setSelected(selected, animated: animated)
......
...@@ -87,26 +87,28 @@ ...@@ -87,26 +87,28 @@
<constraint firstAttribute="trailing" secondItem="dcU-lR-ZVX" secondAttribute="trailing" constant="53.5" id="zbV-6L-D7f"/> <constraint firstAttribute="trailing" secondItem="dcU-lR-ZVX" secondAttribute="trailing" constant="53.5" id="zbV-6L-D7f"/>
</constraints> </constraints>
</view> </view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Z6t-TU-kTM"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Z6t-TU-kTM">
<rect key="frame" x="332" y="59" width="28" height="28"/> <rect key="frame" x="332" y="59" width="28" height="28"/>
<color key="backgroundColor" red="0.29803921570000003" green="0.34901960780000002" blue="0.50196078430000002" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="28" id="w4n-ZK-J9g"/> <constraint firstAttribute="width" constant="28" id="w4n-ZK-J9g"/>
<constraint firstAttribute="height" constant="28" id="yl6-Gd-YKI"/> <constraint firstAttribute="height" constant="28" id="yl6-Gd-YKI"/>
</constraints> </constraints>
<color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" image="rr"/>
<connections> <connections>
<action selector="btnClick:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="uz8-x4-Svq"/> <action selector="btnClick:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="uz8-x4-Svq"/>
</connections> </connections>
</button> </button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lc5-Gn-jWh"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lc5-Gn-jWh">
<rect key="frame" x="15" y="59" width="28" height="28"/> <rect key="frame" x="15" y="59" width="28" height="28"/>
<color key="backgroundColor" red="0.44705882349999998" green="0.39607843139999999" blue="0.89019607840000003" alpha="1" colorSpace="calibratedRGB"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="28" id="HYU-ly-9UX"/> <constraint firstAttribute="width" constant="28" id="HYU-ly-9UX"/>
<constraint firstAttribute="height" constant="28" id="Wpx-pa-nSQ"/> <constraint firstAttribute="height" constant="28" id="Wpx-pa-nSQ"/>
</constraints> </constraints>
<color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" image="ll"/>
<connections> <connections>
<action selector="btnClick:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="xNF-PS-V1Q"/> <action selector="btnClick:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="xNF-PS-V1Q"/>
</connections> </connections>
...@@ -146,6 +148,8 @@ ...@@ -146,6 +148,8 @@
</tableViewCell> </tableViewCell>
</objects> </objects>
<resources> <resources>
<image name="ll" width="9.5" height="28"/>
<image name="rr" width="9.5" height="28"/>
<namedColor name="标题字颜色"> <namedColor name="标题字颜色">
<color red="0.18000000715255737" green="0.18000000715255737" blue="0.18000000715255737" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.18000000715255737" green="0.18000000715255737" blue="0.18000000715255737" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor> </namedColor>
......
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