CategoryPriceCell.m 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //
  2. // CategoryPriceCell.m
  3. // iSales-NPD
  4. //
  5. // Created by Jack on 2016/10/11.
  6. // Copyright © 2016年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "CategoryPriceCell.h"
  9. #import "SetCategoryPriceController.h"
  10. #import "config.h"
  11. @interface CategoryPriceCell ()
  12. @property (strong, nonatomic) IBOutlet UILabel *categoryLabel;
  13. @property (strong, nonatomic) IBOutlet UILabel *priceLabel;
  14. @end
  15. @implementation CategoryPriceCell
  16. - (void)awakeFromNib {
  17. [super awakeFromNib];
  18. // Initialization code
  19. }
  20. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  21. [super setSelected:selected animated:animated];
  22. // Configure the view for the selected state
  23. }
  24. - (void)setCategoryPrice:(NSDictionary *)categoryPrice {
  25. _categoryPrice = categoryPrice;
  26. NSString *basePrice = [categoryPrice objectForKey:@"base_price"];
  27. NSString *discount = [categoryPrice objectForKey:@"price_discount"];
  28. NSString *price = @"";
  29. switch (basePrice.integerValue) {
  30. case 0:{
  31. basePrice = [RASingleton sharedInstance].deliveryString;
  32. }
  33. break;
  34. case 1:{
  35. basePrice = flat_price;
  36. }
  37. default:
  38. break;
  39. }
  40. if ([discount hasPrefix:@"-"]) {
  41. discount = [discount substringFromIndex:1];
  42. price = [NSString stringWithFormat:@"%@ - %@",basePrice,discount];
  43. } else if ([discount hasSuffix:@"%"]) {
  44. price = [NSString stringWithFormat:@"%@ x %@",basePrice,discount];
  45. } else {
  46. price = [NSString stringWithFormat:@"%@ + %@",basePrice,discount];
  47. }
  48. self.categoryLabel.text = [self.categoryPrice objectForKey:@"title"];
  49. self.priceLabel.text = price;
  50. }
  51. @end