Commit 6b482276 authored by Sandy's avatar Sandy

商品管理一级界面网络请求数据

parent f69d1d50
......@@ -21,7 +21,7 @@
@implementation AddCommodityCollectionViewCell
- (void)cellWithModel:(CatgoryModel *)model indexPath:(NSIndexPath *)indexPath {
[self.imgView sd_setImageWithURL:[NSURL URLWithString:model.pictures] placeholderImage:nil];
[self.imgView sd_setImageWithURL:[NSURL URLWithString:model.pictures] placeholderImage:kPlaceHolderImage];
self.labelDsc.text = model.adescription;
self.labelTItle.text = model.name;
......
......@@ -24,7 +24,7 @@
- (void)cellWithModel:(CommotityListModel *)model {
self.labelPrice.text = [NSString stringWithFormat:@"%.0f",model.price];
[self.imageViewTop sd_setImageWithURL:[NSURL URLWithString:model.pictures] placeholderImage:nil];
[self.imageViewTop sd_setImageWithURL:[NSURL URLWithString:model.pictures] placeholderImage:kPlaceHolderImage];
self.labelOriginalPrice.text = [NSString stringWithFormat:@"%.0f", model.originalPrice];
self.labelBrokerageRate.text = [NSString stringWithFormat:@"%.2f", model.brokerageRate];
self.labelTitle.text = model.name;
......
......@@ -7,7 +7,8 @@
//
#import <UIKit/UIKit.h>
#import "CommotityListModel.h"
@interface CommodityTableViewCell : UITableViewCell
- (void)cellWithModel:(CommotityListModel *)model;
@end
......@@ -8,12 +8,30 @@
#import "CommodityTableViewCell.h"
@interface CommodityTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *imgViewCommodity;
@property (weak, nonatomic) IBOutlet UILabel *labelTitle;
@property (weak, nonatomic) IBOutlet UILabel *labelPrice;
@property (weak, nonatomic) IBOutlet UILabel *labelBrokerageRate;
@property (weak, nonatomic) IBOutlet UILabel *labelSaleNumber;
@end
@implementation CommodityTableViewCell
- (void)awakeFromNib {
// Initialization code
}
- (void)cellWithModel:(CommotityListModel *)model
{
[self.imgViewCommodity sd_setImageWithURL:[NSURL URLWithString:model.pictures] placeholderImage:kPlaceHolderImage];
self.labelTitle.text = model.name;
self.labelPrice.text = [NSString stringWithFormat:@"¥%.0f",model.price];
self.labelBrokerageRate.text = [NSString stringWithFormat:@"%.2f",model.brokerageRate];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
......
......@@ -15,7 +15,7 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="129"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="commodityManagementImage" translatesAutoresizingMaskIntoConstraints="NO" id="f2b-xv-2mY">
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="commodityManagementImage" translatesAutoresizingMaskIntoConstraints="NO" id="f2b-xv-2mY">
<rect key="frame" x="16" y="13" width="90" height="103"/>
<constraints>
<constraint firstAttribute="width" constant="90" id="1q5-Yj-TUg"/>
......@@ -85,6 +85,13 @@
</tableViewCellContentView>
<color key="tintColor" red="0.48627450980392156" green="0.76470588235294112" blue="0.14509803921568626" alpha="1" colorSpace="calibratedRGB"/>
<inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
<connections>
<outlet property="imgViewCommodity" destination="f2b-xv-2mY" id="FGQ-WA-scQ"/>
<outlet property="labelBrokerageRate" destination="eSJ-Pe-NgQ" id="pic-rX-Z9U"/>
<outlet property="labelPrice" destination="exC-Ji-hHu" id="KTN-qN-5Vb"/>
<outlet property="labelSaleNumber" destination="WH8-2u-i8A" id="HMf-bf-D0R"/>
<outlet property="labelTitle" destination="sKb-Ty-VZw" id="vHT-NS-l8S"/>
</connections>
<point key="canvasLocation" x="274" y="244"/>
</tableViewCell>
</objects>
......
......@@ -10,11 +10,19 @@
#import "CommodityManagementTopView.h"
#import "UITableView+Category.h"
#import "CommodityTableViewCell.h"
#import "CommotityRequestModel.h"
#import "CommodityListModel/CommotityListModel.h"
#define kCellID @"commodityCell"
#define kPageSize @10
#define kCellId @"CommodityTableViewCell.h"
@interface CommodityManagementViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) CommodityManagementTopView *topView;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *arrItemDatas;
@property (nonatomic, assign) NSInteger page;
@property (nonatomic, copy) NSString *field; //排序的字段
@property (nonatomic, copy) NSString *direction; //排序的顺序 升序或降序
@property (nonatomic, copy) NSString *searchText; //正在搜索的字段
@end
@implementation CommodityManagementViewController
......@@ -27,7 +35,6 @@
rightBtn.tintColor = kTextColorDarkGray;
self.navigationItem.rightBarButtonItem = rightBtn;
[self.view addSubview:self.topView];
[self.view addSubview:self.sorView];
self.sorView.leftTableSelect = ^(NSInteger row){
......@@ -42,10 +49,48 @@
_tableView = [UITableView plainTableViewWithTarget:self cellNibName:@"CommodityTableViewCell" cellId:kCellId];
[self.view addSubview:_tableView];
_tableView.sd_layout.topSpaceToView(self.sorView,0).leftEqualToView(self.view).rightEqualToView(self.view).bottomEqualToView(self.view);
// Do any additional setup after loading the view.
[self setUpData];
}
- (NSMutableArray *)arrItemDatas {
if (!_arrItemDatas) {
_arrItemDatas = [NSMutableArray array];
}
return _arrItemDatas;
}
- (void)setUpData {
//前期发送请求生成参数的方式,后来不这么做了
NSString *jsonString = @"{\"defintion\":{\"conditions\":[{\"operation\":\"string\",\"parameter\":{},\"parameters\":[{}]}],\"orders\":[{\"field\":\"string\",\"direction\":\"asc\"}],\"pageSize\":0,\"page\":0,\"probePages\":0},\"fetchParts\":[\"string\"]}";
NSDictionary *dic = [jsonString mj_JSONObject];
CommotityRequestModel *requstBody = [CommotityRequestModel modelObjectWithDictionary:dic];
requstBody.defintion.conditions[0].operation = @"shop uuid equals";
requstBody.defintion.conditions[0].parameters = @[[UserInfo shareInstance].shop.uuid];
requstBody.defintion.pageSize = kPageSize;
requstBody.defintion.page = @0;
requstBody.defintion.probePages = @0;
requstBody.defintion.orders[0].field = self.field;
requstBody.defintion.orders[0].direction = self.direction;
//请求模型转化为字典
NSDictionary *params = requstBody.mj_keyValues;
WS(weakSelf)
[[HTTPCilent shareCilent] POST:@"goods/query2" parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
for (NSDictionary *dic in responseObject[@"queryResult"]) {
CommotityListModel *model = [CommotityListModel modelObjectWithDictionary:dic];
[weakSelf.arrItemDatas addObject:model];
}
[weakSelf.tableView reloadData];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
}];
}
#pragma mark =========== action ===========
......@@ -63,12 +108,13 @@
#pragma mark =========== tableview delegate ===========
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
return self.arrItemDatas.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CommodityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId forIndexPath:indexPath];
[cell cellWithModel:self.arrItemDatas[indexPath.row]];
return cell;
}
......
......@@ -9,6 +9,7 @@
#import "LoginViewController.h"
#import "ToLoginViewController.h"
#import "RigistViewController.h"
#import "BaseViewController.h"
@interface LoginViewController ()
@property (weak, nonatomic) IBOutlet UIButton *buttonQQ;
@property (weak, nonatomic) IBOutlet UIButton *buttonWX;
......@@ -34,8 +35,40 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES];
[self defaultLoginAction];
}
//本地已有密码时登录
- (void)defaultLoginAction {
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"userName"]) {
NSDictionary *paramers = @{@"domain":kDomain,
@"loginName":[[NSUserDefaults standardUserDefaults] objectForKey:@"userName"] ,
@"password":[[NSUserDefaults standardUserDefaults] objectForKey:@"passWord"],
@"rememberMe":@"true"};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
WS(weakSelf)
[[HTTPCilent shareCilent] POST:@"app/resellerLogin" parameters:paramers success:^(NSURLSessionDataTask *task, id responseObject) {
UserInfo *info = [UserInfo shareInstance];
[info UserInfoWithDictionary:responseObject[@"reseller"]];
[MBProgressHUD hideHUDForView:self.view animated:YES];
BaseViewController *baseVC = [[BaseViewController alloc] init];
baseVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[weakSelf presentViewController:baseVC animated:YES completion:nil];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
}];
}
}
- (IBAction)rigistAction:(UIButton *)sender {
RigistViewController *rigistVC = [[RigistViewController alloc] initWithNibName:@"RigistViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:rigistVC animated:YES];
......
......@@ -9,7 +9,6 @@
#import "ToLoginViewController.h"
#import "ResetPasswordViewController.h"
#import "BaseViewController.h"
#import "UserInfoBaseClass.h"
@interface ToLoginViewController ()
@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextFiled;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextFiled;
......@@ -32,23 +31,25 @@
@"password":[self.passwordTextFiled.text MD5String],
@"rememberMe":@"true"};
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
WS(weakSelf)
[[HTTPCilent shareCilent] POST:@"app/resellerLogin" parameters:paramers success:^(NSURLSessionDataTask *task, id responseObject) {
UserInfo *info = [UserInfo shareInstance];
// [UserInfo mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
// return @{@"description":@"adescription"};
// }];
// info = [UserInfo mj_objectWithKeyValues:responseObject[@"reseller"]];
[info UserInfoWithDictionary:responseObject[@"reseller"]];
[[NSUserDefaults standardUserDefaults] setObject:weakSelf.phoneNumberTextFiled.text forKey:@"userName"];
[[NSUserDefaults standardUserDefaults] setObject:[weakSelf.passwordTextFiled.text MD5String] forKey:@"passWord"];
[MBProgressHUD hideHUDForView:self.view animated:YES];
BaseViewController *baseVC = [[BaseViewController alloc] init];
baseVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[weakSelf presentViewController:baseVC animated:YES completion:nil];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
}];
BaseViewController *baseVC = [[BaseViewController alloc] init];
baseVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:baseVC animated:YES completion:nil];
}
......
......@@ -24,6 +24,8 @@
#define kCutLineColorGray [UIColor colorWithWhite:0.820 alpha:1.000]
#define kCutLineColorDarkGray [UIColor colorWithWhite:0.757 alpha:1.000]
#define kPriceColor [UIColor colorWithRed:1.000 green:0.392 blue:0.392 alpha:1.000];
#define kPlaceHolderImage [UIImage imageNamed:@""]
#pragma mark =========== 通用宏定义 start ===========
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment