commodityRecordsVC.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. //
  2. // commodityRecordsVC.m
  3. // YBVideo
  4. //
  5. // Created by IOS1 on 2019/7/5.
  6. // Copyright © 2019 cat. All rights reserved.
  7. //
  8. #import "commodityRecordsVC.h"
  9. #import "commodityRecordsCell.h"
  10. #import "YBGetVideoObj.h"
  11. #import "YBGoodsInfoVC.h"
  12. @interface commodityRecordsVC ()<UITableViewDelegate,UITableViewDataSource>{
  13. UITableView *listTable;
  14. NSMutableArray *listArray;
  15. int page;
  16. }
  17. @end
  18. @implementation commodityRecordsVC
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. self.view.backgroundColor = RGB_COLOR(@"#110D24", 1);
  22. self.titleL.text = YZMsg(@"商品记录");
  23. page = 1;
  24. listArray = [NSMutableArray array];
  25. [self creatUI];
  26. [self requestData];
  27. }
  28. - (void)creatUI{
  29. listTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-64-statusbarHeight) style:0];
  30. listTable.delegate = self;
  31. listTable.dataSource = self;
  32. listTable.backgroundColor = RGB_COLOR(@"#110D24", 1);
  33. listTable.separatorStyle = 0;
  34. [self.view addSubview:listTable];
  35. listTable.mj_header = [MJRefreshHeader headerWithRefreshingBlock:^{
  36. page = 1;
  37. [self requestData];
  38. }];
  39. listTable.mj_footer = [MJRefreshBackFooter footerWithRefreshingBlock:^{
  40. page ++;
  41. [self requestData];
  42. }];
  43. }
  44. - (void)requestData{
  45. NSString *url = [purl stringByAppendingFormat:@"?service=Shop.getGoodsList"];
  46. [YBNetworking postWithUrl:@"Shop.getGoodsList" Dic:@{@"uid":[Config getOwnID],@"token":[Config getOwnToken],@"p":@(page)} Suc:^(int code, id info, NSString *msg) {
  47. [listTable.mj_header endRefreshing];
  48. [listTable.mj_footer endRefreshing];
  49. if (code == 0 ) {
  50. NSArray *list = [NSArray arrayWithArray:info];
  51. if (page == 1) {
  52. [listArray removeAllObjects];
  53. }
  54. [listArray addObjectsFromArray:list];
  55. }
  56. if (listArray.count<=0) {
  57. [PublicView showTextNoData:listTable text1:@"" text2:YZMsg(@"暂无数据") centerY:0.8];
  58. }else{
  59. [PublicView hiddenTextNoData:listTable];
  60. }
  61. [listTable reloadData];
  62. } Fail:^(id fail) {
  63. [listTable.mj_header endRefreshing];
  64. [listTable.mj_footer endRefreshing];
  65. }];
  66. }
  67. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  68. return listArray.count;
  69. }
  70. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  71. commodityRecordsCell *cell = [tableView dequeueReusableCellWithIdentifier:@"commodityRecordsCELL"];
  72. if (!cell) {
  73. cell = [[[NSBundle mainBundle] loadNibNamed:@"commodityRecordsCell" owner:nil options:nil] lastObject];
  74. }
  75. NSDictionary *subDic = listArray[indexPath.row];
  76. [cell.thumbImgV sd_setImageWithURL:[NSURL URLWithString:minstr([subDic valueForKey:@"thumb"])]];
  77. cell.nameL.text = minstr([subDic valueForKey:@"name"]);
  78. cell.contentL.text = minstr([subDic valueForKey:@"des"]);
  79. cell.priceL.text = minstr([subDic valueForKey:@"price"]);
  80. cell.priceL2.text = minstr([subDic valueForKey:@"old_price"]);
  81. cell.numL.text = [NSString stringWithFormat:@"%@:%@%@",YZMsg(@"查看次数"),minstr([subDic valueForKey:@"hits"]),YZMsg(@"次")];
  82. return cell;
  83. }
  84. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  85. return 150;
  86. }
  87. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  88. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  89. NSDictionary *subDic = listArray[indexPath.row];
  90. //[self coverClickVideoid:minstr([subDic valueForKey:@"videoid"])];
  91. [self goGoodsInfo:minstr([subDic valueForKey:@"id"])];
  92. }
  93. -(void)goGoodsInfo:(NSString *)goodsid {
  94. YBGoodsInfoVC *infoVC = [[YBGoodsInfoVC alloc]init];
  95. infoVC.infoType = InfoEnterType_Record;
  96. infoVC.touserID = [Config getOwnID];
  97. infoVC.goodsID = goodsid;
  98. [[YBBaseAppDelegate sharedAppDelegate]pushViewController: infoVC animated:YES];
  99. }
  100. - (void)coverClickVideoid:(NSString *)videoid {
  101. NSLog(@"播放视频");
  102. [YBGetVideoObj lookManeger].fromWhere = @"commodityRecordsVC";
  103. [YBGetVideoObj lookManeger].videoID = videoid;
  104. [YBGetVideoObj lookManeger].playIndex = 0;
  105. [YBGetVideoObj lookManeger].videoList = @[].mutableCopy;
  106. [YBGetVideoObj lookManeger].paging = 1;
  107. [YBGetVideoObj lookManeger].baseUrl = @"";
  108. [[YBGetVideoObj lookManeger]goLookVC];
  109. }
  110. /*
  111. #pragma mark - Navigation
  112. // In a storyboard-based application, you will often want to do a little preparation before navigation
  113. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  114. // Get the new view controller using [segue destinationViewController].
  115. // Pass the selected object to the new view controller.
  116. }
  117. */
  118. @end