Skip to content

Commit 8df0be6

Browse files
author
ccharlesren
committed
1 parent 0d058d8 commit 8df0be6

File tree

6 files changed

+81
-25
lines changed

6 files changed

+81
-25
lines changed

Source/LinkApp/Classes/Module/Home/Controller/TIoTHomeViewController.m

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,22 @@ - (void)getFamilyInfoAddressWithFamilyID:(NSString *)currentFamilyId {
609609

610610
NSString *addressString = responseObject[@"Data"][@"Address"]?:@"";
611611

612-
[self getFamilyLocationWith:addressString];
612+
NSDictionary *dic = [NSString jsonToObject:addressString?:@""];
613+
if (dic != nil) {
614+
double lat = [dic[@"latitude"] doubleValue];
615+
double lng = [dic[@"longitude"] doubleValue];
616+
617+
self.latitude = lat;
618+
self.longitude = lng;
619+
620+
//请求天气数据
621+
[self requestWeatherData];
622+
623+
}else {
624+
[self getFamilyLocationWith:addressString];
625+
}
626+
627+
613628

614629
} failure:^(NSString *reason, NSError *error, NSDictionary *dic) {
615630

Source/LinkApp/Classes/Module/Map/Controller/TIoTMapVC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import "TIoTBaseMapViewController.h"
1010

1111
NS_ASSUME_NONNULL_BEGIN
12-
typedef void(^TIoTMapAddrssParseBlock)(NSString *address);
12+
typedef void(^TIoTMapAddrssParseBlock)(NSString *address, NSString *addressJson);
1313

1414
@interface TIoTMapVC : TIoTBaseMapViewController
1515
@property (nonatomic, strong) NSString *addressString;

Source/LinkApp/Classes/Module/Map/Controller/TIoTMapVC.m

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,26 +102,44 @@ - (void)setupPointAnnotation {
102102
}
103103

104104
- (void)setupHavedLocation {
105-
TIoTAppConfigModel *model = [TIoTAppConfig loadLocalConfigList];
106-
107-
NSString *urlString = [NSString stringWithFormat:@"%@%@&key=%@",MapSDKAddressParseURL,self.addressString?:@"",model.TencentMapSDKValue];
108105

109-
NSString *urlEncoded = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
110-
[[TIoTRequestObject shared] get:urlEncoded isNormalRequest:YES success:^(id responseObject) {
111-
TIoTAddressParseModel *addressModel = [TIoTAddressParseModel yy_modelWithJSON:responseObject[@"result"]];
106+
NSDictionary *addJsonDic = [NSString jsonToObject:self.addressString?:@""];
107+
if (addJsonDic != nil) {
108+
double lat = [addJsonDic[@"latitude"] doubleValue];
109+
double lng = [addJsonDic[@"longitude"] doubleValue];
112110

113-
CLLocationCoordinate2D addressLocation = CLLocationCoordinate2DMake(addressModel.location.lat,addressModel.location.lng);
111+
CLLocationCoordinate2D addressLocation = CLLocationCoordinate2DMake(lat,lng);
114112

115113
//定位大头针
116114
[self.mapView setCenterCoordinate:addressLocation];
117115

118116
//刷新地点列表
119117
[self resetRequestPragma];
120118
[self requestLocationList:addressLocation];
119+
}else {
120+
TIoTAppConfigModel *model = [TIoTAppConfig loadLocalConfigList];
121121

122-
} failure:^(NSString *reason, NSError *error, NSDictionary *dic) {
122+
NSString *urlString = [NSString stringWithFormat:@"%@%@&key=%@",MapSDKAddressParseURL,self.addressString?:@"",model.TencentMapSDKValue];
123123

124-
}];
124+
NSString *urlEncoded = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
125+
[[TIoTRequestObject shared] get:urlEncoded isNormalRequest:YES success:^(id responseObject) {
126+
TIoTAddressParseModel *addressModel = [TIoTAddressParseModel yy_modelWithJSON:responseObject[@"result"]];
127+
128+
CLLocationCoordinate2D addressLocation = CLLocationCoordinate2DMake(addressModel.location.lat,addressModel.location.lng);
129+
130+
//定位大头针
131+
[self.mapView setCenterCoordinate:addressLocation];
132+
133+
//刷新地点列表
134+
[self resetRequestPragma];
135+
[self requestLocationList:addressLocation];
136+
137+
} failure:^(NSString *reason, NSError *error, NSDictionary *dic) {
138+
139+
}];
140+
}
141+
142+
125143
}
126144

127145
- (void)setupBottomView {
@@ -615,8 +633,14 @@ - (TIoTIntelligentBottomActionView *)bottomActionView {
615633
if (weakSelf.addressBlcok) {
616634
if (weakSelf.selectedIndex>=0) {
617635
TIoTPoisModel *cellModel = weakSelf.searchResultArray[weakSelf.selectedIndex];
618-
NSString *addressString = [NSString stringWithFormat:@"%@%@%@%@",cellModel.ad_info.province?:@"",cellModel.ad_info.city?:@"",cellModel.ad_info.district?:@"",cellModel.address?:@""];
619-
weakSelf.addressBlcok(addressString);
636+
NSString *addressString = cellModel.title?:@"";
637+
NSString *addressDetail = [NSString stringWithFormat:@"%@%@%@%@",cellModel.ad_info.province?:@"",cellModel.ad_info.city?:@"",cellModel.ad_info.district?:@"",cellModel.address?:@""];
638+
NSString *lat = [NSString stringWithFormat:@"%f",cellModel.location.lat];
639+
NSString *lng = [NSString stringWithFormat:@"%f",cellModel.location.lng];
640+
NSDictionary *addressDic = @{@"address":addressDetail,@"latitude":lat,@"longitude":lng,@"city":cellModel.ad_info.city?:@"",@"name":cellModel.ad_info.name?:@"",@"title":addressString};
641+
642+
NSString *addressJson = [addressDic yy_modelToJSONString];
643+
weakSelf.addressBlcok(addressString, addressJson);
620644
}
621645
}
622646
[weakSelf.navigationController popViewControllerAnimated:YES];

Source/LinkApp/Classes/Module/Mine/Controller/Family/TIoTAddFamilyVC.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
116116
NSMutableDictionary *addressDictionary = self.dataArray[indexPath.row];
117117
mapVC.addressString = addressDictionary[@"value"];
118118
__weak typeof(self)weakSelf = self;
119-
mapVC.addressBlcok = ^(NSString * _Nonnull address) {
119+
mapVC.addressBlcok = ^(NSString * _Nonnull address, NSString * _Nonnull addressJson) {
120120
NSMutableDictionary *addressDic = weakSelf.dataArray[indexPath.row];
121121
[addressDic setValue:address forKey:@"value"];
122+
[addressDic setValue:addressJson forKey:@"addressJson"];
122123
[weakSelf.dataArray replaceObjectAtIndex:indexPath.row withObject:addressDic];
123124
TIoTAddFamilyCell *cell = [tableView cellForRowAtIndexPath:indexPath];
124125
cell.contentLabel.text = address;
@@ -145,7 +146,7 @@ - (UITableView *)tableView {
145146
- (NSMutableArray *)dataArray {
146147
if (!_dataArray) {
147148
_dataArray = [NSMutableArray arrayWithArray:@[[NSMutableDictionary dictionaryWithDictionary:@{@"title":NSLocalizedString(@"family_name", @"家庭名称"),@"value":@"",@"placeHold":NSLocalizedString(@"fill_family_name", @"请输入家庭名称")}],
148-
[NSMutableDictionary dictionaryWithDictionary:@{@"title":NSLocalizedString(@"family_address", @"家庭位置"),@"value":@"",@"placeHold":NSLocalizedString(@"setting_family_address", @"设置位置")}]]];
149+
[NSMutableDictionary dictionaryWithDictionary:@{@"title":NSLocalizedString(@"family_address", @"家庭位置"),@"value":@"",@"placeHold":NSLocalizedString(@"setting_family_address", @"设置位置"),@"addressJson":@""}]]];
149150
}
150151
return _dataArray;
151152
}

Source/LinkApp/Classes/Module/Mine/Controller/Family/TIoTFamilyInfoVC.m

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ - (void)getFamilyInfo {
6565
NSMutableDictionary *addressDic = self.dataArr[0][2];
6666
NSString *addressString = responseObject[@"Data"][@"Address"]?:@"";
6767
if (![NSString isNullOrNilWithObject:addressString]) {
68-
[addressDic setValue:responseObject[@"Data"][@"Address"] forKey:@"name"];
68+
69+
NSDictionary *addDic = [NSString jsonToObject:addressString];
70+
71+
[addressDic setValue:addDic[@"title"]?:@"" forKey:@"name"];
72+
[addressDic setValue:addressString forKey:@"addresJson"];
6973
}
7074
//刷新
7175
[self.coll reloadData];
@@ -125,16 +129,28 @@ - (void)leaveFamily
125129
}];
126130
}
127131

128-
- (void)modifyFamily:(NSString *)name adddress:(NSString *)address
132+
- (void)modifyFamily:(NSString *)name addressTitle:(NSString *)title isModifyAddrss:(BOOL)modifyAdd addJson:(NSString *)addJson
129133
{
130-
NSDictionary *param = @{@"FamilyId":self.familyInfo[@"FamilyId"],@"Name":name,@"Address":address};
134+
NSDictionary *param = nil;
135+
136+
if (modifyAdd == NO) {
137+
param = @{@"FamilyId":self.familyInfo[@"FamilyId"],@"Name":name};
138+
}else {
139+
param = @{@"FamilyId":self.familyInfo[@"FamilyId"],@"Name":name,@"Address":addJson};
140+
}
141+
131142
[[TIoTRequestObject shared] post:AppModifyFamily Param:param success:^(id responseObject) {
132143

133144
[HXYNotice addUpdateFamilyListPost];
134145

135146
NSMutableDictionary *dic = self.dataArr[0][0];
136147
[dic setValue:name forKey:@"name"];
137-
[self.coll reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForItem:0 inSection:0]]];
148+
149+
NSMutableDictionary *tempDic = self.dataArr[0][2];
150+
[tempDic setValue:title forKey:@"name"];
151+
[tempDic setValue:addJson forKey:@"addresJson"];
152+
153+
[self.coll reloadData];
138154
} failure:^(NSString *reason, NSError *error,NSDictionary *dic) {
139155

140156
}];
@@ -291,7 +307,7 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
291307
modifyNameVC.modifyNameBlock = ^(NSString * _Nonnull name) {
292308
NSMutableDictionary *addressDic = self.dataArr[0][2];
293309
if (name.length > 0) {
294-
[self modifyFamily:name adddress:addressDic[@"name"]?:@""];
310+
[self modifyFamily:name addressTitle:addressDic[@"name"] isModifyAddrss:NO addJson:@""];
295311
}
296312

297313
};
@@ -313,14 +329,14 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPa
313329
NSMutableDictionary *addressDictionary = self.dataArr[0][2];
314330
TIoTMapVC *mapVC = [[TIoTMapVC alloc]init];
315331
mapVC.title = NSLocalizedString(@"choose_location", @"地图选点");
316-
mapVC.addressString = addressDictionary[@"name"];
317-
mapVC.addressBlcok = ^(NSString * _Nonnull address) {
332+
mapVC.addressString = addressDictionary[@"addresJson"];
333+
mapVC.addressBlcok = ^(NSString * _Nonnull address, NSString * _Nonnull addressJson) {
318334
NSMutableDictionary *addressDic = self.dataArr[0][2];
319335
[addressDic setValue:address forKey:@"name"];
320336
[self.coll reloadItemsAtIndexPaths:@[indexPath]];
321337

322338
NSMutableDictionary *nameDic = self.dataArr[0][0];
323-
[self modifyFamily:nameDic[@"name"]?:@"" adddress:address?:@""];
339+
[self modifyFamily:nameDic[@"name"]?:@"" addressTitle:address isModifyAddrss:YES addJson:addressJson?:@""];
324340

325341
};
326342
[self.navigationController pushViewController:mapVC animated:YES];
@@ -400,7 +416,7 @@ - (NSMutableArray *)dataArr
400416
NSMutableArray *firstSection = [NSMutableArray array];
401417
[firstSection addObject:[NSMutableDictionary dictionaryWithDictionary:@{@"title":NSLocalizedString(@"family_name", @"家庭名称"),@"name":self.familyInfo[@"FamilyName"],@"Role":self.familyInfo[@"Role"]?:@""}]];
402418
[firstSection addObject:[NSMutableDictionary dictionaryWithDictionary:@{@"title":NSLocalizedString(@"room_manager", @"房间管理"),@"name":@"",@"RoomCount":@"",@"Role":@"1"}]];
403-
[firstSection addObject:[NSMutableDictionary dictionaryWithDictionary:@{@"title":NSLocalizedString(@"family_location", @"家庭位置"),@"name":NSLocalizedString(@"setting_family_address", @"设置位置")}]];
419+
[firstSection addObject:[NSMutableDictionary dictionaryWithDictionary:@{@"title":NSLocalizedString(@"family_location", @"家庭位置"),@"name":NSLocalizedString(@"setting_family_address", @"设置位置"),@"addresJson":@""}]];
404420

405421
if ([self.familyInfo[@"Role"] integerValue] == 1) {
406422
[firstSection addObject:[NSMutableDictionary dictionaryWithDictionary:@{@"title":NSLocalizedString(@"invite_family_member", @"邀请家庭成员"),@"name":@""}]];

Source/LinkApp/Supporting Files/app-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"XgAccessKey": "IA2MA3SNYWF5",
77
"XgUSAAccessId": "1630001536",
88
"XgUSAAccessKey": "ISH1Z2BMPTAB",
9-
"TencentMapSDKValue": "",
9+
"TencentMapSDKValue": "ZV6BZ-3ATCP-5BZDE-VFIJI-I7NO6-TIBAG",
1010
"HEweatherKey": ""
1111
}

0 commit comments

Comments
 (0)