Commit 9e499913 authored by 曹云霄's avatar 曹云霄

修改界面

parent 40d8fc4f
......@@ -23,6 +23,8 @@
29D9E2722051182900E1C3F5 /* Color+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E2712051182800E1C3F5 /* Color+Extension.swift */; };
29D9E27420511E8C00E1C3F5 /* DensityResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E27320511E8C00E1C3F5 /* DensityResult.swift */; };
29D9E27A2051216000E1C3F5 /* AxisValueFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E2792051216000E1C3F5 /* AxisValueFormatter.swift */; };
29D9E38C20513A7100E1C3F5 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E38B20513A7100E1C3F5 /* DetailViewController.swift */; };
29D9E39020513F6500E1C3F5 /* UIView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29D9E38F20513F6500E1C3F5 /* UIView+Extension.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
......@@ -44,6 +46,8 @@
29D9E2712051182800E1C3F5 /* Color+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Color+Extension.swift"; sourceTree = "<group>"; };
29D9E27320511E8C00E1C3F5 /* DensityResult.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DensityResult.swift; sourceTree = "<group>"; };
29D9E2792051216000E1C3F5 /* AxisValueFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AxisValueFormatter.swift; sourceTree = "<group>"; };
29D9E38B20513A7100E1C3F5 /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = "<group>"; };
29D9E38F20513F6500E1C3F5 /* UIView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Extension.swift"; sourceTree = "<group>"; };
741C820678A2593F5FCD1236 /* Pods-SHZX.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SHZX.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SHZX/Pods-SHZX.debug.xcconfig"; sourceTree = "<group>"; };
F4B2B6ED73482878EC2355ED /* Pods_SHZX.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SHZX.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
......@@ -113,6 +117,7 @@
children = (
29D7E018204E72DB00010071 /* AppDelegate.swift */,
29D7E01A204E72DB00010071 /* ViewController.swift */,
29D9E38B20513A7100E1C3F5 /* DetailViewController.swift */,
29D9E2782051213C00E1C3F5 /* Formatter */,
29D9E26E20510DDA00E1C3F5 /* Extension */,
29266CB3204FF03E000CBB4B /* Response */,
......@@ -130,6 +135,7 @@
children = (
29D9E26F20510DED00E1C3F5 /* Date+Extensions.swift */,
29D9E2712051182800E1C3F5 /* Color+Extension.swift */,
29D9E38F20513F6500E1C3F5 /* UIView+Extension.swift */,
);
path = Extension;
sourceTree = "<group>";
......@@ -295,8 +301,10 @@
buildActionMask = 2147483647;
files = (
29D9E27420511E8C00E1C3F5 /* DensityResult.swift in Sources */,
29D9E39020513F6500E1C3F5 /* UIView+Extension.swift in Sources */,
29D7E01B204E72DB00010071 /* ViewController.swift in Sources */,
29D9E27A2051216000E1C3F5 /* AxisValueFormatter.swift in Sources */,
29D9E38C20513A7100E1C3F5 /* DetailViewController.swift in Sources */,
29D9E2722051182900E1C3F5 /* Color+Extension.swift in Sources */,
29D9E27020510DED00E1C3F5 /* Date+Extensions.swift in Sources */,
29266CB2204FEE57000CBB4B /* NetworkAPI.swift in Sources */,
......@@ -443,7 +451,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 2G3393EZPN;
DEVELOPMENT_TEAM = W54V2VB863;
INFOPLIST_FILE = SHZX/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
......@@ -460,7 +468,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 2G3393EZPN;
DEVELOPMENT_TEAM = W54V2VB863;
INFOPLIST_FILE = SHZX/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
......
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"filename" : "logo(1)iPadNotifications_20pt.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"idiom" : "ipad",
"filename" : "logo(1)iPadNotifications_20pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"idiom" : "ipad",
"filename" : "logo(1)iPadSpootlight5_29pt.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"idiom" : "ipad",
"filename" : "logo(1)iPadSpootlight5_29pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"idiom" : "ipad",
"filename" : "logo(1)iPadSpootlight7_40pt.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"idiom" : "ipad",
"filename" : "logo(1)iPadSpootlight7_40pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"idiom" : "ipad",
"filename" : "logo(1)iPadApp_76pt.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"idiom" : "ipad",
"filename" : "logo(1)iPadApp_76pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "logo(1)iPadProApp_83.5pt@2x.png",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "logo(1)store_1024pt.png",
"scale" : "1x"
}
],
......
......@@ -2,16 +2,15 @@
"images" : [
{
"idiom" : "universal",
"filename" : "back.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "back@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "back@3x.png",
"scale" : "3x"
}
],
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"images" : [
{
"idiom" : "universal",
"filename" : "zoom.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
This diff is collapsed.
//
// DetailViewController.swift
// SHZX
//
// Created by 曹云霄 on 2018/3/8.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import UIKit
import WebKit
class DetailViewController: UIViewController {
final var webView: WKWebView!
open var imageString: String!
override func viewDidLoad() {
super.viewDidLoad()
setupWebView()
}
// MARK: - 初始化WKWebView
fileprivate func setupWebView() {
webView = WKWebView(frame: CGRect(x: 0, y: 64, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height))
view.addSubview(webView)
view.sendSubview(toBack: webView)
webView.load(URLRequest(url: URL(string: imageString)!))
}
// MARK: - 关闭
@IBAction func dismissClickAction(_ sender: UIButton) {
dismiss(animated: true, completion: nil)
}
}
......@@ -28,6 +28,16 @@ extension Date {
return nil
}
}
//MARK: date转日期字符串
public func dateToDateString(dateFormat:String) -> String {
let timeZone = NSTimeZone.local
let formatter = DateFormatter()
formatter.timeZone = timeZone
formatter.dateFormat = dateFormat
let date = formatter.string(from: self)
return date
}
/// EZSE: Initializes Date from string returned from an http response, according to several RFCs / ISO
public init?(httpDateString: String) {
......
//
// UIView+Extension.swift
// SHZX
//
// Created by 曹云霄 on 2018/3/8.
// Copyright © 2018年 上海勾芒信息科技有限公司. All rights reserved.
//
import UIKit
extension UIView {
func copyView<T: UIView>() -> T {
return NSKeyedUnarchiver.unarchiveObject(with: NSKeyedArchiver.archivedData(withRootObject: self)) as! T
}
}
......@@ -4,6 +4,8 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>上海中心</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
......@@ -15,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>1.0.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
......
......@@ -27,7 +27,7 @@ class ViewController: UIViewController {
var oldFrame: CGRect!
/// 横坐标title
final lazy var xTitles: Array<String> = {
var xTitles = ["8", "11", "14", "17", "20","23"]
var xTitles = ["8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23"]
return xTitles
}()
......@@ -37,6 +37,12 @@ class ViewController: UIViewController {
/// 登陆用户信息
var userData: LoginData!
var imageArray: Array<String> = {
var imageArray = ["http://121.40.116.34:8077/KlImages/KlyAPI?ID=2&Type=SHZX","http://121.40.116.34:8077/KlImages/KlyAPI?ID=2&Type=SHZX"]
return imageArray
}()
override func viewDidLoad() {
super.viewDidLoad()
......@@ -65,13 +71,13 @@ class ViewController: UIViewController {
// MARK: - 拍摄照片
fileprivate func setupPhotoImg() {
photoImg1.kf.setImage(with: URL(string: "http://121.40.116.34:8077/KlImages/KlyAPI?ID=1&Type=SHZX"))
photoImg2.kf.setImage(with: URL(string: "http://121.40.116.34:8077/KlImages/KlyAPI?ID=2&Type=SHZX"))
photoImg1.kf.setImage(with: ImageResource(downloadURL: URL(string: imageArray.first!)!), placeholder: nil, options: [KingfisherOptionsInfoItem.transition(ImageTransition.fade(1)), KingfisherOptionsInfoItem.forceRefresh], progressBlock: nil, completionHandler: nil)
photoImg2.kf.setImage(with: ImageResource(downloadURL: URL(string: imageArray.last!)!), placeholder: nil, options: [KingfisherOptionsInfoItem.transition(ImageTransition.fade(1)), KingfisherOptionsInfoItem.forceRefresh], progressBlock: nil, completionHandler: nil)
}
// MARK: - 获取折线图数据
fileprivate func getSpotsDataAction() {
let time = Date().toString()
let time = Date().dateToDateString(dateFormat: "yyyy-MM-dd HH:mm:ss")
Network.request(target: .Spots(userData.uuid, time), success: {[weak self] (json) in
let model = SpotsResult(fromJson: json)
if model.success {
......@@ -79,15 +85,14 @@ class ViewController: UIViewController {
var yesterdayValue = Array<Double>()
for i in 0..<self!.xTitles.count {
if let count = model.data.last?.hour.object(forKey: self!.xTitles[i]) {
todayValue.append(count as! Double)
yesterdayValue.append(count as! Double)
}else {
todayValue.append(0)
yesterdayValue.append(0)
}
if let count = model.data.first?.hour.object(forKey: self!.xTitles[i]) {
yesterdayValue.append(count as! Double)
todayValue.append(count as! Double)
}else {
yesterdayValue.append(0)
todayValue.append(0)
}
}
self?.setChart(todayValue: todayValue, yesterdayValue: yesterdayValue)
......@@ -101,7 +106,7 @@ class ViewController: UIViewController {
// MARK: - 获取柱状图数据
fileprivate func getDensityDataAction() {
let time = Date().toString()
let time = Date().dateToDateString(dateFormat: "yyyy-MM-dd HH:mm:ss")
Network.request(target: .GETDensity(userData.uuid, time), success: {[weak self] (json) in
let model = DensityResult(fromJson: json)
if model.success {
......@@ -124,14 +129,13 @@ class ViewController: UIViewController {
fileprivate func setupLineChartView() {
chartView.chartDescription?.text = nil
chartView.legend.form = .none
chartView.highlightPerTapEnabled = false
chartView.rightAxis.drawAxisLineEnabled = false
chartView.rightAxis.enabled = false
chartView.leftAxis.axisLineColor = UIColor.white
chartView.leftAxis.gridColor = UIColor.clear
chartView.leftAxis.labelTextColor = UIColor.white
chartView.dragEnabled = false
chartView.doubleTapToZoomEnabled = false
chartView.scaleYEnabled = false
}
// MARK: - 填充折线图数据
......@@ -139,9 +143,11 @@ class ViewController: UIViewController {
var todayDataEntries: [ChartDataEntry] = []
var tyesterdayDataEntries: [ChartDataEntry] = []
for i in 0..<xTitles.count {
let dataEntry = ChartDataEntry(x: Double(i), y: todayValue[i])
todayDataEntries.append(dataEntry)
let time = Date().hour
if Int(xTitles[i])! <= time {
let dataEntry = ChartDataEntry(x: Double(i), y: todayValue[i])
todayDataEntries.append(dataEntry)
}
let dataEntry1 = ChartDataEntry(x: Double(i), y: yesterdayValue[i])
tyesterdayDataEntries.append(dataEntry1)
}
......@@ -178,6 +184,7 @@ class ViewController: UIViewController {
fileprivate func setupBarChartView() {
barChartView.chartDescription?.text = nil
barChartView.legend.form = .none
barChartView.highlightPerTapEnabled = false
barChartView.rightAxis.drawAxisLineEnabled = false
barChartView.rightAxis.enabled = false
barChartView.leftAxis.axisLineColor = UIColor.white
......@@ -187,8 +194,6 @@ class ViewController: UIViewController {
barChartView.xAxis.labelPosition = .bottom
barChartView.xAxis.gridColor = UIColor.clear
barChartView.xAxis.labelTextColor = UIColor.white
barChartView.scaleXEnabled = false
barChartView.scaleYEnabled = false
}
// MARK: - 填充柱状图数据
......@@ -213,33 +218,26 @@ class ViewController: UIViewController {
// MARK: - 添加点击手势
fileprivate func addTapGestureRecognizer() {
lineChartBgView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(ViewController.zoomClickAction)))
histogramBgView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(ViewController.zoomClickAction)))
photoImg1BgView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(ViewController.zoomClickAction)))
photoImg2BgView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(ViewController.zoomClickAction)))
}
// MARK: - 缩放
@objc open func zoomClickAction(_ tap: UIGestureRecognizer) {
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let detailVc = storyBoard.instantiateViewController(withIdentifier: "DetailViewController") as! DetailViewController
detailVc.imageString = imageArray[tap.view!.tag]
present(detailVc, animated: true, completion: nil)
}
// MARK: - 更新数据
@IBAction func updateBtnClickAction(_ sender: UIButton) {
getSpotsDataAction()
getDensityDataAction()
setupPhotoImg()
}
}
//extension ViewController: IAxisValueFormatter {
// func stringForValue(_ value: Double, axis: AxisBase?) -> String {
// let title = xTitles[Int(value)]
// if title.isEmpty {
// return ""
// }
// return title + ":00"
// }
//}
......
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