Commit 6b482276 authored by Sandy's avatar Sandy

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

parent f69d1d50
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
@implementation AddCommodityCollectionViewCell @implementation AddCommodityCollectionViewCell
- (void)cellWithModel:(CatgoryModel *)model indexPath:(NSIndexPath *)indexPath { - (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.labelDsc.text = model.adescription;
self.labelTItle.text = model.name; self.labelTItle.text = model.name;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
- (void)cellWithModel:(CommotityListModel *)model { - (void)cellWithModel:(CommotityListModel *)model {
self.labelPrice.text = [NSString stringWithFormat:@"%.0f",model.price]; 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.labelOriginalPrice.text = [NSString stringWithFormat:@"%.0f", model.originalPrice];
self.labelBrokerageRate.text = [NSString stringWithFormat:@"%.2f", model.brokerageRate]; self.labelBrokerageRate.text = [NSString stringWithFormat:@"%.2f", model.brokerageRate];
self.labelTitle.text = model.name; self.labelTitle.text = model.name;
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "CommotityListModel.h"
@interface CommodityTableViewCell : UITableViewCell @interface CommodityTableViewCell : UITableViewCell
- (void)cellWithModel:(CommotityListModel *)model;
@end @end
...@@ -8,12 +8,30 @@ ...@@ -8,12 +8,30 @@
#import "CommodityTableViewCell.h" #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 @implementation CommodityTableViewCell
- (void)awakeFromNib { - (void)awakeFromNib {
// Initialization code // 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 { - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated]; [super setSelected:selected animated:animated];
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="129"/> <rect key="frame" x="0.0" y="0.0" width="320" height="129"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask"/>
<subviews> <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"/> <rect key="frame" x="16" y="13" width="90" height="103"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="90" id="1q5-Yj-TUg"/> <constraint firstAttribute="width" constant="90" id="1q5-Yj-TUg"/>
...@@ -85,6 +85,13 @@ ...@@ -85,6 +85,13 @@
</tableViewCellContentView> </tableViewCellContentView>
<color key="tintColor" red="0.48627450980392156" green="0.76470588235294112" blue="0.14509803921568626" alpha="1" colorSpace="calibratedRGB"/> <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"/> <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"/> <point key="canvasLocation" x="274" y="244"/>
</tableViewCell> </tableViewCell>
</objects> </objects>
......
...@@ -10,11 +10,19 @@ ...@@ -10,11 +10,19 @@
#import "CommodityManagementTopView.h" #import "CommodityManagementTopView.h"
#import "UITableView+Category.h" #import "UITableView+Category.h"
#import "CommodityTableViewCell.h" #import "CommodityTableViewCell.h"
#import "CommotityRequestModel.h"
#import "CommodityListModel/CommotityListModel.h"
#define kCellID @"commodityCell"
#define kPageSize @10
#define kCellId @"CommodityTableViewCell.h" #define kCellId @"CommodityTableViewCell.h"
@interface CommodityManagementViewController ()<UITableViewDelegate, UITableViewDataSource> @interface CommodityManagementViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) CommodityManagementTopView *topView; @property (nonatomic, strong) CommodityManagementTopView *topView;
@property (nonatomic, strong) UITableView *tableView; @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 @end
@implementation CommodityManagementViewController @implementation CommodityManagementViewController
...@@ -27,7 +35,6 @@ ...@@ -27,7 +35,6 @@
rightBtn.tintColor = kTextColorDarkGray; rightBtn.tintColor = kTextColorDarkGray;
self.navigationItem.rightBarButtonItem = rightBtn; self.navigationItem.rightBarButtonItem = rightBtn;
[self.view addSubview:self.topView]; [self.view addSubview:self.topView];
[self.view addSubview:self.sorView]; [self.view addSubview:self.sorView];
self.sorView.leftTableSelect = ^(NSInteger row){ self.sorView.leftTableSelect = ^(NSInteger row){
...@@ -42,10 +49,48 @@ ...@@ -42,10 +49,48 @@
_tableView = [UITableView plainTableViewWithTarget:self cellNibName:@"CommodityTableViewCell" cellId:kCellId]; _tableView = [UITableView plainTableViewWithTarget:self cellNibName:@"CommodityTableViewCell" cellId:kCellId];
[self.view addSubview:_tableView]; [self.view addSubview:_tableView];
_tableView.sd_layout.topSpaceToView(self.sorView,0).leftEqualToView(self.view).rightEqualToView(self.view).bottomEqualToView(self.view); _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 =========== #pragma mark =========== action ===========
...@@ -63,12 +108,13 @@ ...@@ -63,12 +108,13 @@
#pragma mark =========== tableview delegate =========== #pragma mark =========== tableview delegate ===========
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10; return self.arrItemDatas.count;
} }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CommodityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId forIndexPath:indexPath]; CommodityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellId forIndexPath:indexPath];
[cell cellWithModel:self.arrItemDatas[indexPath.row]];
return cell; return cell;
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#import "LoginViewController.h" #import "LoginViewController.h"
#import "ToLoginViewController.h" #import "ToLoginViewController.h"
#import "RigistViewController.h" #import "RigistViewController.h"
#import "BaseViewController.h"
@interface LoginViewController () @interface LoginViewController ()
@property (weak, nonatomic) IBOutlet UIButton *buttonQQ; @property (weak, nonatomic) IBOutlet UIButton *buttonQQ;
@property (weak, nonatomic) IBOutlet UIButton *buttonWX; @property (weak, nonatomic) IBOutlet UIButton *buttonWX;
...@@ -34,8 +35,40 @@ ...@@ -34,8 +35,40 @@
- (void)viewWillAppear:(BOOL)animated { - (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES]; [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 { - (IBAction)rigistAction:(UIButton *)sender {
RigistViewController *rigistVC = [[RigistViewController alloc] initWithNibName:@"RigistViewController" bundle:[NSBundle mainBundle]]; RigistViewController *rigistVC = [[RigistViewController alloc] initWithNibName:@"RigistViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:rigistVC animated:YES]; [self.navigationController pushViewController:rigistVC animated:YES];
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#import "ToLoginViewController.h" #import "ToLoginViewController.h"
#import "ResetPasswordViewController.h" #import "ResetPasswordViewController.h"
#import "BaseViewController.h" #import "BaseViewController.h"
#import "UserInfoBaseClass.h"
@interface ToLoginViewController () @interface ToLoginViewController ()
@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextFiled; @property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextFiled;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextFiled; @property (weak, nonatomic) IBOutlet UITextField *passwordTextFiled;
...@@ -32,23 +31,25 @@ ...@@ -32,23 +31,25 @@
@"password":[self.passwordTextFiled.text MD5String], @"password":[self.passwordTextFiled.text MD5String],
@"rememberMe":@"true"}; @"rememberMe":@"true"};
[MBProgressHUD showHUDAddedTo:self.view animated:YES]; [MBProgressHUD showHUDAddedTo:self.view animated:YES];
WS(weakSelf)
[[HTTPCilent shareCilent] POST:@"app/resellerLogin" parameters:paramers success:^(NSURLSessionDataTask *task, id responseObject) { [[HTTPCilent shareCilent] POST:@"app/resellerLogin" parameters:paramers success:^(NSURLSessionDataTask *task, id responseObject) {
UserInfo *info = [UserInfo shareInstance]; UserInfo *info = [UserInfo shareInstance];
// [UserInfo mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
// return @{@"description":@"adescription"};
// }];
// info = [UserInfo mj_objectWithKeyValues:responseObject[@"reseller"]];
[info UserInfoWithDictionary: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]; [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) { } failure:^(NSURLSessionDataTask *task, NSError *error) {
}]; }];
BaseViewController *baseVC = [[BaseViewController alloc] init];
baseVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:baseVC animated:YES completion:nil];
} }
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#define kCutLineColorGray [UIColor colorWithWhite:0.820 alpha:1.000] #define kCutLineColorGray [UIColor colorWithWhite:0.820 alpha:1.000]
#define kCutLineColorDarkGray [UIColor colorWithWhite:0.757 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 kPriceColor [UIColor colorWithRed:1.000 green:0.392 blue:0.392 alpha:1.000];
#define kPlaceHolderImage [UIImage imageNamed:@""]
#pragma mark =========== 通用宏定义 start =========== #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