ASGoodsDetailsVM.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // ASGoodsDetailsVM.m
  3. // Asteria
  4. //
  5. // Created by 王猛 on 2023/12/26.
  6. //
  7. #import "ASGoodsDetailsVM.h"
  8. @implementation ASGoodsDetailsVM
  9. - (void)ry_respnsSucessWithPath:(NSString *)mark data:(id)data reqNetType:(ReqNetType)reqNetType{
  10. if([mark isEqualToString:Goods_productGetProductsById]){
  11. GoodsInformationM *model = [GoodsInformationM mj_objectWithKeyValues:data];
  12. [ASGoodsDetailsVM tool_addGooodsImgUrlValue:model];
  13. NSMutableArray *ary = [NSMutableArray arrayWithArray:@[model]];
  14. [self ry_VMconfigDelegateData:data parseAry:ary success:YES mark:mark reqNetType:reqNetType];
  15. }else if ([mark isEqualToString:Goods_productGetProductsReview]){
  16. NSMutableArray <GoodsReviewsListM *>*array = [GoodsReviewsListM mj_objectArrayWithKeyValuesArray:data[@"items"]];
  17. [self ry_VMconfigDelegateData:data parseAry:array success:YES mark:mark reqNetType:reqNetType];
  18. }else if ([mark isEqualToString:Goods_RecommendGoods]){
  19. NSMutableArray <HomeFilterModel *>*array = [HomeFilterModel mj_objectArrayWithKeyValuesArray:data];
  20. [self ry_VMconfigDelegateData:data parseAry:array success:YES mark:mark reqNetType:reqNetType];
  21. }else{
  22. [self ry_VMconfigDelegateData:data parseAry:[NSMutableArray array] success:YES mark:mark reqNetType:reqNetType];
  23. }
  24. }
  25. +(void)tool_addGooodsImgUrlValue:(GoodsInformationM *)infoModel{
  26. NSMutableArray <MediaGalleryEntriesModel *>*imgArry =[NSMutableArray arrayWithArray:infoModel.media_gallery_entries];
  27. for (int i = 0; i< imgArry.count; i++) {
  28. MediaGalleryEntriesModel *tempmodel = imgArry[i];
  29. if(i==0){
  30. infoModel.add_gooodsImgUrl = tempmodel.file;
  31. }
  32. }
  33. }
  34. +(NSMutableAttributedString *)tool_changePriceAtr:(GoodsInformationM *)model{
  35. NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",model.currency_symbol,model.final_prices]];
  36. [priceAtr addAttribute: NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#0B0B0B"] range:NSMakeRange(0, priceAtr.length)];
  37. [priceAtr addAttribute:NSFontAttributeName value:[UIFont fontWithName:Rob_Bold size:20] range:NSMakeRange(0, priceAtr.length)];
  38. if([model.final_prices floatValue] == [model.price floatValue]){
  39. return priceAtr;
  40. }else{
  41. [priceAtr appendAttributedString:[[NSAttributedString alloc]initWithString:@" "]];
  42. NSMutableAttributedString *priceAtrSub1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",model.price]];
  43. [priceAtrSub1 addAttribute:NSForegroundColorAttributeName
  44. value:[UIColor colorWithHexString:@"#8c8c8c"]
  45. range:NSMakeRange(0, priceAtrSub1.length)];
  46. [priceAtrSub1 addAttribute:NSFontAttributeName
  47. value:[UIFont fontWithName:Rob_Regular size:14]
  48. range:NSMakeRange(0, priceAtrSub1.length)];
  49. [priceAtrSub1 addAttribute:NSStrikethroughStyleAttributeName
  50. value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
  51. range:NSMakeRange(0, priceAtrSub1.length)];
  52. [priceAtr appendAttributedString:priceAtrSub1];
  53. return priceAtr;
  54. }
  55. }
  56. +(NSMutableAttributedString *)tool_addOptionPrice:(CGFloat)addPrice quantity:(NSInteger)quantity infoMoel:(GoodsInformationM *)model{
  57. CGFloat add_final_price_f = [model.show_final_prices floatValue];
  58. NSString *add_final_price = [NSString stringWithFormat:@"%.2f",add_final_price_f];
  59. NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",model.currency_symbol,add_final_price]];
  60. [priceAtr addAttribute: NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#0B0B0B"] range:NSMakeRange(0, priceAtr.length)];
  61. [priceAtr addAttribute:NSFontAttributeName value:[UIFont fontWithName:Rob_Bold size:20] range:NSMakeRange(0, priceAtr.length)];
  62. if([model.show_final_prices floatValue] == [model.show_prices floatValue]){
  63. return priceAtr;
  64. }else{
  65. CGFloat add_price_f = [model.show_prices floatValue];
  66. NSString *add_price = [NSString stringWithFormat:@"%@%.2f",model.currency_symbol, add_price_f];
  67. [priceAtr appendAttributedString:[[NSAttributedString alloc]initWithString:@" "]];
  68. NSMutableAttributedString *priceAtrSub1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",add_price]];
  69. [priceAtrSub1 addAttribute:NSForegroundColorAttributeName
  70. value:[UIColor colorWithHexString:@"#8c8c8c"]
  71. range:NSMakeRange(0, priceAtrSub1.length)];
  72. [priceAtrSub1 addAttribute:NSFontAttributeName
  73. value:[UIFont fontWithName:Rob_Regular size:14]
  74. range:NSMakeRange(0, priceAtrSub1.length)];
  75. [priceAtrSub1 addAttribute:NSStrikethroughStyleAttributeName
  76. value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
  77. range:NSMakeRange(0, priceAtrSub1.length)];
  78. [priceAtr appendAttributedString:priceAtrSub1];
  79. return priceAtr;
  80. }
  81. }
  82. @end