|
@@ -12,25 +12,35 @@
|
|
#import "User.h"
|
|
#import "User.h"
|
|
#import "NTESService.h"
|
|
#import "NTESService.h"
|
|
#import "NTESLoginManager.h"
|
|
#import "NTESLoginManager.h"
|
|
|
|
+#import "TradePriorityItemData.h"
|
|
|
|
+#import "CityManager.h"
|
|
|
|
|
|
|
|
|
|
@interface HttpRequest()
|
|
@interface HttpRequest()
|
|
|
|
|
|
@property (nonatomic, strong) NSString *urlRoot;
|
|
@property (nonatomic, strong) NSString *urlRoot;
|
|
|
|
|
|
|
|
+//register & login
|
|
@property (nonatomic, strong) NSString *urlLogin;
|
|
@property (nonatomic, strong) NSString *urlLogin;
|
|
@property (nonatomic, strong) NSString *urlRegister;
|
|
@property (nonatomic, strong) NSString *urlRegister;
|
|
|
|
|
|
|
|
+//location
|
|
|
|
+@property (nonatomic, strong) NSString *urlLocation;
|
|
|
|
+@property (nonatomic, strong) NSString *urlCoordinate2Location;
|
|
|
|
+
|
|
|
|
+//social
|
|
@property (nonatomic, strong) NSString *urlSocialDataList;
|
|
@property (nonatomic, strong) NSString *urlSocialDataList;
|
|
@property (nonatomic, strong) NSString *urlSocialLike;
|
|
@property (nonatomic, strong) NSString *urlSocialLike;
|
|
@property (nonatomic, strong) NSString *urlSocialLikeList;
|
|
@property (nonatomic, strong) NSString *urlSocialLikeList;
|
|
@property (nonatomic, strong) NSString *urlSocialComment;
|
|
@property (nonatomic, strong) NSString *urlSocialComment;
|
|
@property (nonatomic, strong) NSString *urlSocialCommentList;
|
|
@property (nonatomic, strong) NSString *urlSocialCommentList;
|
|
|
|
|
|
|
|
+//trade
|
|
@property (nonatomic, strong) NSString *urlTradePublish;
|
|
@property (nonatomic, strong) NSString *urlTradePublish;
|
|
@property (nonatomic, strong) NSString *urlTradeEdit;
|
|
@property (nonatomic, strong) NSString *urlTradeEdit;
|
|
@property (nonatomic, strong) NSString *urlTradeDelete;
|
|
@property (nonatomic, strong) NSString *urlTradeDelete;
|
|
@property (nonatomic, strong) NSString *urlTradeDataList;
|
|
@property (nonatomic, strong) NSString *urlTradeDataList;
|
|
|
|
+@property (nonatomic, strong) NSString *urlTradeSearchDataList;
|
|
@property (nonatomic, strong) NSString *urlTradeLatestDataList;
|
|
@property (nonatomic, strong) NSString *urlTradeLatestDataList;
|
|
@property (nonatomic, strong) NSString *urlTradeFollow;
|
|
@property (nonatomic, strong) NSString *urlTradeFollow;
|
|
@property (nonatomic, strong) NSString *urlTradeDeleteFollow;
|
|
@property (nonatomic, strong) NSString *urlTradeDeleteFollow;
|
|
@@ -57,19 +67,27 @@
|
|
{
|
|
{
|
|
self.urlRoot = @"http://whosay.dashgame.com/";
|
|
self.urlRoot = @"http://whosay.dashgame.com/";
|
|
|
|
|
|
|
|
+
|
|
self.urlRegister = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=register"];
|
|
self.urlRegister = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=register"];
|
|
self.urlLogin = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=login"];
|
|
self.urlLogin = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=login"];
|
|
|
|
|
|
|
|
+
|
|
|
|
+ self.urlLocation = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=location"];
|
|
|
|
+ self.urlCoordinate2Location = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=coordinate_2_location"];
|
|
|
|
+
|
|
|
|
+
|
|
self.urlSocialDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=lists"];
|
|
self.urlSocialDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=lists"];
|
|
self.urlSocialLike = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=like"];
|
|
self.urlSocialLike = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=like"];
|
|
self.urlSocialLikeList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=like_list"];
|
|
self.urlSocialLikeList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=like_list"];
|
|
self.urlSocialComment = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=comment"];
|
|
self.urlSocialComment = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=comment"];
|
|
self.urlSocialCommentList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=comment_list"];
|
|
self.urlSocialCommentList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=comment_list"];
|
|
|
|
|
|
|
|
+
|
|
self.urlTradePublish = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=publish"];
|
|
self.urlTradePublish = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=publish"];
|
|
self.urlTradeEdit = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=edit"];
|
|
self.urlTradeEdit = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=edit"];
|
|
self.urlTradeDelete = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=delete"];
|
|
self.urlTradeDelete = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=delete"];
|
|
self.urlTradeDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=lists"];
|
|
self.urlTradeDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=lists"];
|
|
|
|
+ self.urlTradeSearchDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=search"];
|
|
self.urlTradeLatestDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=latest_lists"];
|
|
self.urlTradeLatestDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=latest_lists"];
|
|
self.urlTradeFollow = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=follow"];
|
|
self.urlTradeFollow = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=follow"];
|
|
self.urlTradeDeleteFollow = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=delete_follow"];
|
|
self.urlTradeDeleteFollow = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=delete_follow"];
|
|
@@ -206,6 +224,18 @@
|
|
user.districtRoomId = [data valueForKey:@"district_room_id"];
|
|
user.districtRoomId = [data valueForKey:@"district_room_id"];
|
|
user.firstTimeJoin = YES;
|
|
user.firstTimeJoin = YES;
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ NSMutableArray *tradePriorityItemArr = [data valueForKey:@"trade_priority"];
|
|
|
|
+ [user.tradePriorityItemArr removeAllObjects];
|
|
|
|
+ for(int i=0; i<tradePriorityItemArr.count; i++)
|
|
|
|
+ {
|
|
|
|
+ TradePriorityItemData *priorityItem = [[TradePriorityItemData alloc] initByJson:[tradePriorityItemArr objectAtIndex:i]];
|
|
|
|
+ [user.tradePriorityItemArr addObject:priorityItem];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [CityManager shared];
|
|
|
|
+
|
|
if(success)
|
|
if(success)
|
|
success();
|
|
success();
|
|
|
|
|
|
@@ -252,8 +282,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+//location
|
|
|
|
+- (void)location:(double)longitude
|
|
|
|
+ latitude:(double)latitude
|
|
|
|
+ success:(void (^_Nullable)(NSString * _Nullable province, NSString * _Nullable city, NSString * _Nullable district, NSString * _Nullable provinceRoomId, NSString * _Nullable cityRoomId, NSString * _Nullable districtRoomId))success
|
|
|
|
+ failure:(void (^_Nullable)())failure{
|
|
|
|
+
|
|
|
|
+ NSDictionary *parameters = @{@"longitude":@(longitude), @"latitude":@(latitude)};
|
|
|
|
+
|
|
|
|
+ [self request:_urlLocation parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
|
+
|
|
|
|
+ NSString *province = [jsonData objectForKey:@"province"];
|
|
|
|
+ NSString *city = [jsonData objectForKey:@"city"];
|
|
|
|
+ NSString *district = [jsonData objectForKey:@"district"];
|
|
|
|
+
|
|
|
|
+ NSString *provinceRoomId = [jsonData objectForKey:@"province_room_id"];
|
|
|
|
+ NSString *cityRoomId = [jsonData objectForKey:@"city_room_id"];
|
|
|
|
+ NSString *districtRoomId = [jsonData objectForKey:@"district_room_id"];
|
|
|
|
+
|
|
|
|
+ if(success)
|
|
|
|
+ success(province, city, district, provinceRoomId, cityRoomId, districtRoomId);
|
|
|
|
+
|
|
|
|
+ } failure:^{
|
|
|
|
+ if(failure)
|
|
|
|
+ failure();
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+- (void)coordinate2Location:(void (^_Nullable)())success
|
|
|
|
+ failure:(void (^_Nullable)())failure
|
|
|
|
+{
|
|
|
|
+ __weak User *user = [User sharedInfo];
|
|
|
|
+
|
|
|
|
+ NSDictionary *parameters = @{@"id":[NSString stringWithFormat:@"%d", user.userId],
|
|
|
|
+ @"longitude":[NSString stringWithFormat:@"%F", user.longitude],
|
|
|
|
+ @"latitude":[NSString stringWithFormat:@"%F", user.latitude]
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ [self request:_urlCoordinate2Location parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
|
+
|
|
|
|
+ if([jsonData objectForKey:@"province"])
|
|
|
|
+ user.province = [jsonData objectForKey:@"province"];
|
|
|
|
+ if([jsonData objectForKey:@"city"])
|
|
|
|
+ user.city = [jsonData objectForKey:@"city"];
|
|
|
|
+ if([jsonData objectForKey:@"district"])
|
|
|
|
+ user.district = [jsonData objectForKey:@"district"];
|
|
|
|
+
|
|
|
|
+ if([jsonData objectForKey:@"province_room_id"])
|
|
|
|
+ user.provinceRoomId = [jsonData objectForKey:@"province_room_id"];
|
|
|
|
+ if([jsonData objectForKey:@"city_room_id"])
|
|
|
|
+ user.cityRoomId = [jsonData objectForKey:@"city_room_id"];
|
|
|
|
+ if([jsonData objectForKey:@"district_room_id"])
|
|
|
|
+ user.districtRoomId = [jsonData objectForKey:@"district_room_id"];
|
|
|
|
+
|
|
|
|
+ if(success)
|
|
|
|
+ success();
|
|
|
|
+
|
|
|
|
+ } failure:^{
|
|
|
|
+ if(failure)
|
|
|
|
+ failure();
|
|
|
|
+ }];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
+//social
|
|
- (void)getSocialDataList:(NSString *)lastId
|
|
- (void)getSocialDataList:(NSString *)lastId
|
|
success:(void (^_Nullable)(NSMutableArray *dataList))success
|
|
success:(void (^_Nullable)(NSMutableArray *dataList))success
|
|
failure:(void (^_Nullable)())failure{
|
|
failure:(void (^_Nullable)())failure{
|
|
@@ -430,6 +526,7 @@
|
|
picArr:(NSMutableArray *)picArr
|
|
picArr:(NSMutableArray *)picArr
|
|
type:(int)type
|
|
type:(int)type
|
|
priority:(int)priority
|
|
priority:(int)priority
|
|
|
|
+ priorityType:(int)priorityType
|
|
success:(void (^_Nullable)())success
|
|
success:(void (^_Nullable)())success
|
|
failure:(void (^_Nullable)())failure{
|
|
failure:(void (^_Nullable)())failure{
|
|
|
|
|
|
@@ -444,6 +541,7 @@
|
|
[parameters setValue:msg forKey:@"msg"];
|
|
[parameters setValue:msg forKey:@"msg"];
|
|
[parameters setValue:picArr forKey:@"pic"];
|
|
[parameters setValue:picArr forKey:@"pic"];
|
|
[parameters setValue:[NSString stringWithFormat:@"%d", priority] forKey:@"priority"];
|
|
[parameters setValue:[NSString stringWithFormat:@"%d", priority] forKey:@"priority"];
|
|
|
|
+ [parameters setValue:[NSString stringWithFormat:@"%d", priorityType] forKey:@"priority_type"];
|
|
[parameters setObject:roomId forKey:@"room_id"];
|
|
[parameters setObject:roomId forKey:@"room_id"];
|
|
|
|
|
|
[self request:_urlTradePublish parameters:parameters progress:nil success:^(id jsonData) {
|
|
[self request:_urlTradePublish parameters:parameters progress:nil success:^(id jsonData) {
|
|
@@ -570,6 +668,55 @@
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+- (void)tradeSearchList:(NSString *)keyWord
|
|
|
|
+ tradeSort:(TradeSort)tradeSort
|
|
|
|
+ page:(int)page
|
|
|
|
+ success:(void (^_Nullable)(NSMutableArray * _Nullable dataList))success
|
|
|
|
+ failure:(void (^_Nullable)())failure{
|
|
|
|
+
|
|
|
|
+ User *user = [User sharedInfo];
|
|
|
|
+
|
|
|
|
+ NSString *province = user.province ? user.province : @"";
|
|
|
|
+ NSString *userId = [NSString stringWithFormat:@"%d", user.userId];
|
|
|
|
+
|
|
|
|
+ NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
|
|
|
|
+ [parameters setValue:[NSString stringWithFormat:@"%ld", (long)tradeSort] forKey:@"sort"];
|
|
|
|
+ [parameters setValue:[NSString stringWithFormat:@"%d", page] forKey:@"page"];
|
|
|
|
+ [parameters setValue:province forKey:@"province"];
|
|
|
|
+ [parameters setValue:userId forKey:@"user_id"];
|
|
|
|
+ [parameters setValue:keyWord forKey:@"key"];
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ [self request:_urlTradeSearchDataList parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
|
+
|
|
|
|
+ NSMutableArray *userIds = [[NSMutableArray alloc] init];
|
|
|
|
+
|
|
|
|
+ NSMutableArray *jsonList = [jsonData objectForKey:@"list"];
|
|
|
|
+ NSMutableArray *list = [[NSMutableArray alloc] init];
|
|
|
|
+
|
|
|
|
+ for(int i=0; i<jsonList.count; i++)
|
|
|
|
+ {
|
|
|
|
+ NSDictionary *json = [jsonList objectAtIndex:i];
|
|
|
|
+ TradeData *data = [[TradeData alloc] init];
|
|
|
|
+ [data setData:json];
|
|
|
|
+ [list addObject:data];
|
|
|
|
+
|
|
|
|
+ [userIds addObject:data.userId];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ [[NIMSDK sharedSDK].userManager fetchUserInfos:userIds completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
|
|
|
|
+ if(success)
|
|
|
|
+ success(list);
|
|
|
|
+ }];
|
|
|
|
+
|
|
|
|
+ } failure:^{
|
|
|
|
+ if(failure)
|
|
|
|
+ failure();
|
|
|
|
+ }];
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
- (void)tradeLatestList:(void (^_Nullable)(NSMutableArray *dataList))success
|
|
- (void)tradeLatestList:(void (^_Nullable)(NSMutableArray *dataList))success
|
|
failure:(void (^_Nullable)())failure{
|
|
failure:(void (^_Nullable)())failure{
|