HttpRequest.m 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322
  1. //
  2. // HttpRequest.m
  3. // zhuxun
  4. //
  5. // Created by 张建伟 on 15/4/7.
  6. // Copyright (c) 2015年 张建伟. All rights reserved.
  7. //
  8. #import "HttpRequest.h"
  9. //#import "LoginAPI.h"
  10. //#import "AuthAPI.h"
  11. #import "NSMutableDictionary+MuiltKeyValue.h"
  12. #define CloudStorageURL @"http://192.168.16.181:9123"//开发测试_云盘_API地址
  13. //#define CloudStorageURL @"http://netdisk.cloud.wswin.cn:9123"//生产环境_云盘_API地址
  14. #define CloudStorageDownUpUrl @"http://192.168.16.181"//开发测试_云盘_上传下载地址
  15. //#define CloudStorageDownUpUrl @"http://netdisk.cloud.wswin.cn:9120"//生产环境_云盘_上传下载地址
  16. @implementation HttpRequest
  17. + (instancetype)sharedManager {
  18. static HttpRequest *shared_manager = nil;
  19. static dispatch_once_t pred;
  20. dispatch_once(&pred, ^{
  21. shared_manager = [[HttpRequest alloc] init];
  22. });
  23. return shared_manager;
  24. }
  25. #pragma mark Login
  26. - (void)request_Login_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block{
  27. [[HttpClient sharedJsonClient] requestJsonDataWithPath:@"" withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  28. //获取数据
  29. id resultData = [data valueForKeyPath:@"data"];
  30. // if (resultData) {
  31. // User *curLoginUser = [NSObject objectOfClass:@"User" fromJSON:resultData];
  32. // if (curLoginUser) {
  33. // [Login doLogin:resultData];
  34. // }
  35. // block(curLoginUser, nil);
  36. // }else{
  37. // block(nil, error);
  38. // }
  39. }];
  40. }
  41. //--ok
  42. #warning 安全改造后以下代码无用##############################################
  43. -(void)postLoginParams:(NSDictionary *)params complete:(void (^)(BOOL success, id data, NSError *error)) complete
  44. {
  45. NSString *path = @"/v1/user/login";
  46. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  47. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  48. id resultData = [data valueForKey:@"data"];
  49. if (resultData) {
  50. complete(YES,data,nil);
  51. }else{
  52. complete(NO,nil,error);
  53. }
  54. }];
  55. }
  56. - (void)cloudStoragePostLoginWithParams:(NSDictionary *)params complete:(void (^)(BOOL success, id data, NSError *error)) complete
  57. {
  58. NSString *path = @"/v2/api/login";
  59. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  60. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  61. id resultData = [data valueForKey:@"data"];
  62. if (![resultData isKindOfClass:[NSNull class]]) {
  63. NSString *auth = resultData[@"authorization"];
  64. if (auth) {
  65. [userDefaults setObject:auth forKey:@"authorization"];
  66. }
  67. }
  68. NSString * key = [userDefaults objectForKey:@"authorization"];
  69. if (!key) {
  70. [userDefaults setObject:@"eHhqOkEwQTQ3NUNGNDU0Q0Y5QTA2OTc5MDM0MDk4MTY3QjlF" forKey:@"authorization"];
  71. }
  72. if (resultData) {
  73. complete(YES,data,nil);
  74. }else{
  75. complete(NO,nil,error);
  76. }
  77. }];
  78. }
  79. - (void)cloudStorageGetFilesWithPid:(NSString *)pid searchKey:(NSString *)key ext:(NSString *)ext complete:(void (^)(BOOL success, id data, NSError *error)) complete
  80. {
  81. NSString *path = @"/v2/api/item";
  82. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  83. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  84. if (pid) {
  85. [dict setObject:pid forKey:@"pid"];
  86. }
  87. if (key) {
  88. [dict setObject:key forKey:@"key"];
  89. }
  90. if (ext) {
  91. [dict setObject:ext forKey:@"ext"];
  92. }
  93. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Get andBlock:^(id data, NSError *error) {
  94. id resultData = [data valueForKey:@"data"];
  95. if (resultData) {
  96. complete(YES,data,nil);
  97. }else{
  98. complete(NO,nil,error);
  99. }
  100. }];
  101. }
  102. - (void)cloudStorageGetRecycledFilesWithComplete:(void (^)(BOOL success, id data, NSError *error)) complete
  103. {
  104. NSString *path = @"/v2/api/item/recycle";
  105. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  106. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
  107. id resultData = [data valueForKey:@"data"];
  108. if (resultData) {
  109. complete(YES,data,nil);
  110. }else{
  111. complete(NO,nil,error);
  112. }
  113. }];
  114. }
  115. - (void)cloudStorageFileDeleteWithItemIDs:(NSArray *)fileIDs deleteLevel:(NSInteger)deleteLevel complete:(void (^)(BOOL success, id data, NSError *error)) complete
  116. {
  117. NSString *path = @"/v2/api/item/delete";
  118. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  119. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  120. if (fileIDs) {
  121. [dict setObject:fileIDs forKey:@"item_ids"];
  122. }
  123. if (deleteLevel) {
  124. [dict setObject:@(deleteLevel) forKey:@"is_remove"];
  125. }
  126. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
  127. id resultData = [data valueForKey:@"data"];
  128. if (resultData) {
  129. complete(YES,data,nil);
  130. }else{
  131. complete(NO,nil,error);
  132. }
  133. }];
  134. }
  135. - (void)cloudStorageGetAllFolderWithPid:(NSString *)pid excludeIds:(NSArray *)excludeIds complete:(void (^)(BOOL success, id data, NSError *error)) complete
  136. {
  137. NSString *path = [NSString stringWithFormat:@"/v2/api/item/%@/folder",pid];
  138. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  139. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  140. if (excludeIds) {
  141. [dict setObject:excludeIds forKey:@"item_ids"];
  142. }
  143. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
  144. id resultData = [data valueForKey:@"data"];
  145. if (resultData) {
  146. complete(YES,data,nil);
  147. }else{
  148. complete(NO,nil,error);
  149. }
  150. }];
  151. }
  152. - (void)cloudStorageGetAllChildsWithPids:(NSArray *)pids complete:(void (^)(BOOL success, id data, NSError *error)) complete
  153. {
  154. NSString *path = @"/v2/api/item/childs";
  155. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  156. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  157. if (pids) {
  158. [dict setObject:pids forKey:@"ids"];
  159. }
  160. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
  161. id resultData = [data valueForKey:@"data"];
  162. if (resultData) {
  163. complete(YES,data,nil);
  164. }else{
  165. complete(NO,nil,error);
  166. }
  167. }];
  168. }
  169. - (void)cloudStorageFileReNameWithNewName:(NSString *)name fileID:(NSString *)itemID complete:(void (^)(BOOL success, id data, NSError *error)) complete
  170. {
  171. NSString *path = @"/v2/api/item/rename";
  172. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  173. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  174. if (name) {
  175. [dict setObject:name forKey:@"name"];
  176. }
  177. if (itemID) {
  178. [dict setObject:itemID forKey:@"_id"];
  179. }
  180. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
  181. id resultData = [data valueForKey:@"data"];
  182. if (resultData) {
  183. complete(YES,data,nil);
  184. }else{
  185. complete(NO,nil,error);
  186. }
  187. }];
  188. }
  189. - (void)cloudStorageCreateNewFileFolderWithFolderName:(NSString *)folderName pid:(NSString *)pid delflag:(NSString *)delflag complete:(void (^)(BOOL success, id data, NSError *error)) complete
  190. {
  191. NSString *path = @"/v2/api/item";
  192. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  193. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  194. [dict setObject:@1 forKey:@"isdir"];
  195. if (folderName) {
  196. [dict setObject:folderName forKey:@"name"];
  197. }
  198. if (pid) {
  199. [dict setObject:pid forKey:@"pid"];
  200. }
  201. if (delflag) {
  202. [dict setObject:delflag forKey:@"delflag"];
  203. }
  204. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
  205. id resultData = [data valueForKey:@"data"];
  206. if (resultData) {
  207. complete(YES,data,nil);
  208. }else{
  209. complete(NO,nil,error);
  210. }
  211. }];
  212. }
  213. - (void)cloudStorageCheckFileNameIsExitWithPid:(NSString *)pid fileName:(NSString *)fileName isdir:(BOOL)isdir ext:(NSString *)ext complete:(void (^)(BOOL success, id data, NSError *error)) complete
  214. {
  215. NSString *path = @"/v2/api/item/check_rename";
  216. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  217. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  218. [dict setObject:pid forKey:@"pid"];
  219. [dict setObject:fileName forKey:@"name"];
  220. [dict setObject:@(isdir) forKey:@"isdir"];
  221. if (ext) {
  222. [dict setObject:ext forKey:@"ext"];
  223. }
  224. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
  225. id resultData = [data valueForKey:@"data"];
  226. if (resultData) {
  227. complete(YES,data,nil);
  228. }else{
  229. complete(NO,nil,error);
  230. }
  231. }];
  232. }
  233. - (void)cloudStorageCreateNewFileWithFileName:(NSString *)fileName md5:(NSString *)md5 pid:(NSString *)pid delflag:(NSString *)delflag ext:(NSString *)ext size:(NSNumber*)size complete:(void (^)(BOOL success, id data, NSError *error)) complete
  234. {
  235. NSString *path = @"/v2/api/item";
  236. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  237. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  238. [dict setObject:@0 forKey:@"isdir"];
  239. if (fileName) {
  240. [dict setObject:fileName forKey:@"name"];
  241. }
  242. if (pid) {
  243. [dict setObject:pid forKey:@"pid"];
  244. }else{
  245. [dict setObject:@"0" forKey:@"pid"];
  246. }
  247. if (delflag) {
  248. [dict setObject:delflag forKey:@"delflag"];
  249. }
  250. //
  251. if (md5) {
  252. [dict setObject:md5 forKey:@"md5"];
  253. }
  254. if (ext) {
  255. [dict setObject:ext forKey:@"ext"];
  256. }
  257. if (size) {
  258. [dict setObject:size forKey:@"size"];
  259. }
  260. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
  261. id resultData = [data valueForKey:@"data"];
  262. if (resultData) {
  263. complete(YES,data,nil);
  264. }else{
  265. complete(NO,nil,error);
  266. }
  267. }];
  268. }
  269. -(void)cloudStorageMoveFilesToOtherPid:(NSString *)pid needMoveFiles:(NSArray *)csfiles complete:(void (^)(BOOL, id, NSError *))complete
  270. {
  271. NSString *path = [NSString stringWithFormat:@"/v2/api/item/move_file/to/%@",pid];
  272. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  273. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  274. [dict setObject:csfiles forKey:@"item_ids"];
  275. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
  276. id resultData = [data valueForKey:@"data"];
  277. if (resultData) {
  278. complete(YES,data,nil);
  279. }else{
  280. complete(NO,nil,error);
  281. }
  282. }];
  283. }
  284. - (void)cloudStorageCopyFilesToOtherPid:(NSString *)pid needCopyFiles:(NSArray *)csfiles complete:(void (^)(BOOL, id, NSError *))complete{
  285. NSString *path = [NSString stringWithFormat:@"/v2/api/item/copy_file/to/%@",pid];
  286. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  287. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  288. [dict setObject:csfiles forKey:@"item_ids"];
  289. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
  290. id resultData = [data valueForKey:@"data"];
  291. if (resultData) {
  292. complete(YES,data,nil);
  293. }else{
  294. complete(NO,nil,error);
  295. }
  296. }];
  297. }
  298. - (void)cloudStorageGetFileDownloadURLWithMD5:(NSString *)md5 complete:(void (^)(BOOL success, id data, NSError *error)) complete
  299. {
  300. NSString *path = [NSString stringWithFormat:@"/api/download/%@",md5];
  301. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageDownUpUrl,path];
  302. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  303. // [dict setObject:md5 forKey:@"md5"];
  304. [[HttpClient sharedJsonClient] cloudStorageDownUpJsonDataWithPath:fullPath withParams:dict withMethodType:Get andBlock:^(id data, NSError *error) {
  305. if (data) {
  306. complete(YES,data,nil);
  307. }else{
  308. complete(NO,nil,error);
  309. }
  310. }];
  311. }
  312. - (void)cloudStorageGetFileUploadURLWithMD5:(NSString *)md5 complete:(void (^)(BOOL success, id data, NSError *error)) complete
  313. {
  314. NSString *path = [NSString stringWithFormat:@"/api/upload/%@/%@",@"tcp",md5];
  315. // NSString *path = @"/api/upload";
  316. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageDownUpUrl,path];
  317. // NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  318. // [dict setObject:md5 forKey:@"md5"];
  319. // [dict setObject:@"tcp" forKey:@"type"];
  320. [[HttpClient sharedJsonClient] cloudStorageDownUpJsonDataWithPath:fullPath withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
  321. if (data) {
  322. complete(YES,data,nil);
  323. }else{
  324. complete(NO,nil,error);
  325. }
  326. }];
  327. }
  328. - (void)cloudStorageCreateShareFiles:(NSArray *)filesdic WithReceivers:(NSArray*)receivers complete:(void (^)(BOOL success, id data, NSError *error)) complete
  329. {
  330. NSString *path = @"/v2/api/share";
  331. NSString *fullPath = [NSString stringWithFormat:@"%@%@",CloudStorageURL,path];
  332. NSMutableDictionary *dict = [NSMutableDictionary dictionary];
  333. NSMutableString *mstr = [NSMutableString string];
  334. NSMutableArray *item_ids = [NSMutableArray array];
  335. [dict setObject:receivers forKey:@"users"];//移动端没有部门 直接用户多选
  336. for (NSDictionary *sdic in filesdic) {
  337. NSString *name = [sdic objectForKey:@"name"];
  338. NSString *item_id = [sdic objectForKey:@"id"];
  339. [mstr appendString:name];
  340. [item_ids addObject:item_id];
  341. }
  342. NSDictionary *share_file =@{@"name":mstr,
  343. @"item_ids":item_ids};
  344. [dict setObject:share_file forKey:@"share_file"];
  345. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:dict withMethodType:Post andBlock:^(id data, NSError *error) {
  346. if (data) {
  347. complete(YES,data,nil);
  348. }else{
  349. complete(NO,nil,error);
  350. }
  351. }];
  352. }
  353. - (void)cloudStorageGetShareFiles:(NSString *)shareID complete:(void (^)(BOOL success, id data, NSError *error)) complete
  354. {
  355. NSString *path = @"/v2/api/share/package/";
  356. NSString *fullPath = [NSString stringWithFormat:@"%@%@%@",CloudStorageURL,path,shareID];
  357. [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:fullPath withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
  358. if (data) {
  359. complete(YES,data,nil);
  360. }else{
  361. complete(NO,nil,error);
  362. }
  363. }];
  364. }
  365. #pragma mark --- 云盘相关结束
  366. //
  367. ////获取群组通信和存储信息 --ok
  368. //-(void)getGroupParams:(NSDictionary *)params complete:(void (^)(BOOL success, id data, NSError *error)) complete
  369. //{
  370. //
  371. // NSString *path = @"/v1/servers";
  372. // NSString *aPath = [NSString stringWithFormat:@"http://%@:%@%@",[userDefaults objectForKey:USERDEFAULT_GROUP_HOST],[userDefaults objectForKey:USERDEFAULT_GROUP_PORT],path];
  373. //#warning 2016-06-28 中心服务器地址有问题??
  374. // [[HttpClient sharedJsonClient] cloudStorageRequestJsonDataWithPath:aPath withParams:params withMethodType:Get andBlock:^(id data, NSError *error) {
  375. //
  376. //
  377. // /*
  378. // {
  379. // "socket": {
  380. // "host": "120.26.126.129",
  381. // "port": 6714,
  382. // "id": "120.26.126.129:6714",
  383. // "online": 4,
  384. // "type": "mix",
  385. // "ver": "3.2.0"
  386. // },
  387. // "storage": {
  388. // "host": "120.26.126.129",
  389. // "port": 6713
  390. // }
  391. // }
  392. // */
  393. //
  394. // complete(data?1:0,data,error);
  395. //
  396. // }];
  397. //}
  398. //
  399. //--ok
  400. -(void)postDeviceInfo:(NSDictionary *)params complete:(void (^)(BOOL, id, NSError *))complete{
  401. NSString *path = @"/v1/device/perfect";
  402. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  403. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  404. id resultData = [data valueForKey:@"message"];
  405. if (resultData) {
  406. complete(YES,data,nil);
  407. }else{
  408. complete(NO,nil,error);
  409. }
  410. }];
  411. }
  412. //--ok
  413. -(void)request_resetUnreadCount_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  414. {
  415. NSString *path = @"/zhuxunserver/devices/resetUnreadCount";
  416. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  417. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  418. id resultData = [data valueForKeyPath:@"data"];
  419. if (resultData) {
  420. // User *curLoginUser = [NSObject objectOfClass:@"User" fromJSON:resultData];
  421. // if (curLoginUser) {
  422. // [Login doLogin:resultData];
  423. // }
  424. // block(curLoginUser, nil);
  425. }else{
  426. // block(nil, error);
  427. }
  428. }];
  429. }
  430. //--ok
  431. -(void)search_users_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  432. {
  433. NSString *path = @"/zhuxunserver/branchs/searchUsers";
  434. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  435. //@"branchs/searchUsers"
  436. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  437. //获取数据
  438. id resultData = [data valueForKeyPath:@"data"];
  439. //如果数据存在
  440. if (resultData) {
  441. //获取对象数组
  442. // NSArray *items = [resultData valueForKeyPath:@"items"];
  443. //将数组传递出去
  444. block(resultData, nil);
  445. }else{
  446. block(nil, error);
  447. }
  448. }];
  449. }
  450. //-ok
  451. #warning mark - - users/getUserDetail
  452. -(void)request_userDetail_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  453. {
  454. NSString *path = @"/zhuxunserver/users/getUserDetail";
  455. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  456. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  457. id resultData = [data valueForKeyPath:@"data"];
  458. if (resultData) {
  459. block(resultData, nil);
  460. }else{
  461. block(nil, error);
  462. }
  463. }];
  464. }
  465. //请求用户状态--废弃
  466. -(void)request_userState_WithParams:(id)params andBlock:(void (^)(id, NSError *))block{
  467. // NSString *StrUrl = @"http://120.26.126.129:30001/zhuxunserver/users/getUserStates"; /zhuxunserver/
  468. NSString *path = @"/zhuxunserver/users/getUserStates";
  469. NSString *aPath =[NSString stringWithFormat:@"%@%@",APP_HOST,path];
  470. [[HttpClient sharedJsonClient] postRequestToUrl:aPath netWorkMethod:Post aPath:aPath WithParams:params complete:^(BOOL successed, NSDictionary *result) {
  471. id resultData = [result valueForKeyPath:@"data"];
  472. // NSLog(@"resultData: %@",resultData);
  473. // if (result) {
  474. block(resultData,nil);
  475. // }
  476. }];
  477. }
  478. //请求多用户状态
  479. -(void)request_UserDetailListWith:(id)params andBlock:(void(^)(id data,NSError *error))block
  480. {
  481. NSString *path = @"/v1/users/detailList";
  482. NSString *aPath =[NSString stringWithFormat:@"%@%@",APP_HOST,path];
  483. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  484. if (error) {
  485. //提示
  486. return ;
  487. }
  488. id result = data[@"data"];
  489. if (!result) {
  490. return;
  491. }
  492. block(result,nil);
  493. }];
  494. }
  495. //--废弃
  496. -(void)request_Branches_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
  497. {
  498. //客户端的数据请求 类型为 post params: -1
  499. NSString *path = @"/zhuxunserver/branchs/getBranchsByParentID";
  500. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  501. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  502. id resultData = [data valueForKeyPath:@"data"];
  503. if (resultData) {
  504. block(resultData, nil);
  505. }else{
  506. block(nil, error);
  507. }
  508. }];
  509. }
  510. //通过传入的参数 'params' ,向服务器获取所有的分支机构--ok
  511. -(void)request_allChildOfBranch_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  512. {
  513. NSString *path = @"/zhuxunserver/branchs/getAllChildrenByParentID";
  514. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  515. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  516. id resultData = [data valueForKeyPath:@"data"];
  517. if (resultData) {
  518. block(resultData, nil);
  519. }else{
  520. block(nil, error);
  521. }
  522. }];
  523. }
  524. //--ok
  525. -(void)upload_headImage_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
  526. {
  527. NSString *path = @"/zhuxunserver/users/uploadHeadImage";
  528. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  529. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  530. id resultData = [data valueForKeyPath:@"data"];
  531. if (resultData) {
  532. block(resultData, nil);
  533. }else{
  534. block(nil, error);
  535. }
  536. }];
  537. }
  538. //同步通讯录 使用数据请求--ok
  539. -(void)request_personalAddrbook_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
  540. {
  541. NSString *path = @"/zhuxunserver/addressBooks/sync";
  542. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  543. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  544. //取数据 data
  545. id resultData = [data valueForKeyPath:@"data"];
  546. //如果有数据,就block回调数据
  547. if (resultData) {
  548. block(resultData, nil);
  549. }else{
  550. block(nil, error);
  551. }
  552. }];
  553. }
  554. //--ok
  555. -(void)request_sendSMS_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
  556. {
  557. NSString *path = @"/zhuxunserver/sms/sendCode";
  558. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  559. //原来的是 sms/sendCode
  560. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  561. id resultData = [data valueForKeyPath:@"data"];
  562. if (resultData) {
  563. NSLog(@"resultData: %@",resultData);
  564. block(resultData, nil);
  565. }else{
  566. block(nil, error);
  567. }
  568. }];
  569. }
  570. //--ok
  571. -(void)request_authSMS_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
  572. {
  573. NSString *path = @"/zhuxunserver/sms/authCode";
  574. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  575. LOG(@"\n\nappHost: %@\n\n",APP_HOST);
  576. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  577. id resultData = [data valueForKeyPath:@"data"];
  578. if (resultData) {
  579. block(resultData, nil);
  580. }else{
  581. block(nil, error);
  582. }
  583. }];
  584. }
  585. //请求通知公告提醒--ok
  586. -(void)request_NoticeOffline_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
  587. {
  588. NSString *path = @"/zx/notice/offline";
  589. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  590. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  591. id resultData = [data valueForKeyPath:@"data"];
  592. if (resultData) {
  593. block(resultData,nil);
  594. }else{
  595. block(nil,error);
  596. }
  597. }];
  598. }
  599. -(void) request_with:(NetworkMethod)method andUrl:(NSString *)url andPrams:(id)params andBlock:(void (^)(id))block
  600. {
  601. [[HttpClient sharedJsonClient] requestJsonDataWithPath:url withParams:params withMethodType:method andBlock:^(id data, NSError *error) {
  602. if(error){
  603. // 提示
  604. return;
  605. }
  606. id resultData = [data valueForKeyPath:@"data"];
  607. block(resultData);
  608. }];
  609. }
  610. //获取离线消息--废弃
  611. -(void)request_MsgOffLine_WithParams:(id)params andBlock:(void (^)(id, NSError *))block
  612. {
  613. NSString *path = @"/v1/msg/offline";
  614. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  615. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  616. id resultData = [data valueForKeyPath:@"data"];
  617. if (resultData) {
  618. block(resultData,nil);
  619. }else{
  620. block(nil,error);
  621. }
  622. }];
  623. }
  624. //获取历史消息--废弃
  625. -(void)request_HistoryMessage_WithParams:(id)params andBlock:(void(^)(id data ,NSError *error))block
  626. {
  627. //history
  628. NSString *path = @"/v1/msg/sync";
  629. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  630. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  631. if(error){
  632. //用户提示;
  633. return;
  634. }
  635. NSLog(@"%@",data[@"message"]);
  636. BOOL success = data[@"success"];
  637. id result = nil;
  638. if (success) {
  639. result = data[@"data"];
  640. }
  641. block(result,nil);
  642. }];
  643. }
  644. //获取发送者离线同步消息 /v1/msg/offlinesync 自己在PC发送的消息
  645. -(void)request_MsgOffLinesync_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  646. {
  647. NSString *path = @"/v1/msg/offlinesync";
  648. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  649. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  650. if(error){
  651. //用户提示;
  652. return;
  653. }
  654. NSLog(@"%@",data[@"message"]);
  655. BOOL success = data[@"success"];
  656. id result = nil;
  657. if (success) {
  658. result = data[@"data"];
  659. }
  660. block(result,nil);
  661. }];
  662. }
  663. /**
  664. * 统一获取离线消息--废弃
  665. *
  666. * @param params
  667. * @param block
  668. */
  669. -(void)request_MsgOffLinesMsgsParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  670. {
  671. /*
  672. 参数说明:
  673. String target -必填项,目标用户,格式:CID+serverID-loginName
  674. String uuid -可选项,请求唯一标识
  675. 参数格式: { target : "0578+serverID-loginName", uuid:""
  676. */
  677. NSString *path = @"/v1/msg/offlineFull";
  678. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  679. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  680. if(error){
  681. //用户提示;
  682. return;
  683. }
  684. NSLog(@"%@",data[@"message"]);
  685. BOOL success = data[@"success"];
  686. id result = nil;
  687. if (success) {
  688. result = data[@"data"];
  689. }
  690. block(result,nil);
  691. }];
  692. }
  693. /**
  694. * 离线消息获取并反馈成功接口--废弃
  695. *
  696. * @param params
  697. * @param block
  698. */
  699. -(void)request_MsgOffLinesMsgsReceiveResponse:(id)params andBlock:(void (^)(id data, NSError *error))block
  700. {
  701. /*
  702. 参数说明:
  703. Array uuids -必填项,拉取的数据唯一标识uuid数组,示例:['111','222']
  704. String target -可选项,目标用户,格式:CID+serverID-loginName
  705. String uuid -可选项,请求唯一标识
  706. 参数格式: { uuids:['111','222'], target : "0578+serverID-loginName", uuid:"" }
  707. */
  708. NSString *path = @"/v1/msg/receivedFull";
  709. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  710. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  711. if(error){
  712. //用户提示;
  713. return;
  714. }
  715. NSLog(@"%@",data[@"message"]);
  716. BOOL success = data[@"success"];
  717. id result = nil;
  718. if (success) {
  719. result = data[@"data"];
  720. }
  721. block(result,nil);
  722. }];
  723. }
  724. /**
  725. * 用户最近联系人列表(只含有未读消息)--ok
  726. *
  727. * @param params id
  728. * @param block return
  729. */
  730. - (void)request_UnReadMsgListWithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  731. {
  732. NSString *path = @"/v1/user/unread";
  733. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  734. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  735. if(error){
  736. //用户提示;
  737. return;
  738. }
  739. NSLog(@"%@",data[@"message"]);
  740. BOOL success = data[@"success"];
  741. id result = nil;
  742. if (success) {
  743. result = data[@"data"];
  744. }
  745. block(result,nil);
  746. }];
  747. }
  748. /**
  749. * 获取单人聊天历史纪录--ok
  750. *
  751. * @param params id
  752. * @param block return
  753. */
  754. //- (void)request_SingleUnReadMsgsWithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  755. //{
  756. // NSString *path = @"/v1/msg/offlineSimple";
  757. // NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  758. // //对params中的参数进行二次校验,符合继续不符合return;@"0578+(null)"
  759. // if ([[params objectForKey:@"target"] isEqualToString:[NSString stringWithFormat:@"%@+(null)",[userDefaults objectForKey:USERDEFAULT_ContentServer]]] ) {
  760. // return;
  761. // }
  762. // [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  763. // if(error){
  764. // //用户提示;
  765. // return;
  766. // }
  767. // NSLog(@"%@",data[@"message"]);
  768. // BOOL success = data[@"success"];
  769. // id result = nil;
  770. // if (success) {
  771. // result = data[@"data"];
  772. //
  773. // }
  774. // block(result,nil);
  775. // }];
  776. //}
  777. /**
  778. * 获取单人聊天历史纪录成功的反馈--废弃
  779. *
  780. * @param params id
  781. 参数说明:
  782. String current -必填项,当前用户,格式:CID+serverID-loginName
  783. String target -必填项,目标用户,格式:CID+serverID-loginName
  784. String|int time -必填项,拉取的消息中最新的消息时间戳,Number类型
  785. String uuid -可选项,请求唯一标识
  786. 参数格式:{ current:"CID+serverID-loginName", target:"CID+serverID-loginName", time:123455678.45, uuid:"" }
  787. * @param block return
  788. */
  789. - (void)request_SingleUnReadMsgsResponseWithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  790. {
  791. NSString *path = @"/v1/msg/receivedSimple";
  792. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  793. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  794. if(error){
  795. //用户提示;
  796. return;
  797. }
  798. NSLog(@"%@",data[@"message"]);
  799. BOOL success = data[@"success"];
  800. id result = nil;
  801. if (success) {
  802. result = data[@"data"];
  803. }
  804. block(result,nil);
  805. }];
  806. }
  807. //获取单对单历史消息--废弃
  808. -(void)request_chatObjectHistory_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  809. {
  810. NSString *path = @"/zhuxunserver/v2/msg/history";
  811. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  812. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  813. if (error) {
  814. return ;
  815. }
  816. BOOL success = data[@"success"];
  817. id result = nil;
  818. if (success) {
  819. result = data[@"data"];
  820. }
  821. block(result,nil);
  822. }];
  823. }
  824. -(void)public_Request_With_MethodType:(RequestMethod)method path:(NSString *)path params:(id)params andBlock:(void (^) (id data, NSError *error))block{
  825. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  826. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  827. if (!error) {
  828. id resultData = [data valueForKey:@"data"];
  829. block(data,nil);
  830. }else{
  831. block(nil,error);
  832. }
  833. }];
  834. }
  835. //拉取设备比对--ok
  836. -(void)request_User_lastDevice_WithParams:(id)params andBlock:(void(^)(id data, NSError *error))block{
  837. NSString *path = @"/v1/user/lastDevice";
  838. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  839. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  840. BOOL success = [data[@"success"] boolValue];
  841. if (success) {
  842. block(data,nil);
  843. }else{
  844. if (error) {
  845. block(nil,error);
  846. }
  847. }
  848. }];
  849. }
  850. //微助手自带短信--ok
  851. -(void)request_SendSMS_NoLocalWithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  852. {
  853. NSString *path = @"/zhuxunserver/sms/send";
  854. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  855. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  856. BOOL success = data[@"success"];
  857. if (success) {
  858. block(data,nil);
  859. }else{
  860. block(nil,error);
  861. }
  862. }];
  863. }
  864. //删除用户聊天信息--ok
  865. -(void)request_deleteCurrentChatMessagesWithParams:(id)params andBlock:(void (^)(id data,NSError *error))block
  866. {
  867. NSString *path = @"/v1/msg/delete";
  868. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  869. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  870. if (error) {
  871. block(nil,error);
  872. }else{
  873. block(data,nil);
  874. }
  875. }];
  876. }
  877. //注销登录 -- 0k
  878. - (void)logout_withParams:(id)params andBlock:(void (^)(id data,NSError *error))block
  879. {
  880. NSString *path = @"/v1/user/logout";
  881. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  882. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  883. if (error) {
  884. block(nil,error);
  885. }else{
  886. block(data,nil);
  887. }
  888. }];
  889. }
  890. //获取我的客服
  891. - (void)getMyCustomerServicerwithParams:(id)params andBlock:(void (^)(id data,NSError *error))block
  892. {
  893. NSString *path = @"/v1/customerService";
  894. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  895. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Get andBlock:^(id data, NSError *error) {
  896. if (error) {
  897. block(nil,error);
  898. }else{
  899. block(data,nil);
  900. }
  901. }];
  902. }
  903. // 获取我的常用联系人
  904. - (void)getMyFrequentContactswithParams:(id)params andBlock:(void (^)(id data,NSError *error))block
  905. {
  906. ///v1/frequentContact
  907. NSString *path = @"/v1/frequentContact";
  908. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  909. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Get andBlock:^(id data, NSError *error) {
  910. if (error) {
  911. block(nil,error);
  912. }else{
  913. block(data,nil);
  914. }
  915. }];
  916. }
  917. // 添加我的常用联系人
  918. - (void)addMyFrequentContactswithParams:(id)params andBlock:(void (^)(id data,NSError *error))block
  919. {
  920. NSString *path = @"/v1/frequentContact";
  921. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  922. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  923. if (error) {
  924. block(nil,error);
  925. }else{
  926. block(data,nil);
  927. }
  928. }];
  929. }
  930. // 删除我的常用联系人
  931. - (void)deleteMyFrequentContactswithParams:(id)params andBlock:(void (^)(id data,NSError *error))block
  932. {
  933. NSString *path = @"/v1/frequentContact";
  934. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  935. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Delete andBlock:^(id data, NSError *error) {
  936. if (error) {
  937. block(nil,error);
  938. }else{
  939. block(data,nil);
  940. }
  941. }];
  942. }
  943. //获取顶级部门成员--OK
  944. - (void)postTopDepartmentMembers:(id)params andBlock:(void (^)(id data,NSError *error))block
  945. {
  946. NSString *path = @"/zhuxunserver/branchs/getMyTopBranch";
  947. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  948. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  949. if (error) {
  950. block(nil,error);
  951. }else{
  952. block(data,nil);
  953. }
  954. }];
  955. }
  956. //==========socket.io 模拟的http
  957. //通过传入的请求服务器命令和 sender 获取离线同步消息
  958. -(void)request_isSync_WithParams:(id)params andBlock:(void (^)(id, NSError *))block{
  959. NSString *path = @"/zhuxunserver.chat.message.sync";
  960. NSString *aPath = [NSString stringWithFormat:@"%@%@",APP_HOST,path];
  961. [[HttpClient sharedJsonClient] requestJsonDataWithPath:aPath withParams:params withMethodType:Post andBlock:^(id data, NSError *error) {
  962. id result = [data valueForKey:@"data"];
  963. if (result) {
  964. block(result,nil);
  965. }else{
  966. block(nil,error);
  967. }
  968. }];
  969. }
  970. //-(void)request_login_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  971. //{
  972. // LoginAPI *loginAPI = [LoginAPI new];
  973. // [loginAPI requestWithObject:params Completion:^(id response, NSError *error) {
  974. //
  975. // //登录信息回调
  976. // block(response, nil);
  977. //
  978. // }];
  979. //}
  980. //通过用户的登录名和密码等 认证用户并获取离线消息
  981. //-(void)request_auth_WithParams:(id)params andBlock:(void (^)(id data, NSError *error))block
  982. //{
  983. // AuthAPI *loginApi = [[AuthAPI alloc]init];
  984. // loginApi.noNeedSendAgain = YES;
  985. // //将获取的离线消息数据回调
  986. // [loginApi requestWithObject:params Completion:^(id response, NSError *error) {
  987. //// if (error) {
  988. //// return ;
  989. //// }
  990. // //Error Domain=请求超时 Code=1001 "(null)"
  991. // block(response, error);
  992. // }];
  993. //}
  994. -(BOOL)isNull:(NSDictionary*) data{
  995. return (!data || [data isKindOfClass:[NSNull class]]);
  996. }
  997. -(void)alertWithMessage:(NSString *)msg
  998. {
  999. UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
  1000. [alertView show];
  1001. }
  1002. @end