|
|
@@ -18,7 +18,7 @@
|
|
|
|
|
|
@interface HttpRequest()
|
|
|
|
|
|
-@property (nonatomic, strong) NSString *urlRoot;
|
|
|
+
|
|
|
|
|
|
//register & login
|
|
|
@property (nonatomic, strong) NSString *urlLogin;
|
|
|
@@ -30,26 +30,36 @@
|
|
|
|
|
|
//social
|
|
|
@property (nonatomic, strong) NSString *urlSocialDataList;
|
|
|
+@property (nonatomic, strong) NSString *urlSocialDelete;
|
|
|
@property (nonatomic, strong) NSString *urlSocialLike;
|
|
|
@property (nonatomic, strong) NSString *urlSocialLikeList;
|
|
|
@property (nonatomic, strong) NSString *urlSocialComment;
|
|
|
@property (nonatomic, strong) NSString *urlSocialCommentList;
|
|
|
@property (nonatomic, strong) NSString *urlFollow;
|
|
|
@property (nonatomic, strong) NSString *urlFollowList;
|
|
|
+@property (nonatomic, strong) NSString *urlBefollowedList;
|
|
|
@property (nonatomic, strong) NSString *urlUserInfo;
|
|
|
@property (nonatomic, strong) NSString *urlUpdateUserInfo;
|
|
|
+@property (nonatomic, strong) NSString *urlUpdateAlias;
|
|
|
+@property (nonatomic, strong) NSString *urlFetchAlias;
|
|
|
@property (nonatomic, strong) NSString *urlUpdateNick;
|
|
|
@property (nonatomic, strong) NSString *urlUploadSocialBanner;
|
|
|
@property (nonatomic, strong) NSString *urlNearUser;
|
|
|
@property (nonatomic, strong) NSString *urlPhotoUpload;
|
|
|
+@property (nonatomic, strong) NSString *urlPhotoDelete;
|
|
|
|
|
|
@property (nonatomic, strong) NSString *urlRequestFriend;
|
|
|
@property (nonatomic, strong) NSString *urlFriendRequestList;
|
|
|
@property (nonatomic, strong) NSString *urlAddFriend;
|
|
|
@property (nonatomic, strong) NSString *urlDeleteFriendRequest;
|
|
|
|
|
|
+//chat
|
|
|
+@property (nonatomic, strong) NSString *urlChatRoomIntro;
|
|
|
+@property (nonatomic, strong) NSString *urlLastSystemMsg;
|
|
|
+
|
|
|
//trade
|
|
|
@property (nonatomic, strong) NSString *urlTradePublish;
|
|
|
+@property (nonatomic, strong) NSString *urlTradePublishCount;
|
|
|
@property (nonatomic, strong) NSString *urlTradeEdit;
|
|
|
@property (nonatomic, strong) NSString *urlTradeDelete;
|
|
|
@property (nonatomic, strong) NSString *urlTradeDataList;
|
|
|
@@ -57,9 +67,11 @@
|
|
|
@property (nonatomic, strong) NSString *urlTradeLatestDataList;
|
|
|
@property (nonatomic, strong) NSString *urlTradeFollow;
|
|
|
@property (nonatomic, strong) NSString *urlTradeDeleteFollow;
|
|
|
+@property (nonatomic, strong) NSString *urlTradeInfo;
|
|
|
|
|
|
//setting
|
|
|
@property (nonatomic, strong) NSString *urlChangeMobile;
|
|
|
+@property (nonatomic, strong) NSString *urlForgetPassword;
|
|
|
@property (nonatomic, strong) NSString *urlChangePassword;
|
|
|
@property (nonatomic, strong) NSString *urlFeedBack;
|
|
|
@property (nonatomic, strong) NSString *urlHobbyList;
|
|
|
@@ -67,11 +79,16 @@
|
|
|
@property (nonatomic, strong) NSString *urlContact;
|
|
|
@property (nonatomic, strong) NSString *urlChatStickList;
|
|
|
@property (nonatomic, strong) NSString *urlChatStick;
|
|
|
+@property (nonatomic, strong) NSString *urlResetLocation;
|
|
|
|
|
|
//sms
|
|
|
@property (nonatomic, strong) NSString *urlSendCode;
|
|
|
@property (nonatomic, strong) NSString *urlSendMsg;
|
|
|
|
|
|
+
|
|
|
+//payment
|
|
|
+@property (nonatomic, strong) NSString *urlIOSPayment;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation HttpRequest
|
|
|
@@ -91,7 +108,7 @@
|
|
|
self = [super init];
|
|
|
if(self)
|
|
|
{
|
|
|
- self.urlRoot = @"http://whosay.dashgame.com/";
|
|
|
+ self.urlRoot = @"http://118.31.11.27/";
|
|
|
|
|
|
|
|
|
self.urlRegister = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=register"];
|
|
|
@@ -103,18 +120,23 @@
|
|
|
|
|
|
|
|
|
self.urlSocialDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=lists"];
|
|
|
+ self.urlSocialDelete = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=delete"];
|
|
|
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.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.urlFollow = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=follow"];
|
|
|
self.urlFollowList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=follows"];
|
|
|
+ self.urlBefollowedList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=befollowed"];
|
|
|
self.urlUserInfo = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=get_user"];
|
|
|
self.urlUpdateNick = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=update_nick"];
|
|
|
+ self.urlUpdateAlias = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=update_alias"];
|
|
|
+ self.urlFetchAlias = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=fetch_alias"];
|
|
|
self.urlUpdateUserInfo = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=update_info"];
|
|
|
self.urlUploadSocialBanner = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=banner_upload"];
|
|
|
self.urlNearUser = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=near_user"];
|
|
|
self.urlPhotoUpload = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=photo_upload"];
|
|
|
+ self.urlPhotoDelete = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=photo_delete"];
|
|
|
self.urlContact = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=contact"];
|
|
|
|
|
|
self.urlRequestFriend = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=request_friend"];
|
|
|
@@ -123,7 +145,10 @@
|
|
|
self.urlDeleteFriendRequest = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=social&a=delete_request"];
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
self.urlTradePublish = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=publish"];
|
|
|
+ self.urlTradePublishCount = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=today_count"];
|
|
|
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.urlTradeDataList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=lists"];
|
|
|
@@ -131,9 +156,11 @@
|
|
|
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.urlTradeDeleteFollow = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=delete_follow"];
|
|
|
+ self.urlTradeInfo = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=trade&a=info"];
|
|
|
|
|
|
|
|
|
self.urlChangeMobile = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=change_mobile"];
|
|
|
+ self.urlForgetPassword = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=forget"];
|
|
|
self.urlChangePassword = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=pwd_update"];
|
|
|
self.urlFeedBack = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=feedback&a=report"];
|
|
|
self.urlHobbyList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=hobby_list"];
|
|
|
@@ -141,12 +168,20 @@
|
|
|
self.urlAbout = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=webview&id=about"];
|
|
|
self.urlLaw = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=webview&id=law"];
|
|
|
self.urlAgreement = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=webview&id=agreement"];
|
|
|
+ self.urlChatRoomIntro = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=chatroom_intro"];
|
|
|
self.urlChatStickList = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=chatstick_list"];
|
|
|
self.urlChatStick = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=chatstick"];
|
|
|
+ self.urlResetLocation = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=reset_location"];
|
|
|
|
|
|
|
|
|
self.urlSendCode = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=send_code"];
|
|
|
self.urlSendMsg = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=send_msg"];
|
|
|
+
|
|
|
+ self.urlLastSystemMsg = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=system_msg"];
|
|
|
+
|
|
|
+
|
|
|
+ self.urlIOSPayment = [NSString stringWithFormat:@"%@%@", self.urlRoot, @"index.php?m=who&c=index&a=ios_payment"];
|
|
|
+
|
|
|
}
|
|
|
return self;
|
|
|
}
|
|
|
@@ -211,11 +246,13 @@
|
|
|
|
|
|
} failure:^(NSURLSessionDataTask *task, NSError * error) {
|
|
|
NSLog(@"请求失败,服务器返回的错误信息%@", error);
|
|
|
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:error.description delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
|
|
|
- [alert showAlertWithCompletionHandler:^(NSInteger index) {
|
|
|
- if(failure)
|
|
|
- failure();
|
|
|
- }];
|
|
|
+// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:error.description delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
|
|
|
+// [alert showAlertWithCompletionHandler:^(NSInteger index) {
|
|
|
+// if(failure)
|
|
|
+// failure();
|
|
|
+// }];
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
@@ -248,7 +285,7 @@
|
|
|
|
|
|
[manager POST:URLString parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
|
|
|
|
|
|
- NSData *data = UIImageJPEGRepresentation(image, 1);
|
|
|
+ NSData *data = UIImageJPEGRepresentation(image, Image_Compression_Quality);
|
|
|
[formData appendPartWithFileData:data name:@"upload" fileName:@"banner.jpg" mimeType:@"image/jpg"];
|
|
|
|
|
|
} progress:uploadProgress success:^(NSURLSessionDataTask *task, id responseObject) {
|
|
|
@@ -390,7 +427,11 @@
|
|
|
user.districtRoomId = [data valueForKey:@"district_room_id"];
|
|
|
user.firstTimeJoin = YES;
|
|
|
|
|
|
+ user.tradePublishCountUpdateDate = [NSDate date];
|
|
|
user.tradePublishCount = [[data valueForKey:@"trade_count"] intValue];
|
|
|
+ user.lastSystemMsgId = [[data valueForKey:@"last_sys_msg"] intValue];
|
|
|
+
|
|
|
+ user.security = [[data valueForKey:@"security"] intValue];
|
|
|
|
|
|
NSMutableArray *tradePriorityItemArr = [data valueForKey:@"trade_priority"];
|
|
|
[user.tradePriorityItemArr removeAllObjects];
|
|
|
@@ -520,12 +561,14 @@
|
|
|
|
|
|
//social
|
|
|
- (void)getSocialDataList:(NSString *)lastId
|
|
|
+ targetId:(NSString *_Nullable)targetId
|
|
|
success:(void (^_Nullable)(NSMutableArray *dataList))success
|
|
|
failure:(void (^_Nullable)())failure{
|
|
|
|
|
|
NSString *userId = [NSString stringWithFormat:@"%d", [User sharedInfo].userId];
|
|
|
lastId = lastId ? lastId : @"";
|
|
|
- NSDictionary *parameters = @{@"user_id":userId, @"last_id":lastId};
|
|
|
+ targetId = targetId ? targetId : @"";
|
|
|
+ NSDictionary *parameters = @{@"user_id":userId, @"last_id":lastId, @"target_id":targetId};
|
|
|
|
|
|
[self request:_urlSocialDataList parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
|
|
|
@@ -565,6 +608,26 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+- (void)deleteSocialData:(NSString *_Nullable)socialId
|
|
|
+ success:(void (^_Nullable)(NSString * _Nullable socialId))success
|
|
|
+ failure:(void (^_Nullable)())failure{
|
|
|
+
|
|
|
+ NSString *userId = [NSString stringWithFormat:@"%d", [User sharedInfo].userId];
|
|
|
+ NSDictionary *parameters = @{@"user_id":userId, @"id":socialId};
|
|
|
+ [self request:_urlSocialDelete parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
+
|
|
|
+ NSString *sid = [jsonData objectForKey:@"id"];
|
|
|
+ [User sharedInfo].hasNewSocial = YES;
|
|
|
+
|
|
|
+ if(success)
|
|
|
+ success(sid);
|
|
|
+
|
|
|
+ } failure:^{
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
- (void)socialLike:(NSString *)socialId
|
|
|
success:(void (^_Nullable)(NSString * _Nullable socialId, int currentLikes, NSMutableArray *_Nullable likeList))success
|
|
|
failure:(void (^_Nullable)())failure{
|
|
|
@@ -733,17 +796,39 @@
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+- (void)befollowedList:(void (^_Nullable)(NSMutableArray * _Nullable follows))success
|
|
|
+ failure:(void (^_Nullable)())failure{
|
|
|
+ User *user = [User sharedInfo];
|
|
|
+ NSDictionary *parameters = @{@"user_id":[NSString stringWithFormat:@"%d", user.userId]};
|
|
|
+
|
|
|
+ [self request:_urlBefollowedList parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
+
|
|
|
+ if(success)
|
|
|
+ success(jsonData);
|
|
|
+
|
|
|
+ } failure:^{
|
|
|
+
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
- (void)userInfo:(NSString *_Nullable)userId
|
|
|
+ search:(BOOL *)search
|
|
|
success:(void (^_Nullable)(UserInfo * _Nullable userInfo))success
|
|
|
failure:(void (^_Nullable)())failure{
|
|
|
|
|
|
User *user = [User sharedInfo];
|
|
|
NSDictionary *parameters = @{@"user_id":[NSString stringWithFormat:@"%d", user.userId],
|
|
|
- @"target_id":userId};
|
|
|
+ @"target_id":userId,
|
|
|
+ @"search":search?@"1":@"0"};
|
|
|
|
|
|
[self request:_urlUserInfo parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
|
|
|
UserInfo *userInfo = [[UserInfo alloc] initWithJson:jsonData];
|
|
|
+ [[User sharedInfo] putUserInfo:userInfo];
|
|
|
+ [[NIMKit sharedKit] setAlias:userId alias:userInfo.alias];
|
|
|
|
|
|
if(success)
|
|
|
success(userInfo);
|
|
|
@@ -781,6 +866,66 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+- (void)updateAlias:(NSString *_Nonnull)userId
|
|
|
+ alias:(NSString *_Nonnull)alias
|
|
|
+ success:(void (^_Nullable)())success
|
|
|
+ failure:(void (^_Nullable)())failure{
|
|
|
+ User *user = [User sharedInfo];
|
|
|
+ NSDictionary *parameters = @{@"user_id":[NSString stringWithFormat:@"%d", user.userId],
|
|
|
+ @"target_id":userId,
|
|
|
+ @"alias":alias};
|
|
|
+
|
|
|
+ [self request:_urlUpdateAlias parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
+ [[NIMKit sharedKit] setAlias:userId alias:alias];
|
|
|
+ if(success)
|
|
|
+ success();
|
|
|
+ } failure:^{
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)fetchAlias:(NSMutableArray *_Nonnull)userIds
|
|
|
+ success:(void (^_Nullable)())success
|
|
|
+ failure:(void (^_Nullable)())failure{
|
|
|
+ User *user = [User sharedInfo];
|
|
|
+ NSDictionary *parameters = @{@"user_id":[NSString stringWithFormat:@"%d", user.userId],
|
|
|
+ @"target_ids":userIds};
|
|
|
+
|
|
|
+ int start = (int)[userIds count] - 1;
|
|
|
+ for(int i=start; i>=0; i--)
|
|
|
+ {
|
|
|
+ NSString *targetId = [userIds objectAtIndex:i];
|
|
|
+ if([[NIMKit sharedKit] hasAlias:targetId])
|
|
|
+ {
|
|
|
+ [userIds removeObjectAtIndex:i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(userIds.count == 0)
|
|
|
+ {
|
|
|
+ if(success)
|
|
|
+ success();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ [self request:_urlFetchAlias parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
+
|
|
|
+ NSMutableArray *list = [jsonData objectForKey:@"list"];
|
|
|
+ for(NSDictionary *dict in list)
|
|
|
+ {
|
|
|
+ NSString *targetId = [dict objectForKey:@"target_id"];
|
|
|
+ NSString *alias = [dict objectForKey:@"alias"];
|
|
|
+
|
|
|
+ [[NIMKit sharedKit] setAlias:targetId alias:alias];
|
|
|
+ }
|
|
|
+ if(success)
|
|
|
+ success();
|
|
|
+ } failure:^{
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+ }];
|
|
|
+}
|
|
|
|
|
|
- (void)updateUserInfo:(NSMutableDictionary *_Nonnull)info
|
|
|
success:(void (^_Nullable)())success
|
|
|
@@ -805,6 +950,8 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
- (void)uploadSocialBanner:(UIImage *_Nullable)image
|
|
|
success:(void (^_Nullable)(NSString * _Nullable imgURL))success
|
|
|
failure:(void (^_Nullable)())failure{
|
|
|
@@ -869,8 +1016,11 @@
|
|
|
|
|
|
[self uploadImage:_urlPhotoUpload image:image parameters:dict progress:nil success:^(id jsonData) {
|
|
|
|
|
|
+ NSMutableDictionary *data = [jsonData mutableCopy];
|
|
|
+ NSString *photoId = [[data objectForKey:@"id"] stringValue];
|
|
|
+ [data setValue:photoId forKey:@"id"];
|
|
|
if(success)
|
|
|
- success(jsonData);
|
|
|
+ success(data);
|
|
|
|
|
|
} failure:^{
|
|
|
if(failure)
|
|
|
@@ -879,6 +1029,20 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+- (void)deletePhoto:(NSString *_Nullable)photoId
|
|
|
+ success:(void (^_Nullable)())success
|
|
|
+ failure:(void (^_Nullable)())failure
|
|
|
+{
|
|
|
+ NSDictionary *dict = @{@"id":photoId};
|
|
|
+ [self request:_urlPhotoDelete parameters:dict progress:nil success:^(id jsonData) {
|
|
|
+ if(success)
|
|
|
+ success();
|
|
|
+ } failure:^{
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
@@ -990,7 +1154,13 @@
|
|
|
|
|
|
[self request:_urlTradePublish parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
|
|
|
+ float coin = [[jsonData objectForKey:@"coin"] floatValue];
|
|
|
+ int tradeId = [[jsonData objectForKey:@"id"] intValue];
|
|
|
+ [User sharedInfo].coin = coin;
|
|
|
+ [User sharedInfo].tradePublishCountUpdateDate = [NSDate date];
|
|
|
[User sharedInfo].tradePublishCount++;
|
|
|
+ if(!roomId)
|
|
|
+ [User sharedInfo].tradePublishLastId = tradeId;
|
|
|
|
|
|
if(success)
|
|
|
success();
|
|
|
@@ -1004,6 +1174,34 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+- (void)tradePublishCount:(void (^_Nullable)(int count))success
|
|
|
+ failure:(void (^_Nullable)())failure
|
|
|
+{
|
|
|
+ User *user = [User sharedInfo];
|
|
|
+ NSString *userId = [NSString stringWithFormat:@"%d", user.userId];
|
|
|
+
|
|
|
+ NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
|
|
|
+ [parameters setValue:userId forKey:@"user_id"];
|
|
|
+
|
|
|
+ [self request:_urlTradePublishCount parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
+
|
|
|
+ int count = [[jsonData objectForKey:@"count"] intValue];
|
|
|
+ [User sharedInfo].tradePublishCount = count;
|
|
|
+ [User sharedInfo].tradePublishCountUpdateDate = [NSDate date];
|
|
|
+
|
|
|
+ if(success)
|
|
|
+ success(count);
|
|
|
+
|
|
|
+ } failure:^{
|
|
|
+
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
- (void)tradeEdit:(NSString *)tradeId
|
|
|
msg:(NSString *)msg
|
|
|
picArr:(NSMutableArray *)picArr
|
|
|
@@ -1027,6 +1225,9 @@
|
|
|
NSMutableArray *picIdArr = [jsonData objectForKey:@"pic_ids"];
|
|
|
int priority = [[jsonData objectForKey:@"priority"] intValue];
|
|
|
|
|
|
+ int coin = [[jsonData objectForKey:@"coin"] intValue];
|
|
|
+ [User sharedInfo].coin = coin;
|
|
|
+
|
|
|
if(success)
|
|
|
success(tradeId, picArr, thumbArr, picIdArr, priority);
|
|
|
|
|
|
@@ -1075,12 +1276,16 @@
|
|
|
User *user = [User sharedInfo];
|
|
|
|
|
|
NSString *province = user.province ? user.province : @"";
|
|
|
+ NSString *city = user.city ? user.city : @"";
|
|
|
+ NSString *district = user.district ? user.district : @"";
|
|
|
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:city forKey:@"city"];
|
|
|
+ [parameters setValue:district forKey:@"district"];
|
|
|
[parameters setValue:userId forKey:@"user_id"];
|
|
|
|
|
|
|
|
|
@@ -1262,6 +1467,32 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
+- (void)tradeInfo:(NSString *_Nullable)tradeId
|
|
|
+ success:(void (^_Nullable)(TradeData * _Nullable data))success
|
|
|
+ failure:(void (^_Nullable)())failure
|
|
|
+{
|
|
|
+ User *user = [User sharedInfo];
|
|
|
+ NSString *userId = [NSString stringWithFormat:@"%d", user.userId];
|
|
|
+
|
|
|
+ NSDictionary *parameters = @{@"id":tradeId, @"user_id":userId};
|
|
|
+
|
|
|
+ [self request:_urlTradeInfo parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
+
|
|
|
+ TradeData *data = [[TradeData alloc] init];
|
|
|
+ [data setData:jsonData];
|
|
|
+
|
|
|
+ if(success)
|
|
|
+ success(data);
|
|
|
+
|
|
|
+ } failure:^{
|
|
|
+
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
//settings
|
|
|
@@ -1296,6 +1527,37 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+- (void)forgetPassword:(NSString *_Nullable)mobile
|
|
|
+ code:(NSString *_Nullable)code
|
|
|
+ password:(NSString *_Nullable)password
|
|
|
+ success:(void (^_Nullable)())success
|
|
|
+ failure:(void (^_Nullable)())failure{
|
|
|
+
|
|
|
+ User *user = [User sharedInfo];
|
|
|
+
|
|
|
+ NSString *userId = [NSString stringWithFormat:@"%d", user.userId];
|
|
|
+
|
|
|
+ NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
|
|
|
+ [parameters setValue:userId forKey:@"user_id"];
|
|
|
+ [parameters setValue:mobile forKey:@"mobile"];
|
|
|
+ [parameters setValue:code forKey:@"code"];
|
|
|
+ [parameters setValue:password forKey:@"pwd"];
|
|
|
+
|
|
|
+
|
|
|
+ [self request:_urlForgetPassword parameters:parameters progress:nil success:^(id jsonData) {
|
|
|
+
|
|
|
+ if(success)
|
|
|
+ success();
|
|
|
+
|
|
|
+ } failure:^{
|
|
|
+
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
- (void)changePassword:(NSString *_Nullable)pwd
|
|
|
changePwd:(NSString *_Nullable)changePwd
|
|
|
@@ -1318,6 +1580,8 @@
|
|
|
if(update)
|
|
|
{
|
|
|
NSString *token = [jsonData objectForKey:@"token"];
|
|
|
+ int security = [[jsonData objectForKey:@"security"] intValue];
|
|
|
+ [User sharedInfo].security = security;
|
|
|
|
|
|
LoginData *sdkData = [NTESLoginManager sharedManager].currentLoginData;
|
|
|
sdkData.token = token;
|
|
|
@@ -1478,4 +1742,108 @@
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+- (void)chatRoomIntro:(void (^)(NSString * _Nullable intro))success failure:(void (^)())failure
|
|
|
+{
|
|
|
+ NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
|
|
|
+
|
|
|
+ [self request:_urlChatRoomIntro parameters:parameters progress:nil
|
|
|
+ success:^(id jsonData) {
|
|
|
+ if(success)
|
|
|
+ success(jsonData);
|
|
|
+ } failure:^{
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+- (void)lastSystemMsg:(void (^_Nullable)(NSMutableDictionary * _Nullable data))success
|
|
|
+ failure:(void (^_Nullable)())failure
|
|
|
+{
|
|
|
+ NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
|
|
|
+
|
|
|
+ [self request:_urlLastSystemMsg parameters:parameters progress:nil
|
|
|
+ success:^(id jsonData) {
|
|
|
+
|
|
|
+ NSMutableArray *list = [jsonData objectForKey:@"list"];
|
|
|
+ if(success)
|
|
|
+ {
|
|
|
+ if(list.count > 0)
|
|
|
+ {
|
|
|
+ success([list firstObject]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ success(nil);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } failure:^{
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+- (void)resetLocation:(NSString *)province city:(NSString *)city district:(NSString *)district success:(void (^)())success failure:(void (^)())failure
|
|
|
+{
|
|
|
+ User *user = [User sharedInfo];
|
|
|
+ NSDictionary *parameters = @{@"id":[NSString stringWithFormat:@"%d", user.userId],
|
|
|
+ @"province":province,
|
|
|
+ @"city":city,
|
|
|
+ @"district":district
|
|
|
+ };
|
|
|
+
|
|
|
+ [self request:_urlResetLocation parameters:parameters progress:nil
|
|
|
+ success:^(id jsonData) {
|
|
|
+
|
|
|
+ user.province = province;
|
|
|
+ user.city = city;
|
|
|
+ user.district = district;
|
|
|
+
|
|
|
+ user.provinceRoomId = [jsonData objectForKey:@"province"];
|
|
|
+ user.cityRoomId = [jsonData objectForKey:@"city"];
|
|
|
+ user.districtRoomId = [jsonData objectForKey:@"district"];
|
|
|
+
|
|
|
+ if(success)
|
|
|
+ {
|
|
|
+ success();
|
|
|
+ }
|
|
|
+ } failure:^{
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+ }];
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+- (void)iosPayment:(NSString *_Nullable)code
|
|
|
+ receipt:(NSString *_Nullable)receipt
|
|
|
+ success:(void (^_Nullable)())success
|
|
|
+ failure:(void (^_Nullable)())failure
|
|
|
+{
|
|
|
+ User *user = [User sharedInfo];
|
|
|
+ NSDictionary *parameters = @{@"user_id":[NSString stringWithFormat:@"%d", user.userId],
|
|
|
+ @"code":code,
|
|
|
+ @"receipt":receipt
|
|
|
+ };
|
|
|
+ [self request:_urlIOSPayment parameters:parameters progress:nil
|
|
|
+ success:^(id jsonData) {
|
|
|
+
|
|
|
+ user.coin = [[jsonData objectForKey:@"coin"] intValue];
|
|
|
+
|
|
|
+ if(success)
|
|
|
+ {
|
|
|
+ success();
|
|
|
+ }
|
|
|
+ } failure:^{
|
|
|
+ if(failure)
|
|
|
+ failure();
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
@end
|