LoginSignUpV.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. //
  2. // LoginSignUpV.m
  3. // Asteria
  4. //
  5. // Created by 王猛 on 2023/5/17.
  6. //
  7. #import "LoginSignUpV.h"
  8. #import "PassWordSecureBtnV.h"
  9. #import "EamilTFmatchV.h"
  10. #import <BRPickerView/BRPickerView.h>
  11. #import "YJLAttributesLabel.h"
  12. @interface LoginSignUpV ()
  13. @property (nonatomic, strong) TT_CustonTF *xxx_firstName;
  14. @property (nonatomic, strong) TT_CustonTF *xxx_lasetName;
  15. @property (nonatomic, strong) EamilTFmatchV *xxx_regMmailV;
  16. @property (nonatomic, strong) PassWordSecureBtnV *xxx_regPassWord;
  17. @property (nonatomic, strong) UILabel *xxx_dateLab;
  18. @property (nonatomic, strong) UIButton *xxx_creatBtn;
  19. @property (nonatomic, strong) UIButton *xxx_subscribedBtn;
  20. @property (nonatomic, strong) QMUILabel *xxx_subscribedLab;
  21. @property (nonatomic, strong) YJLAttributesLabel *xxx_ClickLab;
  22. @property (nonatomic, strong) UIButton *xxx_selectBtn;
  23. @property (nonatomic, strong) NSDate *birthdaySelectDate;
  24. @property (nonatomic, strong) NSString *xxx_netDateStr;
  25. @end
  26. @implementation LoginSignUpV
  27. - (void)tt_setupViews{
  28. [self addSubview:self.xxx_firstName];
  29. [self addSubview:self.xxx_lasetName];
  30. [self addSubview:self.xxx_regMmailV];
  31. [self addSubview:self.xxx_regPassWord];
  32. [self addSubview:self.xxx_dateLab];
  33. [self addSubview:self.xxx_creatBtn];
  34. [self addSubview:self.xxx_subscribedBtn];
  35. [self addSubview:self.xxx_subscribedLab];
  36. [self addSubview:self.xxx_selectBtn];
  37. [self addSubview:self.xxx_ClickLab];
  38. [self bringSubviewToFront:self.xxx_regMmailV];
  39. self.birthdaySelectDate = [NSDate date];
  40. }
  41. #pragma mark - **************** action ****************
  42. -(void)action_dateOfBirth{
  43. UIViewController *topVC = topViewController();
  44. [topVC.view endEditing:YES];
  45. BRDatePickerView *datePickerView = [[BRDatePickerView alloc]init];
  46. datePickerView.pickerMode = BRDatePickerModeDate;
  47. datePickerView.title = @"Please Select The Date Of Birth";
  48. datePickerView.selectDate = self.birthdaySelectDate;
  49. datePickerView.minDate = [NSDate br_setYear:1900 month:1 day:1];
  50. datePickerView.maxDate = [NSDate date];
  51. datePickerView.isAutoSelect = YES;
  52. datePickerView.resultBlock = ^(NSDate *selectDate, NSString *selectValue) {
  53. self.birthdaySelectDate = selectDate;
  54. NSDateFormatter *formartter= [[NSDateFormatter alloc]init];
  55. [formartter setDateFormat:@"MM/dd/yyyy"];
  56. NSString *currentDateStr = [formartter stringFromDate:selectDate];
  57. self.xxx_dateLab.text = currentDateStr;
  58. self.xxx_dateLab.textColor = [UIColor qmui_colorWithHexString:@"#000000"];
  59. NSDateFormatter *netFormartter= [[NSDateFormatter alloc]init];
  60. [formartter setDateFormat:@"yyyy/MM/dd"];
  61. NSString *netDateStr = [formartter stringFromDate:selectDate];
  62. self.xxx_netDateStr = netDateStr;
  63. };
  64. [datePickerView show];
  65. }
  66. -(void)action_creatClick{
  67. if (self.xxx_selectBtn.selected == NO) {
  68. [self makeToast:@"Please select 'I Agree' to continue." duration:2 position:CSToastPositionCenter];
  69. return;
  70. }else if (self.xxx_firstName.text.length == 0) {
  71. [self makeToast:@"Please Input FirstName" duration:2 position:CSToastPositionCenter];
  72. return;
  73. }else if (self.xxx_lasetName.text.length == 0){
  74. [self makeToast:@"Please Input LastName" duration:2 position:CSToastPositionCenter];
  75. return;
  76. }else if(self.xxx_regMmailV.xxx_emailTF.text.length == 0 || ![Current_normalTool xxx_isValidateEmail:self.xxx_regMmailV.xxx_emailTF.text]){
  77. [self makeToast:@"Please prvide an email address." duration:2 position:CSToastPositionCenter];
  78. return;
  79. }else if(self.xxx_regPassWord.xxx_passwordTF.text.length<6){
  80. [self makeToast:@"Please set the correct password." duration:2 position:CSToastPositionCenter];
  81. return;
  82. }else if(!isValid(self.xxx_netDateStr)){
  83. [self makeToast:@"Please set Date Of Birth." duration:2 position:CSToastPositionCenter];
  84. return;
  85. }
  86. NSMutableDictionary *customer = [NSMutableDictionary dictionary];
  87. [customer setObject:self.xxx_firstName.text forKey:@"firstname"];
  88. [customer setObject:self.xxx_lasetName.text forKey:@"lastname"];
  89. [customer setObject:self.xxx_regMmailV.xxx_emailTF.text forKey:@"email"];
  90. [customer setObject:self.xxx_netDateStr forKey:@"dob"];
  91. NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
  92. [tempDic setObject:customer forKey:@"customer"];
  93. [tempDic setObject:self.xxx_regPassWord.xxx_passwordTF.text forKey:@"password"];
  94. BOOL isSubscribedSelect = self.xxx_subscribedBtn.selected;
  95. if(isSubscribedSelect){
  96. NSDictionary *extension_attributes = @{
  97. @"is_subscribed": @true
  98. };;
  99. [tempDic setObject:extension_attributes forKey:@"extension_attributes"];
  100. }
  101. [self generaltriggermethodType:1 data:tempDic];
  102. }
  103. -(void)action_xxx_subscribedBtnClick:(UIButton *)btn{
  104. btn.selected = !btn.selected;
  105. }
  106. -(void)action_selectClick:(UIButton *)btn{
  107. btn.selected = !btn.selected;
  108. }
  109. -(TT_CustonTF *)xxx_firstName{
  110. if (!_xxx_firstName) {
  111. _xxx_firstName = [TT_ControlTool FTT_ControlToolUITextFieldFrame:CGRectMake(20, 0, (KScreenWidth-60)/2, 50)
  112. PlaceHolder:@"* FIRST NAME"
  113. andLifImage:nil
  114. AndRightImage:nil
  115. LiftImageFrame:CGRectZero
  116. RightImageFrame:CGRectZero
  117. AndTag:0
  118. AndKeyboardType:UIKeyboardTypeDefault
  119. clearButtonMode:UITextFieldViewModeAlways
  120. AndReturnKeyType:UIReturnKeyDone
  121. masksToBounds:YES
  122. conrenRadius:4
  123. BorderColor:[UIColor colorWithHexString:@"#000000"]
  124. BorderWidth:1];
  125. _xxx_firstName.font = [UIFont fontWithName:Rob_Regular size:14];
  126. _xxx_firstName.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
  127. }
  128. return _xxx_firstName;
  129. }
  130. -(TT_CustonTF *)xxx_lasetName{
  131. if (!_xxx_lasetName) {
  132. _xxx_lasetName = [TT_ControlTool FTT_ControlToolUITextFieldFrame:CGRectMake(CGRectGetMaxX(self.xxx_firstName.frame)+20, 0, (KScreenWidth-60)/2, 50)
  133. PlaceHolder:@"* LAST NAME"
  134. andLifImage:nil
  135. AndRightImage:nil
  136. LiftImageFrame:CGRectZero
  137. RightImageFrame:CGRectZero
  138. AndTag:0
  139. AndKeyboardType:UIKeyboardTypeDefault
  140. clearButtonMode:UITextFieldViewModeAlways
  141. AndReturnKeyType:UIReturnKeyDone
  142. masksToBounds:YES
  143. conrenRadius:4
  144. BorderColor:[UIColor colorWithHexString:@"#000000"]
  145. BorderWidth:1];
  146. _xxx_lasetName.font = [UIFont fontWithName:Rob_Regular size:14];
  147. _xxx_lasetName.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
  148. }
  149. return _xxx_lasetName;
  150. }
  151. -(EamilTFmatchV *)xxx_regMmailV{
  152. if (!_xxx_regMmailV) {
  153. _xxx_regMmailV = [[EamilTFmatchV alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(self.xxx_firstName.frame)+30 , KScreenWidth, 50)];
  154. }
  155. return _xxx_regMmailV;
  156. }
  157. -(PassWordSecureBtnV *)xxx_regPassWord{
  158. if (!_xxx_regPassWord) {
  159. _xxx_regPassWord = [[PassWordSecureBtnV alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(self.xxx_regMmailV.frame)+30, KScreenWidth-40, 50+20)];
  160. }
  161. return _xxx_regPassWord;
  162. }
  163. -(UILabel *)xxx_dateLab{
  164. if (!_xxx_dateLab) {
  165. _xxx_dateLab = [TT_ControlTool uc_ControlToolUILabelFrame:CGRectMake(20,CGRectGetMaxY(self.xxx_regPassWord.frame)+10, KScreenWidth-40, 50)
  166. AndTitle:@"DATE OF BIRTH"
  167. AndFontSize:14
  168. AndTitleColor:[UIColor colorWithHexString:@"#999999"]
  169. Numberoflines:1
  170. TextAlignment:NSTextAlignmentCenter
  171. adjustesFontSizesTowidth:NO
  172. masksToBounds:YES
  173. conrenrRadius:4
  174. userInteractionEnabled:YES
  175. tap_selector:@selector(action_dateOfBirth)
  176. object:self];
  177. _xxx_dateLab.layer.borderColor = [UIColor colorWithHexString:@"#000000"].CGColor;
  178. _xxx_dateLab.layer.borderWidth = 1;
  179. _xxx_dateLab.text = @"DATE OF BIRTH";
  180. }
  181. return _xxx_dateLab;
  182. }
  183. - (UIButton *)xxx_creatBtn {
  184. if (!_xxx_creatBtn) {
  185. _xxx_creatBtn = [TT_ControlTool FTT_ControlToolUIButtonFrame:CGRectMake(20,CGRectGetMaxY(self.xxx_dateLab.frame)+30 ,KScreenWidth-40,50)
  186. taeget:self
  187. sel:@selector(action_creatClick)
  188. tag:0
  189. AntTitle:@"CREATE ACCOUNT"
  190. titleFont:17
  191. titleColor:[UIColor whiteColor]
  192. andImage:nil
  193. AndBackColor:nil
  194. adjustsFontSizesTowidth:NO
  195. masksToBounds:YES
  196. conrenRadius:5
  197. BorderColor:nil
  198. BorderWidth:0
  199. ContentHorizontalAligment:0];
  200. _xxx_creatBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:16];
  201. _xxx_creatBtn.backgroundColor = ThemeColor;
  202. }
  203. return _xxx_creatBtn;
  204. }
  205. -(UIButton *)xxx_subscribedBtn{
  206. if (!_xxx_subscribedBtn) {
  207. _xxx_subscribedBtn = [TT_ControlTool FTT_ControlToolUIButtonFrame:CGRectMake(20,CGRectGetMaxY(self.xxx_creatBtn.frame)+20, 40, 40)
  208. taeget:self
  209. sel:@selector(action_xxx_subscribedBtnClick:)
  210. tag:0
  211. AntTitle:nil
  212. titleFont:0
  213. titleColor:nil
  214. andImage:@"login_selectRido"
  215. AndBackColor:[UIColor clearColor]
  216. adjustsFontSizesTowidth:NO
  217. masksToBounds:NO
  218. conrenRadius:0
  219. BorderColor:nil
  220. BorderWidth:0
  221. ContentHorizontalAligment:0];
  222. [_xxx_subscribedBtn setImage:[UIImage imageNamed:@"login_selectRido_select"] forState:UIControlStateSelected];
  223. _xxx_subscribedBtn.selected = YES;
  224. }
  225. return _xxx_subscribedBtn;
  226. }
  227. -(QMUILabel *)xxx_subscribedLab{
  228. if (!_xxx_subscribedLab) {
  229. _xxx_subscribedLab = [[QMUILabel alloc]init];
  230. _xxx_subscribedLab.frame = CGRectMake(60, CGRectGetMaxY(self.xxx_creatBtn.frame)+20, KScreenWidth - 20-20-40, 40);
  231. NSString *string = @"I’d Like To Receive Emails Or Sms With Exclusive Discounts And News From Asteriahair";
  232. _xxx_subscribedLab.text = string;
  233. _xxx_subscribedLab.font = [UIFont fontWithName:Rob_Regular size:12];
  234. _xxx_subscribedLab.textColor = [UIColor colorWithHexString:@"#000000"];
  235. }
  236. return _xxx_subscribedLab;
  237. }
  238. -(UIButton *)xxx_selectBtn{
  239. if (!_xxx_selectBtn) {
  240. _xxx_selectBtn = [TT_ControlTool FTT_ControlToolUIButtonFrame:CGRectMake(20,CGRectGetMaxY(self.xxx_subscribedBtn.frame)+10, 40, 40)
  241. taeget:self
  242. sel:@selector(action_selectClick:)
  243. tag:1
  244. AntTitle:nil
  245. titleFont:0
  246. titleColor:nil
  247. andImage:@"login_selectRido"
  248. AndBackColor:[UIColor clearColor]
  249. adjustsFontSizesTowidth:NO
  250. masksToBounds:NO
  251. conrenRadius:0
  252. BorderColor:nil
  253. BorderWidth:0
  254. ContentHorizontalAligment:0];
  255. [_xxx_selectBtn setImage:[UIImage imageNamed:@"login_selectRido_select"] forState:UIControlStateSelected];
  256. }
  257. return _xxx_selectBtn;
  258. }
  259. -(YJLAttributesLabel *)xxx_ClickLab{
  260. if (!_xxx_ClickLab) {
  261. _xxx_ClickLab = [[YJLAttributesLabel alloc]init];
  262. _xxx_ClickLab.numberOfLines = 0;
  263. _xxx_ClickLab.frame = CGRectMake(60, CGRectGetMaxY(self.xxx_subscribedBtn.frame)+10, KScreenWidth - 20-20-40, 60);
  264. NSString *string = @"I Agree To Asteriahair Terms & Conditions And Privacy Policy.";
  265. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:string];
  266. NSMutableArray *arr_text = [[NSMutableArray alloc]initWithObjects:@"Terms & Conditions",@"Privacy Policy." ,nil];
  267. attrStr = [self textArr:arr_text AttributedString:attrStr Connet:string];
  268. NSMutableArray * arr_range = [[NSMutableArray alloc]initWithObjects:@"23",@"46", nil];//点击的文字开始位置设置
  269. [_xxx_ClickLab setAttributesText:attrStr actionText:arr_text actionRange:arr_range];//d添加到UILabel上面
  270. _xxx_ClickLab.YJLAttributesBlock = ^(NSString * _Nonnull clicktext) {//点击事件的d返回
  271. if([clicktext isEqualToString:@"Terms & Conditions"]){
  272. NSString *temrUrl = [NSString stringWithFormat:@"https:%@%@",HostPath,@"/terms-conditions"];
  273. [Fuction_Tool push_BaseWebUrl:temrUrl webTitle:@"Terms & Conditions"];
  274. }else if ([clicktext isEqualToString:@"Privacy Policy."]){
  275. NSString *PrivacyUrl =[NSString stringWithFormat:@"https:%@%@",HostPath,@"/privacy_policy"];
  276. [Fuction_Tool push_BaseWebUrl:PrivacyUrl webTitle:@"Privacy Policy"];
  277. }
  278. };
  279. _xxx_ClickLab.font = [UIFont systemFontOfSize:12];
  280. }
  281. return _xxx_ClickLab;
  282. }
  283. #pragma mark 多个点击位置进行简单设置
  284. -(NSMutableAttributedString *)textArr:(NSMutableArray *)textarr AttributedString:(NSMutableAttributedString *)String Connet:(NSString *)connet{
  285. for (int i=0; i<textarr.count; i++) {
  286. NSRange range = [connet rangeOfString:textarr[i]];
  287. [String addAttribute:NSLinkAttributeName
  288. value:textarr[i]
  289. range: range];
  290. [String addAttribute:NSForegroundColorAttributeName
  291. value:ThemeColor
  292. range:range];
  293. [String addAttribute:NSUnderlineStyleAttributeName
  294. value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
  295. range:range];
  296. }
  297. return String;
  298. }
  299. @end