| | |
| | | 13BEEAEB2A4D92A200685667 /* ExchangeRecordTCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13BEEAE92A4D92A200685667 /* ExchangeRecordTCell.xib */; }; |
| | | 13CCC4BB2A4A81F900DEDF19 /* StudentCourseDetailHeadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13CCC4BA2A4A81F900DEDF19 /* StudentCourseDetailHeadView.swift */; }; |
| | | 13CCC4BD2A4A820100DEDF19 /* StudentCourseDetailHeadView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13CCC4BC2A4A820100DEDF19 /* StudentCourseDetailHeadView.xib */; }; |
| | | 13CE11CE2AF1F23300F6ACA4 /* CommmonBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13CE11CD2AF1F23300F6ACA4 /* CommmonBannerView.swift */; }; |
| | | 13CE11D02AF203E000F6ACA4 /* JJPageControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13CE11CF2AF203E000F6ACA4 /* JJPageControl.swift */; }; |
| | | 13D084552A40666A005B05D5 /* CalendarPickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13D084542A40666A005B05D5 /* CalendarPickerView.swift */; }; |
| | | 13D084572A406672005B05D5 /* CalendarPickerView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13D084562A406672005B05D5 /* CalendarPickerView.xib */; }; |
| | | 13D084592A4071F2005B05D5 /* YardBookingListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13D084582A4071F2005B05D5 /* YardBookingListVC.swift */; }; |
| | |
| | | 13BEEAE92A4D92A200685667 /* ExchangeRecordTCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ExchangeRecordTCell.xib; sourceTree = "<group>"; }; |
| | | 13CCC4BA2A4A81F900DEDF19 /* StudentCourseDetailHeadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StudentCourseDetailHeadView.swift; sourceTree = "<group>"; }; |
| | | 13CCC4BC2A4A820100DEDF19 /* StudentCourseDetailHeadView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = StudentCourseDetailHeadView.xib; sourceTree = "<group>"; }; |
| | | 13CE11CD2AF1F23300F6ACA4 /* CommmonBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommmonBannerView.swift; sourceTree = "<group>"; }; |
| | | 13CE11CF2AF203E000F6ACA4 /* JJPageControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JJPageControl.swift; sourceTree = "<group>"; }; |
| | | 13D084542A40666A005B05D5 /* CalendarPickerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarPickerView.swift; sourceTree = "<group>"; }; |
| | | 13D084562A406672005B05D5 /* CalendarPickerView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CalendarPickerView.xib; sourceTree = "<group>"; }; |
| | | 13D084582A4071F2005B05D5 /* YardBookingListVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YardBookingListVC.swift; sourceTree = "<group>"; }; |
| | |
| | | 8D5C15072A31885B00A8BCC9 /* View */ = { |
| | | isa = PBXGroup; |
| | | children = ( |
| | | 13CE11CF2AF203E000F6ACA4 /* JJPageControl.swift */, |
| | | 8D5C150A2A31885B00A8BCC9 /* CommonAlertView.swift */, |
| | | 8D5C15082A31885B00A8BCC9 /* CommonAlertView.xib */, |
| | | 8D5C150B2A31885B00A8BCC9 /* AgreentView.swift */, |
| | |
| | | 130EC17F2AD3F6AF003CA9BA /* CommonAlertSheetView.swift */, |
| | | 130EC1812AD3F6C0003CA9BA /* CommonAlertSheetView.xib */, |
| | | 1350BF162ADFD1D9007FC49F /* RatingBar.swift */, |
| | | 13CE11CD2AF1F23300F6ACA4 /* CommmonBannerView.swift */, |
| | | ); |
| | | path = View; |
| | | sourceTree = "<group>"; |
| | |
| | | 130E40262A4EC029003A3D75 /* SearchStoreDetailVC.swift in Sources */, |
| | | 1347D1BC2AB448C20052082A /* CourseUnAssignView.swift in Sources */, |
| | | 13DA7D4F2AAF03F90085ABF9 /* CommonScanQRCodeVC.swift in Sources */, |
| | | 13CE11D02AF203E000F6ACA4 /* JJPageControl.swift in Sources */, |
| | | 139A39F02A41374100737AFB /* YardBookingSubListVC.swift in Sources */, |
| | | 136FD9B12A4C354000933B7C /* WelfareRedeemGoodsDetailVC.swift in Sources */, |
| | | 8D5732BD2A3724A900B2F8E3 /* AddStudentVC.swift in Sources */, |
| | |
| | | 8D8400E92A2F14A3003AF6A2 /* LoginVC.swift in Sources */, |
| | | 1376A6992A4A7B7B00D4C851 /* StudentCourseDetailVC.swift in Sources */, |
| | | 133A61862A4E78340066C4E6 /* CustomerListVC.swift in Sources */, |
| | | 13CE11CE2AF1F23300F6ACA4 /* CommmonBannerView.swift in Sources */, |
| | | 13A7F72C2AB7E0EC000B3436 /* CourseEXPVC.swift in Sources */, |
| | | 136B63982A4ECDD900E594F9 /* SearchStoreDetail_1_TCell.swift in Sources */, |
| | | 8D4905A92A31A6EC00E38513 /* HomeCCell.swift in Sources */, |
New file |
| | |
| | | // |
| | | // CommmonBannerView.swift |
| | | // WanPai |
| | | // |
| | | // Created by 无故事王国 on 2023/11/1. |
| | | // |
| | | |
| | | import UIKit |
| | | |
| | | //struct CommmonBannerModel { |
| | | // var index = 0 //自定义索引 |
| | | // var id:Int? //ID |
| | | // var name:String? //名称 |
| | | // var resource:String? //数据源:URL等 |
| | | // var mediaType:CommmonBannerView.MediaType? |
| | | //} |
| | | |
| | | //class CommmonBannerView: UIView, UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout { |
| | | // |
| | | // enum MediaType { |
| | | // case videoUrl,imageUrl,imageLocal,videoLocal |
| | | // } |
| | | // |
| | | // private lazy var collectionView:UICollectionView = { |
| | | // var layout = UICollectionViewFlowLayout() |
| | | // layout.minimumLineSpacing = 0 |
| | | // layout.minimumInteritemSpacing = 0 |
| | | // layout.scrollDirection = .horizontal |
| | | // layout.sectionInset = .zero |
| | | // layout.headerReferenceSize = .zero |
| | | // layout.footerReferenceSize = .zero |
| | | // layout.itemSize = CGSize(width: self.width, height: self.height) |
| | | // let collectionView = UICollectionView(frame:CGRect(x: 0, y: 0, width: self.width, height: self.height), collectionViewLayout: layout) |
| | | // collectionView.delegate = self |
| | | // collectionView.dataSource = self |
| | | // collectionView.isPagingEnabled = true |
| | | // collectionView.showsHorizontalScrollIndicator = false |
| | | // collectionView.register(CommmonBannerViewCell.self, forCellWithReuseIdentifier: "BannerView") |
| | | // collectionView.decelerationRate = .normal |
| | | // collectionView.contentInsetAdjustmentBehavior = .never |
| | | // collectionView.backgroundColor = .white |
| | | // collectionView.bounces = false |
| | | // return collectionView |
| | | // }() |
| | | // |
| | | // private lazy var pageControl:UIPageControl = { |
| | | // let control = UIPageControl() |
| | | // control.currentPageIndicatorTintColor = .white |
| | | // control.pageIndicatorTintColor = .gray.withAlphaComponent(0.6) |
| | | // return control |
| | | // }() |
| | | // |
| | | // private var timer:Timer? |
| | | // |
| | | // private var items = [CommmonBannerModel]() |
| | | // private var selectClouse:((CommmonBannerModel)->Void)? |
| | | // private var autoRoll:Bool = true |
| | | // private var currentPage:Int = 0 |
| | | // private var timeInterval:Int = 5 |
| | | // |
| | | // override func awakeFromNib() { |
| | | // super.awakeFromNib() |
| | | // setUI() |
| | | // } |
| | | // |
| | | // public func setItems(items:[CommmonBannerModel],autoRoll:Bool = true,selectClouse:((CommmonBannerModel)->Void)? = nil){ |
| | | // |
| | | // self.items = items |
| | | // if items.count > 1{ |
| | | // self.items.append(items.first!) |
| | | // } |
| | | // self.autoRoll = autoRoll |
| | | // self.selectClouse = selectClouse |
| | | // if items.count <= 1{self.autoRoll = false} |
| | | // |
| | | // setUI() |
| | | // collectionView.reloadData() |
| | | // |
| | | // if self.autoRoll{ |
| | | // DispatchQueue.main.asyncAfter(deadline: .now()+5) { |
| | | // self.startTimer() |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // private func setUI(){ |
| | | // addSubview(collectionView) |
| | | // collectionView.snp.makeConstraints { make in |
| | | // make.edges.equalToSuperview() |
| | | // } |
| | | // |
| | | // if items.count > 1{ |
| | | // pageControl.numberOfPages = items.count - 1 |
| | | // |
| | | // addSubview(pageControl) |
| | | // pageControl.snp.makeConstraints { make in |
| | | // make.centerX.equalToSuperview() |
| | | // make.bottom.equalToSuperview().offset(-10) |
| | | // make.height.equalTo(8) |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // private func startTimer(){ |
| | | // timer = Timer(timeInterval: TimeInterval(timeInterval), repeats: true, block: {[weak self] t in |
| | | // guard let weakSelf = self else { return } |
| | | // weakSelf.currentPage += 1 |
| | | // |
| | | // if weakSelf.currentPage >= weakSelf.pageControl.numberOfPages{ |
| | | // weakSelf.currentPage = 0 |
| | | // weakSelf.collectionView.setContentOffset(.zero, animated: false) |
| | | // weakSelf.pageControl.currentPage = 0 |
| | | // } |
| | | // weakSelf.collectionView.setContentOffset(CGPoint(x: weakSelf.currentPage * Int(weakSelf.width), y: 0), animated: true) |
| | | // }) |
| | | // timer?.fire() |
| | | // RunLoop.current.add(timer!, forMode: .common) |
| | | // } |
| | | // |
| | | // func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | // return items.count |
| | | // } |
| | | // |
| | | // func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | // let item = items[indexPath.row] |
| | | // selectClouse?(item) |
| | | // } |
| | | // |
| | | // func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { |
| | | // return CGSize(width:collectionView.bounds.size.width,height:ceil(collectionView.bounds.size.height)) |
| | | // } |
| | | // |
| | | // func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { |
| | | // print("--开始滑动") |
| | | // timer?.fireDate = Date.distantFuture |
| | | // } |
| | | // |
| | | // func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { |
| | | // print("--结束滑动") |
| | | // timer?.fireDate = Date.init(timeIntervalSinceNow: 3.0) //3秒后开启 |
| | | // } |
| | | // |
| | | // func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { |
| | | // let page = scrollView.contentOffset.x / scrollView.width |
| | | // if page.int > pageControl.numberOfPages{ |
| | | // pageControl.currentPage = 0 |
| | | // }else{ |
| | | // pageControl.currentPage = page.int |
| | | // } |
| | | // } |
| | | // |
| | | // func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { |
| | | // let page = scrollView.contentOffset.x / scrollView.width |
| | | // if page.int >= pageControl.numberOfPages{ |
| | | // pageControl.currentPage = 0 |
| | | // collectionView.setContentOffset(.zero, animated: false) |
| | | // }else{ |
| | | // pageControl.currentPage = page.int |
| | | // } |
| | | // } |
| | | // |
| | | // func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | // let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "BannerView", for: indexPath) as! CommmonBannerViewCell |
| | | // let item = items[indexPath.row] |
| | | // |
| | | // switch item.mediaType { |
| | | // case .imageUrl: |
| | | // if let i = item.resource{ |
| | | // cell.imgView.sd_setImage(with: URL(string: i)) |
| | | // } |
| | | // case .imageLocal: |
| | | // if let i = item.resource{ |
| | | // cell.imgView.image = UIImage(named: i) |
| | | // } |
| | | // default:break |
| | | // } |
| | | // return cell |
| | | // } |
| | | //} |
| | | // |
| | | //class CommmonBannerViewCell: UICollectionViewCell { |
| | | // |
| | | // lazy var imgView:UIImageView = { |
| | | // let img = UIImageView() |
| | | // img.contentMode = .scaleAspectFit |
| | | // return img |
| | | // }() |
| | | // |
| | | // override init(frame: CGRect) { |
| | | // super.init(frame: frame) |
| | | // contentView.addSubview(imgView) |
| | | // imgView.snp.makeConstraints { make in |
| | | // make.edges.equalToSuperview() |
| | | // } |
| | | // } |
| | | // |
| | | // required init?(coder aDecoder: NSCoder) { |
| | | // fatalError("init(coder:) has not been implemented") |
| | | // } |
| | | //} |
| | |
| | | |
| | | import UIKit |
| | | import SDWebImage |
| | | struct CommonBannerModel { |
| | | var index = 0 //自定义索引 |
| | | var id:Int? //ID |
| | | var name:String? //名称 |
| | | var resource:String? //数据源:URL等 |
| | | var mediaType:CommonBannerView.MediaType? |
| | | } |
| | | |
| | | class CommonBannerView: UIView,UIScrollViewDelegate { |
| | | class CommonBannerView: UIView, UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout { |
| | | |
| | | //图⽚⽔平放置到scrollView上 |
| | | private var scrollView:UIScrollView = UIScrollView() |
| | | //⼩圆点标识 |
| | | private var pageControl:UIPageControl = UIPageControl() |
| | | private var imageViews:Array = Array<UIImageView>() |
| | | enum MediaType { |
| | | case videoUrl,imageUrl,imageLocal,videoLocal |
| | | } |
| | | |
| | | private lazy var collectionView:UICollectionView = { |
| | | var layout = UICollectionViewFlowLayout() |
| | | layout.minimumLineSpacing = 0 |
| | | layout.minimumInteritemSpacing = 0 |
| | | layout.scrollDirection = .horizontal |
| | | layout.sectionInset = .zero |
| | | layout.headerReferenceSize = .zero |
| | | layout.footerReferenceSize = .zero |
| | | layout.itemSize = CGSize(width: self.width, height: self.height) |
| | | let collectionView = UICollectionView(frame:CGRect(x: 0, y: 0, width: self.width, height: self.height), collectionViewLayout: layout) |
| | | collectionView.delegate = self |
| | | collectionView.dataSource = self |
| | | collectionView.isPagingEnabled = true |
| | | collectionView.showsHorizontalScrollIndicator = false |
| | | collectionView.register(CommonBannerViewCell.self, forCellWithReuseIdentifier: "BannerView") |
| | | collectionView.decelerationRate = .normal |
| | | collectionView.contentInsetAdjustmentBehavior = .never |
| | | collectionView.backgroundColor = .white |
| | | collectionView.bounces = false |
| | | return collectionView |
| | | }() |
| | | |
| | | //图⽚集合 |
| | | private var images:Array<String> = [] |
| | | private var type:ImageType? |
| | | |
| | | // private var width:CGFloat = 0 |
| | | // private var height:CGFloat = 0 |
| | | |
| | | private var currIndex = 0 |
| | | private var clickBlock :(Int)->Void = {index in} |
| | | private lazy var pageControl:UIPageControl = { |
| | | let control = UIPageControl() |
| | | control.currentPageIndicatorTintColor = .white |
| | | control.pageIndicatorTintColor = .gray.withAlphaComponent(0.6) |
| | | return control |
| | | }() |
| | | |
| | | private var timer:Timer? |
| | | |
| | | // 默认⾃动播放 设置为false只能⼿动滑动 |
| | | var isAuto = true |
| | | // 轮播间隔时间 默认6秒可以⾃⼰修改 |
| | | var interval:Double = 3 |
| | | private var items = [CommonBannerModel]() |
| | | private var selectClouse:((CommonBannerModel)->Void)? |
| | | private var autoRoll:Bool = true |
| | | private var currentPage:Int = 0 |
| | | private var timeInterval:Int = 5 |
| | | |
| | | private var startOffsetX:CGFloat = 0 |
| | | private var fillBounds:CGRect? |
| | | |
| | | override func layoutSubviews() { |
| | | super.layoutSubviews() |
| | | override func awakeFromNib() { |
| | | super.awakeFromNib() |
| | | setUI() |
| | | } |
| | | |
| | | public func setImages(images:Array<String>,type:ImageType |
| | | = .Image,fillBounds:CGRect? = nil,imageClickBlock:@escaping (Int) -> Void) { |
| | | self.type = type |
| | | self.fillBounds = fillBounds |
| | | self.images = images |
| | | self.clickBlock = imageClickBlock |
| | | self.initLayout() |
| | | public func setItems(items:[CommonBannerModel],autoRoll:Bool = true,selectClouse:((CommonBannerModel)->Void)? = nil){ |
| | | |
| | | self.items = items |
| | | if items.count > 1{ |
| | | self.items.append(items.first!) |
| | | } |
| | | self.autoRoll = autoRoll |
| | | self.selectClouse = selectClouse |
| | | if items.count <= 1{self.autoRoll = false} |
| | | |
| | | setUI() |
| | | collectionView.reloadData() |
| | | |
| | | if self.autoRoll{ |
| | | DispatchQueue.main.asyncAfter(deadline: .now()+5) { |
| | | self.startTimer() |
| | | } |
| | | } |
| | | } |
| | | |
| | | private func initLayout(){ |
| | | if(self.images.count == 0){ |
| | | return |
| | | private func setUI(){ |
| | | addSubview(collectionView) |
| | | collectionView.snp.makeConstraints { make in |
| | | make.edges.equalToSuperview() |
| | | } |
| | | |
| | | if fillBounds != nil{ |
| | | width = fillBounds!.width |
| | | height = fillBounds!.height |
| | | scrollView.frame = CGRect(origin: .zero, size: fillBounds!.size) |
| | | }else{ |
| | | width = self.bounds.width |
| | | height = self.bounds.height |
| | | scrollView.frame = self.bounds |
| | | } |
| | | if items.count > 1{ |
| | | pageControl.numberOfPages = items.count - 1 |
| | | |
| | | scrollView.contentSize = CGSize(width:width * CGFloat(images.count + |
| | | 2),height:height) |
| | | scrollView.contentOffset = CGPoint(x:width,y:0) |
| | | scrollView.isUserInteractionEnabled = true |
| | | scrollView.isPagingEnabled = true |
| | | scrollView.isScrollEnabled = images.count > 1 |
| | | scrollView.contentInsetAdjustmentBehavior = .never |
| | | scrollView.showsHorizontalScrollIndicator = false |
| | | scrollView.delegate = self |
| | | self.addSubview(scrollView) |
| | | |
| | | var image = UIImageView() |
| | | image.sizeToFit() |
| | | image.frame = CGRect(x:0,y:0,width:width,height:height) |
| | | image.contentMode = .scaleToFill |
| | | image.tag = images.count - 1 |
| | | image.isUserInteractionEnabled = true |
| | | setImage(image: image, index: images.count - 1) |
| | | scrollView.addSubview(image) |
| | | addTapGesWithImage(image: image) |
| | | |
| | | for i in 1 ... images.count{ |
| | | let image = UIImageView() |
| | | image.frame = CGRect(x:width * |
| | | CGFloat(i),y:0,width:width,height:height) |
| | | image.contentMode = .scaleToFill |
| | | image.isUserInteractionEnabled = true |
| | | image.tag = i - 1 |
| | | scrollView.addSubview(image) |
| | | setImage(image: image, index: i - 1) |
| | | addTapGesWithImage(image: image) |
| | | } |
| | | image = UIImageView() |
| | | image.sizeToFit() |
| | | image.frame = CGRect(x:width * CGFloat(images.count + |
| | | 1),y:0,width:width,height:height) |
| | | image.contentMode = .scaleToFill |
| | | image.tag = 0 |
| | | image.isUserInteractionEnabled = true |
| | | scrollView.addSubview(image) |
| | | setImage(image: image, index: 0) |
| | | addTapGesWithImage(image: image) |
| | | |
| | | // pageControl.center = CGPoint(x:width/2,y:height - CGFloat(15)) |
| | | pageControl.isEnabled = true |
| | | pageControl.numberOfPages = images.count |
| | | pageControl.currentPageIndicatorTintColor = UIColor.white |
| | | pageControl.pageIndicatorTintColor = UIColor.gray.withAlphaComponent(0.5) |
| | | pageControl.isUserInteractionEnabled = false |
| | | pageControl.isHidden = images.count == 1 |
| | | self.addSubview(pageControl) |
| | | addSubview(pageControl) |
| | | pageControl.snp.makeConstraints { make in |
| | | make.bottom.equalToSuperview().offset(0) |
| | | make.centerX.equalToSuperview() |
| | | make.bottom.equalToSuperview().offset(-10) |
| | | make.height.equalTo(8) |
| | | } |
| | | |
| | | //当前显示的只有 center_image 其他两个只是⽤来增加滑动时效果⽽已,不 |
| | | //addTapGesWithImage(image: center_image) |
| | | if(isAuto){ |
| | | openTimer() |
| | | } |
| | | setCurrent(currIndex: 0) |
| | | } |
| | | |
| | | private func setImage(image:UIImageView,index:Int){ |
| | | if(type == .Image){ |
| | | image.image = UIImage.init(named:images[index]) |
| | | }else{ |
| | | image.sd_setImage(with: URL(string: images[index])) |
| | | } |
| | | } |
| | | |
| | | func setCurrent(currIndex:Int,animate:Bool = false) { |
| | | if(currIndex < 0){ |
| | | self.currIndex = images.count - 1 |
| | | }else{ |
| | | self.currIndex = currIndex |
| | | } |
| | | pageControl.currentPage = self.currIndex |
| | | private func startTimer(){ |
| | | timer = Timer(timeInterval: TimeInterval(timeInterval), repeats: true, block: {[weak self] t in |
| | | guard let weakSelf = self else { return } |
| | | weakSelf.currentPage += 1 |
| | | |
| | | if animate{ |
| | | scrollView.setContentOffset(CGPoint(x:width * CGFloat(self.currIndex + 1),y:0), animated: false) |
| | | if weakSelf.currentPage >= weakSelf.pageControl.numberOfPages{ |
| | | weakSelf.currentPage = 0 |
| | | weakSelf.collectionView.setContentOffset(.zero, animated: false) |
| | | weakSelf.pageControl.currentPage = 0 |
| | | } |
| | | weakSelf.collectionView.setContentOffset(CGPoint(x: weakSelf.currentPage * Int(weakSelf.width), y: 0), animated: true) |
| | | }) |
| | | timer?.fire() |
| | | RunLoop.current.add(timer!, forMode: .common) |
| | | } |
| | | |
| | | //给图⽚添加点击⼿势 |
| | | private func addTapGesWithImage(image:UIImageView) { |
| | | let tap = UITapGestureRecognizer(target: self, action: #selector(tap(_:))) |
| | | image.isUserInteractionEnabled = true //让控件可以触发交互事件 |
| | | image.contentMode = .scaleToFill |
| | | // image.clipsToBounds = true //超出⽗控件的部分不显示 |
| | | image.addGestureRecognizer(tap) |
| | | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | return items.count |
| | | } |
| | | |
| | | //点击图⽚,调⽤block |
| | | @objc func tap(_ ges:UITapGestureRecognizer) { |
| | | clickBlock((ges.view?.tag)!) |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | let item = items[indexPath.row] |
| | | selectClouse?(item) |
| | | } |
| | | |
| | | func scrollViewDidScroll(_ scrollView: UIScrollView) { |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { |
| | | return CGSize(width:collectionView.bounds.size.width,height:ceil(collectionView.bounds.size.height)) |
| | | } |
| | | |
| | | func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { |
| | | startOffsetX = scrollView.contentOffset.x |
| | | closeTimer() |
| | | print("--开始滑动") |
| | | timer?.fireDate = Date.distantFuture |
| | | } |
| | | |
| | | func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate |
| | | decelerate: Bool) { |
| | | func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { |
| | | print("--结束滑动") |
| | | timer?.fireDate = Date.init(timeIntervalSinceNow: 3.0) //3秒后开启 |
| | | } |
| | | |
| | | func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { |
| | | let page = scrollView.contentOffset.x / scrollView.width |
| | | if page.int > pageControl.numberOfPages{ |
| | | pageControl.currentPage = 0 |
| | | }else{ |
| | | pageControl.currentPage = page.int |
| | | } |
| | | } |
| | | |
| | | func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { |
| | | if(scrollView.contentOffset.x > startOffsetX){ |
| | | currIndex = (currIndex + 1) % images.count |
| | | let page = scrollView.contentOffset.x / scrollView.width |
| | | if page.int >= pageControl.numberOfPages{ |
| | | pageControl.currentPage = 0 |
| | | collectionView.setContentOffset(.zero, animated: false) |
| | | }else{ |
| | | currIndex = (currIndex - 1) % images.count |
| | | } |
| | | setCurrent(currIndex: currIndex) |
| | | openTimer() |
| | | } |
| | | |
| | | func openTimer(){ |
| | | if(isAuto){ |
| | | closeTimer() |
| | | timer = Timer.scheduledTimer(timeInterval: interval, target: self, selector: |
| | | #selector(startAutoScroll), userInfo: nil, repeats: true) |
| | | pageControl.currentPage = page.int |
| | | } |
| | | } |
| | | |
| | | func closeTimer(){ |
| | | if(timer != nil){ |
| | | timer?.invalidate() |
| | | timer = nil |
| | | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| | | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "BannerView", for: indexPath) as! CommonBannerViewCell |
| | | let item = items[indexPath.row] |
| | | |
| | | switch item.mediaType { |
| | | case .imageUrl: |
| | | if let i = item.resource{ |
| | | cell.imgView.sd_setImage(with: URL(string: i)) |
| | | } |
| | | case .imageLocal: |
| | | if let i = item.resource{ |
| | | cell.imgView.image = UIImage(named: i) |
| | | } |
| | | default:break |
| | | } |
| | | return cell |
| | | } |
| | | } |
| | | |
| | | class CommonBannerViewCell: UICollectionViewCell { |
| | | |
| | | @objc func startAutoScroll(){ |
| | | if(isDisplayInScreen()){ |
| | | setCurrent(currIndex: (currIndex + 1) % images.count,animate: true) |
| | | lazy var imgView:UIImageView = { |
| | | let img = UIImageView() |
| | | img.contentMode = .scaleAspectFit |
| | | return img |
| | | }() |
| | | |
| | | override init(frame: CGRect) { |
| | | super.init(frame: frame) |
| | | contentView.addSubview(imgView) |
| | | imgView.snp.makeConstraints { make in |
| | | make.edges.equalToSuperview() |
| | | } |
| | | } |
| | | |
| | | func isDisplayInScreen() -> Bool{ |
| | | if(self.window == nil){ |
| | | return false |
| | | required init?(coder aDecoder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | return true |
| | | } |
| | | |
| | | } |
| | | enum ImageType{ |
| | | case Image //本地图⽚ |
| | | case URL //URL |
| | | |
| | | } |
New file |
| | |
| | | // |
| | | // JJPageControl.swift |
| | | // JJPageControl |
| | | // |
| | | // https://github.com/zxhkit/JJPageControl |
| | | // Created by xuanhe on 2022/9/1. |
| | | // |
| | | |
| | | import UIKit |
| | | |
| | | enum JJPageControlAliment { |
| | | case Center |
| | | case Left |
| | | case Right |
| | | } |
| | | |
| | | protocol JJPageControlDelegate { |
| | | func jj_pageControlClick(pageControl: JJPageControl, index: Int) |
| | | } |
| | | |
| | | class JJPageControl: UIControl { |
| | | |
| | | /// 闭包点击事件 |
| | | var clickPointClosure: ((_ num : Int) -> Void)? |
| | | |
| | | /// 当前点的大小 |
| | | var currentPointSize: CGSize = CGSize(width: 6, height: 6) { |
| | | didSet{ |
| | | assert((currentPointSize.width >= 1 && currentPointSize.height >= 1), "Parameter value is not valid. currentPointSize must be greater than 1.") |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | /// 其他点的大小 |
| | | var otherPointSize: CGSize = CGSize(width: 6, height: 6) { |
| | | didSet{ |
| | | assert((otherPointSize.width >= 1 && otherPointSize.height >= 1), "Parameter value is not valid. otherPointSize must be greater than 1.") |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | /// 点-切圆角 |
| | | var pointCornerRadius:CGFloat = 3 { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | /// 位置 |
| | | var pageAliment: JJPageControlAliment = .Center { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | /// 分页数量 |
| | | var numberOfPages: Int = 0 { |
| | | didSet{ |
| | | if oldValue != numberOfPages { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// 当前点所在下标 |
| | | var currentPage: Int = 0 { |
| | | didSet{ |
| | | if currentPage >= 0 { |
| | | exchangePointView(oldValue, currentPage) |
| | | }else{ |
| | | currentPage = 0 |
| | | } |
| | | } |
| | | } |
| | | ///点的间距 |
| | | var controlSpacing: CGFloat = 8 { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | ///左右间距 |
| | | var leftAndRightSpacing: CGFloat = 10 { |
| | | didSet{ |
| | | if leftAndRightSpacing < 0 { |
| | | leftAndRightSpacing = 0 |
| | | }else{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /// 其他点未选中颜色 |
| | | var otherColor: UIColor = .gray { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | /// 当前点颜色 |
| | | var currentColor: UIColor = .orange { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | /// 其他点背景图片 |
| | | var otherBkImage: UIImage? { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | /// 当前点背景图片 |
| | | var currentBkImage: UIImage? { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | ///当前选中点的layer宽 |
| | | var currentLayerBorderWidth: CGFloat = 1 { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | |
| | | ///其他点的layer宽 |
| | | var otherLayerBorderWidth: CGFloat = 1 { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | |
| | | ///当前选中点的layer颜色 |
| | | var currentLayerBorderColor: UIColor? { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | ///其他选中点的layer颜色 |
| | | var otherLayerBorderColor: UIColor? { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /// 当只有一个点的时候是否隐藏 |
| | | var isHidesForSinglePage = false { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | /// 是否可以点击 默认不可以点击 |
| | | var isCanClickPoint = false { |
| | | didSet{ |
| | | if numberOfPages > 0 { |
| | | createPointView() |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// 重写设置frame |
| | | override var frame:CGRect { |
| | | didSet{ |
| | | let mainWidth = (CGFloat(numberOfPages) - 1) * otherPointSize.width + (CGFloat(numberOfPages) - 1) * controlSpacing + currentPointSize.width + leftAndRightSpacing * 2 |
| | | |
| | | if frame.width < mainWidth { |
| | | frame.size.width = mainWidth |
| | | } |
| | | let max_height = max(otherPointSize.height, currentPointSize.height) |
| | | if frame.height < max_height { |
| | | frame.size.height = max_height |
| | | } |
| | | createPointView() |
| | | } |
| | | } |
| | | |
| | | /// 协议代理 |
| | | var delegate:JJPageControlDelegate? |
| | | |
| | | private var dots = [UIImageView]() |
| | | |
| | | /// 创建视图 |
| | | private func createPointView() { |
| | | /// 先清除视图 |
| | | clearView() |
| | | |
| | | if numberOfPages <= 0 { |
| | | return |
| | | } |
| | | |
| | | if isHidesForSinglePage == true ,numberOfPages == 1{ |
| | | return |
| | | } |
| | | //居中控件 |
| | | var startX:CGFloat = 0 |
| | | var startY_current:CGFloat = 0 |
| | | var startY_other:CGFloat = 0 |
| | | |
| | | |
| | | let mainWidth = (CGFloat(numberOfPages) - 1) * otherPointSize.width + (CGFloat(numberOfPages) - 1) * controlSpacing + currentPointSize.width + leftAndRightSpacing * 2 + 1 |
| | | if frame.width < mainWidth { |
| | | frame.size.width = mainWidth |
| | | }else{ |
| | | if pageAliment == .Left { |
| | | startX = leftAndRightSpacing |
| | | } else if pageAliment == .Center { |
| | | startX = (self.frame.size.width - mainWidth)/2.0 |
| | | } else { |
| | | startX = frame.width - mainWidth |
| | | } |
| | | } |
| | | |
| | | let max_height = max(otherPointSize.height, currentPointSize.height) |
| | | if frame.height < max_height { |
| | | frame.size.height = max_height |
| | | startY_current = max_height - currentPointSize.height |
| | | startY_other = max_height - otherPointSize.height |
| | | |
| | | } else { |
| | | startY_current = (frame.height - max_height)/2.0 + (max_height - currentPointSize.height) |
| | | startY_other = (frame.height - max_height)/2.0 + (max_height - otherPointSize.height) |
| | | } |
| | | |
| | | for page in 0..<numberOfPages { |
| | | if page == currentPage { |
| | | let currentPoint = UIImageView(frame: CGRect(x: startX, y: startY_current, width: currentPointSize.width, height: currentPointSize.height)) |
| | | currentPoint.layer.masksToBounds = true |
| | | currentPoint.layer.cornerRadius = pointCornerRadius |
| | | currentPoint.tag = 1000 + page |
| | | currentPoint.backgroundColor = currentColor |
| | | currentPoint.isUserInteractionEnabled = true |
| | | currentPoint.image = currentBkImage |
| | | |
| | | if self.currentLayerBorderColor != nil { |
| | | currentPoint.layer.borderColor = self.currentLayerBorderColor?.cgColor |
| | | currentPoint.layer.borderWidth = self.currentLayerBorderWidth |
| | | }else{ |
| | | currentPoint.layer.borderWidth = 0 |
| | | } |
| | | |
| | | if isCanClickPoint == true { |
| | | let tapGesture = UITapGestureRecognizer(target: self, action: #selector(clickAction(_:))) |
| | | currentPoint.addGestureRecognizer(tapGesture) |
| | | } |
| | | |
| | | addSubview(currentPoint) |
| | | |
| | | startX = currentPoint.frame.maxX + controlSpacing |
| | | if let _ = currentBkImage { |
| | | currentPoint.backgroundColor = .clear |
| | | } |
| | | dots.append(currentPoint) |
| | | }else{ |
| | | let otherPoint = UIImageView(frame: CGRect(x: startX, y: startY_other, width: otherPointSize.width, height: otherPointSize.height)) |
| | | otherPoint.layer.masksToBounds = true |
| | | otherPoint.layer.cornerRadius = pointCornerRadius |
| | | otherPoint.tag = 1000 + page |
| | | otherPoint.backgroundColor = otherColor |
| | | otherPoint.isUserInteractionEnabled = true |
| | | otherPoint.image = otherBkImage |
| | | |
| | | if self.otherLayerBorderColor != nil { |
| | | otherPoint.layer.borderColor = self.otherLayerBorderColor?.cgColor |
| | | otherPoint.layer.borderWidth = self.otherLayerBorderWidth |
| | | }else{ |
| | | otherPoint.layer.borderWidth = 0 |
| | | } |
| | | |
| | | if isCanClickPoint == true { |
| | | let tapGesture = UITapGestureRecognizer(target: self, action: #selector(clickAction(_:))) |
| | | otherPoint.addGestureRecognizer(tapGesture) |
| | | } |
| | | addSubview(otherPoint) |
| | | |
| | | startX = otherPoint.frame.maxX + controlSpacing |
| | | |
| | | if let _ = otherBkImage { |
| | | otherPoint.backgroundColor = .clear |
| | | } |
| | | dots.append(otherPoint) |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @objc private func clickAction(_ recognizer: UITapGestureRecognizer) { |
| | | |
| | | if let tag = recognizer.view?.tag { |
| | | let index = tag - 1000 |
| | | if index >= 0 { |
| | | currentPage = index |
| | | delegate?.jj_pageControlClick(pageControl: self, index: index) |
| | | if let closure = self.clickPointClosure { |
| | | closure(index) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | func clearView() { |
| | | subviews.forEach { subView in |
| | | subView.removeFromSuperview() |
| | | } |
| | | |
| | | subviews.forEach { $0.removeFromSuperview()} |
| | | dots.removeAll() |
| | | } |
| | | |
| | | func exchangePointView(_ oldPage: Int, _ newPage: Int) { |
| | | if oldPage == newPage { |
| | | return |
| | | } |
| | | if oldPage > dots.count { |
| | | return |
| | | } |
| | | if newPage > dots.count { |
| | | return |
| | | } |
| | | |
| | | |
| | | let oldDot = dots[oldPage] |
| | | let oldFrame = oldDot.frame |
| | | |
| | | let newDot = dots[newPage] |
| | | let newFrame = newDot.frame |
| | | |
| | | newDot.image = currentBkImage |
| | | if let _ = currentBkImage { |
| | | newDot.backgroundColor = .clear |
| | | }else{ |
| | | newDot.backgroundColor = currentColor |
| | | } |
| | | |
| | | oldDot.image = otherBkImage |
| | | if let _ = otherBkImage { |
| | | oldDot.backgroundColor = .clear |
| | | }else{ |
| | | oldDot.backgroundColor = otherColor |
| | | } |
| | | |
| | | if self.currentLayerBorderColor != nil { |
| | | newDot.layer.borderColor = self.currentLayerBorderColor?.cgColor |
| | | newDot.layer.borderWidth = self.currentLayerBorderWidth |
| | | }else{ |
| | | newDot.layer.borderWidth = 0 |
| | | } |
| | | |
| | | if self.otherLayerBorderColor != nil { |
| | | oldDot.layer.borderColor = self.otherLayerBorderColor?.cgColor |
| | | oldDot.layer.borderWidth = self.otherLayerBorderWidth |
| | | }else{ |
| | | oldDot.layer.borderWidth = 0 |
| | | } |
| | | |
| | | var oldMinx = oldFrame.minX |
| | | var newMinx = newFrame.minX |
| | | |
| | | UIView.animate(withDuration: 0.25) { |
| | | if newPage < oldPage { |
| | | oldMinx = oldMinx + (self.currentPointSize.width - self.otherPointSize.width) |
| | | } |
| | | oldDot.frame = CGRect(x: oldMinx, y: newFrame.minY, width: self.otherPointSize.width, height: self.otherPointSize.height) |
| | | |
| | | if newPage > oldPage { |
| | | newMinx = newMinx - (self.currentPointSize.width - self.otherPointSize.width) |
| | | } |
| | | newDot.frame = CGRect(x: newMinx, y: oldFrame.minY, width: self.currentPointSize.width, height: self.currentPointSize.height) |
| | | |
| | | |
| | | if newPage - oldPage > 1 { //往右滑动 |
| | | for index in (oldPage+1)..<newPage { |
| | | if index < self.dots.count { |
| | | let point = self.dots[index] |
| | | point.frame = CGRect(x: point.frame.minX - (self.currentPointSize.width - self.otherPointSize.width), |
| | | y: point.frame.minY, |
| | | width: self.otherPointSize.width, |
| | | height: self.otherPointSize.height) |
| | | }else{ |
| | | return |
| | | } |
| | | } |
| | | } |
| | | |
| | | if newPage - oldPage < -1 { //往左滑动 |
| | | for index in (newPage+1)..<oldPage { |
| | | if index < self.dots.count { |
| | | let point = self.dots[index] |
| | | point.frame = CGRect(x: point.frame.minX + (self.currentPointSize.width - self.otherPointSize.width), |
| | | y: point.frame.minY, |
| | | width: self.otherPointSize.width, |
| | | height: self.otherPointSize.height) |
| | | }else{ |
| | | return |
| | | } |
| | | } |
| | | } |
| | | } completion: { finshed in |
| | | if finshed == false { //执行代码和执行过程中代码一样 |
| | | if newPage < oldPage { |
| | | oldMinx = oldMinx + (self.currentPointSize.width - self.otherPointSize.width) |
| | | } |
| | | oldDot.frame = CGRect(x: oldMinx, y: newFrame.minY, width: self.otherPointSize.width, height: self.otherPointSize.height) |
| | | |
| | | if newPage > oldPage { |
| | | newMinx = newMinx - (self.currentPointSize.width - self.otherPointSize.width) |
| | | } |
| | | newDot.frame = CGRect(x: newMinx, y: oldFrame.minY, width: self.currentPointSize.width, height: self.currentPointSize.height) |
| | | |
| | | |
| | | if newPage - oldPage > 1 { //往右滑动 |
| | | for index in (oldPage+1)..<newPage { |
| | | if index < self.dots.count { |
| | | let point = self.dots[index] |
| | | point.frame = CGRect(x: point.frame.minX - (self.currentPointSize.width - self.otherPointSize.width), |
| | | y: point.frame.minY, |
| | | width: self.otherPointSize.width, |
| | | height: self.otherPointSize.height) |
| | | }else{ |
| | | return |
| | | } |
| | | } |
| | | } |
| | | |
| | | if newPage - oldPage < -1 { //往左滑动 |
| | | for index in (newPage+1)..<oldPage { |
| | | if index < self.dots.count { |
| | | let point = self.dots[index] |
| | | point.frame = CGRect(x: point.frame.minX + (self.currentPointSize.width - self.otherPointSize.width), |
| | | y: point.frame.minY, |
| | | width: self.otherPointSize.width, |
| | | height: self.otherPointSize.height) |
| | | }else{ |
| | | return |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | #if DEBUG |
| | | //let All_Url = "http://192.168.110.27:56666" //罗易胜 |
| | | //let All_Url = "http://192.168.110.22:56666" //刘杰 |
| | | //let Socket_Url = "192.168.110.22" |
| | | let All_Url = "http://8.137.22.229:56666" //正式地址 |
| | | //let All_Url = "http://8.137.22.229:56666" //正式地址 |
| | | let Game_Url = "https://try.daowepark.com" |
| | | #else |
| | | let All_Url = "http://8.137.22.229:56666" //正式地址 |
| | |
| | | cons_tableHei.constant = Double(students.count) * 100 |
| | | tableView.reloadData() |
| | | |
| | | bannerView.setImages(images: activityDetailModel.imgs.components(separatedBy: ","), type: .URL) { index in |
| | | |
| | | let imgs = activityDetailModel.imgs.components(separatedBy: ",") |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | bannerView.setItems(items: items) |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | btn_enroll.setTitle(name, for: .normal) |
| | | btn_enroll.backgroundColor = color |
| | | |
| | | bannerView.setImages(images:activityDetailModel.imgs.components(separatedBy: ","), type: .URL) { index in |
| | | |
| | | let imgs = activityDetailModel.imgs.components(separatedBy: ",") |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | bannerView.setItems(items: items) |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | guard let m = activityDetailModel else {return} |
| | | |
| | | view_banner.setImages(images: m.imgs.components(separatedBy: ","), type: .URL) { index in |
| | | |
| | | let imgs = m.imgs.components(separatedBy: ",") |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | view_banner.setItems(items: items) |
| | | |
| | | label_title.text = m.name |
| | | label_joinCondition.text = m.registerCondition.strTitle + "参与" |
| | |
| | | tableView.reloadData() |
| | | changePrice(selectClassIndex) |
| | | |
| | | view_banner.setImages(images: m.detailDrawing.components(separatedBy: ","), type: .URL,fillBounds: CGRect(origin: .zero, size: CGSize(width: view.frame.width, height: view.frame.width * 0.564))) { index in |
| | | |
| | | let imgs = m.detailDrawing.components(separatedBy: ",") |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | view_banner.setItems(items: items) |
| | | } |
| | | |
| | | |
| | |
| | | <constraint firstAttribute="height" constant="1" id="u8b-0U-pfO"/> |
| | | </constraints> |
| | | </view> |
| | | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="课包有效期:" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZRD-rc-kTH"> |
| | | <rect key="frame" x="14" y="17" width="86" height="20"/> |
| | | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="运动营有效期:" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZRD-rc-kTH"> |
| | | <rect key="frame" x="14" y="17" width="100" height="20"/> |
| | | <constraints> |
| | | <constraint firstAttribute="height" constant="20" id="TBn-Cd-xOT"/> |
| | | </constraints> |
| | |
| | | <nil key="highlightedColor"/> |
| | | </label> |
| | | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="购买当天有效" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Pge-j1-6mL"> |
| | | <rect key="frame" x="100" y="18.333333333333314" width="86" height="17"/> |
| | | <rect key="frame" x="114" y="18.333333333333314" width="86" height="17"/> |
| | | <fontDescription key="fontDescription" type="system" pointSize="14"/> |
| | | <nil key="textColor"/> |
| | | <nil key="highlightedColor"/> |
| | |
| | | self.cons_img1Height.constant = JQ_ScreenW / radio |
| | | } |
| | | |
| | | view_banner.setImages(images: m.detailDrawing.components(separatedBy: ","), type: .URL) { index in |
| | | |
| | | let imgs = m.detailDrawing.components(separatedBy: ",") |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | view_banner.setItems(items: items) |
| | | |
| | | if let subM = m.list.first { |
| | | switch subM.payType { |
| | |
| | | <constraint firstAttribute="height" constant="1" id="lMg-iG-y1M"/> |
| | | </constraints> |
| | | </view> |
| | | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="课包有效期:" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="J40-Op-gJP"> |
| | | <rect key="frame" x="14" y="17" width="86" height="20"/> |
| | | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="运动营有效期:" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="J40-Op-gJP"> |
| | | <rect key="frame" x="14" y="17" width="100" height="20"/> |
| | | <constraints> |
| | | <constraint firstAttribute="height" constant="20" id="gTX-eR-YgG"/> |
| | | </constraints> |
| | |
| | | <nil key="highlightedColor"/> |
| | | </label> |
| | | <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="--" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ggM-zF-PfG"> |
| | | <rect key="frame" x="100" y="18.333333333333314" width="13" height="17"/> |
| | | <rect key="frame" x="114" y="18.333333333333314" width="13" height="17"/> |
| | | <fontDescription key="fontDescription" type="system" pointSize="14"/> |
| | | <nil key="textColor"/> |
| | | <nil key="highlightedColor"/> |
| | |
| | | } |
| | | Services.bannerList(position: type).subscribe(onNext: {[weak self] data in |
| | | if let models = data.data{ |
| | | self?.searchView.bannerView.setImages(images: models.map({$0.img}),type: .URL, imageClickBlock: { index in |
| | | |
| | | }) |
| | | let imgs = models.map({$0.img}) |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | self?.searchView.bannerView.setItems(items: items) |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | |
| | |
| | | super.awakeFromNib() |
| | | view_bannerBg.addSubview(bannerView) |
| | | bannerView.frame = CGRect(origin: .zero, size: CGSize(width: JQ_ScreenW, height: JQ_ScreenW * 0.564)) |
| | | bannerView.isAuto = true |
| | | } |
| | | |
| | | override func layoutSubviews() { |
| | |
| | | }).disposed(by: disposeBag) |
| | | |
| | | Services.bannerList(position: .homeTop).subscribe(onNext: {[weak self] data in |
| | | guard let weakSelf = self else { return } |
| | | if let models = data.data{ |
| | | let imgs = models.compactMap({$0.img}) |
| | | self?.view_banner.setImages(images: imgs, type: .URL) { index in |
| | | jumpPage(model: models[index].model, page: models[index].page, type: models[index].type, id: models[index].turnId) |
| | | var bannerResources = [CommonBannerModel]() |
| | | for (i,item) in models.enumerated() { |
| | | bannerResources.append(CommonBannerModel(index:i,resource:item.img,mediaType:.imageUrl)) |
| | | } |
| | | self?.view_banner.setItems(items: bannerResources,selectClouse: { m in |
| | | jumpPage(model: models[m.index].model, page: models[m.index].page, type: models[m.index].type, id: models[m.index].turnId) |
| | | }) |
| | | } |
| | | }) { error in |
| | | |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22154" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> |
| | | <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> |
| | | <device id="retina6_12" orientation="portrait" appearance="light"/> |
| | | <dependencies> |
| | | <deployment identifier="iOS"/> |
| | | <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22130"/> |
| | | <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/> |
| | | <capability name="Safe area layout guides" minToolsVersion="9.0"/> |
| | | <capability name="System colors in document resources" minToolsVersion="11.0"/> |
| | | <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> |
| | |
| | | if let models = data.data,models.count > 0{ |
| | | let bannberView = CommonBannerView(frame: CGRect(x: 0, y: 0, width: JQ_ScreenW, height: JQ_ScreenW * 0.564)) |
| | | self?.tableView.tableHeaderView = bannberView |
| | | bannberView.setImages(images: models.map({$0.img}), type: .URL) { index in |
| | | let model = models[index] |
| | | |
| | | let imgs = models.map({$0.img}) |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | |
| | | bannberView.setItems(items: items) { m in |
| | | let model = models[m.index] |
| | | jumpPage(model: model.model, page: model.page, type: model.type, id: model.turnId) |
| | | } |
| | | self?.tableView.reloadData() |
| | |
| | | |
| | | self.view_banner.addSubview(bannerView) |
| | | bannerView.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: 220) |
| | | bannerView.setImages(images: searchStoreDetailModel.images, type: .URL) { index in |
| | | |
| | | let imgs = searchStoreDetailModel.images |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | bannerView.setItems(items: items) |
| | | } |
| | | } |
| | | |
| | |
| | | self?.webView.loadHTMLString(model.contents.jq_wrapHtml(), baseURL: nil) |
| | | } |
| | | |
| | | self?.bannerView.setImages(images: model.pics, type: .URL) { index in |
| | | |
| | | let imgs = model.pics |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | self?.bannerView.setItems(items: items) |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | |
| | | var items = Array<NormalSimpleModel>() |
| | | items.append(NormalSimpleModel(id: 0, name: "全部")) |
| | | items.append(NormalSimpleModel(id: 1, name: "实体")) |
| | | items.append(NormalSimpleModel(id: 2, name: "课包")) |
| | | items.append(NormalSimpleModel(id: 2, name: "运动营")) |
| | | items.append(NormalSimpleModel(id: 3, name: "门票")) |
| | | items.append(NormalSimpleModel(id: 4, name: "优惠券")) |
| | | |
| | |
| | | self?.webView.loadHTMLString(model.contents.jq_wrapHtml(), baseURL: nil) |
| | | } |
| | | |
| | | self?.bannerView.setImages(images: model.pics, type: .URL) { index in |
| | | |
| | | let imgs = model.pics |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | self?.bannerView.setItems(items: items) |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | weakSelf.view_banner.setImages(images: model.detailDrawing.components(separatedBy: ","), type: .URL) { index in |
| | | |
| | | let imgs = model.detailDrawing.components(separatedBy: ",") |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | self?.view_banner.setItems(items: items) |
| | | |
| | | // weakSelf.img_intro2.sd_setImage(with: URL(string: model.introduceDrawing)) {[weak self] image, error, type, url in |
| | | // if let img = image{ |
| | |
| | | var items = Array<NormalSimpleModel>() |
| | | items.append(NormalSimpleModel(id: 0, name: "全部")) |
| | | items.append(NormalSimpleModel(id: 1, name: "实体商品")) |
| | | items.append(NormalSimpleModel(id: 2, name: "课包商品")) |
| | | items.append(NormalSimpleModel(id: 2, name: "运动营商品")) |
| | | items.append(NormalSimpleModel(id: 3, name: "门票商品")) |
| | | items.append(NormalSimpleModel(id: 4, name: "优惠券")) |
| | | |
| | |
| | | |
| | | weakSelf.web_introduce.loadHTMLString(model.introduce.jq_wrapHtml(), baseURL: nil) |
| | | weakSelf.view_banner.frame = CGRect(origin: .zero, size: CGSize(width: JQ_ScreenW, height: JQ_ScreenW * 0.56)) |
| | | weakSelf.view_banner.setImages(images: model.imgs.components(separatedBy: ","),type: .URL) { index in |
| | | |
| | | let imgs = model.imgs.components(separatedBy: ",") |
| | | var items = [CommonBannerModel]() |
| | | for (index,img) in imgs.enumerated(){ |
| | | items.append(CommonBannerModel(index: index,resource: img,mediaType: .imageUrl)) |
| | | } |
| | | weakSelf.view_banner.setItems(items: items) |
| | | |
| | | weakSelf.view_yardType.isHidden = model.nextName.filter({!$0.isEmpty}).count == 0 |
| | | DispatchQueue.main.asyncAfter(deadline: .now()+0.5) { |