口袋优选

KBGoodDetailRequestViewModel.m 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // KBGoodDetailRequestViewModel.m
  3. // YouHuiProject
  4. //
  5. // Created by xiaoxi on 2018/1/24.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "KBGoodDetailRequestViewModel.h"
  9. @implementation KBGoodDetailRequestViewModel
  10. + (void)requestGoodDetailParamGoods_id:(DetailRequestModel *)requestModel success:(void (^)(KBGoodDetailModel *model,NSDictionary *dic))success failure:(void (^)(NSError *))failure {
  11. NSString *urlString = [NSString stringWithFormat:@"%@/api/v2/goods/detail", BaseURL];
  12. NSDictionary *para = [requestModel modelToDictionary];
  13. [KBHttp post:urlString params:para success:^(id json) {
  14. KBGoodDetailModel *model = [KBGoodDetailModel yy_modelWithJSON:json[@"data"]];
  15. NSDictionary *dic = json[@"data"];
  16. success(model,dic);
  17. } failure:^(NSError *error) {
  18. failure(error);
  19. }];
  20. }
  21. + (void)requestGoodSimilarParamGoods_id:(NSString *)goods_id page:(NSNumber *)page success:(void (^)(NSArray *))success failure:(void (^)(NSError *))failure {
  22. NSString *urlString = [NSString stringWithFormat:@"%@/api/v2/goods/recommendlist", BaseURL];
  23. [KBHttp post:urlString params:@{@"goods_id":goods_id,@"page":page} success:^(id json) {
  24. NSArray *arr = [NSArray yy_modelArrayWithClass:[KBChildGoodModel class] json:json[@"data"]];
  25. success(arr);
  26. } failure:^(NSError *error) {
  27. failure(error);
  28. }];
  29. }
  30. + (void)requestShopGoodParamSellerId:(NSString *)sellerId Page:(NSInteger)page success:(void (^)(NSArray *))success failure:(void (^)(NSError *))failure {
  31. NSString *urlString = [NSString stringWithFormat:@"%@/api/category/shopItems", BaseURL];
  32. [KBHttp post:urlString params:@{@"sellerId":sellerId,@"page":@(page)} success:^(id json) {
  33. NSArray *arr = [NSArray yy_modelArrayWithClass:[KBChildGoodModel class] json:json[@"data"]];
  34. success(arr);
  35. } failure:^(NSError *error) {
  36. failure(error);
  37. }];
  38. }
  39. + (void)requestCollectGoodParamGoods_id:(NSDictionary *)para success:(void (^)(NSString *))success failure:(void (^)(NSError *))failure {
  40. NSString *urlString = [NSString stringWithFormat:@"%@/api/v2/goods/addFavorites", BaseURL];
  41. [KBHttp post:urlString params:para success:^(id json) {
  42. success(json[@"msg"]);
  43. } failure:^(NSError *error) {
  44. failure(error);
  45. }];
  46. }
  47. + (void)requestTicketProcessParamGoods_id:(NSString *)goods_id coupon_price:(NSString *)coupon_price success:(void (^)(NSString *))success failure:(void (^)(NSError *))failure {
  48. NSString *urlString = [NSString stringWithFormat:@"%@/api/goods/ticketProcess", BaseURL];
  49. [KBHttp post:urlString params:@{@"goods_id":goods_id,@"coupon_price":coupon_price} success:^(id json) {
  50. success(json[@"msg"]);
  51. } failure:^(NSError *error) {
  52. failure(error);
  53. }];
  54. }
  55. @end