ASBirthdayTreatViewController.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  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. // weak_self.codeDesLB.text = [NSString stringWithFormat: @"USE CODE: %@\nGET DISCOUNT & GIFTPACK", weak_self.vm.code];
  42. // NSString *birthStr = [NSString stringWithFormat: @"Our Gift To You?\n$%@ To Spend On Your\nFavorite Hair.", weak_self.vm.amount];
  43. // weak_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. // KWLoginedUserModel *info = [KWLoginedManager.shareInstance getCurrentLoginedUser];
  57. // NSDate *date = [NSDate dateWithString:info.dob format:@"yyyy-MM-dd hh:mm:ss"];
  58. NSDate *date = [NSDate new];
  59. self.dayLb.text = [NSString stringWithFormat:@"%ld" ,date.day];
  60. NSString *monStr = @"JANUARY";
  61. NSInteger mon = date.month;
  62. switch (mon) {
  63. case 1:
  64. monStr = @"JANUARY";
  65. break;
  66. case 2:
  67. monStr = @"FEBRUARY";
  68. break;
  69. case 3:
  70. monStr = @"MARCH";
  71. break;
  72. case 4:
  73. monStr = @"APRIL";
  74. break;
  75. case 5:
  76. monStr = @"MAY";
  77. break;
  78. case 6:
  79. monStr = @"JUNE";
  80. break;
  81. case 7:
  82. monStr = @"JULY";
  83. break;
  84. case 8:
  85. monStr = @"AUGUST";
  86. break;
  87. case 9:
  88. monStr = @"SEPTEMBER";
  89. break;
  90. case 10:
  91. monStr = @"OCTOBER";
  92. break;
  93. case 11:
  94. monStr = @"NOVEMBER";
  95. break;
  96. default:
  97. monStr = @"DECEMBER";
  98. break;
  99. }
  100. self.monthLb.text = monStr;
  101. self.yearLb.text = [NSString stringWithFormat:@"%ld" ,date.year];// @"2000";
  102. NSString *birthStr = @"Our Gift To You?\n$30 To Spend On Your\nFavorite Hair.";
  103. 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];
  104. self.contentLB.text = self.isBirthday ? birthStr : defualtStr;
  105. }
  106. - (void)loadSubviews {
  107. [self.view addSubview:self.scrollV];
  108. [self.scrollV addSubview:self.bgV];
  109. [self.scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
  110. make.top.equalTo(self.customNavBar.mas_bottom);
  111. make.right.left.bottom.equalTo(self.view);
  112. }];
  113. [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.edges.equalTo(self.scrollV);
  115. make.width.equalTo(self.view);
  116. make.height.greaterThanOrEqualTo([NSNumber numberWithFloat:SCREEN_HEIGHT - (NavigationBarHeight+StatusHeight)]);
  117. }];
  118. // UIImageView *tl_imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_birth_top_left"]];
  119. // UIImageView *tr_imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_birth_top_right"]];
  120. // UIImageView *bl_imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_birth_bottom_left"]];
  121. // UIImageView *br_imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_birth_bottom_right"]];
  122. // UIImageView *top_line_imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_birth_line_top"]];
  123. // UIImageView *bottom_line_imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_birth_line_top"]];
  124. // UIImageView *left_line_imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_birth_line_left"]];
  125. // UIImageView *right_line_imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_birth_line_left"]];
  126. //
  127. // UIImageView *top_left_bg_imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_birth_top_left_bg"]];
  128. // UIImageView *bottom_right_bg_imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_birth_top_left_bg"]];
  129. //
  130. // [self.bgV addSubview:top_left_bg_imgV];
  131. // [self.bgV addSubview:bottom_right_bg_imgV];
  132. // [self.bgV addSubview:tl_imgV];
  133. // [self.bgV addSubview:tr_imgV];
  134. // [self.bgV addSubview:bl_imgV];
  135. // [self.bgV addSubview:br_imgV];
  136. // [self.bgV addSubview:top_line_imgV];
  137. // [self.bgV addSubview:bottom_line_imgV];
  138. // [self.bgV addSubview:left_line_imgV];
  139. // [self.bgV addSubview:right_line_imgV];
  140. // [top_left_bg_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  141. // make.top.equalTo(@0);
  142. // make.left.equalTo(self.bgV).offset(0);
  143. // make.width.height.equalTo(@180);
  144. // }];
  145. //
  146. // [bottom_right_bg_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  147. // make.bottom.equalTo(@0);
  148. // make.right.equalTo(self.bgV).offset(0);
  149. // make.width.height.equalTo(@180);
  150. // }];
  151. //
  152. // bottom_right_bg_imgV.transform = CGAffineTransformMakeRotation(M_PI);
  153. //
  154. // [tl_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  155. // make.top.equalTo(@50);
  156. // make.left.equalTo(self.bgV).offset(20);
  157. // make.width.height.equalTo(@24);
  158. // }];
  159. // [tr_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  160. // make.top.equalTo(@50);
  161. // make.right.equalTo(self.bgV).offset(-20);
  162. // make.width.height.equalTo(@24);
  163. // }];
  164. // [bl_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  165. // make.bottom.equalTo(self.bgV).offset(-50);
  166. // make.left.equalTo(self.bgV).offset(20);
  167. // make.width.height.equalTo(@24);
  168. // }];
  169. // [br_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  170. // make.bottom.equalTo(self.bgV).offset(-50);
  171. // make.right.equalTo(self.bgV).offset(-20);
  172. // make.width.height.equalTo(@24);
  173. // }];
  174. //
  175. // [top_line_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  176. // make.centerX.equalTo(self.bgV);
  177. // make.width.equalTo(self.bgV).offset(-120);
  178. // make.top.equalTo(self.bgV).offset(50);
  179. // }];
  180. // [bottom_line_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  181. // make.centerX.equalTo(self.bgV);
  182. // make.width.equalTo(self.bgV).offset(-120);
  183. // make.bottom.equalTo(self.bgV.mas_bottom).offset(-50);
  184. // }];
  185. //
  186. // [left_line_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  187. // make.left.equalTo(tl_imgV.mas_left);
  188. // make.top.equalTo(tl_imgV.mas_bottom).offset(20);
  189. // make.bottom.equalTo(bl_imgV.mas_top).offset(-20);
  190. // }];
  191. //
  192. // [right_line_imgV mas_makeConstraints:^(MASConstraintMaker *make) {
  193. // make.right.equalTo(tr_imgV.mas_right);
  194. // make.top.equalTo(tr_imgV.mas_bottom).offset(20);
  195. // make.bottom.equalTo(br_imgV.mas_top).offset(-20);
  196. // }];
  197. [self.bgV addSubview:self.bgImgV];
  198. [self.bgImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  199. make.edges.equalTo(self.bgV);
  200. }];
  201. UIStackView *stackV = [[UIStackView alloc] init];
  202. stackV.axis = UILayoutConstraintAxisVertical;
  203. stackV.distribution = UIStackViewDistributionFill;
  204. stackV.alignment = UIStackViewAlignmentFill;
  205. stackV.spacing = 20;
  206. [self.bgV addSubview:stackV];
  207. [stackV mas_makeConstraints:^(MASConstraintMaker *make) {
  208. make.centerX.equalTo(self.bgV);
  209. make.width.equalTo([NSNumber numberWithFloat:SCREEN_WIDTH - 120]);
  210. make.top.equalTo(self.bgV.mas_top).offset(38);
  211. make.bottom.equalTo(self.bgV.mas_bottom).offset(-150);
  212. }];
  213. UIStackView *topSt = [[UIStackView alloc] init];
  214. topSt.axis = UILayoutConstraintAxisVertical;
  215. topSt.distribution = UIStackViewDistributionFill;
  216. topSt.alignment = UIStackViewAlignmentFill;
  217. topSt.spacing = 8;
  218. [topSt addArrangedSubview:self.topImgV];
  219. [self.topImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  220. make.height.equalTo(@102);
  221. }];
  222. [topSt addArrangedSubview:self.titleImgV];
  223. [self.titleImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  224. make.height.equalTo(@68);
  225. }];
  226. [stackV addArrangedSubview:topSt];
  227. [stackV addArrangedSubview:self.contentLB];
  228. // [stackV addArrangedSubview:self.lineV];
  229. // [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
  230. // make.height.equalTo(@50);
  231. // }];
  232. [stackV addArrangedSubview:self.btnV];
  233. [self.btnV mas_makeConstraints:^(MASConstraintMaker *make) {
  234. make.height.equalTo(@45);
  235. }];
  236. [self.btnV addSubview:self.startBt];
  237. [self.startBt mas_makeConstraints:^(MASConstraintMaker *make) {
  238. make.height.equalTo(@45);
  239. make.width.equalTo([NSNumber numberWithFloat:SCREEN_WIDTH-150]);
  240. make.center.equalTo(self.btnV);
  241. }];
  242. [stackV addArrangedSubview:self.codeDesLB];
  243. [self.codeDesLB mas_makeConstraints:^(MASConstraintMaker *make) {
  244. make.height.equalTo(@48);
  245. }];
  246. [stackV addArrangedSubview:self.dateV];
  247. [self.dateV addSubview:self.monthLb];
  248. [self.dateV addSubview:self.dayBgV];
  249. [self.dateV addSubview:self.dayLb];
  250. [self.dateV addSubview:self.yearLb];
  251. [self.monthLb mas_makeConstraints:^(MASConstraintMaker *make) {
  252. make.height.equalTo(@17);
  253. make.centerX.equalTo(self.dateV);
  254. make.top.equalTo(self.dateV).offset(10);
  255. }];
  256. [self.dayBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  257. make.height.equalTo(@45);
  258. make.width.equalTo(@36.5);
  259. make.centerX.equalTo(self.dateV);
  260. make.top.equalTo(self.monthLb.mas_bottom).offset(5);
  261. }];
  262. [self.dayLb mas_makeConstraints:^(MASConstraintMaker *make) {
  263. make.center.equalTo(self.dayBgV);
  264. make.height.equalTo(self.dayBgV);
  265. make.width.equalTo(self.dayBgV);
  266. }];
  267. [self.yearLb mas_makeConstraints:^(MASConstraintMaker *make) {
  268. make.height.equalTo(@17);
  269. make.centerX.equalTo(self.dateV);
  270. make.top.equalTo(self.dayBgV.mas_bottom).offset(5);
  271. make.bottom.equalTo(self.dateV).offset(-10);
  272. }];
  273. dispatch_async(dispatch_get_main_queue(), ^{
  274. [self viewAddLineColorBg:self.bgV colorArr:@[
  275. (id)_E0FFF5.CGColor,
  276. (id)Col_FFF.CGColor
  277. ]];
  278. });
  279. }
  280. - (UIScrollView *)scrollV {
  281. if (!_scrollV) {
  282. UIScrollView *v = [UIScrollView new];
  283. v.showsVerticalScrollIndicator = false;
  284. v.showsHorizontalScrollIndicator = false;
  285. v.backgroundColor = Col_FFF;
  286. _scrollV = v;
  287. }
  288. return _scrollV;
  289. }
  290. - (UIView *)bgV {
  291. if (!_bgV) {
  292. UIView *v = [UIView new];
  293. _bgV = v;
  294. }
  295. return _bgV;
  296. }
  297. - (UIImageView *)bgImgV {
  298. if (!_bgImgV) {
  299. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_bg"]];
  300. v.contentMode = UIViewContentModeScaleToFill;
  301. _bgImgV = v;
  302. }
  303. return _bgImgV;
  304. }
  305. - (UIImageView *)topImgV {
  306. if (!_topImgV) {
  307. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_topImg"]];
  308. v.contentMode = UIViewContentModeScaleAspectFit;
  309. _topImgV = v;
  310. }
  311. return _topImgV;
  312. }
  313. - (UIImageView *)titleImgV {
  314. if (!_titleImgV) {
  315. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_titleImg_1"]];
  316. v.contentMode = UIViewContentModeScaleAspectFit;
  317. _titleImgV = v;
  318. }
  319. return _titleImgV;
  320. }
  321. - (UILabel *)contentLB {
  322. if (!_contentLB) {
  323. UILabel *lb = [[UILabel alloc] init];
  324. lb.numberOfLines = 0;
  325. lb.textAlignment = NSTextAlignmentCenter;
  326. lb.textColor = UIColor.blackColor;
  327. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  328. lb.qmui_lineHeight = 24;
  329. _contentLB = lb;
  330. }
  331. return _contentLB;
  332. }
  333. //- (UIView *)lineV {
  334. // if (!_lineV) {
  335. // UIView *v = [UIView new];
  336. // v.backgroundColor = UIColor.clearColor;
  337. // UIView *line = [UIView new];
  338. // line.backgroundColor = UIColor.blackColor;
  339. // [v addSubview:line];
  340. // [line mas_makeConstraints:^(MASConstraintMaker *make) {
  341. // make.width.equalTo([NSNumber numberWithFloat:SCREEN_WIDTH-140]);
  342. // make.height.equalTo(@1);
  343. // make.center.equalTo(v);
  344. // }];
  345. // _lineV = v;
  346. // }
  347. // return _lineV;
  348. //}
  349. - (UILabel *)codeDesLB {
  350. if (!_codeDesLB) {
  351. UILabel *lb = [[UILabel alloc] init];
  352. lb.numberOfLines = 0;
  353. lb.textColor = _043632;
  354. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  355. lb.qmui_lineHeight = 24;
  356. lb.textAlignment = NSTextAlignmentCenter;
  357. lb.lineBreakMode = NSLineBreakByWordWrapping;
  358. lb.text = @"USE CODE: BIRTHDAY\nGET DISCOUNT & GIFTPACK";
  359. _codeDesLB = lb;
  360. }
  361. return _codeDesLB;
  362. }
  363. - (UIView *)btnV {
  364. if (!_btnV) {
  365. UIView *v = [UIView new];
  366. v.backgroundColor = UIColor.clearColor;
  367. _btnV = v;
  368. }
  369. return _btnV;
  370. }
  371. - (UIButton *)startBt {
  372. if (!_startBt) {
  373. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  374. bt.backgroundColor = [UIColor blackColor];
  375. bt.layer.cornerRadius = 4;
  376. bt.layer.masksToBounds = true;
  377. [bt setTitle:@"GET THE PARTY STARTED" forState:UIControlStateNormal];
  378. [bt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  379. bt.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
  380. [bt addTarget:self action:@selector(btnAction) forControlEvents:UIControlEventTouchUpInside];
  381. _startBt = bt;
  382. }
  383. return _startBt;
  384. }
  385. - (void)btnAction {
  386. // if (![self.vm.typeId isEqualToString:@""]) {
  387. // KWProductListViewController *vc = [[KWProductListViewController alloc] init];
  388. // vc.titleName = @"HD Lace";
  389. // vc.type = self.vm.typeId;
  390. // [self.navigationController pushViewController:vc animated:YES];
  391. // } else {
  392. // [self.view makeToast:@"Get Birth Products Type Error"];
  393. // }
  394. }
  395. - (UIView *)dateV {
  396. if (!_dateV) {
  397. UIView *v = [UIView new];
  398. v.backgroundColor = UIColor.clearColor;
  399. _dateV = v;
  400. }
  401. return _dateV;
  402. }
  403. - (UILabel *)monthLb {
  404. if (!_monthLb) {
  405. UILabel *lb = [[UILabel alloc] init];
  406. lb.numberOfLines = 0;
  407. lb.textColor = UIColor.blackColor;
  408. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  409. lb.qmui_lineHeight = 20;
  410. _monthLb = lb;
  411. }
  412. return _monthLb;
  413. }
  414. - (UILabel *)dayLb {
  415. if (!_dayLb) {
  416. UILabel *lb = [[UILabel alloc] init];
  417. lb.numberOfLines = 0;
  418. lb.textColor = UIColor.blackColor;
  419. lb.font = [UIFont fontWithName:Rob_Bold size:20];
  420. lb.qmui_lineHeight = 20;
  421. lb.textAlignment = NSTextAlignmentCenter;
  422. _dayLb = lb;
  423. }
  424. return _dayLb;
  425. }
  426. - (UILabel *)yearLb {
  427. if (!_yearLb) {
  428. UILabel *lb = [[UILabel alloc] init];
  429. lb.numberOfLines = 0;
  430. lb.textColor = UIColor.blackColor;
  431. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  432. lb.qmui_lineHeight = 20;
  433. _yearLb = lb;
  434. }
  435. return _yearLb;
  436. }
  437. - (UIImageView *)dayBgV {
  438. if (!_dayBgV) {
  439. UIImageView *v = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"birth_dayTime_bg"]];
  440. v.contentMode = UIViewContentModeScaleAspectFit;
  441. _dayBgV = v;
  442. }
  443. return _dayBgV;
  444. }
  445. - (void)viewAddLineColorBg:(UIView *)bgV colorArr:(NSArray *)colors {
  446. CAGradientLayer *layer = [[CAGradientLayer alloc] init];
  447. layer.frame = bgV.bounds;
  448. layer.colors = colors;
  449. layer.startPoint = CGPointMake(0.44, 0.2);
  450. layer.endPoint = CGPointMake(0.5, 1);
  451. layer.locations = @[@0,@1.0f];
  452. layer.name = @"colorLayer";
  453. [bgV.layer insertSublayer:layer atIndex:0];
  454. }
  455. @end