MyLessonBodyView.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  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. [KSNetworkingManager queryMyLiveCourse:KS_POST classDate:self.classDate status:self.status subjectId:self.subjectId page:self.pages rows:self.rows success:^(NSDictionary * _Nonnull dic) {
  132. [self endRefresh];
  133. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  134. NSArray *sourceArray = [[dic ks_dictionaryValueForKey:@"data"] ks_arrayValueForKey:@"rows"];
  135. for (NSDictionary *parm in sourceArray) {
  136. LiveLessonModel *model = [[LiveLessonModel alloc] initWithDictionary:parm];
  137. [self.dataArray addObject:model];
  138. }
  139. if (sourceArray.count < self.rows) {
  140. self.isLoadMore = NO;
  141. }
  142. }
  143. else {
  144. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  145. }
  146. [self.tableView reloadData];
  147. [self changePromptLabelStateWithArray:self.dataArray];
  148. } faliure:^(NSError * _Nonnull error) {
  149. [self endRefresh];
  150. if (self.networkAvaiable == NO) {
  151. [self setPromptString:@"暂无网络" imageName:@"no_networking" inView:self.tableView];
  152. }
  153. [self.dataArray removeAllObjects];
  154. [self.tableView reloadData];
  155. [self changePromptLabelStateWithArray:self.dataArray];
  156. }];
  157. }
  158. else { // 琴房课
  159. [KSNetworkingManager queryPianoClassRequest:KS_POST classMonth:self.classDate status:self.status subjectId:self.subjectId page:self.pages rows:self.rows success:^(NSDictionary * _Nonnull dic) {
  160. [self endRefresh];
  161. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  162. NSArray *sourceArray = [[dic ks_dictionaryValueForKey:@"data"] ks_arrayValueForKey:@"rows"];
  163. for (NSDictionary *parm in sourceArray) {
  164. MusicRoomListModel *model = [[MusicRoomListModel alloc] initWithDictionary:parm];
  165. [self.dataArray addObject:model];
  166. }
  167. if (sourceArray.count < self.rows) {
  168. self.isLoadMore = NO;
  169. }
  170. }
  171. else {
  172. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  173. }
  174. [self.tableView reloadData];
  175. [self changePromptLabelStateWithArray:self.dataArray];
  176. } faliure:^(NSError * _Nonnull error) {
  177. [self endRefresh];
  178. if (self.networkAvaiable == NO) {
  179. [self setPromptString:@"暂无网络" imageName:@"no_networking" inView:self.tableView];
  180. }
  181. [self.dataArray removeAllObjects];
  182. [self.tableView reloadData];
  183. [self changePromptLabelStateWithArray:self.dataArray];
  184. }];
  185. }
  186. }
  187. - (void)beginRefreshImmediately {
  188. [self.tableView.mj_header beginRefreshing];
  189. }
  190. - (void)beginFirstRefresh {
  191. if (!self.isHeaderRefreshed) {
  192. [self beginRefreshImmediately];
  193. }
  194. }
  195. - (void)selectCellAtIndexPath:(NSIndexPath *)indexPath {
  196. if (self.lastSelectedIndexPath == indexPath) {
  197. return;
  198. }
  199. if (self.lastSelectedIndexPath != nil) {
  200. UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:self.lastSelectedIndexPath];
  201. [cell setSelected:NO animated:NO];
  202. }
  203. UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
  204. [cell setSelected:YES animated:NO];
  205. self.lastSelectedIndexPath = indexPath;
  206. }
  207. - (void)layoutSubviews {
  208. [super layoutSubviews];
  209. self.tableView.frame = self.bounds;
  210. CGFloat topHeight = 55.0f;
  211. self.tableView.frame = CGRectMake(0, topHeight, self.bounds.size.width, self.bounds.size.height - topHeight);
  212. if (!_sortView) {
  213. _sortView = [MyLessonSearchView shareInstance];
  214. _sortView.frame = CGRectMake(0, 0, kScreenWidth, 55);
  215. MJWeakSelf;
  216. [_sortView sortAction:^(SORT_TYPE type) {
  217. [weakSelf sortWithType:type];
  218. }];
  219. [self.dateFormatter setDateFormat:@"yyyy年MM月"];
  220. NSDate *currentDate = [NSDate date];
  221. [self.sortView.firstLabel setText:[self.dateFormatter stringFromDate:currentDate]];
  222. [self addSubview:self.sortView];
  223. }
  224. }
  225. - (void)sortWithType:(SORT_TYPE)type {
  226. if (type == SORT_TYPE_TIME) { // time
  227. [self showPickerView];
  228. }
  229. else if (type == SORT_TYPE_STATUS) { // 状态
  230. [self.popView refreshWithSourceArray:@[@"全部",@"未开始",@"进行中",@"已结束"] preChooseIndex:_secondChooseIndex inView:self actionItem:1];
  231. }
  232. else if (type == SORT_TYPE_SUBJECT) {
  233. if (self.subjectList.count) {
  234. NSMutableArray *nameArray = [NSMutableArray array];
  235. [nameArray addObject:@"全部"];
  236. for (NSDictionary *parm in self.subjectList) {
  237. [nameArray addObject:[parm ks_stringValueForKey:@"subjectName"]];
  238. }
  239. MJWeakSelf;
  240. KSChoosePicker *picker = [[KSChoosePicker alloc] initWithTitle:@"声部筛选" sourceData:nameArray lastChooseIndex:0 sureButtonColor:CLIENT_THEMECOLOR chooseReturnWithBlock:^(NSString * _Nonnull returnValue, NSInteger chooseIndex) {
  241. if (chooseIndex == 0) {
  242. [weakSelf.sortView.thirdLabel setText:@"全部声部"];
  243. weakSelf.subjectId = nil;
  244. }
  245. else {
  246. [weakSelf.sortView.thirdLabel setText:returnValue];
  247. NSDictionary *parm = self.subjectList[chooseIndex-1];
  248. weakSelf.subjectId = [parm ks_stringValueForKey:@"subjectId"];
  249. }
  250. self.sortView.thirdArrowUp = NO;
  251. [weakSelf refreshAndRequestData];
  252. } cancel:^{
  253. self.sortView.thirdArrowUp = NO;
  254. }];
  255. [picker showPicker];
  256. }
  257. else {
  258. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"无声部信息"];
  259. self.sortView.thirdArrowUp = NO;
  260. }
  261. }
  262. else {
  263. [self hiddenPopView];
  264. }
  265. }
  266. - (void)showPickerView {
  267. KSFullDatePicker *picker = [[KSFullDatePicker alloc] initWithTitle:@"" date:[NSDate date] pickMode:KSDATEPICKER_MODE_YEAR_MONTH sureButtonColor:CLIENT_THEMECOLOR selectDateBlock:^(NSString *date) {
  268. self.classDate = date;
  269. NSString *displayTime = [self getTimeDisplay:date];
  270. [self.sortView.firstLabel setText:displayTime];
  271. [self resetPickerStatus];
  272. // 请求数据
  273. [self refreshAndRequestData];
  274. } cancleBlock:^{
  275. [self resetPickerStatus];
  276. }];
  277. [picker show];
  278. }
  279. - (NSString *)getTimeDisplay:(NSString *)chooseMonth {
  280. [self.dateFormatter setDateFormat:@"yyyy-MM"];
  281. NSDate *chooseDate = [self.dateFormatter dateFromString:chooseMonth];
  282. [self.dateFormatter setDateFormat:@"yyyy年MM月"];
  283. NSString *displayTime = [self.dateFormatter stringFromDate:chooseDate];
  284. return displayTime;
  285. }
  286. - (void)resetPickerStatus {
  287. self.sortView.firstArrowUp = NO;
  288. }
  289. - (NewClassPopView *)popView {
  290. if (!_popView) {
  291. MJWeakSelf;
  292. _popView = [[NewClassPopView alloc] initWithFrame:CGRectMake(0, 55, kScreenWidth, kScreenHeight - 55 - kNaviBarHeight - iPhoneXSafeBottomMargin) chooseCallback:^(NSString * _Nonnull sortStr, NSInteger chooseIndex, NSInteger item) {
  293. if (chooseIndex != 0) {
  294. // 回调
  295. [weakSelf sortWithChooseIndex:chooseIndex item:item title:sortStr];
  296. }
  297. [weakSelf hiddenPopView];
  298. }];
  299. }
  300. return _popView;
  301. }
  302. - (void)sortWithChooseIndex:(NSInteger)chooseIndex item:(NSInteger)item title:(NSString *)title {
  303. if (item == 0) { //
  304. }
  305. else if (item == 1) { // 课程状态
  306. self.secondChooseIndex = chooseIndex;
  307. self.thirdChooseIndex = 0;
  308. [self.sortView.secondLabel setText:title];
  309. switch (chooseIndex) {
  310. case 1:
  311. {
  312. self.status = nil;
  313. [self.sortView.secondLabel setText:@"课程状态"];
  314. }
  315. break;
  316. case 2:
  317. {
  318. self.status = @"NOT_START";
  319. }
  320. break;
  321. case 3:
  322. {
  323. self.status = @"ING";
  324. }
  325. break;
  326. case 4:
  327. {
  328. self.status = @"COMPLETE";
  329. }
  330. break;
  331. default:
  332. break;
  333. }
  334. }
  335. else if (item == 2) { // 声部筛选
  336. self.thirdChooseIndex = chooseIndex;
  337. [self.sortView.thirdLabel setText:title];
  338. if (chooseIndex == 1) {
  339. self.subjectId = nil;
  340. [self.sortView.thirdLabel setText:@"全部声部"];
  341. }
  342. else {
  343. NSDictionary *parm = self.subjectMessageArray[chooseIndex-1];
  344. self.subjectId = [parm ks_stringValueForKey:@"subjectId"];
  345. }
  346. }
  347. [self resetParamenter];
  348. [self requestData];
  349. }
  350. - (void)hiddenPopView {
  351. self.sortView.firstArrowUp = NO;
  352. self.sortView.secondArrowUp = NO;
  353. self.sortView.thirdArrowUp = NO;
  354. [self.popView hiddenView];
  355. }
  356. #pragma mark - UITableViewDataSource
  357. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  358. return self.dataArray.count;
  359. }
  360. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  361. if (self.selectIndex == 0 || self.selectIndex == 3) {
  362. return 127.0f;
  363. }
  364. else {
  365. return 164.0f;
  366. }
  367. }
  368. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  369. if (self.selectIndex == 0) {
  370. AccompanyLessonModel *model = self.dataArray[indexPath.row];
  371. AccompanyCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AccompanyCourseCell"];
  372. MJWeakSelf;
  373. [cell configWithSource:model actionCallback:^(ACCOMPANY_TYPE type, AccompanyLessonModel * _Nonnull source) {
  374. [weakSelf courseOperation:type sourceModel:source];
  375. }];
  376. return cell;
  377. }
  378. else if (self.selectIndex == 1) {
  379. LiveLessonModel *model = self.dataArray[indexPath.row];
  380. MyLiveCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyLiveCourseCell"];
  381. MJWeakSelf;
  382. [cell configCellWithSource:model callback:^(NSString *targetId) {
  383. [weakSelf chatAction:targetId];
  384. }];
  385. return cell;
  386. }
  387. else {
  388. MusicRoomListModel *model = self.dataArray[indexPath.row];
  389. MusicRoomCourseCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MusicRoomCourseCell"];
  390. MJWeakSelf;
  391. [cell configWithSource:model beforeTime:0 callback:^(NSString * _Nonnull targetId) {
  392. [weakSelf chatAction:targetId];
  393. }];
  394. return cell;
  395. }
  396. }
  397. - (void)courseOperation:(ACCOMPANY_TYPE)type sourceModel:(AccompanyLessonModel *)model {
  398. switch (type) {
  399. case ACCOMPANY_TYPE_CHAT: // 聊天
  400. {
  401. TUIChatConversationModel *conversation = [[TUIChatConversationModel alloc] init];
  402. conversation.userID = model.imUserId;
  403. KSChatConversationViewController *ctrl = [[KSChatConversationViewController alloc] init];
  404. ctrl.conversation = conversation;
  405. [self.naviController pushViewController:ctrl animated:YES];
  406. }
  407. break;
  408. case ACCOMPANY_DETAIL: // 陪练课详情
  409. {
  410. [self showAccompanyDetail:model];
  411. }
  412. break;
  413. default:
  414. break;
  415. }
  416. }
  417. - (void)showAccompanyDetail:(AccompanyLessonModel *)model {
  418. AccompanyDetailViewController *detailVC = [[AccompanyDetailViewController alloc] init];
  419. detailVC.courseId = model.courseId;
  420. detailVC.courseGroupId = model.courseGoupId;
  421. detailVC.teacherId = model.userId;
  422. [self.naviController pushViewController:detailVC animated:YES];
  423. }
  424. - (void)chatAction:(NSString *)targetId {
  425. if ([NSString isEmptyString:targetId]) {
  426. [LOADING_MANAGER MBShowAUTOHidingInWindow:@"报名未结束,暂无群组"];
  427. return;
  428. }
  429. TUIChatConversationModel *model = [[TUIChatConversationModel alloc] init];
  430. model.groupID = targetId;
  431. KSGroupConversationController *ctrl = [[KSGroupConversationController alloc] init];
  432. ctrl.conversation = model;
  433. [self.naviController pushViewController:ctrl animated:YES];
  434. }
  435. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  436. if (self.selectIndex == 0) { // 进入陪练课详情
  437. AccompanyLessonModel *model = self.dataArray[indexPath.row];
  438. [self showAccompanyDetail:model];
  439. }
  440. else if (self.selectIndex == 1) { // 直播课程组详情
  441. LiveLessonModel *model = self.dataArray[indexPath.row];
  442. KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
  443. NSString *url = [NSString stringWithFormat:@"%@/#/liveDetail?joinRoom=1&groupId=%@&classId=%@", WEBHOST, model.courseGoupId,model.courseId];
  444. ctrl.url = url;
  445. [self.naviController pushViewController:ctrl animated:YES];
  446. }
  447. else {
  448. MusicRoomListModel *model = self.dataArray[indexPath.row];
  449. [self showMusicRoomDetail:model];
  450. }
  451. }
  452. - (void)showMusicRoomDetail:(MusicRoomListModel *)model {
  453. MusicRoomDetailViewController *detailVC = [[MusicRoomDetailViewController alloc] init];
  454. detailVC.courseId = model.courseId;
  455. detailVC.courseGroupId = model.courseGroupId;
  456. detailVC.teacherId = model.teacherId;
  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