ASGoodsDetailsVM.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 if ([mark isEqualToString:Goods_productCoupon]){
  22. NSMutableArray <ASGoodsCouponModel *>*array = [ASGoodsCouponModel mj_objectArrayWithKeyValuesArray:data];
  23. [self ry_VMconfigDelegateData:data parseAry:array success:YES mark:mark reqNetType:reqNetType];
  24. }else{
  25. [self ry_VMconfigDelegateData:data parseAry:[NSMutableArray array] success:YES mark:mark reqNetType:reqNetType];
  26. }
  27. }
  28. +(void)tool_addGooodsImgUrlValue:(GoodsInformationM *)infoModel{
  29. NSMutableArray <MediaGalleryEntriesModel *>*imgArry =[NSMutableArray arrayWithArray:infoModel.media_gallery_entries];
  30. for (int i = 0; i< imgArry.count; i++) {
  31. MediaGalleryEntriesModel *tempmodel = imgArry[i];
  32. if(i==0){
  33. infoModel.add_gooodsImgUrl = tempmodel.file;
  34. }
  35. }
  36. }
  37. +(NSMutableAttributedString *)tool_changePriceAtr:(GoodsInformationM *)model{
  38. NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%.2f",model.currency_symbol, [model.final_prices floatValue]]];
  39. [priceAtr addAttribute: NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#0B0B0B"] range:NSMakeRange(0, priceAtr.length)];
  40. [priceAtr addAttribute:NSFontAttributeName value:[UIFont fontWithName:Rob_Bold size:18] range:NSMakeRange(0, priceAtr.length)];
  41. if([model.final_prices floatValue] == [model.price floatValue]){
  42. return priceAtr;
  43. }else{
  44. [priceAtr appendAttributedString:[[NSAttributedString alloc]initWithString:@" "]];
  45. NSMutableAttributedString *priceAtrSub1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%.2f", model.currency_symbol, [model.price floatValue]]];
  46. [priceAtrSub1 addAttribute:NSForegroundColorAttributeName
  47. value:[UIColor colorWithHexString:@"#8c8c8c"]
  48. range:NSMakeRange(0, priceAtrSub1.length)];
  49. [priceAtrSub1 addAttribute:NSFontAttributeName
  50. value:[UIFont fontWithName:Rob_Regular size:14]
  51. range:NSMakeRange(0, priceAtrSub1.length)];
  52. [priceAtrSub1 addAttribute:NSStrikethroughStyleAttributeName
  53. value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
  54. range:NSMakeRange(0, priceAtrSub1.length)];
  55. [priceAtr appendAttributedString:priceAtrSub1];
  56. return priceAtr;
  57. }
  58. }
  59. +(NSMutableAttributedString *)tool_addOptionPrice:(CGFloat)addPrice quantity:(NSInteger)quantity infoMoel:(GoodsInformationM *)model{
  60. CGFloat add_final_price_f = [model.show_final_prices floatValue];
  61. NSString *add_final_price = [NSString stringWithFormat:@"%.2f",add_final_price_f];
  62. NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",model.currency_symbol,add_final_price]];
  63. [priceAtr addAttribute: NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#0B0B0B"] range:NSMakeRange(0, priceAtr.length)];
  64. [priceAtr addAttribute:NSFontAttributeName value:[UIFont fontWithName:Rob_Bold size:20] range:NSMakeRange(0, priceAtr.length)];
  65. if([model.show_final_prices floatValue] == [model.show_prices floatValue]){
  66. return priceAtr;
  67. }else{
  68. CGFloat add_price_f = [model.show_prices floatValue];
  69. NSString *add_price = [NSString stringWithFormat:@"%@%.2f",model.currency_symbol, add_price_f];
  70. [priceAtr appendAttributedString:[[NSAttributedString alloc]initWithString:@" "]];
  71. NSMutableAttributedString *priceAtrSub1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",add_price]];
  72. [priceAtrSub1 addAttribute:NSForegroundColorAttributeName
  73. value:[UIColor colorWithHexString:@"#8c8c8c"]
  74. range:NSMakeRange(0, priceAtrSub1.length)];
  75. [priceAtrSub1 addAttribute:NSFontAttributeName
  76. value:[UIFont fontWithName:Rob_Regular size:14]
  77. range:NSMakeRange(0, priceAtrSub1.length)];
  78. [priceAtrSub1 addAttribute:NSStrikethroughStyleAttributeName
  79. value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
  80. range:NSMakeRange(0, priceAtrSub1.length)];
  81. [priceAtr appendAttributedString:priceAtrSub1];
  82. return priceAtr;
  83. }
  84. }
  85. @end