LoginSignUpV.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. }
  83. // else if(!isValid(self.xxx_netDateStr)){
  84. // [self makeToast:@"Please set Date Of Birth." duration:2 position:CSToastPositionCenter];
  85. // return;
  86. // }
  87. NSMutableDictionary *customer = [NSMutableDictionary dictionary];
  88. [customer setObject:self.xxx_firstName.text forKey:@"firstname"];
  89. [customer setObject:self.xxx_lasetName.text forKey:@"lastname"];
  90. [customer setObject:self.xxx_regMmailV.xxx_emailTF.text forKey:@"email"];
  91. [customer setObject:AS_String_NotNull(self.xxx_netDateStr) forKey:@"dob"];
  92. NSMutableDictionary *tempDic = [NSMutableDictionary dictionary];
  93. [tempDic setObject:customer forKey:@"customer"];
  94. [tempDic setObject:self.xxx_regPassWord.xxx_passwordTF.text forKey:@"password"];
  95. BOOL isSubscribedSelect = self.xxx_subscribedBtn.selected;
  96. if(isSubscribedSelect){
  97. NSDictionary *extension_attributes = @{
  98. @"is_subscribed": @true
  99. };;
  100. [tempDic setObject:extension_attributes forKey:@"extension_attributes"];
  101. }
  102. [self generaltriggermethodType:1 data:tempDic];
  103. }
  104. -(void)action_xxx_subscribedBtnClick:(UIButton *)btn{
  105. btn.selected = !btn.selected;
  106. }
  107. -(void)action_selectClick:(UIButton *)btn{
  108. btn.selected = !btn.selected;
  109. }
  110. -(TT_CustonTF *)xxx_firstName{
  111. if (!_xxx_firstName) {
  112. _xxx_firstName = [TT_ControlTool FTT_ControlToolUITextFieldFrame:CGRectMake(20, 0, (KScreenWidth-60)/2, 50)
  113. PlaceHolder:@"* FIRST NAME"
  114. andLifImage:nil
  115. AndRightImage:nil
  116. LiftImageFrame:CGRectZero
  117. RightImageFrame:CGRectZero
  118. AndTag:0
  119. AndKeyboardType:UIKeyboardTypeDefault
  120. clearButtonMode:UITextFieldViewModeAlways
  121. AndReturnKeyType:UIReturnKeyDone
  122. masksToBounds:YES
  123. conrenRadius:4
  124. BorderColor:[UIColor colorWithHexString:@"#000000"]
  125. BorderWidth:1];
  126. _xxx_firstName.font = [UIFont fontWithName:Rob_Regular size:14];
  127. _xxx_firstName.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
  128. }
  129. return _xxx_firstName;
  130. }
  131. -(TT_CustonTF *)xxx_lasetName{
  132. if (!_xxx_lasetName) {
  133. _xxx_lasetName = [TT_ControlTool FTT_ControlToolUITextFieldFrame:CGRectMake(CGRectGetMaxX(self.xxx_firstName.frame)+20, 0, (KScreenWidth-60)/2, 50)
  134. PlaceHolder:@"* LAST NAME"
  135. andLifImage:nil
  136. AndRightImage:nil
  137. LiftImageFrame:CGRectZero
  138. RightImageFrame:CGRectZero
  139. AndTag:0
  140. AndKeyboardType:UIKeyboardTypeDefault
  141. clearButtonMode:UITextFieldViewModeAlways
  142. AndReturnKeyType:UIReturnKeyDone
  143. masksToBounds:YES
  144. conrenRadius:4
  145. BorderColor:[UIColor colorWithHexString:@"#000000"]
  146. BorderWidth:1];
  147. _xxx_lasetName.font = [UIFont fontWithName:Rob_Regular size:14];
  148. _xxx_lasetName.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
  149. }
  150. return _xxx_lasetName;
  151. }
  152. -(EamilTFmatchV *)xxx_regMmailV{
  153. if (!_xxx_regMmailV) {
  154. _xxx_regMmailV = [[EamilTFmatchV alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(self.xxx_firstName.frame)+30 , KScreenWidth, 50)];
  155. }
  156. return _xxx_regMmailV;
  157. }
  158. -(PassWordSecureBtnV *)xxx_regPassWord{
  159. if (!_xxx_regPassWord) {
  160. _xxx_regPassWord = [[PassWordSecureBtnV alloc]initWithFrame:CGRectMake(20, CGRectGetMaxY(self.xxx_regMmailV.frame)+30, KScreenWidth-40, 50+20)];
  161. }
  162. return _xxx_regPassWord;
  163. }
  164. -(UILabel *)xxx_dateLab{
  165. if (!_xxx_dateLab) {
  166. _xxx_dateLab = [TT_ControlTool uc_ControlToolUILabelFrame:CGRectMake(20,CGRectGetMaxY(self.xxx_regPassWord.frame)+10, KScreenWidth-40, 50)
  167. AndTitle:@"DATE OF BIRTH"
  168. AndFontSize:14
  169. AndTitleColor:[UIColor colorWithHexString:@"#999999"]
  170. Numberoflines:1
  171. TextAlignment:NSTextAlignmentCenter
  172. adjustesFontSizesTowidth:NO
  173. masksToBounds:YES
  174. conrenrRadius:4
  175. userInteractionEnabled:YES
  176. tap_selector:@selector(action_dateOfBirth)
  177. object:self];
  178. _xxx_dateLab.layer.borderColor = [UIColor colorWithHexString:@"#000000"].CGColor;
  179. _xxx_dateLab.layer.borderWidth = 1;
  180. _xxx_dateLab.text = @"DATE OF BIRTH";
  181. }
  182. return _xxx_dateLab;
  183. }
  184. - (UIButton *)xxx_creatBtn {
  185. if (!_xxx_creatBtn) {
  186. _xxx_creatBtn = [TT_ControlTool FTT_ControlToolUIButtonFrame:CGRectMake(20,CGRectGetMaxY(self.xxx_dateLab.frame)+30 ,KScreenWidth-40,50)
  187. taeget:self
  188. sel:@selector(action_creatClick)
  189. tag:0
  190. AntTitle:@"CREATE ACCOUNT"
  191. titleFont:17
  192. titleColor:[UIColor whiteColor]
  193. andImage:nil
  194. AndBackColor:nil
  195. adjustsFontSizesTowidth:NO
  196. masksToBounds:YES
  197. conrenRadius:5
  198. BorderColor:nil
  199. BorderWidth:0
  200. ContentHorizontalAligment:0];
  201. _xxx_creatBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:16];
  202. _xxx_creatBtn.backgroundColor = ThemeColor;
  203. }
  204. return _xxx_creatBtn;
  205. }
  206. -(UIButton *)xxx_subscribedBtn{
  207. if (!_xxx_subscribedBtn) {
  208. _xxx_subscribedBtn = [TT_ControlTool FTT_ControlToolUIButtonFrame:CGRectMake(20,CGRectGetMaxY(self.xxx_creatBtn.frame)+20, 40, 40)
  209. taeget:self
  210. sel:@selector(action_xxx_subscribedBtnClick:)
  211. tag:0
  212. AntTitle:nil
  213. titleFont:0
  214. titleColor:nil
  215. andImage:@"login_selectRido"
  216. AndBackColor:[UIColor clearColor]
  217. adjustsFontSizesTowidth:NO
  218. masksToBounds:NO
  219. conrenRadius:0
  220. BorderColor:nil
  221. BorderWidth:0
  222. ContentHorizontalAligment:0];
  223. [_xxx_subscribedBtn setImage:[UIImage imageNamed:@"login_selectRido_select"] forState:UIControlStateSelected];
  224. _xxx_subscribedBtn.selected = YES;
  225. }
  226. return _xxx_subscribedBtn;
  227. }
  228. -(QMUILabel *)xxx_subscribedLab{
  229. if (!_xxx_subscribedLab) {
  230. _xxx_subscribedLab = [[QMUILabel alloc]init];
  231. _xxx_subscribedLab.frame = CGRectMake(60, CGRectGetMaxY(self.xxx_creatBtn.frame)+20, KScreenWidth - 20-20-40, 40);
  232. NSString *string = @"I’d Like To Receive Emails Or Sms With Exclusive Discounts And News From Asteriahair";
  233. _xxx_subscribedLab.text = string;
  234. _xxx_subscribedLab.font = [UIFont fontWithName:Rob_Regular size:12];
  235. _xxx_subscribedLab.textColor = [UIColor colorWithHexString:@"#000000"];
  236. }
  237. return _xxx_subscribedLab;
  238. }
  239. -(UIButton *)xxx_selectBtn{
  240. if (!_xxx_selectBtn) {
  241. _xxx_selectBtn = [TT_ControlTool FTT_ControlToolUIButtonFrame:CGRectMake(20,CGRectGetMaxY(self.xxx_subscribedBtn.frame)+10, 40, 40)
  242. taeget:self
  243. sel:@selector(action_selectClick:)
  244. tag:1
  245. AntTitle:nil
  246. titleFont:0
  247. titleColor:nil
  248. andImage:@"login_selectRido"
  249. AndBackColor:[UIColor clearColor]
  250. adjustsFontSizesTowidth:NO
  251. masksToBounds:NO
  252. conrenRadius:0
  253. BorderColor:nil
  254. BorderWidth:0
  255. ContentHorizontalAligment:0];
  256. [_xxx_selectBtn setImage:[UIImage imageNamed:@"login_selectRido_select"] forState:UIControlStateSelected];
  257. }
  258. return _xxx_selectBtn;
  259. }
  260. -(YJLAttributesLabel *)xxx_ClickLab{
  261. if (!_xxx_ClickLab) {
  262. _xxx_ClickLab = [[YJLAttributesLabel alloc]init];
  263. _xxx_ClickLab.numberOfLines = 0;
  264. _xxx_ClickLab.frame = CGRectMake(60, CGRectGetMaxY(self.xxx_subscribedBtn.frame)+10, KScreenWidth - 20-20-40, 60);
  265. NSString *string = @"I Agree To Asteriahair Terms & Conditions And Privacy Policy.";
  266. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:string];
  267. NSMutableArray *arr_text = [[NSMutableArray alloc]initWithObjects:@"Terms & Conditions",@"Privacy Policy." ,nil];
  268. attrStr = [self textArr:arr_text AttributedString:attrStr Connet:string];
  269. NSMutableArray * arr_range = [[NSMutableArray alloc]initWithObjects:@"23",@"46", nil];//点击的文字开始位置设置
  270. [_xxx_ClickLab setAttributesText:attrStr actionText:arr_text actionRange:arr_range];//d添加到UILabel上面
  271. _xxx_ClickLab.YJLAttributesBlock = ^(NSString * _Nonnull clicktext) {//点击事件的d返回
  272. if([clicktext isEqualToString:@"Terms & Conditions"]){
  273. NSString *temrUrl = [NSString stringWithFormat:@"https:%@%@",HostPath,@"/terms-conditions"];
  274. [Fuction_Tool push_BaseWebUrl:temrUrl webTitle:@"Terms & Conditions"];
  275. }else if ([clicktext isEqualToString:@"Privacy Policy."]){
  276. NSString *PrivacyUrl =[NSString stringWithFormat:@"https:%@%@",HostPath,@"/privacy_policy"];
  277. [Fuction_Tool push_BaseWebUrl:PrivacyUrl webTitle:@"Privacy Policy"];
  278. }
  279. };
  280. _xxx_ClickLab.font = [UIFont systemFontOfSize:12];
  281. }
  282. return _xxx_ClickLab;
  283. }
  284. #pragma mark 多个点击位置进行简单设置
  285. -(NSMutableAttributedString *)textArr:(NSMutableArray *)textarr AttributedString:(NSMutableAttributedString *)String Connet:(NSString *)connet{
  286. for (int i=0; i<textarr.count; i++) {
  287. NSRange range = [connet rangeOfString:textarr[i]];
  288. [String addAttribute:NSLinkAttributeName
  289. value:textarr[i]
  290. range: range];
  291. [String addAttribute:NSForegroundColorAttributeName
  292. value:ThemeColor
  293. range:range];
  294. [String addAttribute:NSUnderlineStyleAttributeName
  295. value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
  296. range:range];
  297. }
  298. return String;
  299. }
  300. @end