MyLessonBodyView.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. //
  2. // MyLessonBodyView.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by 王智 on 2022/4/12.
  6. //
  7. #import "MyLessonBodyView.h"
  8. #import "KSBaseWKWebViewController.h"
  9. #import "MyLiveCourseCell.h"
  10. #import "AccompanyCourseCell.h"
  11. #import "LiveLessonModel.h"
  12. #import "AccompanyLessonModel.h"
  13. #import "KSChatConversationViewController.h"
  14. #include "KSGroupConversationController.h"
  15. #import "MyLessonSearchView.h"
  16. #import "NewClassPopView.h"
  17. #import <KSFullDatePicker.h>
  18. #import "AccompanyDetailViewController.h"
  19. #import <KSChoosePicker.h>
  20. #import "MusicRoomCourseCell.h"
  21. #import "MusicRoomListModel.h"
  22. #import "MusicRoomDetailViewController.h"
  23. @interface MyLessonBodyView ()<UITableViewDelegate,UITableViewDataSource>
  24. @property (nonatomic, strong) NSDateFormatter *dateFormatter;
  25. @property (nonatomic, copy) MyLessonSearchView *sortView;
  26. @property (nonatomic, strong) NewClassPopView *popView;
  27. @property (nonatomic, strong) NSMutableArray *dataArray;
  28. @property (nonatomic, strong) StateView *promptView;
  29. @property (nonatomic, strong) UIView *promptPlaceView;
  30. @property (nonatomic, assign) BOOL networkAvaiable; // 网络是否可用
  31. @property (nonatomic, assign) BOOL isLoadMore;
  32. @property (nonatomic, assign) NSInteger rows;
  33. @property (nonatomic, assign) NSInteger pages;
  34. @property (nonatomic, assign) NSInteger secondChooseIndex;
  35. @property (nonatomic, assign) NSInteger thirdChooseIndex;
  36. @property (nonatomic, strong) NSString *classDate;
  37. @property (nonatomic, strong) NSString *status;
  38. @property (nonatomic, strong) NSString *subjectId;
  39. @property (nonatomic, strong) NSMutableArray *subjectMessageArray;
  40. @end
  41. @implementation MyLessonBodyView
  42. - (instancetype)initWithFrame:(CGRect)frame {
  43. self = [super initWithFrame:frame];
  44. if (self) {
  45. self.backgroundColor = HexRGB(0xf6f8f9);
  46. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height) style:UITableViewStylePlain];
  47. self.tableView.backgroundColor = HexRGB(0xf6f8f9);
  48. self.tableView.showsVerticalScrollIndicator = NO;
  49. self.tableView.dataSource = self;
  50. self.tableView.delegate = self;
  51. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  52. [self addSubview:self.tableView];
  53. UIView *headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
  54. headView.backgroundColor = HexRGB(0xf6f8f9);
  55. self.tableView.tableHeaderView = headView;
  56. UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 10)];
  57. bottomView.backgroundColor = HexRGB(0xf6f8f9);
  58. self.tableView.tableFooterView = bottomView;
  59. [self.tableView registerNib:[UINib nibWithNibName:@"AccompanyCourseCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"AccompanyCourseCell"];
  60. [self.tableView registerNib:[UINib nibWithNibName:@"MyLiveCourseCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MyLiveCourseCell"];
  61. [self.tableView registerNib:[UINib nibWithNibName:@"MusicRoomCourseCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MusicRoomCourseCell"];
  62. [self.dateFormatter setDateFormat:@"yyyy-MM"];
  63. NSDate *currentDate = [NSDate date];
  64. self.classDate = [self.dateFormatter stringFromDate:currentDate];
  65. MJWeakSelf;
  66. self.tableView.mj_header = [KSGifRefreshHeader headerWithRefreshingBlock:^{
  67. [weakSelf resetParamenter];
  68. [weakSelf requestData];
  69. }];
  70. self.tableView.mj_footer = [KSGifRefreshFooter footerWithRefreshingBlock:^{
  71. if (weakSelf.isLoadMore) {
  72. weakSelf.pages += 1;
  73. [weakSelf requestData];
  74. }
  75. else {
  76. [weakSelf.tableView.mj_footer endRefreshingWithNoMoreData];
  77. }
  78. }];
  79. }
  80. return self;
  81. }
  82. - (void)endRefresh {
  83. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  84. [self.tableView.mj_header endRefreshing];
  85. [self.tableView.mj_footer endRefreshing];
  86. });
  87. }
  88. - (void)refreshAndRequestData {
  89. [self resetParamenter];
  90. [self requestData];
  91. }
  92. - (void)resetParamenter {
  93. self.isLoadMore = YES;
  94. self.pages = 1;
  95. self.rows = 10;
  96. self.dataArray = [NSMutableArray array];
  97. [self.tableView.mj_footer resetNoMoreData];
  98. [self setPromptString:@"暂无课程" imageName:@"empty_course" inView:self.tableView];
  99. [self.tableView reloadData];
  100. }
  101. - (void)requestData {
  102. if (self.selectIndex == 0) { // 趣纠课
  103. [KSNetworkingManager queryStudentPracticeCourse:KS_POST classMonth:self.classDate status:self.status subjectId:self.subjectId page:self.pages rows:self.rows success:^(NSDictionary * _Nonnull dic) {
  104. [self endRefresh];
  105. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  106. NSArray *sourceArray = [[dic ks_dictionaryValueForKey:@"data"] ks_arrayValueForKey:@"rows"];
  107. for (NSDictionary *parm in sourceArray) {
  108. AccompanyLessonModel *model = [[AccompanyLessonModel alloc] initWithDictionary:parm];
  109. [self.dataArray addObject:model];
  110. }
  111. if (sourceArray.count < self.rows) {
  112. self.isLoadMore = NO;
  113. }
  114. }
  115. else {
  116. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  117. }
  118. [self.tableView reloadData];
  119. [self changePromptLabelStateWithArray:self.dataArray];
  120. } faliure:^(NSError * _Nonnull error) {
  121. [self endRefresh];
  122. if (self.networkAvaiable == NO) {
  123. [self setPromptString:@"暂无网络" imageName:@"no_networking" inView:self.tableView];
  124. }
  125. [self.dataArray removeAllObjects];
  126. [self.tableView reloadData];
  127. [self changePromptLabelStateWithArray:self.dataArray];
  128. }];
  129. }
  130. else if (self.selectIndex == 1) { // 直播课
  131. NSString *searchKey = nil;
  132. [KSNetworkingManager queryMyLiveCourse:KS_POST classDate:self.classDate status:self.status subjectId:self.subjectId search:searchKey page:self.pages rows:self.rows success:^(NSDictionary * _Nonnull dic) {
  133. [self endRefresh];
  134. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  135. NSArray *sourceArray = [[dic ks_dictionaryValueForKey:@"data"] ks_arrayValueForKey:@"rows"];
  136. for (NSDictionary *parm in sourceArray) {
  137. LiveLessonModel *model = [[LiveLessonModel alloc] initWithDictionary:parm];
  138. [self.dataArray addObject:model];
  139. }
  140. if (sourceArray.count < self.rows) {
  141. self.isLoadMore = NO;
  142. }
  143. }
  144. else {
  145. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  146. }
  147. [self.tableView reloadData];
  148. [self changePromptLabelStateWithArray:self.dataArray];
  149. } faliure:^(NSError * _Nonnull error) {
  150. [self endRefresh];
  151. if (self.networkAvaiable == NO) {
  152. [self setPromptString:@"暂无网络" imageName:@"no_networking" inView:self.tableView];
  153. }
  154. [self.dataArray removeAllObjects];
  155. [self.tableView reloadData];
  156. [self changePromptLabelStateWithArray:self.dataArray];
  157. }];
  158. }
  159. else { // 琴房课
  160. [KSNetworkingManager queryPianoClassRequest:KS_POST classMonth:self.classDate status:self.status subjectId:self.subjectId page:self.pages rows:self.rows success:^(NSDictionary * _Nonnull dic) {
  161. [self endRefresh];
  162. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  163. NSArray *sourceArray = [[dic ks_dictionaryValueForKey:@"data"] ks_arrayValueForKey:@"rows"];
  164. for (NSDictionary *parm in sourceArray) {
  165. MusicRoomListModel *model = [[MusicRoomListModel alloc] initWithDictionary:parm];
  166. [self.dataArray addObject:model];
  167. }
  168. if (sourceArray.count < self.rows) {
  169. self.isLoadMore = NO;
  170. }
  171. }
  172. else {
  173. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  174. }
  175. [self.tableView reloadData];
  176. [self changePromptLabelStateWithArray:self.dataArray];
  177. } faliure:^(NSError * _Nonnull error) {
  178. [self endRefresh];
  179. if (self.networkAvaiable == NO) {
  180. [self setPromptString:@"暂无网络" imageName:@"no_networking" inView:self.tableView];
  181. }
  182. [self.dataArray removeAllObjects];
  183. [self.tableView reloadData];
  184. [self changePromptLabelStateWithArray:self.dataArray];
  185. }];
  186. }
  187. }
  188. - (void)beginRefreshImmediately {
  189. [self.tableView.mj_header beginRefreshing];
  190. }
  191. - (void)beginFirstRefresh {
  192. if (!self.isHeaderRefreshed) {
  193. [self beginRefreshImmediately];
  194. }
  195. }
  196. - (void)selectCellAtIndexPath:(NSIndexPath *)indexPath {
  197. if (self.lastSelectedIndexPath == indexPath) {
  198. return;
  199. }
  200. if (self.lastSelectedIndexPath != nil) {
  201. UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:self.lastSelectedIndexPath];
  202. [cell setSelected:NO animated:NO];
  203. }
  204. UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
  205. [cell setSelected:YES animated:NO];
  206. self.lastSelectedIndexPath = indexPath;
  207. }
  208. - (void)layoutSubviews {
  209. [super layoutSubviews];
  210. self.tableView.frame = self.bounds;
  211. CGFloat topHeight = 55.0f;
  212. self.tableView.frame = CGRectMake(0, topHeight, self.bounds.size.width, self.bounds.size.height - topHeight);
  213. if (!_sortView) {
  214. _sortView = [MyLessonSearchView shareInstance];
  215. _sortView.frame = CGRectMake(0, 0, kScreenWidth, 55);
  216. MJWeakSelf;
  217. [_sortView sortAction:^(SORT_TYPE type) {
  218. [weakSelf sortWithType:type];
  219. }];
  220. [self.dateFormatter setDateFormat:@"yyyy年MM月"];
  221. NSDate *currentDate = [NSDate date];
  222. [self.sortView.firstLabel setText:[self.dateFormatter stringFromDate:currentDate]];
  223. [self addSubview:self.sortView];
  224. }
  225. }
  226. - (void)sortWithType:(SORT_TYPE)type {
  227. if (type == SORT_TYPE_TIME) { // time
  228. [self showPickerView];
  229. }
  230. else if (type == SORT_TYPE_STATUS) { // 状态
  231. [self.popView refreshWithSourceArray:@[@"全部",@"未开始",@"进行中",@"已结束"] preChooseIndex:_secondChooseIndex inView:self actionItem:1];
  232. }
  233. else if (type == SORT_TYPE_SUBJECT) {
  234. if (self.subjectList.count) {
  235. NSMutableArray *nameArray = [NSMutableArray array];
  236. [nameArray addObject:@"全部"];
  237. for (NSDictionary *parm in self.subjectList) {
  238. [nameArray addObject:[parm ks_stringValueForKey:@"subjectName"]];
  239. }
  240. MJWeakSelf;
  241. KSChoosePicker *picker = [[KSChoosePicker alloc] initWithTitle:@"声部筛选" sourceData:nameArray lastChooseIndex:0 sureButtonColor:CLIENT_THEMECOLOR chooseReturnWithBlock:^(NSString * _Nonnull returnValue, NSInteger chooseIndex) {
  242. if (chooseIndex == 0) {
  243. [weakSelf.sortView.thirdLabel setText:@"全部声部"];
  244. weakSelf.subjectId = nil;
  245. }
  246. else {
  247. [weakSelf.sortView.thirdLabel setText:returnValue];
  248. NSDictionary *parm = self.subjectList[chooseIndex-1];
  249. weakSelf.subjectId = [parm ks_stringValueForKey:@"subjectId"];
  250. }
  251. self.sortView.thirdArrowUp = NO;
  252. [weakSelf refreshAndRequestData];
  253. } cancel:^{
  254. self.sortView.thirdArrowUp = NO;
  255. }];
  256. [picker showPicker];
  257. }
  258. else {
  259. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"无声部信息"];
  260. self.sortView.thirdArrowUp = NO;
  261. }
  262. }
  263. else {
  264. [self hiddenPopView];
  265. }
  266. }
  267. - (void)showPickerView {
  268. KSFullDatePicker *picker = [[KSFullDatePicker alloc] initWithTitle:@"" date:[NSDate date] pickMode:KSDATEPICKER_MODE_YEAR_MONTH sureButtonColor:CLIENT_THEMECOLOR selectDateBlock:^(NSString *date) {
  269. self.classDate = date;
  270. NSString *displayTime = [self getTimeDisplay:date];
  271. [self.sortView.firstLabel setText:displayTime];
  272. [self resetPickerStatus];
  273. // 请求数据
  274. [self refreshAndRequestData];
  275. } cancleBlock:^{
  276. [self resetPickerStatus];
  277. }];
  278. [picker show];
  279. }
  280. - (NSString *)getTimeDisplay:(NSString *)chooseMonth {
  281. [self.dateFormatter setDateFormat:@"yyyy-MM"];
  282. NSDate *chooseDate = [self.dateFormatter dateFromString:chooseMonth];
  283. [self.dateFormatter setDateFormat:@"yyyy年MM月"];
  284. NSString *displayTime = [self.dateFormatter stringFromDate:chooseDate];
  285. return displayTime;
  286. }
  287. - (void)resetPickerStatus {
  288. self.sortView.firstArrowUp = NO;
  289. }
  290. - (NewClassPopView *)popView {
  291. if (!_popView) {
  292. MJWeakSelf;
  293. _popView = [[NewClassPopView alloc] initWithFrame:CGRectMake(0, 55, kScreenWidth, kScreenHeight - 55 - kNaviBarHeight - iPhoneXSafeBottomMargin) chooseCallback:^(NSString * _Nonnull sortStr, NSInteger chooseIndex, NSInteger item) {
  294. if (chooseIndex != 0) {
  295. // 回调
  296. [weakSelf sortWithChooseIndex:chooseIndex item:item title:sortStr];
  297. }
  298. [weakSelf hiddenPopView];
  299. }];
  300. }
  301. return _popView;
  302. }
  303. - (void)sortWithChooseIndex:(NSInteger)chooseIndex item:(NSInteger)item title:(NSString *)title {
  304. if (item == 0) { //
  305. }
  306. else if (item == 1) { // 课程状态
  307. self.secondChooseIndex = chooseIndex;
  308. self.thirdChooseIndex = 0;
  309. [self.sortView.secondLabel setText:title];
  310. switch (chooseIndex) {
  311. case 1:
  312. {
  313. self.status = nil;
  314. [self.sortView.secondLabel setText:@"课程状态"];
  315. }
  316. break;
  317. case 2:
  318. {
  319. self.status = @"NOT_START";
  320. }
  321. break;
  322. case 3:
  323. {
  324. self.status = @"ING";
  325. }
  326. break;
  327. case 4:
  328. {
  329. self.status = @"COMPLETE";
  330. }
  331. break;
  332. default:
  333. break;
  334. }
  335. }
  336. else if (item == 2) { // 声部筛选
  337. self.thirdChooseIndex = chooseIndex;
  338. [self.sortView.thirdLabel setText:title];
  339. if (chooseIndex == 1) {
  340. self.subjectId = nil;
  341. [self.sortView.thirdLabel setText:@"全部声部"];
  342. }
  343. else {
  344. NSDictionary *parm = self.subjectMessageArray[chooseIndex-1];
  345. self.subjectId = [parm ks_stringValueForKey:@"subjectId"];
  346. }
  347. }
  348. [self resetParamenter];
  349. [self requestData];
  350. }
  351. - (void)hiddenPopView {
  352. self.sortView.firstArrowUp = NO;
  353. self.sortView.secondArrowUp = NO;
  354. self.sortView.thirdArrowUp = NO;
  355. [self.popView hiddenView];
  356. }
  357. #pragma mark - UITableViewDataSource
  358. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  359. return self.dataArray.count;
  360. }
  361. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  362. if (self.selectIndex == 0 || self.selectIndex == 3) {
  363. return 127.0f;
  364. }
  365. else {
  366. return 164.0f;
  367. }
  368. }
  369. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  370. if (self.selectIndex == 0) {
  371. AccompanyLessonModel *model = self.dataArray[indexPath.row];
  372. AccompanyCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyCourseCell"];
  373. MJWeakSelf;
  374. [cell configWithSource:model actionCallback:^(ACCOMPANY_TYPE type, AccompanyLessonModel * _Nonnull source) {
  375. [weakSelf courseOperation:type sourceModel:source];
  376. }];
  377. return cell;
  378. }
  379. else if (self.selectIndex == 1) {
  380. LiveLessonModel *model = self.dataArray[indexPath.row];
  381. MyLiveCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyLiveCourseCell"];
  382. MJWeakSelf;
  383. [cell configCellWithSource:model callback:^(NSString *targetId) {
  384. [weakSelf chatAction:targetId];
  385. }];
  386. return cell;
  387. }
  388. else {
  389. MusicRoomListModel *model = self.dataArray[indexPath.row];
  390. MusicRoomCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MusicRoomCourseCell"];
  391. MJWeakSelf;
  392. [cell configWithSource:model beforeTime:0 callback:^(NSString * _Nonnull targetId) {
  393. [weakSelf chatAction:targetId];
  394. }];
  395. return cell;
  396. }
  397. }
  398. - (void)courseOperation:(ACCOMPANY_TYPE)type sourceModel:(AccompanyLessonModel *)model {
  399. switch (type) {
  400. case ACCOMPANY_TYPE_CHAT: // 聊天
  401. {
  402. TUIChatConversationModel *conversation = [[TUIChatConversationModel alloc] init];
  403. conversation.userID = model.imUserId;
  404. KSChatConversationViewController *ctrl = [[KSChatConversationViewController alloc] init];
  405. ctrl.conversation = conversation;
  406. [self.naviController pushViewController:ctrl animated:YES];
  407. }
  408. break;
  409. case ACCOMPANY_DETAIL: // 趣纠课详情
  410. {
  411. [self showAccompanyDetail:model];
  412. }
  413. break;
  414. default:
  415. break;
  416. }
  417. }
  418. - (void)showAccompanyDetail:(AccompanyLessonModel *)model {
  419. AccompanyDetailViewController *detailVC = [[AccompanyDetailViewController alloc] init];
  420. detailVC.courseId = model.courseId;
  421. detailVC.courseGroupId = model.courseGoupId;
  422. // detailVC.teacherId = model.userId;
  423. [self.naviController pushViewController:detailVC animated:YES];
  424. }
  425. - (void)chatAction:(NSString *)targetId {
  426. if ([NSString isEmptyString:targetId]) {
  427. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"报名未结束,暂无群组"];
  428. return;
  429. }
  430. TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
  431. model.groupID = targetId;
  432. KSGroupConversationController *ctrl = [[KSGroupConversationController alloc] init];
  433. ctrl.conversation = model;
  434. [self.naviController pushViewController:ctrl animated:YES];
  435. }
  436. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  437. if (self.selectIndex == 0) { // 进入趣纠课详情
  438. AccompanyLessonModel *model = self.dataArray[indexPath.row];
  439. [self showAccompanyDetail:model];
  440. }
  441. else if (self.selectIndex == 1) { // 直播课程组详情
  442. LiveLessonModel *model = self.dataArray[indexPath.row];
  443. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  444. NSString *url = [NSString stringWithFormat:@"%@/#/liveDetail?joinRoom=1&groupId=%@&classId=%@", WEBHOST, model.courseGoupId,model.courseId];
  445. ctrl.url = url;
  446. [self.naviController pushViewController:ctrl animated:YES];
  447. }
  448. else {
  449. MusicRoomListModel *model = self.dataArray[indexPath.row];
  450. [self showMusicRoomDetail:model];
  451. }
  452. }
  453. - (void)showMusicRoomDetail:(MusicRoomListModel *)model {
  454. MusicRoomDetailViewController *detailVC = [[MusicRoomDetailViewController alloc] init];
  455. detailVC.courseId = model.courseId;
  456. detailVC.courseGroupId = model.courseGroupId;
  457. [self.naviController pushViewController:detailVC animated:YES];
  458. }
  459. /**
  460. 设置没有数据时的显示
  461. @param promptString 提示语
  462. @param imgName 图片名称
  463. @param view 显示在什么地方
  464. */
  465. - (void)setPromptString:(NSString *)promptString imageName:(NSString *)imgName inView:(UIView *)view {
  466. if (self.promptView != nil) {
  467. [self.promptView removeFromSuperview];
  468. }
  469. else {
  470. self.promptView = [[StateView alloc]init];
  471. self.promptView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight - 300);
  472. }
  473. _promptPlaceView = view;
  474. //当请求不到数据时 ,自定义提示view 将会出现;
  475. self.promptView.imageName = imgName;
  476. self.promptView.alpha = 0.0f;
  477. [self.promptView setText:promptString];
  478. [view addSubview:self.promptView];
  479. }
  480. // 结束刷新后调用方法
  481. - (void)changePromptLabelStateWithArray:(NSMutableArray *)array {
  482. NSInteger count;
  483. if (array.count) {
  484. count = array.count;
  485. } else {
  486. count = 0;
  487. }
  488. [UIView animateWithDuration:0.1 animations:^{
  489. [[self promptView] setAlpha:count ? 0.0f :1.0f ] ;
  490. }] ;
  491. }
  492. - (BOOL)networkAvaiable {
  493. return [self checkNetworkAvaiable];
  494. }
  495. - (BOOL)checkNetworkAvaiable {
  496. BOOL isExistenceNetwork = YES;
  497. Reachability *reach = [Reachability reachabilityWithHostName:@"www.apple.com"];
  498. switch ([reach currentReachabilityStatus]) {
  499. case NotReachable:
  500. isExistenceNetwork = NO;
  501. //NSLog(@"notReachable");
  502. break;
  503. case ReachableViaWiFi:
  504. isExistenceNetwork = YES;
  505. //NSLog(@"WIFI");
  506. break;
  507. case ReachableViaWWAN:
  508. isExistenceNetwork = YES;
  509. //NSLog(@"3G");
  510. break;
  511. }
  512. return isExistenceNetwork;
  513. }
  514. #pragma mark ----- lazying
  515. - (NSDateFormatter *)dateFormatter {
  516. if (!_dateFormatter) {
  517. _dateFormatter = [NSObject getDateformatter];
  518. }
  519. return _dateFormatter;
  520. }
  521. - (void)setSubjectList:(NSMutableArray *)subjectList {
  522. _subjectList = subjectList;
  523. self.thirdChooseIndex = 0;
  524. }
  525. /*
  526. // Only override drawRect: if you perform custom drawing.
  527. // An empty implementation adversely affects performance during animation.
  528. - (void)drawRect:(CGRect)rect {
  529. // Drawing code
  530. }
  531. */
  532. @end