Commit 8d5eb243 by houweibin

wishlist逻辑调整

parent 050f30f1
......@@ -46,6 +46,7 @@
- (void)reLoadData;
- (void)loadData;
- (BOOL)checkLogin;
- (void)transparentNavigationBar;
- (void)unTransparentNavigationBar;
......
......@@ -16,6 +16,8 @@
#import "PSPDFAlertView.h"
#import "KWMStringUtil.h"
#import "KWMSuperLoadingView.h"
#import "KWMLoginVC.h"
#import "KWMUserModel.h"
@interface KWMBaseVC ()
......@@ -287,6 +289,19 @@
NSAssert(NO, @"调用尚未实现的方法");
}
-(BOOL)checkLogin{
KWMUserModel *user = [KWMUserModel shareUser];
if (user.status != 1) {
//登录
KWMLoginVC *loginVc = (KWMLoginVC *)[KWMBaseVC findControllerBy:[KWMLoginVC kwmTag] fromStoryboard:@"Login"];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVc];
[self presentViewController:nav animated:YES completion:nil];
return NO;
}else{
return YES;
}
}
//显示错误信息
- (void)showError:(NSError *)error{
if ([error.domain isEqualToString:NSURLErrorDomain]) {
......
......@@ -164,6 +164,9 @@ typedef enum{
-(void)kwm_onClickWishMenu{
NSLog(@"wishmenu");
if(![self checkLogin]){
return;
}
KWMWishListVC* vc= (KWMWishListVC *)[KWMBaseVC findControllerBy:[KWMWishListVC kwmTag] fromStoryboard:@"NewProduct"];
[self.navigationController pushViewController:vc animated:YES];
}
......
......@@ -62,8 +62,8 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.productId = @(7436196294);
self.product = nil;
// self.productId = @(7436196294);
// self.product = nil;
[self initView];
}
......@@ -452,7 +452,7 @@
__weak KWMNewProductVC *weakSelf = self;
NSDictionary *customerDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"customer"];
BUYCustomer *customer = [[BUYCustomer alloc] initWithModelManager:self.client.modelManager JSONDictionary:customerDict];
BUYProductVariant *variant = self.detailView1.variant;
BUYProductVariant *variant = self.variant;
if(!customer || !variant){
return;
}
......@@ -521,16 +521,17 @@
if(!customer || !self.variant){
return;
}
BUYProduct *product = (self.color && self.color.product)?self.color.product:self.product;
NSDictionary *parament = @{
@"customer_id":customer.identifier.stringValue,
@"customer_email":customer.email,
@"customer_name":customer.lastName,
@"product_title":self.product.title,
@"product_id":self.product.identifier.stringValue,
@"product_title":product.title,
@"product_id":product.identifier.stringValue,
@"variant_id":self.variant.identifier.stringValue,
@"variant_sku":self.variant.sku,
@"variant_title":self.variant.title,
@"product_handle":self.product.handle,
@"product_handle":product.handle,
@"shop":Shopify_SHOP_DOMAIN
};
void(^failure)(NSURLSessionDataTask *,NSError *) = ^(NSURLSessionDataTask *task,NSError *error){
......
......@@ -26,6 +26,8 @@
@property(nonatomic) IBOutlet UILabel *lbCount;
@property(weak,nonatomic) IBOutlet UIView *vCount;
@property(nonatomic) NSInteger count;
@property(nonatomic) NSDecimalNumber *totalPrice;
......@@ -140,6 +142,7 @@
if(self.selectVariant){
self.totalPrice = [self.selectVariant.price decimalNumberByMultiplyingBy:[NSDecimalNumber decimalNumberWithDecimal:@(self.count).decimalValue]];
}
self.vCount.hidden = self.wish?YES:NO;
self.lbCount.text = [NSString stringWithFormat:@"%ld",(long)self.count];
self.lbPrice.text = [[KWMCurrencyUtil sharedInstance] priceFormatted:self.totalPrice];
}
......@@ -193,10 +196,13 @@
* @param sender <#sender description#>
*/
-(IBAction)onClickComplete:(UIButton *)sender{
if (self.selectVariant == nil || self.count==0) {
if (self.selectVariant == nil) {
[self showToast:@"请选择您想要的规格"];
return;
}
if (self.count <= 0 && self.wish){
[self showToast:@"商品数量不能为0"];
}
//购物车页面
if ([self.delegate respondsToSelector:@selector(kwm_addShopWithVariantId:quantity:variant:buyNow:callback:)]){
__weak id this = self;
......@@ -387,6 +393,12 @@
if(variant && self.selectVariant){
return [variant.identifier isEqualToNumber:self.selectVariant.identifier];
};
if(variant && self.wish && !self.selectVariant){
if([variant.identifier isEqualToNumber:self.wish.variantId]){
self.selectVariant = variant;
return YES;
}
}
return NO;
}
......
......@@ -44,18 +44,24 @@
- (void)initView{
self.title = @"我喜欢的";
[self.tbvWish registerNib:[UINib nibWithNibName:NSStringFromClass([KWMWishCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([KWMWishCell class])];
self.wishArray = [NSMutableArray array];
self.productArray = [NSMutableArray array];
[self setTotalPrice];
}
-(void)removeWish:(NSNumber *)variantId{
for(KWMWish *wish in self.wishArray){
NSInteger removeIndex = -1;
for(NSInteger i = 0;i < self.wishArray.count;i++){
KWMWish *wish = [self.wishArray objectAtIndex:i];
if([wish.variantId isEqualToNumber:variantId]){
[self.wishArray removeObject:wish];
removeIndex = i;
break;
}
}
if(removeIndex != -1){
[self.wishArray removeObjectAtIndex:removeIndex];
[self.tbvWish reloadData];
}
}
//计算总价格
......@@ -73,7 +79,7 @@
}
#pragma mark --KWMVariantsVCDelegate
-(void)kwm_setVariant:(KWMVariantsVC *)variantsVC variant:(BUYProductVariant *)variant{
-(void)kwm_setVariant:(KWMVariantsVC *)variantsVC variant:(BUYProductVariant *)variant color:(KWMColor *)color count:(NSInteger)count{
for(KWMWish *wish in self.wishArray){
if([wish.variantId isEqualToNumber:variantsVC.wish.variantId]){
wish.variantId = variant.identifier;
......@@ -176,11 +182,11 @@
#pragma mark-- KWMAPIManager
-(void)requestWishList{
__weak KWMWishListVC *weakSelf = self;
NSDictionary *customerDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"customer"];
BUYCustomer *customer = [[BUYCustomer alloc] initWithModelManager:self.client.modelManager JSONDictionary:customerDict];
if(!customer){
if(![self checkLogin]){
return;
}
NSDictionary *customerDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"customer"];
BUYCustomer *customer = [[BUYCustomer alloc] initWithModelManager:self.client.modelManager JSONDictionary:customerDict];
NSDictionary *parament = @{
@"customer_id":customer.identifier.stringValue,
@"customer_email":customer.email,
......@@ -193,8 +199,9 @@
void(^success)(NSURLSessionDataTask *,KWMAdditionalListResult *) = ^(NSURLSessionDataTask *task,KWMAdditionalListResult *result){
[weakSelf hideLoading];
if(result && result.data){
NSMutableArray *wishArray = (NSMutableArray *)result.data;
weakSelf.wishArray = wishArray;
NSArray *wishArray = (NSArray *)result.data;
[weakSelf.wishArray removeAllObjects];
[weakSelf.wishArray addObjectsFromArray:wishArray];
[weakSelf.tbvWish reloadData];
[weakSelf requestProductsApi];
}
......
......@@ -509,6 +509,7 @@
<outlet property="lbCount" destination="GZ8-oT-VCl" id="LiQ-6e-76f"/>
<outlet property="lbPrice" destination="0UA-fW-OwV" id="ifJ-78-Kc8"/>
<outlet property="vContentHeight" destination="YBc-tS-Vne" id="qU7-CX-T7w"/>
<outlet property="vCount" destination="zhl-Qy-ueI" id="DHl-4S-o3l"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="MKE-1G-zhs" userLabel="First Responder" sceneMemberID="firstResponder"/>
......
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