Commit 51cce7a2 authored by Sandy's avatar Sandy

首页定位天气功能

parent 74a48f81
......@@ -48,6 +48,10 @@
8F250D8F1F29CF190031B4BC /* ZJAppInstance.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F250D8E1F29CF190031B4BC /* ZJAppInstance.m */; };
8F250D921F29D4B40031B4BC /* UserInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F250D911F29D4B40031B4BC /* UserInfo.m */; };
8F250D961F29D86E0031B4BC /* ZJPermissionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F250D951F29D86E0031B4BC /* ZJPermissionManager.m */; };
8F6C92381F2ADF4F0060E983 /* HomeWeatherBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F6C92371F2ADF4F0060E983 /* HomeWeatherBoard.m */; };
8F6C923B1F2ADFEC0060E983 /* WeatherModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F6C923A1F2ADFEC0060E983 /* WeatherModel.m */; };
8F6C923E1F2AE3430060E983 /* HomeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F6C923D1F2AE3430060E983 /* HomeViewController.m */; };
8F6C92421F2AE4AD0060E983 /* LocationHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F6C92411F2AE4AD0060E983 /* LocationHelper.m */; };
8F8ED4B71F29EEE600F48461 /* RootNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F8ED4B61F29EEE600F48461 /* RootNavigationController.m */; };
8F973C1F1F21FD54003D3ADB /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8F973C121F21FB77003D3ADB /* ViewController.m */; };
8F973C251F21FD54003D3ADB /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 8F973BF51F21F6DD003D3ADB /* LaunchScreen.storyboard */; };
......@@ -165,6 +169,14 @@
8F250D911F29D4B40031B4BC /* UserInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserInfo.m; sourceTree = "<group>"; };
8F250D941F29D86E0031B4BC /* ZJPermissionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZJPermissionManager.h; sourceTree = "<group>"; };
8F250D951F29D86E0031B4BC /* ZJPermissionManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZJPermissionManager.m; sourceTree = "<group>"; };
8F6C92361F2ADF4F0060E983 /* HomeWeatherBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeWeatherBoard.h; sourceTree = "<group>"; };
8F6C92371F2ADF4F0060E983 /* HomeWeatherBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeWeatherBoard.m; sourceTree = "<group>"; };
8F6C92391F2ADFEC0060E983 /* WeatherModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeatherModel.h; sourceTree = "<group>"; };
8F6C923A1F2ADFEC0060E983 /* WeatherModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WeatherModel.m; sourceTree = "<group>"; };
8F6C923C1F2AE3430060E983 /* HomeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HomeViewController.h; sourceTree = "<group>"; };
8F6C923D1F2AE3430060E983 /* HomeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HomeViewController.m; sourceTree = "<group>"; };
8F6C92401F2AE4AD0060E983 /* LocationHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocationHelper.h; sourceTree = "<group>"; };
8F6C92411F2AE4AD0060E983 /* LocationHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocationHelper.m; sourceTree = "<group>"; };
8F8ED4B51F29EEE600F48461 /* RootNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootNavigationController.h; sourceTree = "<group>"; };
8F8ED4B61F29EEE600F48461 /* RootNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RootNavigationController.m; sourceTree = "<group>"; };
8F973BF11F21F6DD003D3ADB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
......@@ -509,6 +521,15 @@
path = ZJPermissionManager;
sourceTree = "<group>";
};
8F6C923F1F2AE4AD0060E983 /* LocationHelper */ = {
isa = PBXGroup;
children = (
8F6C92401F2AE4AD0060E983 /* LocationHelper.h */,
8F6C92411F2AE4AD0060E983 /* LocationHelper.m */,
);
path = LocationHelper;
sourceTree = "<group>";
};
8F973BDB1F21F6DD003D3ADB = {
isa = PBXGroup;
children = (
......@@ -557,6 +578,7 @@
8F973C041F21FB67003D3ADB /* Tools */ = {
isa = PBXGroup;
children = (
8F6C923F1F2AE4AD0060E983 /* LocationHelper */,
8F250D931F29D8420031B4BC /* ZJPermissionManager */,
8F250D8C1F29CF120031B4BC /* ZJAppInstance */,
8F250D601F2980BB0031B4BC /* ZJBaseHttpManager */,
......@@ -602,6 +624,8 @@
8F973C0A1F21FB77003D3ADB /* Models */ = {
isa = PBXGroup;
children = (
8F6C92391F2ADFEC0060E983 /* WeatherModel.h */,
8F6C923A1F2ADFEC0060E983 /* WeatherModel.m */,
);
path = Models;
sourceTree = "<group>";
......@@ -609,6 +633,8 @@
8F973C0B1F21FB77003D3ADB /* ViewControllers */ = {
isa = PBXGroup;
children = (
8F6C923C1F2AE3430060E983 /* HomeViewController.h */,
8F6C923D1F2AE3430060E983 /* HomeViewController.m */,
);
path = ViewControllers;
sourceTree = "<group>";
......@@ -623,6 +649,8 @@
8F973C0D1F21FB77003D3ADB /* Views */ = {
isa = PBXGroup;
children = (
8F6C92361F2ADF4F0060E983 /* HomeWeatherBoard.h */,
8F6C92371F2ADF4F0060E983 /* HomeWeatherBoard.m */,
);
path = Views;
sourceTree = "<group>";
......@@ -925,9 +953,11 @@
8F250D4F1F297DA80031B4BC /* XWFilterAnimator+XWMod.m in Sources */,
8FEF5E6C1F285E56001496E3 /* NSData+EncodeAdditions.m in Sources */,
8F250D511F297DA80031B4BC /* XWFilterAnimator+XWPageCurl.m in Sources */,
8F6C92381F2ADF4F0060E983 /* HomeWeatherBoard.m in Sources */,
8F250D961F29D86E0031B4BC /* ZJPermissionManager.m in Sources */,
8F250D921F29D4B40031B4BC /* UserInfo.m in Sources */,
8F1040B91F25C8A000B4C16E /* MineTableViewController.m in Sources */,
8F6C923B1F2ADFEC0060E983 /* WeatherModel.m in Sources */,
8F250D801F29BDC40031B4BC /* LoginViewController.m in Sources */,
8F250D471F297DA80031B4BC /* XWFilterAnimator+XWBoxBlur.m in Sources */,
8F250D3F1F297DA80031B4BC /* XWCoolAnimator+XWScanning.m in Sources */,
......@@ -938,6 +968,7 @@
8F973C341F21FE32003D3ADB /* main.m in Sources */,
8FEF5EA61F28612B001496E3 /* BaseIQManagerView.m in Sources */,
8F250D871F29C2420031B4BC /* LoginRequest.m in Sources */,
8F6C92421F2AE4AD0060E983 /* LocationHelper.m in Sources */,
8F250D4B1F297DA80031B4BC /* XWFilterAnimator+XWFlash.m in Sources */,
8FEF5EAC1F28612B001496E3 /* BaseStateModel.m in Sources */,
8FEF5EB01F28612B001496E3 /* ZJBaseFileModel.m in Sources */,
......@@ -970,6 +1001,7 @@
8FEF5E661F285E56001496E3 /* ChineseLogHelper.m in Sources */,
8F250D591F297DA80031B4BC /* XWFilterTransitionView.m in Sources */,
8F250D571F297DA80031B4BC /* XWFilterAnimator.m in Sources */,
8F6C923E1F2AE3430060E983 /* HomeViewController.m in Sources */,
8FEF5EA81F28612B001496E3 /* BaseListViewController.m in Sources */,
8F250D551F297DA80031B4BC /* XWFilterAnimator+XWSwipe.m in Sources */,
8F250D491F297DA80031B4BC /* XWFilterAnimator+XWCopyMachine.m in Sources */,
......@@ -1108,7 +1140,7 @@
INFOPLIST_FILE = "$(SRCROOT)/HDMall/HDMall_TEST.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.gomoretech.HDMall;
PRODUCT_BUNDLE_IDENTIFIER = com.gomoretech.HDMall.zj;
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "\"${PODS_ROOT}/**";
};
......@@ -1129,7 +1161,7 @@
INFOPLIST_FILE = "$(SRCROOT)/HDMall/HDMall_TEST.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.gomoretech.HDMall;
PRODUCT_BUNDLE_IDENTIFIER = com.gomoretech.HDMall.zj;
PRODUCT_NAME = "$(TARGET_NAME)";
USER_HEADER_SEARCH_PATHS = "\"${PODS_ROOT}/**";
};
......
......@@ -13,7 +13,7 @@
<!--首页-->
<scene sceneID="elJ-d9-ZJ6">
<objects>
<viewController id="WT4-sO-gHH" customClass="HomeViewController" sceneMemberID="viewController">
<viewController storyboardIdentifier="HomeViewController" id="WT4-sO-gHH" customClass="HomeViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="vNa-88-AnB"/>
<viewControllerLayoutGuide type="bottom" id="sqT-KY-cCy"/>
......@@ -21,7 +21,119 @@
<view key="view" contentMode="scaleToFill" id="yco-R1-GbA">
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gq2-NU-Zzr" userLabel="weather" customClass="HomeWeatherBoard">
<rect key="frame" x="0.0" y="44" width="375" height="113"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="home_bg" translatesAutoresizingMaskIntoConstraints="NO" id="WbR-PG-4zb">
<rect key="frame" x="0.0" y="0.0" width="375" height="113"/>
</imageView>
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleAspectFit" image="location_icon" translatesAutoresizingMaskIntoConstraints="NO" id="EQB-fi-VUn">
<rect key="frame" x="338" y="25" width="17" height="22"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="5cf-O2-tAn"/>
<constraint firstAttribute="width" constant="17" id="CPa-Vr-doF"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="定位中…" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="egB-Ta-Fdr">
<rect key="frame" x="272" y="26" width="62" height="20"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="1" green="0.99997437" blue="0.99999129769999995" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<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="Ym2-Pl-AJb">
<rect key="frame" x="355" y="58" width="0.0" height="0.0"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="1" green="0.99997437" blue="0.99999129769999995" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="GEa-jx-Fuo">
<rect key="frame" x="224" y="22" width="44" height="28"/>
<constraints>
<constraint firstAttribute="width" constant="44" id="GCn-ti-uRN"/>
<constraint firstAttribute="height" constant="28" id="lgS-MQ-aVE"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" red="1" green="0.99997437" blue="0.99999129769999995" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="WbR-PG-4zb" firstAttribute="leading" secondItem="gq2-NU-Zzr" secondAttribute="leading" id="0AE-X3-DMe"/>
<constraint firstAttribute="width" secondItem="gq2-NU-Zzr" secondAttribute="height" multiplier="25:8" id="8bV-Kh-ioP"/>
<constraint firstAttribute="height" constant="113" id="A29-au-diZ"/>
<constraint firstItem="WbR-PG-4zb" firstAttribute="top" secondItem="gq2-NU-Zzr" secondAttribute="top" id="GlS-mO-csN"/>
<constraint firstItem="Ym2-Pl-AJb" firstAttribute="trailing" secondItem="EQB-fi-VUn" secondAttribute="trailing" id="LOE-p5-BFj"/>
<constraint firstItem="egB-Ta-Fdr" firstAttribute="centerY" secondItem="EQB-fi-VUn" secondAttribute="centerY" id="ML4-Gj-FOW"/>
<constraint firstAttribute="trailing" secondItem="WbR-PG-4zb" secondAttribute="trailing" id="OcC-9X-kmz"/>
<constraint firstItem="EQB-fi-VUn" firstAttribute="centerY" secondItem="gq2-NU-Zzr" secondAttribute="centerY" constant="-20" id="RoG-Fd-5jD"/>
<constraint firstAttribute="height" constant="120" id="VwS-nZ-LeN"/>
<constraint firstAttribute="trailing" secondItem="EQB-fi-VUn" secondAttribute="trailing" constant="20" id="ZSa-AI-uBg"/>
<constraint firstItem="GEa-jx-Fuo" firstAttribute="centerY" secondItem="egB-Ta-Fdr" secondAttribute="centerY" id="c9F-hK-upc"/>
<constraint firstItem="egB-Ta-Fdr" firstAttribute="leading" secondItem="GEa-jx-Fuo" secondAttribute="trailing" constant="4" id="eWs-Bk-kzh"/>
<constraint firstItem="egB-Ta-Fdr" firstAttribute="leading" secondItem="GEa-jx-Fuo" secondAttribute="trailing" constant="2" id="p3A-xa-cJ5"/>
<constraint firstAttribute="bottom" secondItem="WbR-PG-4zb" secondAttribute="bottom" id="r6l-Xo-rxq"/>
<constraint firstItem="Ym2-Pl-AJb" firstAttribute="top" secondItem="GEa-jx-Fuo" secondAttribute="bottom" constant="7" id="sPu-qu-dJ1"/>
<constraint firstItem="EQB-fi-VUn" firstAttribute="leading" secondItem="egB-Ta-Fdr" secondAttribute="trailing" constant="4" id="v6F-gf-tOI"/>
<constraint firstItem="Ym2-Pl-AJb" firstAttribute="top" secondItem="egB-Ta-Fdr" secondAttribute="bottom" constant="12" id="vRE-5i-Y3a"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="VwS-nZ-LeN"/>
<exclude reference="8bV-Kh-ioP"/>
<exclude reference="p3A-xa-cJ5"/>
<exclude reference="sPu-qu-dJ1"/>
</mask>
</variation>
<connections>
<outlet property="city" destination="egB-Ta-Fdr" id="k1n-2K-YwL"/>
<outlet property="detail" destination="Ym2-Pl-AJb" id="NKM-mF-XNq"/>
<outlet property="img" destination="GEa-jx-Fuo" id="obr-2H-v4a"/>
<outlet property="imgHomeTopBg" destination="WbR-PG-4zb" id="rc8-hd-obh"/>
</connections>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zah-ph-xHa" userLabel="顶部">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="homepage_logo_origin" translatesAutoresizingMaskIntoConstraints="NO" id="FKv-Nj-Om0">
<rect key="frame" x="16" y="4" width="287" height="36"/>
<constraints>
<constraint firstAttribute="width" constant="287" id="JOb-0t-Rgf"/>
<constraint firstAttribute="width" constant="151" id="dEB-GV-HD6"/>
<constraint firstAttribute="width" secondItem="FKv-Nj-Om0" secondAttribute="height" multiplier="90:19" id="yDj-LI-9cf"/>
<constraint firstAttribute="width" constant="180" id="yhb-mI-xor"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="yDj-LI-9cf"/>
<exclude reference="dEB-GV-HD6"/>
<exclude reference="yhb-mI-xor"/>
</mask>
</variation>
</imageView>
</subviews>
<color key="backgroundColor" red="0.96055269239999996" green="0.96052390340000005" blue="0.96054017540000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="FKv-Nj-Om0" firstAttribute="top" secondItem="zah-ph-xHa" secondAttribute="top" constant="4" id="7lj-6L-2my"/>
<constraint firstAttribute="height" constant="44" id="ghL-zi-5aT"/>
<constraint firstItem="FKv-Nj-Om0" firstAttribute="width" secondItem="zah-ph-xHa" secondAttribute="height" multiplier="45:11" id="q42-cN-gK6"/>
<constraint firstAttribute="bottom" secondItem="FKv-Nj-Om0" secondAttribute="bottom" constant="4" id="tCD-LM-sp7"/>
<constraint firstItem="FKv-Nj-Om0" firstAttribute="leading" secondItem="zah-ph-xHa" secondAttribute="leading" constant="16" id="w3k-mU-Uhb"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="q42-cN-gK6"/>
</mask>
</variation>
</view>
</subviews>
<color key="backgroundColor" red="0.96055269239999996" green="0.96052390340000005" blue="0.96054017540000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="gq2-NU-Zzr" firstAttribute="leading" secondItem="yco-R1-GbA" secondAttribute="leading" id="MH1-Hs-Tri"/>
<constraint firstItem="gq2-NU-Zzr" firstAttribute="top" secondItem="zah-ph-xHa" secondAttribute="bottom" id="Sd9-xK-ah5"/>
<constraint firstItem="zah-ph-xHa" firstAttribute="top" secondItem="vNa-88-AnB" secondAttribute="bottom" id="U4X-6d-kzQ"/>
<constraint firstItem="zah-ph-xHa" firstAttribute="leading" secondItem="yco-R1-GbA" secondAttribute="leading" id="WG8-Wf-Bu5"/>
<constraint firstAttribute="trailing" secondItem="gq2-NU-Zzr" secondAttribute="trailing" id="nRg-tg-A0p"/>
<constraint firstAttribute="trailing" secondItem="zah-ph-xHa" secondAttribute="trailing" id="w8X-mY-5B4"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="" image="home" selectedImage="home_checked" id="ogE-hV-pE8">
<inset key="imageInsets" minX="0.0" minY="6" maxX="0.0" maxY="-6"/>
......@@ -603,7 +715,9 @@
<image name="business" width="25" height="39"/>
<image name="business_checked" width="25" height="38"/>
<image name="home" width="25" height="39"/>
<image name="home_bg" width="1348" height="500"/>
<image name="home_checked" width="25" height="39"/>
<image name="homepage_logo_origin" width="800" height="100"/>
<image name="imageView:M5j-cg-iW9:image" width="16" height="16">
<mutableData key="keyedArchiveRepresentation">
YnBsaXN0MDDUAQIDBAUGODlYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3ASAAGGoKwHCBEW
......@@ -635,6 +749,7 @@ AgEAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAdo
</mutableData>
</image>
<image name="launchImg" width="640" height="1136"/>
<image name="location_icon" width="16" height="20"/>
<image name="login_btn_select" width="160" height="50"/>
<image name="login_button_disable_bg" width="150" height="20"/>
<image name="pwd_icon" width="19" height="23"/>
......
//
// WeatherModel.h
// RealEstateManagement
//
// Created by Z on 16/7/6.
// Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WeatherModel : NSObject
@property (nonatomic, copy) NSString *weather;
@property (nonatomic, copy) NSString *wind;
@property (nonatomic, copy) NSString *temperature;
@property (nonatomic, copy) NSString *date;
@property (nonatomic, copy) NSString *dayPictureUrl;
@property (nonatomic, copy) NSString *nightPictureUrl;
@property (nonatomic, copy) NSString *city;
@end
//
// WeatherModel.m
// RealEstateManagement
//
// Created by Z on 16/7/6.
// Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//
#import "WeatherModel.h"
@implementation WeatherModel
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
}
@end
//
// HomeViewController.h
// HDMall
//
// Created by Javen on 2017/7/28.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "BaseViewController.h"
@interface HomeViewController : BaseViewController
@end
//
// HomeViewController.m
// HDMall
//
// Created by Javen on 2017/7/28.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "HomeViewController.h"
#import "HomeWeatherBoard.h"
@interface HomeViewController ()
@property (strong, nonatomic) HomeWeatherBoard *homeBoard;
@end
@implementation HomeViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleDefault;
}
ZJLazy(HomeWeatherBoard, homeBoard)
@end
//
// HomeWeatherBoard.h
// HDMall
//
// Created by Javen on 2017/7/28.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "WeatherModel.h"
#import "LocationHelper.h"
@interface HomeWeatherBoard : UIView
@property (weak, nonatomic) IBOutlet UIImageView *img;
@property (weak, nonatomic) IBOutlet UILabel *city;
@property (weak, nonatomic) IBOutlet UILabel *detail;
@property (strong, nonatomic) WeatherModel *weatherModel;
/** 顶部天气的背景 */
@property (weak, nonatomic) IBOutlet UIImageView *imgHomeTopBg;
- (void)configWithModel:(WeatherModel *)model;
@end
//
// HomeWeatherBoard.m
// HDMall
//
// Created by Javen on 2017/7/28.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "HomeWeatherBoard.h"
@implementation HomeWeatherBoard
- (void)awakeFromNib {
[super awakeFromNib];
WS(weakSelf);
[[LocationHelper shareInstance] getCityNameSuccess:^(NSString *string) {
[weakSelf httpGetWeather:string];
}
failed:nil];
}
- (void)configWithModel:(WeatherModel *)model {
if (model.city.length > 0) {
self.city.text = model.city;
[self.img sd_setImageWithURL:[NSURL URLWithString:model.dayPictureUrl]];
self.detail.text = [NSString stringWithFormat:@"%@ %@ %@", model.weather, model.wind, model.temperature];
}
}
/** 根据城市名称获取天气 */
- (void)httpGetWeather:(NSString *)cityName
{
if (nil != self.weatherModel) {
return;
}
NSDictionary *myDictionary = @{ @"ak" : BAIDU_AK, @"location" : cityName, @"output" : @"json" };
WS(weakSelf);
[ZJHttpManager GET:WEATHER_SERVER_URL parameters:myDictionary complete:^(id responseObject, NSError *error) {
//更新天气信息
weakSelf.weatherModel = [[WeatherModel alloc] init];
weakSelf.weatherModel.city = myDictionary[@"location"];
[weakSelf.weatherModel setValuesForKeysWithDictionary:responseObject[@"results"][0][@"weather_data"][0]];
[weakSelf configWithModel:weakSelf.weatherModel];
}];
}
@end
......@@ -27,6 +27,10 @@
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSLocationAlwaysUsageDescription</key>
<string>App需要您的同意,才能始终访问位置</string>
<key>NSLocationUsageDescription</key>
<string>App需要您的同意,才能访问位置</string>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
......
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "home_bg.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "homepage_logo_origin.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"filename" : "location_icon.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "location_icon@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -22,6 +22,7 @@
//third
#import "MJRefresh.h"
#import "UIImageView+WebCache.h"
//categories
......
......@@ -23,6 +23,11 @@ static NSString *const BASE_IP = @"http://gomoredev.natapp4.cc";
#endif
#define REST_BASE_URL [NSString stringWithFormat:@"%@/palmmall-server/rest", BASE_IP] //常用
#define REST_BASE_URL [NSString stringWithFormat:@"%@/palmmall-server/rest", BASE_IP]
//天气api
static NSString *const WEATHER_SERVER_URL = @"http://api.map.baidu.com/telematics/v3/weather";
static NSString *const BAIDU_AK = @"442b5fb0a1dc4dcbbccd26975e180e29";
#endif /* URL_h */
//
// LocationHelper.h
// RealEstateManagement
//
// Created by Javen on 2016/10/10.
// Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//
#import <Foundation/Foundation.h>
typedef void (^locationBlock)(NSString *string);
@interface LocationHelper : NSObject
@property (nonatomic, copy) locationBlock blockSuccess;
@property (nonatomic, copy) locationBlock blockFailed;
+ (LocationHelper *)shareInstance;
/**
* 获取当前城市名
*
* @param success 成功回调
* @param failed 失败回调
*/
- (void)getCityNameSuccess:(locationBlock)success failed:(locationBlock)failed;
@end
//
// LocationHelper.m
// RealEstateManagement
//
// Created by Javen on 2016/10/10.
// Copyright © 2016年 上海勾芒信息科技. All rights reserved.
//
#import "LocationHelper.h"
#import <CoreLocation/CoreLocation.h>
@interface LocationHelper ()<CLLocationManagerDelegate>
@property (nonatomic, strong) CLLocationManager *locationManager;
@end
@implementation LocationHelper
+ (LocationHelper *)shareInstance {
static LocationHelper *helper = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
helper = [[LocationHelper alloc] init];
});
return helper;
}
- (void)getCityNameSuccess:(locationBlock)success failed:(locationBlock)failed {
self.blockSuccess = success;
self.blockFailed = failed;
[self startLocation];
}
#pragma mark - 定位方法
//开始定位
- (void)startLocation {
if ([CLLocationManager locationServicesEnabled]) {
// CLog(@"--------开始定位");
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
//控制定位精度,越高耗电量越
self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
// 总是授权
[self.locationManager requestAlwaysAuthorization];
self.locationManager.distanceFilter = 10.0f;
[self.locationManager requestAlwaysAuthorization];
[self.locationManager startUpdatingLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
if ([error code] == kCLErrorDenied) {
if (self.blockFailed) {
self.blockFailed(@"访问被拒绝");
}
}
if ([error code] == kCLErrorLocationUnknown) {
if (self.blockFailed) {
self.blockFailed(@"无法获取位置信息");
}
}
}
//定位代理经纬度回调
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {
CLLocation *newLocation = locations[0];
// 获取当前所在的城市名
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
//根据经纬度反向地理编译出地址信息
WS(weakSelf);
[geocoder reverseGeocodeLocation:newLocation
completionHandler:^(NSArray *array, NSError *error) {
if (array.count > 0) {
CLPlacemark *placemark = [array objectAtIndex:0];
//获取城市
NSString *city = placemark.locality;
NSString *zipCode = placemark.postalCode;
if (!city) {
//四大直辖市的城市信息无法通过locality获得,只能通过获取省份的方法来获得(如果city为空,则可知为直辖市)
city = placemark.administrativeArea;
}
weakSelf.blockSuccess(city);
} else if (error == nil && [array count] == 0) {
NSLog(@"No results were returned.");
} else if (error != nil) {
NSLog(@"An error occurred = %@", error);
}
}];
//系统会一直更新数据,直到选择停止更新,因为我们只需要获得一次经纬度即可,所以获取之后就停止更新
[manager stopUpdatingLocation];
}
@end
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