ASBirthdayTreatViewController.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. //
  2. // ASBirthdayTreatViewController.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/7/1.
  6. //
  7. #import "ASBirthdayTreatViewController.h"
  8. @interface ASBirthdayTreatViewController ()
  9. @property (nonatomic, strong) UIScrollView *scrollV;
  10. @property (nonatomic, strong) UIView *bgV;
  11. @property (nonatomic, strong) UIImageView *bgImgV;
  12. @property (nonatomic, strong) UIImageView *topImgV;
  13. @property (nonatomic, strong) UIImageView *titleImgV;
  14. @property (nonatomic, strong) UILabel * contentLB;
  15. @property (nonatomic, strong) UILabel * codeDesLB;
  16. @property (nonatomic, strong) UIView *btnV;
  17. @property (nonatomic, strong) UIButton *startBt;
  18. @property (nonatomic, strong) UIView *dateV;
  19. @property (nonatomic, strong) UILabel *monthLb;
  20. @property (nonatomic, strong) UILabel *dayLb;
  21. @property (nonatomic, strong) UIImageView *dayBgV;
  22. @property (nonatomic, strong) UILabel *yearLb;
  23. @end
  24. @implementation ASBirthdayTreatViewController
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. // Do any additional setup after loading the view.
  28. self.titleStr = @"Birthday Treat";
  29. [self setNavRightSearch:^{
  30. }];
  31. [self loadSubviews];
  32. [self configSubVs];
  33. }
  34. - (void)viewWillAppear:(BOOL)animated {
  35. [super viewWillAppear:animated];
  36. // KWLoginedUserModel *info = [KWLoginedManager.shareInstance getCurrentLoginedUser];
  37. // if (info.isBirthday) {
  38. // @weakify(self);
  39. // [self.vm getVIPCouponData:^(BOOL flag) {
  40. // if (flag) {
  41. self.codeDesLB.text = [NSString stringWithFormat: @"USE CODE: %@\nGET DISCOUNT & GIFTPACK", ASUserInfoManager.shared.code];
  42. NSString *birthStr = [NSString stringWithFormat: @"Our Gift To You?\n$%@ To Spend On Your\nFavorite Hair.", ASUserInfoManager.shared.amount];
  43. self.contentLB.text = birthStr;
  44. // }
  45. //
  46. //
  47. // }];
  48. // }
  49. }
  50. - (void)configSubVs {
  51. self.statusBgV.backgroundColor = _E0FFF5;
  52. self.customNavBar.backgroundColor = _F0FFFA;
  53. self.titleImgV.image = [UIImage imageNamed:self.isBirthday ? @"birth_titleImg_2" : @"birth_titleImg_1"];
  54. self.codeDesLB.hidden = !self.isBirthday;
  55. self.btnV.hidden = !self.isBirthday;
  56. NSString *time = ASUserInfoManager.shared.birthDay;
  57. NSDate *date = [NSDate dateWithString:time format:@"MM dd, yyyy"];
  58. self.dayLb.text = [NSString stringWithFormat:@"%ld" ,date.day];
  59. NSString *monStr = @"JANUARY";
  60. NSInteger mon = date.month;
  61. switch (mon) {
  62. case 1:
  63. monStr = @"JANUARY";
  64. break;
  65. case 2:
  66. monStr = @"FEBRUARY";
  67. break;
  68. case 3:
  69. monStr = @"MARCH";
  70. break;
  71. case 4:
  72. monStr = @"APRIL";
  73. break;
  74. case 5:
  75. monStr = @"MAY";
  76. break;
  77. case 6:
  78. monStr = @"JUNE";
  79. break;
  80. case 7:
  81. monStr = @"JULY";
  82. break;
  83. case 8:
  84. monStr = @"AUGUST";
  85. break;
  86. case 9:
  87. monStr = @"SEPTEMBER";
  88. break;
  89. case 10:
  90. monStr = @"OCTOBER";
  91. break;
  92. case 11:
  93. monStr = @"NOVEMBER";
  94. break;
  95. default:
  96. monStr = @"DECEMBER";
  97. break;
  98. }
  99. self.monthLb.text = monStr;
  100. self.yearLb.text = [NSString stringWithFormat:@"%ld" ,date.year];// @"2000";
  101. NSString *birthStr = @"Our Gift To You?\n$30 To Spend On Your\nFavorite Hair.";
  102. NSString *defualtStr = [NSString stringWithFormat: @"hello,%@ %@\nThanks for giving us the opportunity to celebratingyour birthday with you in the future.You’re going to receive our special birthday treat.\nLook forward to your special day to come.", @"USER", @"NAME"];//info.lastname, info.firstname];
  103. self.contentLB.text = self.isBirthday ? birthStr : defualtStr;
  104. }
  105. - (void)loadSubviews {
  106. [self.view addSubview:self.scrollV];
  107. [self.scrollV addSubview:self.bgV];
  108. [self.scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.top.equalTo(self.customNavBar.mas_bottom);
  110. make.right.left.bottom.equalTo(self.view);
  111. }];
  112. [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  113. make.edges.equalTo(self.scrollV);
  114. make.width.equalTo(self.view);
  115. make.height.greaterThanOrEqualTo([NSNumber numberWithFloat:SCREEN_HEIGHT - (NavigationBarHeight+StatusHeight)]);
  116. }];
  117. [self.bgV addSubview:self.bgImgV];
  118. [self.bgImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  119. make.edges.equalTo(self.bgV);
  120. }];
  121. UIStackView *stackV = [[UIStackView alloc] init];
  122. stackV.axis = UILayoutConstraintAxisVertical;
  123. stackV.distribution = UIStackViewDistributionFill;
  124. stackV.alignment = UIStackViewAlignmentFill;
  125. stackV.spacing = 20;
  126. [self.bgV addSubview:stackV];
  127. [stackV mas_makeConstraints:^(MASConstraintMaker *make) {
  128. make.centerX.equalTo(self.bgV);
  129. make.width.equalTo([NSNumber numberWithFloat:SCREEN_WIDTH - 120]);
  130. make.top.equalTo(self.bgV.mas_top).offset(38);
  131. make.bottom.equalTo(self.bgV.mas_bottom).offset(-150);
  132. }];
  133. UIStackView *topSt = [[UIStackView alloc] init];
  134. topSt.axis = UILayoutConstraintAxisVertical;
  135. topSt.distribution = UIStackViewDistributionFill;
  136. topSt.alignment = UIStackViewAlignmentFill;
  137. topSt.spacing = 8;
  138. [topSt addArrangedSubview:self.topImgV];
  139. [self.topImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  140. make.height.equalTo(@102);
  141. }];
  142. [topSt addArrangedSubview:self.titleImgV];
  143. [self.titleImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  144. make.height.equalTo(@68);
  145. }];
  146. [stackV addArrangedSubview:topSt];
  147. [stackV addArrangedSubview:self.contentLB];
  148. // [stackV addArrangedSubview:self.lineV];
  149. // [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  150. // make.height.equalTo(@50);
  151. // }];
  152. [stackV addArrangedSubview:self.btnV];
  153. [self.btnV mas_makeConstraints:^(MASConstraintMaker *make) {
  154. make.height.equalTo(@45);
  155. }];
  156. [self.btnV addSubview:self.startBt];
  157. [self.startBt mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.height.equalTo(@45);
  159. make.width.equalTo([NSNumber numberWithFloat:SCREEN_WIDTH-150]);
  160. make.center.equalTo(self.btnV);
  161. }];
  162. [stackV addArrangedSubview:self.codeDesLB];
  163. [self.codeDesLB mas_makeConstraints:^(MASConstraintMaker *make) {
  164. make.height.equalTo(@48);
  165. }];
  166. [stackV addArrangedSubview:self.dateV];
  167. [self.dateV addSubview:self.monthLb];
  168. [self.dateV addSubview:self.dayBgV];
  169. [self.dateV addSubview:self.dayLb];
  170. [self.dateV addSubview:self.yearLb];
  171. [self.monthLb mas_makeConstraints:^(MASConstraintMaker *make) {
  172. make.height.equalTo(@17);
  173. make.centerX.equalTo(self.dateV);
  174. make.top.equalTo(self.dateV).offset(10);
  175. }];
  176. [self.dayBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  177. make.height.equalTo(@45);
  178. make.width.equalTo(@36.5);
  179. make.centerX.equalTo(self.dateV);
  180. make.top.equalTo(self.monthLb.mas_bottom).offset(5);
  181. }];
  182. [self.dayLb mas_makeConstraints:^(MASConstraintMaker *make) {
  183. make.center.equalTo(self.dayBgV);
  184. make.height.equalTo(self.dayBgV);
  185. make.width.equalTo(self.dayBgV);
  186. }];
  187. [self.yearLb mas_makeConstraints:^(MASConstraintMaker *make) {
  188. make.height.equalTo(@17);
  189. make.centerX.equalTo(self.dateV);
  190. make.top.equalTo(self.dayBgV.mas_bottom).offset(5);
  191. make.bottom.equalTo(self.dateV).offset(-10);
  192. }];
  193. dispatch_async(dispatch_get_main_queue(), ^{
  194. [self viewAddLineColorBg:self.bgV colorArr:@[
  195. (id)_E0FFF5.CGColor,
  196. (id)Col_FFF.CGColor
  197. ]];
  198. });
  199. }
  200. - (UIScrollView *)scrollV {
  201. if (!_scrollV) {
  202. UIScrollView *v = [UIScrollView new];
  203. v.showsVerticalScrollIndicator = false;
  204. v.showsHorizontalScrollIndicator = false;
  205. v.backgroundColor = Col_FFF;
  206. _scrollV = v;
  207. }
  208. return _scrollV;
  209. }
  210. - (UIView *)bgV {
  211. if (!_bgV) {
  212. UIView *v = [UIView new];
  213. _bgV = v;
  214. }
  215. return _bgV;
  216. }
  217. - (UIImageView *)bgImgV {
  218. if (!_bgImgV) {
  219. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_bg"]];
  220. v.contentMode = UIViewContentModeScaleToFill;
  221. _bgImgV = v;
  222. }
  223. return _bgImgV;
  224. }
  225. - (UIImageView *)topImgV {
  226. if (!_topImgV) {
  227. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_topImg"]];
  228. v.contentMode = UIViewContentModeScaleAspectFit;
  229. _topImgV = v;
  230. }
  231. return _topImgV;
  232. }
  233. - (UIImageView *)titleImgV {
  234. if (!_titleImgV) {
  235. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_titleImg_1"]];
  236. v.contentMode = UIViewContentModeScaleAspectFit;
  237. _titleImgV = v;
  238. }
  239. return _titleImgV;
  240. }
  241. - (UILabel *)contentLB {
  242. if (!_contentLB) {
  243. UILabel *lb = [[UILabel alloc] init];
  244. lb.numberOfLines = 0;
  245. lb.textAlignment = NSTextAlignmentCenter;
  246. lb.textColor = UIColor.blackColor;
  247. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  248. lb.qmui_lineHeight = 24;
  249. _contentLB = lb;
  250. }
  251. return _contentLB;
  252. }
  253. - (UILabel *)codeDesLB {
  254. if (!_codeDesLB) {
  255. UILabel *lb = [[UILabel alloc] init];
  256. lb.numberOfLines = 0;
  257. lb.textColor = _043632;
  258. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  259. lb.qmui_lineHeight = 24;
  260. lb.textAlignment = NSTextAlignmentCenter;
  261. lb.lineBreakMode = NSLineBreakByWordWrapping;
  262. lb.text = @"USE CODE: BIRTHDAY\nGET DISCOUNT & GIFTPACK";
  263. _codeDesLB = lb;
  264. }
  265. return _codeDesLB;
  266. }
  267. - (UIView *)btnV {
  268. if (!_btnV) {
  269. UIView *v = [UIView new];
  270. v.backgroundColor = UIColor.clearColor;
  271. _btnV = v;
  272. }
  273. return _btnV;
  274. }
  275. - (UIButton *)startBt {
  276. if (!_startBt) {
  277. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  278. bt.backgroundColor = [UIColor blackColor];
  279. bt.layer.cornerRadius = 4;
  280. bt.layer.masksToBounds = true;
  281. [bt setTitle:@"GET THE PARTY STARTED" forState:UIControlStateNormal];
  282. [bt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  283. bt.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
  284. [bt addTarget:self action:@selector(btnAction) forControlEvents:UIControlEventTouchUpInside];
  285. _startBt = bt;
  286. }
  287. return _startBt;
  288. }
  289. - (void)btnAction {
  290. if (![ASUserInfoManager.shared.typeId isEqualToString:@""]) {
  291. NSDictionary *para = @{
  292. @"type":ASUserInfoManager.shared.typeId, //String
  293. @"title":@"HD Lace",//String
  294. @"searchKey":@"",//String
  295. };
  296. UIViewController *vc = [CTMediator.sharedInstance getProductListVc:para];
  297. [self.navigationController pushViewController:vc animated:true];
  298. } else {
  299. [self.view makeToast:@"Get Birth Products Type Error"];
  300. }
  301. }
  302. - (UIView *)dateV {
  303. if (!_dateV) {
  304. UIView *v = [UIView new];
  305. v.backgroundColor = UIColor.clearColor;
  306. _dateV = v;
  307. }
  308. return _dateV;
  309. }
  310. - (UILabel *)monthLb {
  311. if (!_monthLb) {
  312. UILabel *lb = [[UILabel alloc] init];
  313. lb.numberOfLines = 0;
  314. lb.textColor = UIColor.blackColor;
  315. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  316. lb.qmui_lineHeight = 20;
  317. _monthLb = lb;
  318. }
  319. return _monthLb;
  320. }
  321. - (UILabel *)dayLb {
  322. if (!_dayLb) {
  323. UILabel *lb = [[UILabel alloc] init];
  324. lb.numberOfLines = 0;
  325. lb.textColor = UIColor.blackColor;
  326. lb.font = [UIFont fontWithName:Rob_Bold size:20];
  327. lb.qmui_lineHeight = 20;
  328. lb.textAlignment = NSTextAlignmentCenter;
  329. _dayLb = lb;
  330. }
  331. return _dayLb;
  332. }
  333. - (UILabel *)yearLb {
  334. if (!_yearLb) {
  335. UILabel *lb = [[UILabel alloc] init];
  336. lb.numberOfLines = 0;
  337. lb.textColor = UIColor.blackColor;
  338. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  339. lb.qmui_lineHeight = 20;
  340. _yearLb = lb;
  341. }
  342. return _yearLb;
  343. }
  344. - (UIImageView *)dayBgV {
  345. if (!_dayBgV) {
  346. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_dayTime_bg"]];
  347. v.contentMode = UIViewContentModeScaleAspectFit;
  348. _dayBgV = v;
  349. }
  350. return _dayBgV;
  351. }
  352. - (void)viewAddLineColorBg:(UIView *)bgV colorArr:(NSArray *)colors {
  353. CAGradientLayer *layer = [[CAGradientLayer alloc] init];
  354. layer.frame = bgV.bounds;
  355. layer.colors = colors;
  356. layer.startPoint = CGPointMake(0.44, 0.2);
  357. layer.endPoint = CGPointMake(0.5, 1);
  358. layer.locations = @[@0,@1.0f];
  359. layer.name = @"colorLayer";
  360. [bgV.layer insertSublayer:layer atIndex:0];
  361. }
  362. @end