课程背景:
聚合数据是一家国内最大的基础数据 API 提供商。免费提供从天气查询、空气质量、地图坐标到金融基金、电商比价、违章查询等各个领域的安全、稳定和高效的数据。开发者可以免费使用聚合数据 API 进行移动 App 的快速开发,免除数据收集、维护等环节,大大降低开发周期及成本。
核心内容:
1.条码查询器结构分析。
2.如何将聚合数据 SDK 添加到工程中。
3.模型以及业务类的封装。
4.控制器间的数据传递。
5.tableView 以及 webView 的使用。
开发环境:Xcode 6、Mac OS X 10.10
课程大纲
本课时演示如何将 UIViewController 中控制器的 view 换成 webView,并利用 webView 展示购买界面,并利用 MBProgressHUD 给出了电商无购买链接时候的UI提示。
课程原型图
课程代码片段
@interface ViewController () <JKCitiesControllerDelegate>
@property (nonatomic,copy) Nsstring *cityID;
@property (weak,nonatomic) IBOutlet UITextField *inputTextField;
@end
@implementation ViewController
- (IBAction)chaxunOnClick {
if (!self.inputTextField.hasText) {
[MBProgressHUD showError:@"请输入商品条码!"];
return;
}
JKGoodsController *gVC = [[JKGoodsController alloc] init];
BarCodeParam *param = [[BarCodeParam alloc] init];
param.cityid = self.cityID;
#warning 实际开发这里传入的是文本输入看中的字符串
param.barcode = @"6923450601822";
//param.barcode = self.inputTextField.text;
gVC.barCodeParam = param;
[self.navigationController pushViewController:gVC animated:YES];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view,typically from a nib.
[[JHOpenidsupplier sharesupplier] registerJuheAPIByOpenId:JHOpenID];
self.title = @"条码查询器";
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"上海" style:UIBarButtonItemStyleDone target:self action:@selector(openCitiesVC)];
self.cityID = @"1";
//
// [self test:kJHAPIS_EX_JHBAR_CITY parameters:@{ @"pname":@"com.jikexueyuan.JKJHBarCode",@"v":@"2.0"}];
[self test:kJHAPIS_EX_JHBAR_BAR parameters:@{ @"barcode": @"6923450601822",@"cityid":@"1",@"pname":@"com.jikexueyuan.JKJHBarCode",@"v":@"2.0" }];
// [self test:kJHAPIS_EX_JHBAR_BUY parameters:@{ @"barcode":@"6923450601822",@"dsid":@"5",@"v":@"2.0"}];
}
- (void)test:(Nsstring *)path parameters:(NSDictionary *)parameters{
JuheAPI *juheapi = [JuheAPI shareJuheApi];
[juheapi executeWorkWithAPI:path
parameters:parameters
success:^(id responSEObject){
if ([[parameters objectForKey:@"dtype"] isEqualToString:@"xml"]) {
NSLog(@"***xml*** \n %@",responSEObject);
}else{
int error_code = [[responSEObject objectForKey:@"error_code"] intValue];
if (!error_code) {
NSLog(@" %@",responSEObject);
}else{
NSLog(@" %@",responSEObject);
}
}
} failure:^(NSError *error) {
NSLog(@"error: %@",error.description);
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// dispose of any resources that can be recreated.
}
- (void)openCitiesVC
{
JKCitiesController *cVC = [[JKCitiesController alloc] init];
cVC.delegate = self;
[self.navigationController pushViewController:cVC animated:YES];
}
#pragma mark - JKCitiesControllerDelegate
- (void)backToMainVcWithCity:(City *)city
{
// 1.替换右上角中按钮的 title
self.navigationItem.rightBarButtonItem.title = city.cityname;
// 2.传递给主控制器一个 cityid 的数据
self.cityID = [Nsstring stringWithFormat:@"%@",city.cityid];
}
课程地址: http://www.jikexueyuan.com/course/324.html
课程原型图
课程代码片段
@interface ViewController () <JKCitiesControllerDelegate>
@property (nonatomic,copy) Nsstring *cityID;
@property (weak,nonatomic) IBOutlet UITextField *inputTextField;
@end
@implementation ViewController
- (IBAction)chaxunOnClick {
if (!self.inputTextField.hasText) {
[MBProgressHUD showError:@"请输入商品条码!"];
return;
}
JKGoodsController *gVC = [[JKGoodsController alloc] init];
BarCodeParam *param = [[BarCodeParam alloc] init];
param.cityid = self.cityID;
#warning 实际开发这里传入的是文本输入看中的字符串
param.barcode = @"6923450601822";
//param.barcode = self.inputTextField.text;
gVC.barCodeParam = param;
[self.navigationController pushViewController:gVC animated:YES];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view,typically from a nib.
[[JHOpenidsupplier sharesupplier] registerJuheAPIByOpenId:JHOpenID];
self.title = @"条码查询器";
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"上海" style:UIBarButtonItemStyleDone target:self action:@selector(openCitiesVC)];
self.cityID = @"1";
//
// [self test:kJHAPIS_EX_JHBAR_CITY parameters:@{ @"pname":@"com.jikexueyuan.JKJHBarCode",@"v":@"2.0"}];
[self test:kJHAPIS_EX_JHBAR_BAR parameters:@{ @"barcode": @"6923450601822",@"cityid":@"1",@"pname":@"com.jikexueyuan.JKJHBarCode",@"v":@"2.0" }];
// [self test:kJHAPIS_EX_JHBAR_BUY parameters:@{ @"barcode":@"6923450601822",@"dsid":@"5",@"v":@"2.0"}];
}
- (void)test:(Nsstring *)path parameters:(NSDictionary *)parameters{
JuheAPI *juheapi = [JuheAPI shareJuheApi];
[juheapi executeWorkWithAPI:path
parameters:parameters
success:^(id responSEObject){
if ([[parameters objectForKey:@"dtype"] isEqualToString:@"xml"]) {
NSLog(@"***xml*** \n %@",responSEObject);
}else{
int error_code = [[responSEObject objectForKey:@"error_code"] intValue];
if (!error_code) {
NSLog(@" %@",responSEObject);
}else{
NSLog(@" %@",responSEObject);
}
}
} failure:^(NSError *error) {
NSLog(@"error: %@",error.description);
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// dispose of any resources that can be recreated.
}
- (void)openCitiesVC
{
JKCitiesController *cVC = [[JKCitiesController alloc] init];
cVC.delegate = self;
[self.navigationController pushViewController:cVC animated:YES];
}
#pragma mark - JKCitiesControllerDelegate
- (void)backToMainVcWithCity:(City *)city
{
// 1.替换右上角中按钮的 title
self.navigationItem.rightBarButtonItem.title = city.cityname;
// 2.传递给主控制器一个 cityid 的数据
self.cityID = [Nsstring stringWithFormat:@"%@",city.cityid];
}
课程地址: http://www.jikexueyuan.com/course/324.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。