Commit 4141588f by lee

u filter small pic

parent 373bf31a
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#import "KWMOrderPaid.h" #import "KWMOrderPaid.h"
#import "KWMWish.h" #import "KWMWish.h"
#import "KWMHomeDataResult.h" #import "KWMHomeDataResult.h"
#import "KWMDictionaryResult.h"
...@@ -59,6 +60,9 @@ ...@@ -59,6 +60,9 @@
+ (KWMAPIManager *)sharedManager; + (KWMAPIManager *)sharedManager;
- (NSString *)toAbsoluteUrl:(NSString *)relativeUrl; - (NSString *)toAbsoluteUrl:(NSString *)relativeUrl;
- (NSURLSessionDataTask *) adminUserSuccess:(void(^)(NSURLSessionDataTask *task,KWMDictionaryResult *result))success failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure;
/** /**
* 手机登录-获取短信API * 手机登录-获取短信API
* @param parameters {mobile=?手机号} * @param parameters {mobile=?手机号}
......
...@@ -387,6 +387,21 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651"; ...@@ -387,6 +387,21 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
} }
} }
- (NSURLSessionDataTask *)adminUserSuccess:(void (^)(NSURLSessionDataTask *, KWMDictionaryResult *))success failure:(void (^)(NSURLSessionDataTask *, NSError *))failure {
NSNumber *customerId = [[[KWMUserDao shareDao] customer] identifier];
if (!customerId) {
return nil;
}
NSString *apiPath = [[NSString alloc] initWithFormat:@"https://%@/admin/customers/%@.json",Shopify_SHOP_DOMAIN,customerId];
return [self startSessionTask:KWMHTTPMethodGET
apiPath:apiPath
parameters:nil
result:[KWMDictionaryResult class]
model:nil
success:success
failure:failure];
}
- (void)loginWebSuccess:(void (^)())success failure:(void (^)(NSError *))failure { - (void)loginWebSuccess:(void (^)())success failure:(void (^)(NSError *))failure {
KWMUserModel *user= [KWMUserModel shareUser]; KWMUserModel *user= [KWMUserModel shareUser];
NSString *account = user.email; NSString *account = user.email;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import <Aspects/Aspects.h> #import <Aspects/Aspects.h>
#import <RXCollections/RXCollection.h> #import <RXCollections/RXCollection.h>
#import <Mobile-Buy-SDK/Buy/BUYProduct.h> #import <Mobile-Buy-SDK/Buy/BUYProduct.h>
#import "KWMUserDao.h"
@implementation BUYClient (FilterSoldout) @implementation BUYClient (FilterSoldout)
...@@ -18,6 +19,9 @@ ...@@ -18,6 +19,9 @@
NSInvocation *invocation = info.originalInvocation; NSInvocation *invocation = info.originalInvocation;
id completion = ^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error){ id completion = ^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error){
NSArray *ps = [products rx_filterWithBlock:^BOOL(BUYProduct *each) { NSArray *ps = [products rx_filterWithBlock:^BOOL(BUYProduct *each) {
if ([each.tags containsObject:@"small pic"]) {
return [[[[KWMUserDao shareDao] customer] tags] containsString:@"Business"] || [[[KWMUserDao shareDao] tags] containsObject:@"Staff"];
}
return each.availableValue; return each.availableValue;
}]; }];
block(ps,page,reachedEnd,error); block(ps,page,reachedEnd,error);
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#import <Buy/Buy.h> #import <Buy/Buy.h>
#import "KWMCustomsClearance.h" #import "KWMCustomsClearance.h"
#import <Mobile-Buy-SDK/Buy/BUYCustomer.h>
@class KWMUser; @class KWMUser;
@class KWMRequestResult; @class KWMRequestResult;
...@@ -23,16 +25,19 @@ ...@@ -23,16 +25,19 @@
@property (nonatomic, strong) KWMCustomsClearance *customsClearance; @property (nonatomic, strong) KWMCustomsClearance *customsClearance;
@property (nonatomic, strong) BUYCustomer *customer;
@property (nonatomic, strong) NSArray *tags;
+ (KWMUserDao *)shareDao; + (KWMUserDao *)shareDao;
- (BOOL)checkSession; - (BOOL)checkSession;
- (KWMUser *)loginUser; - (KWMUser *)loginUser;
- (BOOL)isLogin; - (BOOL)isLogin;
- (void)logout; - (void)logout;
- (void)saveUser:(KWMUser *)user; - (void)saveUser:(KWMUser *)user;
- (void)saveExchangeRate:(NSNumber *)exchangeRate; - (void)saveExchangeRate:(NSNumber *)exchangeRate;
- (NSDecimalNumber *)exchangeRate; - (NSDecimalNumber *)exchangeRate;
- (void) requestTags;
- (void (^)(NSURLSessionDataTask *, KWMRequestResult *))getLoginSuccessCallback:(void (^)(NSURLSessionDataTask *, KWMRequestResult *))callback; - (void (^)(NSURLSessionDataTask *, KWMRequestResult *))getLoginSuccessCallback:(void (^)(NSURLSessionDataTask *, KWMRequestResult *))callback;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
//#import "JPUSHService.h" //#import "JPUSHService.h"
#import "PSPDFAlertView.h" #import "PSPDFAlertView.h"
#import "KWMStringUtil.h" #import "KWMStringUtil.h"
//#import <Mobile-Buy-SDK/Buy/BUYClient.h>
#define SESSID @"PHPSESSID" #define SESSID @"PHPSESSID"
static NSString *kwmKeySessionId = @"sessionId"; static NSString *kwmKeySessionId = @"sessionId";
...@@ -26,6 +27,7 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword"; ...@@ -26,6 +27,7 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
@interface KWMUserDao () @interface KWMUserDao ()
@property (nonatomic, strong) BUYClient *client;
@end @end
...@@ -45,6 +47,7 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword"; ...@@ -45,6 +47,7 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
@synthesize customsClearance = _customsClearance; @synthesize customsClearance = _customsClearance;
@synthesize currencyCode = _currencyCode; @synthesize currencyCode = _currencyCode;
+ (KWMUserDao *)shareDao { + (KWMUserDao *)shareDao {
static KWMUserDao *_userDao = nil; static KWMUserDao *_userDao = nil;
static dispatch_once_t oncePredicate; static dispatch_once_t oncePredicate;
...@@ -165,6 +168,43 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword"; ...@@ -165,6 +168,43 @@ static NSString *kwmKeySavedAccountPassword = @"savedAccountPassword";
[defaults removeObjectForKey:kwmKeyUser]; [defaults removeObjectForKey:kwmKeyUser];
} }
- (BUYClient *)client {
if (_client == nil){
_client = [[BUYClient alloc] initWithShopDomain:Shopify_SHOP_DOMAIN
apiKey:Shopify_API_KEY
appId:Shopify_APP_ID];
}
_client.pageSize = 20;
NSDictionary *tokenDic = [[NSUserDefaults standardUserDefaults] objectForKey:@"token"];
NSString *path = NSHomeDirectory();//主目录
NSLog(@"NSHomeDirectory:%@",path);
if (tokenDic != nil) {
BUYCustomerToken *token = [BUYCustomerToken customerTokenWithJSONDictionary:[[NSUserDefaults standardUserDefaults] objectForKey:@"token"]];
if (token != nil) {
_client.customerToken = token;
}
}
return _client;
}
-(BUYCustomer *)customer {
if (!_customer) {
NSDictionary *customerDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"customer"];
_customer = [[BUYCustomer alloc] initWithModelManager:self.client.modelManager JSONDictionary:customerDict];
}
return _customer;
}
-(void)requestTags {
[[KWMAPIManager sharedManager] adminUserSuccess:^(NSURLSessionDataTask *task, KWMDictionaryResult *result) {
NSString *tags = result.data[@"customer"][@"tags"];
self.tags = [tags componentsSeparatedByString:@", "];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
NSLog(@"%@",error);
}];
}
-(NSDictionary *)checkOutCache{ -(NSDictionary *)checkOutCache{
NSString *filePath = [self getCheckoutCachePath]; NSString *filePath = [self getCheckoutCachePath];
// 解档 // 解档
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
[defaults synchronize]; [defaults synchronize];
} }
[[KWMAPIManager sharedManager] loginWebSuccess:nil failure:nil]; [[KWMAPIManager sharedManager] loginWebSuccess:nil failure:nil];
[[KWMUserDao shareDao] requestTags];
} }
- (void)initSplash{ - (void)initSplash{
......
...@@ -87,6 +87,7 @@ typedef enum{ ...@@ -87,6 +87,7 @@ typedef enum{
self.titleView.count = count; self.titleView.count = count;
[self.titleView resumeView]; [self.titleView resumeView];
} }
} }
-(void)viewDidDisappear:(BOOL)animated{ -(void)viewDidDisappear:(BOOL)animated{
......
...@@ -225,6 +225,7 @@ static NSString *idStr = @"KWMBrandCaramelCell"; ...@@ -225,6 +225,7 @@ static NSString *idStr = @"KWMBrandCaramelCell";
[tableView registerNib:[UINib nibWithNibName:idStr bundle:nil] forCellReuseIdentifier:idStr]; [tableView registerNib:[UINib nibWithNibName:idStr bundle:nil] forCellReuseIdentifier:idStr];
brandCaramelCell = [tableView dequeueReusableCellWithIdentifier:idStr]; brandCaramelCell = [tableView dequeueReusableCellWithIdentifier:idStr];
} }
brandCaramelCell.isShowBrandTitle = YES;
brandCaramelCell.delegate = self; brandCaramelCell.delegate = self;
brandCaramelCell.selectionStyle = UITableViewCellSelectionStyleNone; brandCaramelCell.selectionStyle = UITableViewCellSelectionStyleNone;
NSInteger position = indexPath.row * 2; NSInteger position = indexPath.row * 2;
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
</dict> </dict>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2017072111</string> <string>2017072116</string>
<key>ITSAppUsesNonExemptEncryption</key> <key>ITSAppUsesNonExemptEncryption</key>
<false/> <false/>
<key>LSApplicationQueriesSchemes</key> <key>LSApplicationQueriesSchemes</key>
......
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