ASUserCenterTopView.m 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. //
  2. // ASUserCenterTopView.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/5/15.
  6. //
  7. #import "ASUserCenterTopView.h"
  8. #import "ASUserAvaterView.h"
  9. #import "ASUserBaseInfoView.h"
  10. @interface ASUserCenterTopView ()
  11. @property (nonatomic, strong) UIView *bgV;
  12. @property (nonatomic, strong) ASUserAvaterView *bgAvaterV;
  13. @property (nonatomic, strong) ASUserBaseInfoView *userInfoV;
  14. @property (nonatomic, strong) UIButton *settingBt;
  15. @property (nonatomic,strong) UIView *vipContentV;
  16. @property (nonatomic,strong) UIView *vipLineV1;
  17. @property (nonatomic,strong) UIView *vipLineV2;
  18. @property (nonatomic,strong) UIView *vipPointV1;
  19. @property (nonatomic,strong) UIView *vipPointV2;
  20. @property (nonatomic,strong) UIImageView *currentVipTipV;
  21. @property (nonatomic,strong) UIImageView *vipLevel1;
  22. @property (nonatomic,strong) UIImageView *vipLevel2;
  23. @property (nonatomic,strong) UILabel *vipDesLb;
  24. @end
  25. @implementation ASUserCenterTopView
  26. - (void)setData {
  27. ASUserModel *user = ASUserInfoManager.shared.userInfo;
  28. NSString *userName = [NSString stringWithFormat:@"%@ %@", user.lastname, user.firstname];
  29. [self.bgAvaterV setUserHeadV:@"" uName:userName];
  30. [self.bgAvaterV setBorderColor:[UIColor clearColor] width:0];
  31. [self.userInfoV setData];
  32. ASVipModel *curVipM = ASUserInfoManager.shared.curVipInfo;
  33. ASVipModel *nexVipM = ASUserInfoManager.shared.nextVipInfo;
  34. self.vipLevel1.image = [UIImage imageNamed:[NSString stringWithFormat:@"uc_vip_level_%ld", curVipM.level.integerValue]];
  35. self.vipDesLb.text = [NSString stringWithFormat:@"Growth Value %ld/%ld", ASUserInfoManager.shared.pointAmount.integerValue, nexVipM.exppoints.integerValue];
  36. self.vipLevel2.image = [UIImage imageNamed:[NSString stringWithFormat:@"uc_vip_level_%ld", nexVipM.level.integerValue]];
  37. }
  38. - (void)settingAction {
  39. if (self.settingBlock) {
  40. self.settingBlock();
  41. }
  42. }
  43. // MARK: - SubUI
  44. - (instancetype)initWithFrame:(CGRect)frame {
  45. self = [super initWithFrame:CGRectMake(0, 0, KScreenWidth, 226)];
  46. if (self) {
  47. self.backgroundColor = UIColor.clearColor;
  48. [self loadSubV];
  49. }
  50. return self;
  51. }
  52. - (void)loadSubV {
  53. self.backgroundColor = Col_FFF;
  54. [self addSubview:self.bgV];
  55. self.bgV.backgroundColor = Col_FFF;
  56. self.bgV.frame = CGRectMake(10, 10, KScreenWidth-20, 206);
  57. UIVisualEffectView *blurV = [UIView getBlurV:self.bgV.bounds];
  58. blurV.alpha = 0.95;
  59. [self.bgV addSubview:self.bgAvaterV];
  60. [self.bgAvaterV mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.edges.equalTo(self.bgV);
  62. }];
  63. [self.bgV addSubview:blurV];
  64. [self.bgV addSubview:self.userInfoV];
  65. [self.bgV addSubview:self.settingBt];
  66. [self.bgV addSubview:self.vipContentV];
  67. [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  68. make.top.leading.equalTo(self).offset(10);
  69. make.bottom.trailing.equalTo(self).offset(-10);
  70. make.height.equalTo(@206);
  71. }];
  72. [self.userInfoV mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.top.leading.equalTo(self.bgV).offset(10);
  74. make.trailing.equalTo(self.bgV).offset(-10);
  75. make.height.equalTo(@100);
  76. }];
  77. [self.settingBt mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.top.equalTo(self.bgV).offset(10);
  79. make.trailing.equalTo(self.bgV).offset(-10);
  80. make.width.height.equalTo(@24);
  81. }];
  82. [self.vipContentV mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.top.equalTo(self.userInfoV.mas_bottom).offset(20);
  84. make.bottom.equalTo(self.bgV).offset(-20);
  85. make.leading.equalTo(self.userInfoV);
  86. make.width.equalTo(self.userInfoV);
  87. }];
  88. // vip
  89. [self.vipContentV addSubview:self.vipDesLb];
  90. [self.vipContentV addSubview:self.vipLineV1];
  91. [self.vipContentV addSubview:self.vipLineV2];
  92. [self.vipContentV addSubview:self.vipPointV1];
  93. [self.vipContentV addSubview:self.vipPointV2];
  94. [self.vipContentV addSubview:self.currentVipTipV];
  95. [self.vipContentV addSubview:self.vipLevel1];
  96. [self.vipContentV addSubview:self.vipLevel2];
  97. [self.vipDesLb mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.left.equalTo(self.vipContentV).offset(0);
  99. make.right.equalTo(self.vipContentV).offset(0);
  100. make.top.equalTo(self.vipContentV).offset(0);
  101. make.height.equalTo(@14);
  102. }];
  103. [self.vipLineV1 mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.left.equalTo(self.vipContentV).offset(0);
  105. make.right.equalTo(self.vipContentV).offset(0);
  106. make.top.equalTo(self.vipDesLb.mas_bottom).offset(17);
  107. make.height.equalTo(@2);
  108. }];
  109. [self.vipLineV2 mas_makeConstraints:^(MASConstraintMaker *make) {
  110. make.trailing.equalTo(self.vipLineV1);
  111. make.centerY.equalTo(self.vipLineV1);
  112. make.width.equalTo(self.vipLineV1.mas_width).multipliedBy(0.68);
  113. make.height.equalTo(self.vipLineV1);
  114. }];
  115. [self.vipPointV1 mas_makeConstraints:^(MASConstraintMaker *make) {
  116. make.centerX.equalTo(self.vipLineV2.mas_left);
  117. make.centerY.equalTo(self.vipLineV1);
  118. make.width.height.equalTo(@10);
  119. }];
  120. [self.vipPointV2 mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.right.equalTo(self.vipLineV2.mas_right);
  122. make.centerY.equalTo(self.vipLineV1);
  123. make.width.height.equalTo(@10);
  124. }];
  125. [self.currentVipTipV mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.bottom.equalTo(self.vipPointV1.mas_top);
  127. make.centerX.equalTo(self.vipPointV1);
  128. make.width.equalTo(@10);
  129. make.height.equalTo(@8);
  130. }];
  131. [self.vipLevel1 mas_makeConstraints:^(MASConstraintMaker *make) {
  132. make.top.equalTo(self.vipPointV1.mas_bottom).offset(5);
  133. make.trailing.equalTo(self.vipPointV1);
  134. make.width.equalTo(@35);
  135. make.height.equalTo(@20);
  136. }];
  137. [self.vipLevel2 mas_makeConstraints:^(MASConstraintMaker *make) {
  138. make.trailing.equalTo(self.vipPointV2);
  139. make.centerY.equalTo(self.vipLevel1);
  140. make.width.equalTo(@35);
  141. make.height.equalTo(@20);
  142. }];
  143. }
  144. - (UIView *)bgV {
  145. if (!_bgV) {
  146. UIView *v = [UIView baseV];
  147. v.layer.cornerRadius = 8;
  148. v.layer.masksToBounds = true;
  149. _bgV = v;
  150. }
  151. return _bgV;
  152. }
  153. - (ASUserAvaterView *)bgAvaterV {
  154. if (!_bgAvaterV) {
  155. ASUserAvaterView *v = [[ASUserAvaterView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth-20, 206)];
  156. _bgAvaterV = v;
  157. }
  158. return _bgAvaterV;
  159. }
  160. - (ASUserBaseInfoView *)userInfoV {
  161. if (!_userInfoV) {
  162. ASUserBaseInfoView *v = [[ASUserBaseInfoView alloc] initWithFrame:CGRectZero];
  163. _userInfoV = v;
  164. }
  165. return _userInfoV;
  166. }
  167. - (UIButton *)settingBt {
  168. if (!_settingBt) {
  169. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  170. [bt setImage:[UIImage imageNamed:@"uc_setting"] forState:UIControlStateNormal];
  171. [bt addTarget:self action:@selector(settingAction) forControlEvents:UIControlEventTouchUpInside];
  172. _settingBt = bt;
  173. }
  174. return _settingBt;
  175. }
  176. // MARK: vip等级
  177. - (UIImageView *)vipLevel1 {
  178. if (!_vipLevel1) {
  179. _vipLevel1 = [UIView baseImgV];
  180. _vipLevel1.image = [UIImage imageNamed:@"vip_1"];
  181. }
  182. return _vipLevel1;
  183. }
  184. -(UIImageView *)vipLevel2 {
  185. if (!_vipLevel2) {
  186. _vipLevel2 = [UIView baseImgV];
  187. _vipLevel2.image = [UIImage imageNamed:@"vip_2"];
  188. }
  189. return _vipLevel2;
  190. }
  191. - (UILabel *)vipDesLb {
  192. if (!_vipDesLb) {
  193. UILabel *lb = [UIView baseLb];
  194. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  195. lb.text = @"Growth Value 7220/10000";
  196. lb.textAlignment = NSTextAlignmentLeft;
  197. _vipDesLb = lb;
  198. }
  199. return _vipDesLb;
  200. }
  201. -(UIView *)vipLineV1 {
  202. if (!_vipLineV1) {
  203. _vipLineV1 = [UIView baseV];
  204. _vipLineV1.backgroundColor = [UIColor blackColor];
  205. }
  206. return _vipLineV1;
  207. }
  208. -(UIView *)vipLineV2 {
  209. if (!_vipLineV2) {
  210. _vipLineV2 = [UIView baseV];
  211. _vipLineV2.backgroundColor = Col_FFF;
  212. }
  213. return _vipLineV2;
  214. }
  215. -(UIView *)vipPointV1 {
  216. if (!_vipPointV1) {
  217. _vipPointV1 = [UIView baseV];
  218. _vipPointV1.backgroundColor = UIColor.blackColor;
  219. _vipPointV1.layer.cornerRadius = 5;
  220. _vipPointV1.layer.masksToBounds = true;
  221. }
  222. return _vipPointV1;
  223. }
  224. -(UIView *)vipPointV2 {
  225. if (!_vipPointV2) {
  226. _vipPointV2 = [UIView baseV];
  227. _vipPointV2.backgroundColor = UIColor.blackColor;
  228. _vipPointV2.layer.cornerRadius = 5;
  229. _vipPointV2.layer.masksToBounds = true;
  230. }
  231. return _vipPointV2;
  232. }
  233. -(UIView *)vipContentV {
  234. if (!_vipContentV) {
  235. _vipContentV = [UIView baseV];
  236. _vipContentV.backgroundColor = UIColor.clearColor;
  237. }
  238. return _vipContentV;
  239. }
  240. -(UIImageView *)currentVipTipV {
  241. if (!_currentVipTipV) {
  242. _currentVipTipV = [UIView baseImgV];
  243. _currentVipTipV.image = [UIImage imageNamed:@"mine_current_position"];
  244. }
  245. return _currentVipTipV;
  246. }
  247. @end