Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ios1x
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
ios1x
Commits
53469421
Commit
53469421
authored
Dec 19, 2017
by
houweibin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moncler品牌商品使用admin api获取
parent
e01dbf27
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
KWMBrandCaramelVC.m
iCemarose/Class/UI/Brand/KWMBrandCaramelVC.m
+52
-0
No files found.
iCemarose/Class/UI/Brand/KWMBrandCaramelVC.m
View file @
53469421
...
...
@@ -365,6 +365,10 @@ static NSString *idStr = @"KWMBrandCaramelCell";
if
([
self
isUseCacheProduct
:
parameters
page
:
tagetPage
]){
return
;
};
if
([
collectionId
.
stringValue
isEqualToString
:
@"171614726"
]){
[
self
getAdminProducts
:
parameters
];
return
;
}
[
self
.
client
getProductsPage
:
tagetPage
inCollection
:
collectionId
withTags
:
tags
sortOrder
:
collectionSort
completion
:^
(
NSArray
*
products
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
){
if
(
!
error
){
[
KWMPPCacheUtil
saveDataToCache
:
parameters
urlKey
:
CACHE_KEY_SDK_getProductsPage
products
:
products
];
...
...
@@ -394,6 +398,53 @@ static NSString *idStr = @"KWMBrandCaramelCell";
}];
}
-
(
void
)
getAdminProducts
:
(
NSDictionary
*
)
parameters
{
__weak
KWMBrandCaramelVC
*
weakSelf
=
self
;
NSInteger
tagetPage
=
self
.
currentPage
.
integerValue
+
1
;
//初始化排序及筛选tag
NSString
*
apiPath
=
[[
NSString
alloc
]
initWithFormat
:
@"https://%@/admin/product_listings.json"
,
Shopify_SHOP_DOMAIN
];
AFHTTPSessionManager
*
sessionManager
=
[
AFHTTPSessionManager
manager
];
[
sessionManager
.
requestSerializer
setValue
:
@"Basic YWRlMDgzZGU2YWJjYjljYjk0ODY5NDg1ZWUwZGQyNmE6MWYyYzVlM2I4N2YyZGJlMTkwZGEzMzU4NmMyMmY3YzQ="
forHTTPHeaderField
:
@"Authorization"
];
[
sessionManager
GET
:
apiPath
parameters
:
parameters
progress
:
nil
success
:^
(
NSURLSessionDataTask
*
_Nonnull
task
,
id
_Nullable
responseObject
)
{
NSArray
*
result
=
nil
;
[
weakSelf
hideLoading
];
if
(
responseObject
){
id
jsonDictionary
=
responseObject
[
@"product_listings"
];
if
(
jsonDictionary
){
@try
{
NSArray
*
array
=
(
NSArray
*
)
jsonDictionary
;
if
(
array
){
BUYModelManager
*
modelManager
=
[[
BUYModelManager
alloc
]
init
];
result
=
[
modelManager
buy_objectsWithEntityName
:[
BUYProduct
entityName
]
JSONArray
:
array
];
}
}
@catch
(
NSException
*
exception
){
NSLog
(
@"exception Name: %@"
,
exception
.
name
);
NSLog
(
@"exception Reason: %@"
,
exception
.
reason
);
}
[
KWMPPCacheUtil
saveDataToCache
:
parameters
urlKey
:
CACHE_KEY_SDK_getProductsPage
products
:
result
];
if
(
!
result
||
result
.
count
==
0
){
weakSelf
.
vNoneGoods
.
hidden
=
NO
;
[
weakSelf
.
dataList
removeAllObjects
];
[
self
.
tbvBrandCaramel
reloadData
];
weakSelf
.
hasNextPage
=
NO
;
}
else
{
if
(
tagetPage
==
1
){
[
weakSelf
.
dataList
removeAllObjects
];
}
weakSelf
.
hasNextPage
=
YES
;
[
weakSelf
appendDataList
:
result
setPage
:
tagetPage
];
weakSelf
.
vNoneGoods
.
hidden
=
YES
;
[
self
.
tbvBrandCaramel
reloadData
];
}
}
}
}
failure
:^
(
NSURLSessionDataTask
*
_Nullable
task
,
NSError
*
_Nonnull
error
)
{
[
weakSelf
hideLoading
];
[
weakSelf
showError
:
error
];
}];
}
#pragma mark -cache
//缓存规则:第一页数据默认先从缓存拿,然后再更新,后面的根据网络判断从缓存拿数据还是从api拿数据
-
(
BOOL
)
isUseCacheProduct
:
(
NSDictionary
*
)
cacheKeyDictionary
page
:
(
NSUInteger
)
page
{
...
...
@@ -430,4 +481,5 @@ static NSString *idStr = @"KWMBrandCaramelCell";
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment