CNLiveContactUsViewController.m
7.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//
// CNLiveContactUsViewController.m
// CNLiveScioLive
//
// Created by CNLive-zxw on 2018/9/21.
// Copyright © 2018年 CNLive. All rights reserved.
//
#import "CNLiveContactUsViewController.h"
#import "GCPlaceholderTextView.h"
@interface CNLiveContactUsViewController ()
@property (nonatomic, strong) GCPlaceholderTextView *textView;
@property (nonatomic, strong) GCPlaceholderTextView *contactView;
@end
@implementation CNLiveContactUsViewController
static const NSInteger margin = 10;
- (void)viewDidLoad {
[super viewDidLoad];
[self setUpNavigationBar];
[self setUpSubControllers];
// Do any additional setup after loading the view.
}
#pragma mark - UI
- (void)setUpNavigationBar{
self.navigationController.navigationBar.barTintColor = Color_Blue;
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
//左
UIButton *headerButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 20, 44)];
headerButton.layer.cornerRadius = 2.0;
headerButton.layer.masksToBounds = true;
[headerButton setImage:[UIImage imageNamed:@"cnlive_white_back"] forState:UIControlStateNormal];
[headerButton addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:headerButton];
self.navigationItem.title = self.navTitle;
}
- (void)setUpSubControllers{
self.view.backgroundColor = [UIColor whiteColor];
_textView = [[GCPlaceholderTextView alloc] initWithFrame:CGRectMake(margin, margin, MainScreenWidth - 2*margin, 150)];
_textView.font = [UIFont systemFontOfSize:15];
_textView.textColor = HEXCOLOR(0x333333);
_textView.placeholder = CustomStr(@"WeWillReplyToYouSoon");
[self.view addSubview:_textView];
UIImageView *lineImage1 = [[UIImageView alloc] initWithFrame:CGRectMake(margin, 160, MainScreenWidth - 2*(margin+2), Line_Height)];
lineImage1.backgroundColor = Color_Line;
[self.view addSubview:lineImage1];
_contactView = [[GCPlaceholderTextView alloc] initWithFrame:CGRectMake(margin+2, 161, MainScreenWidth - 2*margin, 68)];
_contactView.font = [UIFont systemFontOfSize:15];
_contactView.textColor = HEXCOLOR(0x333333);
_contactView.placeholder = CustomStr(@"ForUsToReplyToYourInquiries");
[self.view addSubview:_contactView];
UIImageView *lineImage2 = [[UIImageView alloc] initWithFrame:CGRectMake(margin+2, 230, MainScreenWidth - 2*(margin+2), Line_Height)];
lineImage1.backgroundColor = Color_Line;
[self.view addSubview:lineImage2];
UIButton *doConfirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[doConfirmBtn setFrame:CGRectMake(margin+2, 258, MainScreenWidth - 2*(margin+2), 44)];
[doConfirmBtn addTarget:self action:@selector(doConfirm:) forControlEvents:UIControlEventTouchUpInside];
[doConfirmBtn setBackgroundColor:Color_Blue];
[doConfirmBtn.titleLabel setFont:[UIFont systemFontOfSize:19]];
[doConfirmBtn setTitle:CustomStr(@"Sure") forState:UIControlStateNormal];
[doConfirmBtn setTitleColor:HEXCOLOR(0xffffff) forState:UIControlStateNormal];
doConfirmBtn.layer.masksToBounds = YES;
doConfirmBtn.layer.cornerRadius = 6.0;
[self.view addSubview:doConfirmBtn];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(margin+2, 320, MainScreenWidth - 2*(margin+2), 180)];
titleLabel.numberOfLines = 0;
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.textColor = HEXCOLOR(0x333333);
// titleLabel.text = @" 其他联系方式\n\n 电话:010-65592311\n\n 地址:中国北京东城区朝阳门内大街225号\n\n 邮编:100010";
// titleLabel.text = [NSString stringWithFormat:@" %@\n\n %@:010-65592311\n\n %@\n\n %@:100010",CustomStr(@"OthercContacts"), CustomStr(@"Tel"), CustomStr(@"Address"), CustomStr(@"Postcode")];
titleLabel.text = [NSString stringWithFormat:@" %@\n\n %@:010-88824268\n\n %@:guoxinfabu_taolm@scio.gov.cn \n\n QQ:110016699\n\n",CustomStr(@"OthercContacts"), CustomStr(@"Tel"), CustomStr(@"Email")];
titleLabel.font = [UIFont systemFontOfSize:14];
[self.view addSubview:titleLabel];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Action
- (void)doConfirm:(UIButton *)sender{
sender.userInteractionEnabled = NO;
if (_textView.text.length == 0) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:CustomStr(@"Notice")
message:CustomStr(@"PleaseEnterYourFeedback")
delegate:nil
cancelButtonTitle:CustomStr(@"Sure")
otherButtonTitles:nil];
[alert show];
sender.userInteractionEnabled = YES;
return;
}
if (_contactView.text.length == 0) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:CustomStr(@"Notice")
message:CustomStr(@"PleaseLeaveYourEmailAccountorPhoneNumber")
delegate:nil
cancelButtonTitle:CustomStr(@"Sure")
otherButtonTitles:nil];
[alert show];
sender.userInteractionEnabled = YES;
return;
}
NSStringEncoding encoding = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
NSString *message = [[NSString stringWithFormat:@"%@%@",_textView.text,_contactView.text] stringByAddingPercentEscapesUsingEncoding:encoding];
NSDictionary *dic = @{@"id":SP_ID, @"sp_id":SP_ID, @"msg":message};
// NSMutableDictionary *mudic = [[NSMutableDictionary alloc] init];
// NSString *message = [NSString stringWithFormat:@"%@%@",_textView.text,_contactView.text];
// NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
// message = [message stringByAddingPercentEscapesUsingEncoding:enc];
// [mudic setObject:SP_ID forKey:@"sp_id"];
// [mudic setObject:message forKey:@"msg"];
// [mudic setObject:SP_ID forKey:@"id"];
if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
[AlertViewTool showHUDViewText:CustomStr(@"NetworkiInterruption")];
return;
}
[AlertViewTool showHUDView];
[XWHTTPTool POST:@"http://api.cnlive.com/open/api/CnliveMobile/json/report" params:dic success:^(id json) {
[AlertViewTool hideHUDView];
sender.userInteractionEnabled = YES;
NSLog(@"%@", json);
NSDictionary *dic = [NSDictionary dictionaryWithDictionary:json];
NSLog(@"%@", dic);
if ([dic[@"errorCode"] isEqualToString:@"0"]) {
[AlertViewTool showHUDViewText:CustomStr(@"ThanksForYourFeedback")];
[self.navigationController popViewControllerAnimated:YES];
NSLog(@"成功~");
} else {
[AlertViewTool showHUDViewText:dic[@"errorMessage"]];
}
} failure:^(NSError *error) {
// 请求失败
NSLog(@"%@", [error localizedDescription]);
[AlertViewTool hideHUDView];
[AlertViewTool showHUDViewText:CustomStr(@"ServerBusy")];
sender.userInteractionEnabled = YES;
}];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
[self.view endEditing:YES];
}
@end