ASGoodsDetailsVM.m 4.8 KB

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