ASProductBaseModel.m 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // ASProductBaseModel.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/6/1.
  6. //
  7. #import "ASProductBaseModel.h"
  8. @implementation ASProductBaseModel
  9. + (ASProductBaseModel*)demoModel {
  10. ASProductBaseModel *m = [[ASProductBaseModel alloc] init];
  11. m.img = @"https://marketplace.canva.cn/O0eQI/MADvnEO0eQI/1/screen_2x/canva-surprised-asian-girl-with-pretty-smile-in-pinup-makeup-style-MADvnEO0eQI.jpg";
  12. m.title = @"Transparent Wigs Brazilian Front Wigs Straight Hair Transparent Wigs Brazilian Front Wigs Straight Hair ";
  13. m.sketchy_app = @"Transparent Wigs Brazilian Front Wigs Straight Hair Body Wave…";
  14. m.discount_app = @"10%";
  15. if (arc4random()%2 == 1) {
  16. m.oldPrice = @"";
  17. } else {
  18. m.oldPrice = @"234.43";
  19. }
  20. if (arc4random()%2 == 1) {
  21. m.sketchy_app = @"";
  22. }
  23. m.Id = @(arc4random()%12130).stringValue;
  24. m.nowPrice = @"223.45";
  25. m.rate_star = [NSString stringWithFormat:@"%u",arc4random()%90 + 2];
  26. m.sale_num = @"324123";
  27. return m;
  28. }
  29. - (NSString *)currencySymbol {
  30. if (_currencySymbol == nil) {
  31. return @"";
  32. }
  33. return _currencySymbol;
  34. }
  35. - (NSString *)nowPrice {
  36. NSDecimalNumber *num = [NSDecimalNumber decimalNumberWithString:_nowPrice];
  37. if (num == [NSDecimalNumber decimalNumberWithString:@"NaN"]) {
  38. num = [NSDecimalNumber decimalNumberWithString:@"0"];
  39. }
  40. return [NSString stringWithFormat:@"%@%.2f",self.currencySymbol, num.doubleValue];
  41. }
  42. - (NSString *)oldPrice {
  43. NSDecimalNumber *num = [NSDecimalNumber decimalNumberWithString:_oldPrice];
  44. if (num == [NSDecimalNumber decimalNumberWithString:@"NaN"]) {
  45. num = [NSDecimalNumber decimalNumberWithString:@"0"];
  46. }
  47. return [NSString stringWithFormat:@"%@%.2f",self.currencySymbol, num.doubleValue];
  48. }
  49. - (NSString *)img {
  50. if ([_img hasPrefix:@"http"]) {
  51. return _img;
  52. }
  53. return [NSString stringWithFormat:@"https://%@%@%@",HostPath, ProductImgPath, _img];
  54. }
  55. - (NSString *)sale_num {
  56. return [NSString stringWithFormat:@"%ldK", _sale_num.integerValue/1000];
  57. }
  58. + (NSDictionary *)mj_replacedKeyFromPropertyName {
  59. return @{
  60. @"Id": @"entity_id",
  61. @"oldPrice": @"price",
  62. @"nowPrice":@"final_price",
  63. @"img":@"image",
  64. @"title":@"name",
  65. @"sketchy_app":@"short_description"
  66. };
  67. }
  68. @end