Keine Beschreibung

FKJSInterface.m 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // FKJSInterface.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 15/10/28.
  6. // Copyright © 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "FKJSInterface.h"
  9. @implementation FKJSInterface
  10. #pragma mark - parse
  11. + (BOOL)isForceLogin:(NSDictionary *)dict {
  12. if ([dict isKindOfClass:[NSDictionary class]]) {
  13. NSString *isForceLogin = [NSString stringWithFormat:@"%@", dict[@"force_login"]];
  14. if ([isForceLogin isEqualToString:@"1"]) {
  15. return YES;
  16. }
  17. }
  18. return NO;
  19. }
  20. + (NSDictionary *)dictForUser:(User *)user {
  21. return @{@"code" : [FKUserManager isUserLogin] ? @"1" : @"0",
  22. @"id" : [FLStringHelper replaceNilWithEmpty:user.userID],
  23. @"nickname" : [FLStringHelper replaceNilWithEmpty:user.nickName],
  24. @"head_pic" : [FLStringHelper replaceNilWithEmpty:user.headurl],
  25. @"phone" : [FLStringHelper replaceNilWithEmpty:user.mobile],
  26. @"level" : [FLStringHelper replaceNilWithEmpty:user.level],
  27. @"status" : [FLStringHelper replaceNilWithEmpty:user.status],
  28. @"token" : [FLStringHelper replaceNilWithEmpty:user.token],
  29. };
  30. }
  31. + (FKWeixinItem *)parseWeixinItem:(NSDictionary *)dict {
  32. if ([dict isKindOfClass:[NSDictionary class]]) {
  33. FKWeixinItem *item = [[FKWeixinItem alloc] init];
  34. [item mts_setValuesForKeysWithDictionary:dict];
  35. return item;
  36. }
  37. return nil;
  38. }
  39. + (NSURL *)parseURL:(NSDictionary *)dict {
  40. if ([dict isKindOfClass:[NSDictionary class]]) {
  41. NSURL *url = [NSURL URLWithString:dict[@"url"]];
  42. if ([url.scheme rangeOfString:@"HTTP" options:NSCaseInsensitiveSearch].length > 0) {
  43. return url;
  44. }
  45. }
  46. return nil;
  47. }
  48. #pragma mark - send
  49. @end