YHUserInfo.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. //
  2. // YHUserInfo.m
  3. // github: https://github.com/samuelandkevin
  4. // CSDN: http://blog.csdn.net/samuelandkevin
  5. // Created by kun on 16/4/25.
  6. // Copyright © 2016年 HKP. All rights reserved.
  7. //
  8. #import "YHUserInfo.h"
  9. @implementation YHUserInfo
  10. @synthesize mobilephone = _mobilephone;
  11. @synthesize uid = _uid;
  12. @synthesize accessToken = _accessToken;
  13. @synthesize taxAccount = _taxAccount;
  14. @synthesize avatarImage = _avatarImage;
  15. - (id)init
  16. {
  17. self = [super init];
  18. if (!self)
  19. {
  20. return nil;
  21. }
  22. _isRegister = NO;
  23. _jobTags = [NSMutableArray array];
  24. _workExperiences = [NSMutableArray array];
  25. _eductaionExperiences = [NSMutableArray array];
  26. // self.userConfig = [HHUserConfig new];
  27. return self;
  28. }
  29. #pragma mark - Getter
  30. - (NSString *)uid
  31. {
  32. if (!_uid && _isSelfModel)
  33. {
  34. NSString *userId = [[NSUserDefaults standardUserDefaults] objectForKey:kUserUid];
  35. if (userId)
  36. {
  37. _uid = userId;
  38. }
  39. }
  40. return _uid;
  41. }
  42. - (NSString *)accessToken
  43. {
  44. if (!_accessToken && _isSelfModel)
  45. {
  46. NSString *accessToken = [[NSUserDefaults standardUserDefaults] objectForKey:kAccessToken];
  47. if (accessToken)
  48. {
  49. _accessToken = accessToken;
  50. }
  51. }
  52. return _accessToken;
  53. }
  54. - (NSString *)mobilephone
  55. {
  56. if (!_mobilephone && _isSelfModel)
  57. {
  58. NSString *mobilePhone = [[NSUserDefaults standardUserDefaults] objectForKey:kMobilePhone];
  59. if (mobilePhone)
  60. {
  61. _mobilephone = mobilePhone;
  62. }
  63. }
  64. return _mobilephone;
  65. }
  66. - (NSString *)taxAccount
  67. {
  68. if (!_taxAccount && _isSelfModel)
  69. {
  70. NSString *taxAccount = [[NSUserDefaults standardUserDefaults] objectForKey:kTaxAccount];
  71. if (taxAccount)
  72. {
  73. _taxAccount = taxAccount;
  74. }
  75. }
  76. return _taxAccount;
  77. }
  78. #pragma mark - Setter
  79. - (void)setAccessToken:(NSString *)accessToken
  80. {
  81. if (accessToken)
  82. {
  83. _accessToken = accessToken;
  84. if (_isSelfModel)
  85. {
  86. [[NSUserDefaults standardUserDefaults] setObject:_accessToken forKey:kAccessToken];
  87. [[NSUserDefaults standardUserDefaults] synchronize];
  88. }
  89. }
  90. }
  91. - (void)setMobilephone:(NSString *)mobilephone
  92. {
  93. if (mobilephone)
  94. {
  95. _mobilephone = mobilephone;
  96. if (_isSelfModel)
  97. {
  98. [[NSUserDefaults standardUserDefaults] setObject:_mobilephone forKey:kMobilePhone];
  99. [[NSUserDefaults standardUserDefaults] synchronize];
  100. }
  101. }
  102. }
  103. - (void)setUid:(NSString *)uid
  104. {
  105. if (uid)
  106. {
  107. _uid = uid;
  108. if (_isSelfModel)
  109. {
  110. [[NSUserDefaults standardUserDefaults] setObject:_uid forKey:kUserUid];
  111. [[NSUserDefaults standardUserDefaults] synchronize];
  112. }
  113. }
  114. }
  115. - (void)setTaxAccount:(NSString *)taxAccount
  116. {
  117. if (taxAccount && taxAccount.length)
  118. {
  119. _taxAccount = taxAccount;
  120. if (_isSelfModel)
  121. {
  122. [[NSUserDefaults standardUserDefaults] setObject:_taxAccount forKey:kTaxAccount];
  123. [[NSUserDefaults standardUserDefaults] synchronize];
  124. }
  125. }
  126. }
  127. - (void)setAvatarImage:(UIImage *)avatarImage
  128. {
  129. _avatarImage = avatarImage;
  130. if (!_avatarImage)
  131. {
  132. _avatarImage = [UIImage imageNamed:@"common_avatar_120px"];
  133. }
  134. }
  135. - (UIImage *)avatarImage
  136. {
  137. if (!_avatarImage)
  138. {
  139. _avatarImage = [UIImage imageNamed:@"common_avatar_120px"];
  140. }
  141. return _avatarImage;
  142. }
  143. #pragma mark - Life
  144. - (void)dealloc {
  145. }
  146. @end