@@ -20,8 +20,6 @@ @interface ExchangeGoodsViewController () <UITableViewDataSource, UITableViewDel
2020{
2121}
2222
23- @property (strong , nonatomic ) NSString *tagNameToAdd;
24- @property (strong , nonatomic ) NSMutableArray *tagList, *selectedTags;
2523@property (strong , nonatomic ) TPKeyboardAvoidingTableView *myTableView;
2624@property (strong , nonatomic ) UIButton *shopOrderBtn;
2725
@@ -59,6 +57,8 @@ - (void)orderCommitAction:(UIButton *)button
5957 return ;
6058 }
6159
60+ [self showPwdAlertView ];
61+
6262}
6363
6464#pragma mark-
@@ -111,57 +111,13 @@ - (void)viewDidLoad {
111111 }];
112112 orderBtn;
113113 });
114- // _shopOrderBtn.enabled = NO;
115114 _myTableView.tableFooterView = footView;
116115}
117116
118117- (void )viewWillAppear : (BOOL )animated
119118{
120119 [super viewWillAppear: animated];
121- [self sendRequest ];
122120}
123-
124- - (void )sendRequest
125- {
126- // [self.view beginLoading];
127- // __weak typeof(self) weakSelf = self;
128- // [[Coding_NetAPIManager sharedManager] request_TagListInProject:_curProject type:ProjectTagTypeTopic andBlock:^(id data, NSError *error) {
129- // [weakSelf.view endLoading];
130- // if (data) {
131- // weakSelf.tagList = data;
132- // [weakSelf.myTableView reloadData];
133- // }
134- // }];
135- }
136-
137- #pragma mark - click
138- // - (void)okBtnClick
139- // {
140- // if (self.tagsChangedBlock) {
141- // self.tagsChangedBlock(self, _selectedTags);
142- // }
143- // }
144- //
145- // - (void)addBtnClick:(UIButton *)sender
146- // {
147- // [self.view endEditing:YES];
148- // if (_tagNameToAdd.length > 0) {
149- // __weak typeof(self) weakSelf = self;
150- // ProjectTag *curTag = [ProjectTag tagWithName:_tagNameToAdd];
151- // [[Coding_NetAPIManager sharedManager] request_AddTag:curTag toProject:_curProject andBlock:^(id data, NSError *error) {
152- // if (data) {
153- // curTag.id = data;
154- // [weakSelf.tagList addObject:curTag];
155- // weakSelf.tagNameToAdd = @"";
156- // [weakSelf.myTableView reloadData];
157- // sender.enabled = FALSE;
158- //
159- // [NSObject showHudTipStr:@"添加标签成功^^"];
160- // }
161- // }];
162- // }
163- // }
164- //
165121#pragma mark - UITableViewDataSource
166122- (NSInteger )numberOfSectionsInTableView : (UITableView *)tableView
167123{
@@ -239,38 +195,14 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
239195{
240196 [self .view endEditing: YES ];
241197 [tableView deselectRowAtIndexPath: indexPath animated: YES ];
242-
243- // if (indexPath.section > 0) {
244- // EditLabelCell *cell = (EditLabelCell *)[tableView cellForRowAtIndexPath:indexPath];
245- // cell.selectBtn.selected = !cell.selectBtn.selected;
246- //
247- // ProjectTag *tagInSelected = [ProjectTag tags:_selectedTags hasTag:_tagList[indexPath.row]];
248- // if (cell.selectBtn.selected && !tagInSelected) {
249- // [_selectedTags addObject:_tagList[indexPath.row]];
250- // }else if (!cell.selectBtn.selected && tagInSelected){
251- // [_selectedTags removeObject:tagInSelected];
252- // }
253- // self.navigationItem.rightBarButtonItem.enabled = ![ProjectTag tags:_selectedTags isEqualTo:_orignalTags];
254- // }
255198}
256199
257200#pragma mark - UITextFieldDelegate
258201
259202- (void )textFieldDidChange : (UITextField *)textField
260203{
261- _tagNameToAdd = [textField.text trimWhitespace ];
262- BOOL enabled = _tagNameToAdd.length > 0 ? TRUE : FALSE ;
263- if (enabled) {
264- for (ProjectTag *lbl in _tagList) {
265- if ([lbl.name isEqualToString: _tagNameToAdd]) {
266- enabled = FALSE ;
267- break ;
268- }
269- }
270- }
271-
272- NSIndexPath *indexPath = [NSIndexPath indexPathForRow: 0 inSection: 0 ];
273- ShopOrderTextFieldCell *cell = (ShopOrderTextFieldCell *)[_myTableView cellForRowAtIndexPath: indexPath];
204+ // NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
205+ // ShopOrderTextFieldCell *cell = (ShopOrderTextFieldCell *)[_myTableView cellForRowAtIndexPath:indexPath];
274206}
275207
276208- (BOOL )textFieldShouldReturn : (UITextField *)textField
@@ -285,5 +217,83 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
285217 [self .view endEditing: YES ];
286218}
287219
220+
221+ #pragma mark-
222+ #pragma mark---------------------- AlertView ---------------------------
223+
224+ - (void )showPwdAlertView
225+ {
226+ UIAlertView *_pwdAlertView = [[UIAlertView alloc ] initWithTitle: @" 确认订单" message: @" 请输入密码已确认兑换" delegate: self cancelButtonTitle: @" 取消" otherButtonTitles: @" 确认" , nil ];
227+ _pwdAlertView.alertViewStyle = UIAlertViewStyleSecureTextInput;
228+ [_pwdAlertView show ];
229+ }
230+
231+ - (void )alertView : (UIAlertView *)alertView clickedButtonAtIndex : (NSInteger )buttonIndex {
232+
233+ if (alertView.firstOtherButtonIndex == buttonIndex) {
234+ UITextField *field = [alertView textFieldAtIndex: 0 ];
235+ if ([field.text isEmpty ]) {
236+ [NSObject showHudTipStr: @" 密码不能为空" ];
237+ return ;
238+ }
239+
240+ [self exchangeActionRquest: field.text];
241+
242+ }
243+ }
244+
245+ - (void )exchangeActionRquest : (NSString *)pwd
246+ {
247+ __weak typeof (self) weakSelf = self;
248+ [[Coding_NetAPIManager sharedManager ] request_shop_check_passwordWithpwd: pwd andBlock: ^(id data, NSError *error) {
249+ if (data) {
250+
251+ ShopOrderTextFieldCell *nameCell = [weakSelf.myTableView cellForRowAtIndexPath: [NSIndexPath indexPathForItem: 0 inSection: 0 ]];
252+ ShopOrderTextFieldCell *addressCell = [weakSelf.myTableView cellForRowAtIndexPath: [NSIndexPath indexPathForItem: 1 inSection: 0 ]];
253+ ShopOrderTextFieldCell *phoneCell = [weakSelf.myTableView cellForRowAtIndexPath: [NSIndexPath indexPathForItem: 2 inSection: 0 ]];
254+ ShopOrderTextFieldCell *remarkCell = [weakSelf.myTableView cellForRowAtIndexPath: [NSIndexPath indexPathForItem: 3 inSection: 0 ]];
255+
256+ NSString *receiverName = nameCell.textField .text ;
257+ NSString *receiverAddress = addressCell.textField .text ;
258+ NSString *receiverPhone = phoneCell.textField .text ;
259+ NSString *remark = remarkCell.textField .text ;
260+ NSMutableDictionary *mparms = [NSMutableDictionary dictionary ];
261+ if (![receiverName isEmpty ]) {
262+ [mparms setObject: receiverName forKey: @" receiverName" ];
263+ }
264+ if (![receiverAddress isEmpty ]) {
265+ [mparms setObject: receiverAddress forKey: @" receiverAddress" ];
266+ }
267+ if (![receiverPhone isEmpty ]) {
268+ [mparms setObject: receiverPhone forKey: @" receiverPhone" ];
269+ }
270+ if (![remark isEmpty ]) {
271+ [mparms setObject: remark forKey: @" remark" ];
272+ }else
273+ [mparms setObject: @" " forKey: @" remark" ];
274+
275+ if (![_shopGoods.giftId isEmpty ]) {
276+ [mparms setObject: _shopGoods.id forKey: @" giftId" ];
277+ }
278+ if (![pwd isEmpty ]) {
279+ [mparms setObject: [pwd sha1Str ] forKey: @" " ];
280+ }
281+
282+ [[Coding_NetAPIManager sharedManager ] request_shop_exchangeWithParms: mparms andBlock: ^(id data, NSError *error) {
283+ if (!error) {
284+ [NSObject showHudTipStr: @" 恭喜你,兑换成功!" ];
285+ [self .navigationController popViewControllerAnimated: YES ];
286+ }else
287+ {
288+ [NSObject showError: error];
289+ }
290+ }];
291+ }else
292+ {
293+ [NSObject showHudTipStr: @" 密码不正确" ];
294+ }
295+ }];
296+ }
297+
288298@end
289299
0 commit comments