FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Coding-iOS/Coding_iOS/Models/Shop.m at master · fusen-github/Coding-iOS · GitHub
fusen-github
/
Coding-iOS
Public
forked from
coding/Coding-iOS
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Models
/
Shop.m
Copy path
More file actions
More file actions
Latest commit
History
History
History
110 lines (91 loc) · 2.38 KB
Breadcrumbs
Coding-iOS
/
Coding_iOS
/
Models
/
Shop.m
Copy path
File metadata and controls
110 lines (91 loc) · 2.38 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//
//
Shop.m
//
Coding_iOS
//
//
Created by liaoyp on 15/11/20.
//
Copyright © 2015年 Coding. All rights reserved.
//
#
import
"
Shop.h
"
@implementation
Shop
- (
instancetype
)
init
{
self = [
super
init
];
if
(self) {
self.
page
= @
1
;
self.
pageSize
= @
100
;
self.
shopType
= ShopTypeAll;
self.
shopGoodsArray
= [
NSMutableArray
arrayWithCapacity:
10
];
}
return
self;
}
+ (Shop *)
tweetsWithType
:
(ShopType)
shopType
{
Shop *tweets = [[Shop
alloc
]
init
];
tweets.
shopType
= shopType;
tweets.
canLoadMore
=
NO
;
tweets.
isLoading
=
NO
;
tweets.
willLoadMore
=
NO
;
return
tweets;
}
- (
void
)
setShopType
:
(ShopType)
shopType
{
_shopType = shopType;
switch
(_shopType) {
case
ShopTypeAll:
{
_dateSource = _shopGoodsArray;
}
break
;
case
ShopTypeExchangeable:
{
_dateSource = [
self
getExchangeGiftData
];
}
break
;
default
:
break
;
}
}
- (
NSString
*)
toGiftsPath
{
NSString
*requstPath;
switch
(_shopType) {
case
ShopTypeAll:
requstPath =
@"
/api/gifts
"
;
break
;
case
ShopTypeExchangeable:
break
;
default
:
break
;
}
return
requstPath;
}
- (
void
)
configWithGiftGoods
:
(
NSArray
*)
responseA
{
if
(responseA && [responseA
count
] >
0
) {
[responseA
enumerateObjectsUsingBlock:
^(ShopGoods *obj,
NSUInteger
idx,
BOOL
* _Nonnull stop) {
if
(_points_left.
doubleValue
>= obj.
points_cost
.
doubleValue
) {
obj.
exchangeable
=
YES
;
}
}];
self.
canLoadMore
= (responseA.
count
>= _pageSize.
intValue
);
if
(_page.
intValue
==
1
) {
_shopGoodsArray = [
NSMutableArray
arrayWithArray:
responseA];
}
else
{
[_shopGoodsArray
addObjectsFromArray:
responseA];
}
if
(_shopType == ShopTypeAll) {
_dateSource = _shopGoodsArray;
}
}
else
{
self.
canLoadMore
=
NO
;
}
}
- (
NSArray
*)
getExchangeGiftData
{
NSMutableArray
*mutaleArray = [
NSMutableArray
arrayWithCapacity:
10
];
[_shopGoodsArray
enumerateObjectsUsingBlock:
^(ShopGoods *obj,
NSUInteger
idx,
BOOL
* _Nonnull stop) {
if
(obj.
exchangeable
) {
[mutaleArray
addObject:
obj];
}
}];
return
mutaleArray;
}
@end
Back
|
FazBrowse Home
|
New Git URL