Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
HDMall-iOS
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张杰
HDMall-iOS
Commits
51cce7a2
Commit
51cce7a2
authored
Jul 28, 2017
by
Sandy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页定位天气功能
parent
74a48f81
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
508 additions
and
4 deletions
+508
-4
project.pbxproj
HDMall.xcodeproj/project.pbxproj
+34
-2
HDMall.xcworkspace的替身
HDMall.xcworkspace的替身
+0
-0
Main.storyboard
HDMall/Base.lproj/Main.storyboard
+116
-1
WeatherModel.h
HDMall/CodeClass/Home/Models/WeatherModel.h
+28
-0
WeatherModel.m
HDMall/CodeClass/Home/Models/WeatherModel.m
+17
-0
HomeViewController.h
HDMall/CodeClass/Home/ViewControllers/HomeViewController.h
+13
-0
HomeViewController.m
HDMall/CodeClass/Home/ViewControllers/HomeViewController.m
+32
-0
HomeWeatherBoard.h
HDMall/CodeClass/Home/Views/HomeWeatherBoard.h
+21
-0
HomeWeatherBoard.m
HDMall/CodeClass/Home/Views/HomeWeatherBoard.m
+51
-0
HDMall_TEST.plist
HDMall/HDMall_TEST.plist
+4
-0
Contents.json
HDMall/Supporting Files/Assets.xcassets/Home/Contents.json
+6
-0
Contents.json
...Files/Assets.xcassets/Home/home_bg.imageset/Contents.json
+21
-0
home_bg.png
...g Files/Assets.xcassets/Home/home_bg.imageset/home_bg.png
+0
-0
Contents.json
...xcassets/Home/homepage_logo_origin.imageset/Contents.json
+21
-0
homepage_logo_origin.png
...me/homepage_logo_origin.imageset/homepage_logo_origin.png
+0
-0
Contents.json
...Assets.xcassets/Home/location_icon.imageset/Contents.json
+22
-0
location_icon.png
...ts.xcassets/Home/location_icon.imageset/location_icon.png
+0
-0
location_icon@2x.png
...xcassets/Home/location_icon.imageset/location_icon@2x.png
+0
-0
PrefixHeader.pch
HDMall/Supporting Files/PrefixHeader.pch
+1
-0
URL.h
HDMall/Supporting Files/URL.h
+6
-1
LocationHelper.h
HDMall/Tools/LocationHelper/LocationHelper.h
+22
-0
LocationHelper.m
HDMall/Tools/LocationHelper/LocationHelper.m
+93
-0
No files found.
HDMall.xcodeproj/project.pbxproj
View file @
51cce7a2
...
...
@@ -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}/**"
;
};
...
...
HDMall.xcworkspace的替身
0 → 100644
View file @
51cce7a2
File added
HDMall/Base.lproj/Main.storyboard
View file @
51cce7a2
This diff is collapsed.
Click to expand it.
HDMall/CodeClass/Home/Models/WeatherModel.h
0 → 100644
View file @
51cce7a2
//
// 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
HDMall/CodeClass/Home/Models/WeatherModel.m
0 → 100644
View file @
51cce7a2
//
// 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
HDMall/CodeClass/Home/ViewControllers/HomeViewController.h
0 → 100644
View file @
51cce7a2
//
// HomeViewController.h
// HDMall
//
// Created by Javen on 2017/7/28.
// Copyright © 2017年 上海勾芒信息科技. All rights reserved.
//
#import "BaseViewController.h"
@interface
HomeViewController
:
BaseViewController
@end
HDMall/CodeClass/Home/ViewControllers/HomeViewController.m
0 → 100644
View file @
51cce7a2
//
// 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
HDMall/CodeClass/Home/Views/HomeWeatherBoard.h
0 → 100644
View file @
51cce7a2
//
// 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
HDMall/CodeClass/Home/Views/HomeWeatherBoard.m
0 → 100644
View file @
51cce7a2
//
// 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
HDMall/HDMall_TEST.plist
View file @
51cce7a2
...
...
@@ -27,6 +27,10 @@
<
k
e
y
>
NSAllowsArbitraryLoads
<
/k
e
y
>
<
tru
e
/
>
<
/
d
i
c
t
>
<
k
e
y
>
NSLocationAlwaysUsageDescription
<
/k
e
y
>
<
string
>
App
需要您的同意,才能始终访问位置
<
/string
>
<
k
e
y
>
NSLocationUsageDescription
<
/k
e
y
>
<
string
>
App
需要您的同意,才能访问位置
<
/string
>
<
k
e
y
>
UILaunchStoryboardName
<
/k
e
y
>
<
string
>
LaunchScreen
<
/string
>
<
k
e
y
>
UIMainStoryboardFile
<
/k
e
y
>
...
...
HDMall/Supporting Files/Assets.xcassets/Home/Contents.json
0 → 100644
View file @
51cce7a2
{
"info"
:
{
"version"
:
1
,
"author"
:
"xcode"
}
}
\ No newline at end of file
HDMall/Supporting Files/Assets.xcassets/Home/home_bg.imageset/Contents.json
0 → 100644
View file @
51cce7a2
{
"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
HDMall/Supporting Files/Assets.xcassets/Home/home_bg.imageset/home_bg.png
0 → 100644
View file @
51cce7a2
879 KB
HDMall/Supporting Files/Assets.xcassets/Home/homepage_logo_origin.imageset/Contents.json
0 → 100644
View file @
51cce7a2
{
"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
HDMall/Supporting Files/Assets.xcassets/Home/homepage_logo_origin.imageset/homepage_logo_origin.png
0 → 100644
View file @
51cce7a2
22 KB
HDMall/Supporting Files/Assets.xcassets/Home/location_icon.imageset/Contents.json
0 → 100644
View file @
51cce7a2
{
"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
HDMall/Supporting Files/Assets.xcassets/Home/location_icon.imageset/location_icon.png
0 → 100644
View file @
51cce7a2
1.69 KB
HDMall/Supporting Files/Assets.xcassets/Home/location_icon.imageset/location_icon@2x.png
0 → 100644
View file @
51cce7a2
2.67 KB
HDMall/Supporting Files/PrefixHeader.pch
View file @
51cce7a2
...
...
@@ -22,6 +22,7 @@
//third
#import "MJRefresh.h"
#import "UIImageView+WebCache.h"
//categories
...
...
HDMall/Supporting Files/URL.h
View file @
51cce7a2
...
...
@@ -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 */
HDMall/Tools/LocationHelper/LocationHelper.h
0 → 100644
View file @
51cce7a2
//
// 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
HDMall/Tools/LocationHelper/LocationHelper.m
0 → 100644
View file @
51cce7a2
//
// 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
.
0
f
;
[
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment