Between binding alipay home page and filling in the data binding page,

You need to fill in the mobile phone number and verification code on the filling page, click “confirm binding” and jump back to the binding home page. In addition, the binding button becomes the bound button, and the unbound label becomes the entered Alipay account. And clicking the bound button will jump to the unbound interface.

The whole process is displayed on the APP as

Create a Block in the controller where the message is passed (i.e. the controller where the page is filled) :

FillAlipayViewController. H:

// Create block typedef void(^bindAlipayBlock)(NSDictionary *bindDict); // Listen for the binding status returned @property (nonatomic, copy)bindAlipayBlock returnBlock;
Copy the code
  • Here’s an explanation of the create statement:

    • We can pass the keywordtypedefTo give a block a type name, and then create the block directly from the type name;
    • voidIs the return value;
    • ^bindAlipayBlockIs the block name;
    • NSDictionary *bindDictAs a parameter.
  • Since we need to pass two values (payment id and binding status), the create type is a dictionary, and the name is also explicit about the Block type:

(NSDictionary *bindDict)
Copy the code

FillAlipayViewController. M:

Global variable needs to be created: _alipayAccount is the global variable of alipay account monitored. Alipay account is a string:

{ NSString *_alipayAccount; // Alipay account}Copy the code

In the click event of clicking “confirm” after input, confirm that if Block instance is responded, the dictionary will be outgoing, and corresponding key value will be written in the dictionary (that is to bind YES status and alipay account to outgoing) :

if (self.returnBlock){

self.returnBlock(@{@"isBind": @"YES"The @"alipayAccount":self->_alipayAccount});
}
Copy the code

Return to the previous page binding home page statement:

[self.navigationController popViewControllerAnimated:YES];
Copy the code

Ii. In the controller that receives the signal (namely, in the controller bound to the home page) :

BindAlipayViewController. M:

Create the corresponding global variable to receive the value:

{ BOOL _isBind; // Binding status NSString *_bindAlipayAccount; // Bind alipay account}Copy the code

In the implementation of the jump method:

- (void)jumpToControllerWithType:(NSString *)type{
    if([type intValue]== 1){
        ABFillAlipayViewController *vc=[[ABFillAlipayViewController alloc]init];
        WS(weakself);
        vc.returnBlock = ^(NSDictionary *bindDict) {
            NSLog(@"Returned ~"); Self ->_isBind = [bindDict[@"isBind"] isEqualToString:@"YES"]? YES:NO; Self ->_bindAlipayAccount =bindDict[@"alipayAccount"]; // Refresh data in tableView [weakself.tableView reloadData]; }; [self.navigationController pushViewController:vc animated:YES]; }else if([typeintValue]== 2){ [self.navigationController pushViewController:[[ABRemoveBindAlipayViewController alloc]init] animated:YES]; }}Copy the code

_isBind is equal to YES if the string @ “YES”, otherwise NO.

The _bindalipayAccount is the value passed from the dictionary.

Since the binding home page is drawn with tableView, it is judged in the cell content that if the binding is successful, the corresponding change will be made to assign the value:

if(_isBind == YES) {// bindButton hidden, show bound button cell.bindbutton. hidden = YES; cell.boundButton.hidden = NO; // Display alipay account cell.sublabel. text = _bindPhoneNumber; }else{// bindButton display, hide bound button cell.bindbutton. hidden = NO; cell.boundButton.hidden = YES; // Display "Unbound account" cell.sublabel. text = @ "Unbound account"; }Copy the code

The authors introduce

  • Li Hong: iOS development engineer of Guangzhou Reed APP Team

Push the information

  • We are recruiting partners, interested partners can send your resume to [email protected], note: from the nuggets community
  • For details, please click here –> Guangzhou Reed Information Technology