//
//  RbJSObject.m
//  JZK
//
//  Created by 曾铭 on 16/9/21.
//  Copyright © 2016年 铭 曾. All rights reserved.
//

#import "RbJSObject.h"
#import "JX_SystemWorkbenchViewController.h"

@implementation RbJSObject
-(void)getLocation:(NSDictionary *)dict{
//    NSString *str = [dict JSONString];
    if (_getLocationDataBlock) {
        _getLocationDataBlock(dict);
    }
    
    
    DLog(@"字典 === %@",dict);
    NSArray* sdf =  [JSContext currentArguments];
    NSLog(@"====%@",dict);
    for (JSValue *jsVal in sdf) {
        NSLog(@"u:%@", jsVal.toString);
        JSValue* sud = jsVal[@"success"];
        
        [sud callWithArguments:@[self.locationJsonStr]];
    }
}


-(void)closeWindow:(NSDictionary *)dict{
    if (_getCloseWindowBlock) {
        _getCloseWindowBlock();
    }
}

-(void)startRecord:(NSDictionary *)dict{
    if (_getStartRecordBlock) {
        _getStartRecordBlock(dict);
    }
    
    DLog(@"字典 === %@",dict);

    
        NSArray* sdf =  [JSContext currentArguments];
        NSLog(@"====%@",dict);
        for (JSValue *jsVal in sdf) {
            NSLog(@"u:%@", jsVal.toString);
            JSValue* sud = jsVal[@"success"];
            
            self.recordJV = sud;
//            if (_getRecordObjBlock) {
//                _getRecordObjBlock(sud);
//
//            }
        }
   
   

}

-(void)upload:(NSDictionary *)dict{
    if (_getUploadBlock) {
        _getUploadBlock(dict);
    }
    
    DLog(@"字典 === %@",dict);
    NSArray* sdf =  [JSContext currentArguments];
    NSLog(@"====%@",dict);
    for (JSValue *jsVal in sdf) {
        NSLog(@"u:%@", jsVal.toString);
        JSValue* sud = jsVal[@"success"];
        self.recordJV = sud;
//        [sud callWithArguments:@[self.uploadJsonStr]];
    }
}
//预览
-(void)previewFile:(NSDictionary *)dict{
    if (_getPreviewFileBlock) {
        _getPreviewFileBlock(dict);
    }
    
//    DLog(@"字典 === %@",dict);
//    NSArray* sdf =  [JSContext currentArguments];
//    NSLog(@"====%@",dict);
//    for (JSValue *jsVal in sdf) {
//        NSLog(@"u:%@", jsVal.toString);
//        JSValue* sud = jsVal[@"success"];
//        
//        [sud callWithArguments:@[self.previewFileJsonStr]];
//    }
}


-(void)back:(NSDictionary *)dict{
    //    NSString *str = [dict JSONString];
    if (_getBackBlock) {
        _getBackBlock(dict);
    }
    
    
    DLog(@"字典 === %@",dict);
    NSArray* sdf =  [JSContext currentArguments];
    NSLog(@"====%@",dict);
    for (JSValue *jsVal in sdf) {
        NSLog(@"u:%@", jsVal.toString);
        JSValue* sud = jsVal[@"success"];
        
        [sud callWithArguments:@[self.backJsonStr]];
    }
}


@end
