NYFailSpecialExerciseDetailsCell01.m 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. //
  2. // NYFailSpecialExerciseDetailsCell01.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2024/12/17.
  6. // Copyright © 2024 JCZ. All rights reserved.
  7. //
  8. #import "NYFailSpecialExerciseDetailsCell01.h"
  9. @interface NYFailSpecialExerciseDetailsCell01 ()
  10. @property (nonatomic, readwrite, strong) NYFailSpecialExerciseDetailItemModel *viewModel;
  11. @end
  12. @implementation NYFailSpecialExerciseDetailsCell01
  13. #pragma mark - PublicMethods
  14. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  15. static NSString *ID = @"NYFailSpecialExerciseDetailsCell01";
  16. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  17. NYFailSpecialExerciseDetailsCell01 *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  18. if (!cell) cell = [self rq_viewFromXib];
  19. return cell;
  20. }
  21. - (void)bindViewModel:(NYFailSpecialExerciseDetailItemModel *)viewModel {
  22. @weakify(self)
  23. self.viewModel = viewModel;
  24. if([viewModel.title isEqualToString:@"zhouqi"]||
  25. [viewModel.title isEqualToString:@"tianqi"]){
  26. self.scoreStr_label.attributedText = [self getAttributedString:viewModel.dataModel.title color:UIColorHex(0xFF6714)];
  27. }else{
  28. self.scoreStr_label.text = viewModel.dataModel.title;
  29. }
  30. self.vw_left_label.text = viewModel.itemPointTitle;
  31. __block CGFloat yOffset = 0; // 初始偏移量
  32. __block CGFloat cellHeight = 35.f; // 每个 Cell 的高度(根据实际设计调整)
  33. int bi = 0;
  34. CGFloat imgW = (RQ_SCREEN_WIDTH-22*2);
  35. self.itop_view.hidden = YES;
  36. if(viewModel.dataModel.con.count>0){//手势
  37. // 在方法内定义串行队列
  38. dispatch_queue_t serialQueue = dispatch_queue_create("com.yourapp.imageLoadingQueue", DISPATCH_QUEUE_SERIAL);
  39. self.vw_left_view.hidden = YES;
  40. self.itop_view.hidden = NO;
  41. self.scoreStr_label.text = viewModel.dataModel.mainTit;
  42. __block CGFloat itop_yOffset = 0; // 初始偏移量
  43. __block CGFloat itop_cellHeight = 35.f; // 每个 Cell 的高度(根据实际设计调整)
  44. int itop_bi = 0;
  45. for (int i= 0; i<viewModel.dataModel.con.count; i++) {
  46. NYFailItemPointDataCon *con = viewModel.dataModel.con[i];
  47. if(![con.title isEqualToString:@""]){
  48. self.itop_view.frame = CGRectMake(0, 0, imgW, viewModel.dataModel.iviewH);
  49. // 从 XIB 加载 NYFailItemPointCellView
  50. NYFailItemPointCellView *cellView = [self.itop_view viewWithTag:19+i];
  51. cellView.line_view.hidden = YES;
  52. cellView.hidden = NO;
  53. CGSize str_size = [con.title rq_sizeWithFont:cellView.content_label.font limitWidth:cellView.content_label.width];
  54. if(str_size.height>itop_cellHeight){
  55. itop_cellHeight = str_size.height + 12.f;
  56. }
  57. cellView.content_label.attributedText = [self getAttributedString:con.title color:UIColorHex(0xFF6714)];
  58. NSString *img_url = con.image;
  59. if(![img_url isEqualToString:@""]){
  60. self.itop_view.frame = CGRectMake(0, 0, imgW, viewModel.dataModel.iviewH+viewModel.dataModel.imgsH);
  61. UIImageView *image_view = [self.itop_view viewWithTag:79+i];
  62. __block CGSize imageSize = CGSizeMake(imgW,cellHeight);
  63. dispatch_async(serialQueue, ^{
  64. // 处理耗时操作的代码块...
  65. imageSize = [UIImage getImageSizeWithURL:img_url];
  66. //通知主线程刷新
  67. dispatch_async(dispatch_get_main_queue(), ^{
  68. cellView.frame = CGRectMake(0, itop_yOffset, RQ_SCREEN_WIDTH-22*2, itop_cellHeight);
  69. itop_yOffset +=itop_cellHeight;
  70. //回调或者说是通知主线程刷新,
  71. if (imageSize.width == 0 || imageSize.height == 0) {
  72. cellHeight = imgW * (175.f / 345.f);
  73. } else {
  74. cellHeight = imgW * (imageSize.height / imageSize.width);
  75. }
  76. image_view.frame = CGRectMake(0, itop_yOffset, imgW, cellHeight);
  77. // 调整偏移量
  78. itop_yOffset += cellHeight+10*(i+1);
  79. });
  80. });
  81. [image_view sd_setImageWithURL:[NSURL URLWithString:img_url]];
  82. image_view.hidden = NO;
  83. bi = i+1;
  84. itop_bi = i+1;
  85. }else{
  86. dispatch_async(serialQueue, ^{
  87. //通知主线程刷新
  88. dispatch_async(dispatch_get_main_queue(), ^{
  89. cellView.frame = CGRectMake(0, itop_yOffset, RQ_SCREEN_WIDTH-22*2, itop_cellHeight);
  90. itop_yOffset +=itop_cellHeight;
  91. });
  92. });
  93. itop_bi = i+1;
  94. }
  95. }
  96. if(con.questions.count>0){//二层子集
  97. for (int z= 0; z<con.questions.count; z++) {
  98. NYFailItemPointDataQuesImage *img = con.questions[z];
  99. NSString *subTitle_str = img.subTitle;
  100. NSString *img_url = img.image;
  101. if(![img_url isEqualToString:@""]){
  102. self.itop_view.frame = CGRectMake(0, 0, imgW, viewModel.dataModel.iviewH+viewModel.dataModel.imgsH);
  103. // 从 XIB 加载 NYFailItemPointCellView
  104. NYFailItemPointCellView *cellView = [self.itop_view viewWithTag:19+i+z+1];
  105. cellView.line_view.hidden = YES;
  106. cellView.hidden = NO;
  107. CGSize str_size = [subTitle_str rq_sizeWithFont:cellView.content_label.font limitWidth:cellView.content_label.width];
  108. if(str_size.height>itop_cellHeight){
  109. itop_cellHeight = str_size.height + 12.f;
  110. }
  111. cellView.content_label.attributedText = [self getAttributedString:subTitle_str color:UIColorHex(0xFF6714)];
  112. UIImageView *image_view = [self.itop_view viewWithTag:79+i+z+1];
  113. __block CGSize imageSize = CGSizeMake(imgW,cellHeight);
  114. dispatch_async(serialQueue, ^{
  115. // 处理耗时操作的代码块...
  116. imageSize = [UIImage getImageSizeWithURL:img_url];
  117. //通知主线程刷新
  118. dispatch_async(dispatch_get_main_queue(), ^{
  119. cellView.frame = CGRectMake(0, itop_yOffset, RQ_SCREEN_WIDTH-22*2, itop_cellHeight);
  120. itop_yOffset +=itop_cellHeight;
  121. //回调或者说是通知主线程刷新,
  122. if (imageSize.width == 0 || imageSize.height == 0) {
  123. cellHeight = imgW * (175.f / 345.f);
  124. } else {
  125. cellHeight = imgW * (imageSize.height / imageSize.width);
  126. }
  127. image_view.frame = CGRectMake(0, itop_yOffset, imgW, cellHeight);
  128. // 调整偏移量
  129. itop_yOffset += cellHeight+10*(z+1);
  130. });
  131. });
  132. [image_view sd_setImageWithURL:[NSURL URLWithString:img_url]];
  133. image_view.hidden = NO;
  134. bi += z+1;
  135. itop_bi += z+1;
  136. }
  137. }
  138. }
  139. }
  140. for (int ci=itop_bi; ci<10; ci++) {
  141. NYFailItemPointCellView *cellView = [self.itop_view viewWithTag:19+ci];
  142. cellView.hidden = YES;
  143. }
  144. for (int ci=bi; ci<10; ci++) {
  145. UIImageView *image_view = [self.itop_view viewWithTag:79+ci];
  146. image_view.hidden = YES;
  147. }
  148. }
  149. if(viewModel.dataModel.tagquestions.count>0){
  150. self.vw_left_view.hidden = YES;
  151. self.itop_view.hidden = NO;
  152. self.itop_view.frame = CGRectMake(0, 0, imgW, viewModel.dataModel.iviewH);
  153. CGFloat tagitop_yOffset = 10; // 初始偏移量
  154. CGFloat tagtop_cellHeight = 35.f; // 每个 Cell 的高度(根据实际设计调整)
  155. int tagitop_bi = 0;
  156. int tagitop_bicc = 0;
  157. int tagitop_biccc = 0;
  158. for (int i= 0; i<viewModel.dataModel.tagquestions.count; i++) {
  159. NYFailItemPointDataQuestions *tag = viewModel.dataModel.tagquestions[i];
  160. NSString *tag_str = tag.tag;
  161. // 从 XIB 加载 NYFailItemPointCellView
  162. UIButton *btn = [self.itop_view viewWithTag:29+i];
  163. CGSize tag_size = [tag_str rq_sizeWithFont:btn.titleLabel.font];
  164. btn.hidden = NO;
  165. btn.frame = CGRectMake(10, tagitop_yOffset+10*i, tag_size.width + 20.f, 25.f);
  166. [btn setTitleNormal:tag_str];
  167. // 调整偏移量
  168. tagitop_yOffset += 25.f+10*i;
  169. for (int z= 0; z<tag.tagCon.count; z++) {
  170. NYFailItemPointDataQuesTexts *textItem = tag.tagCon[z];
  171. NSString *title_str = textItem.subTitle;
  172. // 从 XIB 加载 NYFailItemPointCellView
  173. NYFailItemPointCellView *cellView = [self.itop_view viewWithTag:19+z+tagitop_bicc];
  174. cellView.hidden = NO;
  175. CGSize str_size = [title_str rq_sizeWithFont:cellView.content_label.font limitWidth:cellView.content_label.width];
  176. if(str_size.height>tagtop_cellHeight){
  177. tagtop_cellHeight = str_size.height + 12.f;
  178. }
  179. cellView.frame = CGRectMake(0, tagitop_yOffset, RQ_SCREEN_WIDTH-22*2, tagtop_cellHeight);
  180. cellView.content_label.attributedText = [self getAttributedString:title_str color:UIColorHex(0xFF6714)];
  181. // 调整偏移量
  182. tagitop_yOffset += tagtop_cellHeight;
  183. if(textItem.quesItem.count>0){
  184. CGFloat ab_H = 20.f;
  185. for (int t= 0; t<textItem.quesItem.count; t++) {
  186. NSString *item_str = textItem.quesItem[t];
  187. UILabel *label = [self.itop_view viewWithTag:59+t+tagitop_biccc];
  188. label.hidden = NO;
  189. label.attributedText = [self getAttributedString:item_str color:UIColorHex(0xFF6714)];
  190. label.frame = CGRectMake(10, tagitop_yOffset, RQ_SCREEN_WIDTH-22*2, ab_H);
  191. tagitop_yOffset += ab_H;
  192. }
  193. tagitop_biccc += textItem.quesItem.count;
  194. }
  195. }
  196. tagitop_bicc += tag.tagCon.count;
  197. tagitop_bi =i+1;
  198. }
  199. for (int ci=tagitop_bi; ci<10; ci++) {
  200. UIButton *btn = [self.itop_view viewWithTag:29+ci];
  201. btn.hidden = YES;
  202. }
  203. for (int ci=tagitop_biccc; ci<10; ci++) {
  204. UILabel *label = [self.itop_view viewWithTag:59+ci];
  205. label.hidden = YES;
  206. }
  207. for (int ci=tagitop_bicc; ci<10; ci++) {
  208. NYFailItemPointCellView *cellView = [self.itop_view viewWithTag:19+ci];
  209. cellView.hidden = YES;
  210. }
  211. }
  212. if(viewModel.dataModel.iquestions.count>0){
  213. for (int i= 0; i<viewModel.dataModel.iquestions.count; i++) {
  214. NYFailItemPointDataQuesImage *img = viewModel.dataModel.iquestions[i];
  215. NSString *img_url = img.image;
  216. UIImageView *image_view = [self.item_view viewWithTag:99+i];
  217. __block CGSize imageSize = CGSizeMake(imgW,cellHeight);
  218. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  219. // 处理耗时操作的代码块...
  220. imageSize = [UIImage getImageSizeWithURL:img_url];
  221. //通知主线程刷新
  222. dispatch_async(dispatch_get_main_queue(), ^{
  223. //回调或者说是通知主线程刷新,
  224. if (imageSize.width == 0 || imageSize.height == 0) {
  225. cellHeight = imgW * (175.f / 345.f);
  226. } else {
  227. cellHeight = imgW * (imageSize.height / imageSize.width);
  228. }
  229. image_view.frame = CGRectMake(0, yOffset, imgW, cellHeight);
  230. // 调整偏移量
  231. yOffset += cellHeight+10*(i+1);
  232. });
  233. });
  234. [image_view sd_setImageWithURL:[NSURL URLWithString:img_url]];
  235. image_view.hidden = NO;
  236. bi = i+1;
  237. }
  238. for (int ci=bi; ci<10; ci++) {
  239. UIImageView *image_view = [self.item_view viewWithTag:99+ci];
  240. image_view.hidden = YES;
  241. }
  242. }
  243. if(viewModel.dataModel.fquestions.count>0){
  244. self.vw_left_view.hidden = YES;
  245. self.itop_view.hidden = NO;
  246. self.itop_view.frame = CGRectMake(0, 0, imgW, viewModel.dataModel.iviewH);
  247. yOffset = CGRectGetMaxY(self.itop_view.frame) +10.f;
  248. CGFloat fitop_yOffset = 0; // 初始偏移量
  249. CGFloat fitop_cellHeight = 35.f; // 每个 Cell 的高度(根据实际设计调整)
  250. int fitop_bi = 0;
  251. int fitop_bicc = 0;
  252. for (int i= 0; i<viewModel.dataModel.fquestions.count; i++) {
  253. NYFailItemPointDataQuesTexts *textItem = viewModel.dataModel.fquestions[i];
  254. NSString *title_str = textItem.subTitle;
  255. // 从 XIB 加载 NYFailItemPointCellView
  256. NYFailItemPointCellView *cellView = [self.itop_view viewWithTag:19+i];
  257. cellView.hidden = NO;
  258. CGSize str_size = [title_str rq_sizeWithFont:cellView.content_label.font limitWidth:cellView.content_label.width];
  259. if(str_size.height>fitop_cellHeight){
  260. fitop_cellHeight = str_size.height + 12.f;
  261. }
  262. cellView.frame = CGRectMake(0, fitop_yOffset, RQ_SCREEN_WIDTH-22*2, fitop_cellHeight);
  263. cellView.content_label.attributedText = [self getAttributedString:title_str color:UIColorHex(0xFF6714)];
  264. // 调整偏移量
  265. fitop_yOffset += fitop_cellHeight;
  266. fitop_bi = i+1;
  267. if(textItem.quesItem.count>0){
  268. CGFloat ab_H = 20.f;
  269. for (int z= 0; z<textItem.quesItem.count; z++) {
  270. NSString *item_str = textItem.quesItem[z];
  271. UILabel *label = [self.itop_view viewWithTag:59+z+fitop_bicc];
  272. label.numberOfLines = 0;
  273. label.hidden = NO;
  274. CGSize itemstr_size = [item_str rq_sizeWithFont:label.font limitWidth:cellView.content_label.width];
  275. if(itemstr_size.height>ab_H){
  276. ab_H = itemstr_size.height + 10.f;
  277. }
  278. label.attributedText = [self getAttributedString:item_str color:UIColorHex(0xFF6714)];
  279. label.frame = CGRectMake(10, fitop_yOffset, RQ_SCREEN_WIDTH-22*2-10, ab_H);
  280. fitop_yOffset += ab_H;
  281. }
  282. fitop_bicc += textItem.quesItem.count;
  283. }
  284. }
  285. for (int ci=fitop_bicc; ci<10; ci++) {
  286. UILabel *label = [self.itop_view viewWithTag:59+ci];
  287. label.hidden = YES;
  288. }
  289. for (int ci=fitop_bi; ci<10; ci++) {
  290. NYFailItemPointCellView *cellView = [self.itop_view viewWithTag:19+ci];
  291. cellView.hidden = YES;
  292. }
  293. }
  294. if(viewModel.dataModel.questions.quesTexts.count>0){
  295. self.itop_view.hidden = NO;
  296. self.itop_view.frame = CGRectMake(0, 0, imgW, viewModel.dataModel.iviewH);
  297. yOffset = CGRectGetMaxY(self.itop_view.frame) +10.f;
  298. CGFloat itop_yOffset = 0; // 初始偏移量
  299. CGFloat itop_cellHeight = 35.f; // 每个 Cell 的高度(根据实际设计调整)
  300. int itop_bi = 0;
  301. int itop_bicc = 0;
  302. for (int i= 0; i<viewModel.dataModel.questions.quesTexts.count; i++) {
  303. NYFailItemPointDataQuesTexts *textItem = viewModel.dataModel.questions.quesTexts[i];
  304. NSString *title_str = textItem.subTitle;
  305. // 从 XIB 加载 NYFailItemPointCellView
  306. NYFailItemPointCellView *cellView = [self.itop_view viewWithTag:19+i];
  307. cellView.hidden = NO;
  308. CGSize str_size = [title_str rq_sizeWithFont:cellView.content_label.font limitWidth:cellView.content_label.width];
  309. if(str_size.height>itop_cellHeight){
  310. itop_cellHeight = str_size.height + 12.f;
  311. }
  312. cellView.frame = CGRectMake(0, itop_yOffset, RQ_SCREEN_WIDTH-22*2, itop_cellHeight);
  313. cellView.content_label.attributedText = [self getAttributedString:title_str color:UIColorHex(0xFF6714)];
  314. // 调整偏移量
  315. itop_yOffset += itop_cellHeight;
  316. itop_bi = i+1;
  317. if(textItem.quesItem.count>0){
  318. CGFloat ab_H = 20.f;
  319. for (int z= 0; z<textItem.quesItem.count; z++) {
  320. NSString *item_str = textItem.quesItem[z];
  321. UILabel *label = [self.itop_view viewWithTag:59+z+itop_bicc];
  322. label.hidden = NO;
  323. label.attributedText = [self getAttributedString:item_str color:UIColorHex(0xFF6714)];
  324. label.frame = CGRectMake(10, itop_yOffset, RQ_SCREEN_WIDTH-22*2, ab_H);
  325. itop_yOffset += ab_H;
  326. }
  327. itop_bicc += textItem.quesItem.count;
  328. }
  329. }
  330. for (int ci=itop_bicc; ci<10; ci++) {
  331. UILabel *label = [self.itop_view viewWithTag:59+ci];
  332. label.hidden = YES;
  333. }
  334. for (int ci=itop_bi; ci<10; ci++) {
  335. NYFailItemPointCellView *cellView = [self.itop_view viewWithTag:19+ci];
  336. cellView.hidden = YES;
  337. }
  338. }
  339. if(viewModel.dataModel.questions.images.count>0){
  340. for (int i= 0; i<viewModel.dataModel.questions.images.count; i++) {
  341. NSString *img_url = viewModel.dataModel.questions.images[i];
  342. UIImageView *image_view = [self.item_view viewWithTag:99+i];
  343. __block CGSize imageSize = CGSizeMake(imgW,cellHeight);
  344. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  345. @strongify(self)
  346. // 处理耗时操作的代码块...
  347. imageSize = [UIImage getImageSizeWithURL:img_url];
  348. //通知主线程刷新
  349. dispatch_async(dispatch_get_main_queue(), ^{
  350. //回调或者说是通知主线程刷新,
  351. if (imageSize.width == 0 || imageSize.height == 0) {
  352. cellHeight = imgW * (175.f / 345.f);
  353. } else {
  354. cellHeight = imgW * (imageSize.height / imageSize.width);
  355. }
  356. image_view.frame = CGRectMake(0, yOffset, imgW, cellHeight);
  357. // 调整偏移量
  358. yOffset += cellHeight+10*(i+1);
  359. });
  360. });
  361. [image_view sd_setImageWithURL:[NSURL URLWithString:img_url]];
  362. image_view.hidden = NO;
  363. bi = i+1;
  364. }
  365. }
  366. for (int ci=bi; ci<10; ci++) {
  367. UIImageView *image_view = [self.item_view viewWithTag:99+ci];
  368. image_view.hidden = YES;
  369. }
  370. }
  371. - (NSMutableAttributedString*)getAttributedString:(NSString *)str color:(UIColor*)color {
  372. // 使用正则表达式匹配所有 [ ] 中的内容
  373. NSError *error = nil;
  374. NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\[([^\\]]+)\\]" options:0 error:&error];
  375. if (error) {
  376. NSLog(@"正则表达式错误: %@", error.localizedDescription);
  377. return [[NSMutableAttributedString alloc] initWithString:str];
  378. }
  379. // 用于存储需要替换的内容和范围
  380. NSMutableArray<NSDictionary *> *replacements = [NSMutableArray array];
  381. // 匹配 [ ] 中的内容
  382. NSArray<NSTextCheckingResult *> *matches = [regex matchesInString:str options:0 range:NSMakeRange(0, str.length)];
  383. for (NSTextCheckingResult *match in matches) {
  384. if (match.numberOfRanges > 1) {
  385. // 提取 [ ] 内部的内容
  386. NSRange innerRange = [match rangeAtIndex:1];
  387. NSString *matchedText = [str substringWithRange:innerRange];
  388. // 保存替换内容和范围
  389. [replacements addObject:@{
  390. @"text": matchedText,
  391. @"range": [NSValue valueWithRange:match.range]
  392. }];
  393. }
  394. }
  395. // 创建可变字符串以进行替换
  396. NSMutableString *updatedString = [NSMutableString stringWithString:str];
  397. NSMutableArray<NSValue *> *highlightedRanges = [NSMutableArray array];
  398. NSInteger offset = 0;
  399. for (NSDictionary *replacement in replacements) {
  400. NSString *text = replacement[@"text"];
  401. NSRange range = [replacement[@"range"] rangeValue];
  402. // 调整范围以匹配当前字符串的变化
  403. range.location += offset;
  404. // 替换 [ ] 为其内部内容
  405. [updatedString replaceCharactersInRange:range withString:text];
  406. // 记录调整后的范围
  407. NSRange adjustedRange = NSMakeRange(range.location, text.length);
  408. [highlightedRanges addObject:[NSValue valueWithRange:adjustedRange]];
  409. // 更新偏移量
  410. offset += (text.length - range.length);
  411. }
  412. // 创建 NSMutableAttributedString
  413. NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:updatedString];
  414. // 设置高亮颜色(黄色)
  415. for (NSValue *rangeValue in highlightedRanges) {
  416. [attributedString addAttribute:NSForegroundColorAttributeName value:color range:rangeValue.rangeValue];
  417. }
  418. return attributedString;
  419. }
  420. - (IBAction)submit_clickdo:(UIButton *)sender {
  421. if([@"考点1" isEqualToString:self.viewModel.itemPointTitle]){
  422. NSString *questionIds = self.viewModel.dataModel.questionIds;
  423. NSArray *arr = [[RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Error_Special_List questionIds:questionIds].rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
  424. return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
  425. }].toArray;
  426. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  427. RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
  428. RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject),
  429. RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice),
  430. RQViewModelIDKey : @"标题",
  431. RQExerciseTypeKey : @(RQExerciseType_Error_Special_List),
  432. RQViewModelUtilKey : arr,
  433. }];
  434. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  435. return;
  436. }
  437. if (RQ_VIP_Module.isSubject1Vip && RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne) {//判断是否 科一vip
  438. NSString *questionIds = self.viewModel.dataModel.questionIds;
  439. NSArray *arr = [[RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Error_Special_List questionIds:questionIds].rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
  440. return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
  441. }].toArray;
  442. RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  443. RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
  444. RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject),
  445. RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice),
  446. RQViewModelIDKey : @"标题",
  447. RQExerciseTypeKey : @(RQExerciseType_Error_Special_List),
  448. RQViewModelUtilKey : arr,
  449. }];
  450. [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  451. }else{
  452. //充值
  453. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  454. }
  455. // NSString *questionIds = self.viewModel.dataModel.questionIds;
  456. // NSArray *arr = [[RQ_YDTQuestion_Module getQuestionWithExerciseType:RQExerciseType_Error_Special_List questionIds:questionIds].rac_sequence.signal map:^id _Nullable(RQYDTQuestionModel *ydtQuestionModel) {
  457. // return [RQExerciseModel exerciseModelWithRQYDTQuestionModel:ydtQuestionModel];
  458. // }].toArray;
  459. // RQExerciseViewModel *exerciseViewModel = [[RQExerciseViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{
  460. // RQHomePageCarTypeKey : @(RQ_YDTQuestion_Module.carType),
  461. // RQHomePageSubjectTypeKey : @(RQ_YDTQuestion_Module.subject),
  462. // RQHomeSubPageTypeKey : @(RQHomeSubPageType_SequentialPractice),
  463. // RQViewModelIDKey : @"标题",
  464. // RQExerciseTypeKey : @(RQExerciseType_Error_Special_List),
  465. // RQViewModelUtilKey : arr,
  466. // }];
  467. // [RQ_APPDELEGATE.services pushViewModel:exerciseViewModel animated:YES];
  468. }
  469. #pragma mark - SystemMethods
  470. - (void)awakeFromNib {
  471. [super awakeFromNib];
  472. [self initTbList_view];
  473. }
  474. - (void)initTbList_view{
  475. self.vm_bm_imageView.image = [UIImage rq_resizableImage:@"blue_jb_bg"];
  476. UIView *itop_view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH-22*2, 20)];
  477. itop_view.backgroundColor = UIColor.whiteColor;
  478. itop_view.layer.cornerRadius = 5.f;
  479. itop_view.layer.masksToBounds = YES;
  480. itop_view.hidden = YES;
  481. [self.item_view addSubview:itop_view];
  482. self.itop_view = itop_view;
  483. //10 + 10
  484. for (int i= 0; i<10; i++) {
  485. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  486. [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
  487. btn.titleLabel.font = [UIFont systemFontOfSize:15.f];
  488. btn.backgroundColor = UIColorHex(0xC1D7FF);
  489. btn.layer.cornerRadius = 5.f;
  490. btn.layer.masksToBounds = YES;
  491. btn.tag = 29+i;
  492. btn.hidden = YES;
  493. [self.itop_view addSubview:btn];
  494. }
  495. for (int i= 0; i<10; i++) {
  496. NYFailItemPointCellView *cellView = [[NYFailItemPointCellView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH-22*2, 0)];
  497. cellView.tag = 19+i;
  498. cellView.hidden = YES;
  499. [self.itop_view addSubview:cellView];
  500. }
  501. for (int i= 0; i<10; i++) {
  502. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, RQ_SCREEN_WIDTH-22*2, 0)];
  503. label.font = [UIFont systemFontOfSize:11.f];
  504. label.textColor = UIColorHex(0x5C6066);
  505. label.tag = 59+i;
  506. label.hidden = YES;
  507. [self.itop_view addSubview:label];
  508. }
  509. for (int i= 0; i<10; i++) {
  510. UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH-22*2, 0)];
  511. imageView.tag = 79+i;
  512. imageView.hidden = YES;
  513. [self.itop_view addSubview:imageView];
  514. }
  515. CGFloat yOffset = 0; // 初始偏移量
  516. CGFloat cellHeight = 1.f; // 每个 Cell 的高度(根据实际设计调整)
  517. for (int i= 0; i<10; i++) {
  518. UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, yOffset, RQ_SCREEN_WIDTH-22*2, cellHeight)];
  519. imageView.tag = 99+i;
  520. imageView.hidden = YES;
  521. imageView.layer.cornerRadius = 10.f;
  522. imageView.layer.masksToBounds = YES;
  523. // 添加到 tbList_view
  524. [self.item_view addSubview:imageView];
  525. // 调整偏移量
  526. yOffset += cellHeight;
  527. }
  528. }
  529. @end