Commit 39541fe2 by houweibin

1,新商品详情页。(部分API未提供,因此未接入,不在1.4版本更新计划中,该页面暂不显示出来,仍显示旧商品详情页面。)

parent 53bc6d92
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_like@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_like@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_like_1@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_like_1@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_new_share@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_new_share@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_product_14day@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_product_14day@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_product_gift@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_product_gift@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_product_real@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_product_real@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ic_selected_color@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "ic_selected_color@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "test_home_cloth_2@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "test_home_cloth_2@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "test_product_detail@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "test_product_detail@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@
#import "KWMCategoryVC.h"
#import "KWMProductDetailVC.h"
#import "KWMNewProductVC.h"
#import "KWMLeftCategoryCell.h"
#import "KWMRightProductCell.h"
#import "KWMBrandsTypeModel.h"
......@@ -130,7 +131,7 @@
#pragma mark - UICollectionViewDelegate
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
KWMProductDetailVC *productDetailVC = (KWMProductDetailVC *)[KWMProductDetailVC findControllerBy:[KWMProductDetailVC kwmTag] fromStoryboard:@"New"];
KWMNewProductVC *productDetailVC = (KWMNewProductVC *)[KWMNewProductVC findControllerBy:[KWMNewProductVC kwmTag] fromStoryboard:@"NewProduct"];
BUYProduct *product = (BUYProduct *)[self.refreshUtil.dataList objectAtIndex:indexPath.row];
productDetailVC.product = product;
[self.navigationController pushViewController:productDetailVC animated:YES];
......
//
// KWMProductDetailView.h
// iCemarose
//
// Created by HouWeiBin on 2017/1/11.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "Buy/Buy.h"
@protocol KWMFirstDetailViewDelegate <NSObject>
- (void)kwm_onClickImage:(NSMutableArray *)imageArr currentIndex:(NSInteger)currentIndex;
- (void)kwm_onClickSizeBtn;
- (void)kwm_goToBrandVC;
@end
@interface KWMFirstDetailView : UIView
@property (weak, nonatomic) id<KWMFirstDetailViewDelegate>delegate;
-(void)setData:(BUYProduct *)product;
@end
//
// KWMProductDetailView.m
// iCemarose
//
// Created by HouWeiBin on 2017/1/11.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMFirstDetailView.h"
#import "KWMImageUtil.h"
#import "KWMStringUtil.h"
#import "KWMPageControl.h"
#import "YYWebImage/YYWebImage.h"
@interface KWMFirstDetailView ()<UIScrollViewDelegate>
@property(nonatomic,weak) IBOutlet UIView *vView;
@property(nonatomic,weak) IBOutlet UIScrollView *imageScrollView;
@property(nonatomic,weak) IBOutlet UIButton *btnBrand;
@property(nonatomic,weak) IBOutlet UILabel *lbName;
@property(nonatomic,weak) IBOutlet UILabel *lbPrice;
@property(nonatomic,weak) IBOutlet UILabel *lbOldPrice;
@property(nonatomic,weak) IBOutlet UILabel *lbDetail;
//单位label
@property(nonatomic,weak) IBOutlet UILabel *lbUnit;
@property(nonatomic,weak) IBOutlet KWMPageControl *pageControl;
@property (nonatomic) BUYProduct *product;
@property (nonatomic) NSMutableArray *imageArr;
@property (nonatomic) NSTimer *timer;
@property (nonatomic) BOOL isFirstScroll;
@property (nonatomic) BOOL isShowCNY;
- (IBAction)onClickSizeBtn:(id)sender;
- (IBAction)onClickBlandBtn:(id)sender;
@end
@implementation KWMFirstDetailView
- (id)init{
if (self=[super init]){
[self addView];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self addView];
}
return self;
}
-(instancetype)initWithFrame:(CGRect)frame{
if (self =[super initWithFrame:frame]) {
[self addView];
}
return self;
}
-(void)awakeFromNib{
[super awakeFromNib];
}
-(void) addView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
NSLog(@"KWMProductDetailView%f%f",self.frame.size.width,self.frame.size.height);
self.vView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vView];
}
-(void) addTimer{
if ([self.timer isValid]) {
return;
}
self.timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(doTimer) userInfo:nil repeats:YES];
[self.timer setFireDate:[NSDate new]];//开启
}
-(void) removeTimer{
//结束
if ([self.timer isValid]) {
[self.timer invalidate];
self.timer = nil;
}
}
//开始计时
-(void) doTimer{
if (self.isFirstScroll) {
self.isFirstScroll = NO;
return;
}
NSInteger currentIndex = self.pageControl.currentPage;
currentIndex ++;
currentIndex = currentIndex % self.pageControl.numberOfPages;
[self.imageScrollView setContentOffset:CGPointMake(UI_SCREEN_WIDTH * currentIndex, 0) animated:YES];
self.pageControl.currentPage = currentIndex;
}
-(void)setData:(BUYProduct *)product{
if(product == nil){
return;
}
self.isShowCNY = YES;
self.isFirstScroll = YES;
[self removeTimer];
self.product = product;
self.imageScrollView.delegate = self;
[self.imageScrollView setContentOffset:CGPointMake(0, 0) animated:NO];
for (UIView *subview in self.imageScrollView.subviews) {
[subview removeFromSuperview];
}
[self initImage:product];
[self initView:product];
//[self addTimer];
}
-(void)initImage:(BUYProduct *)product{
if(product == nil){
return;
}
NSInteger imageCount = product.imagesArray == nil? 0:product.imagesArray.count;
self.imageArr = [NSMutableArray array];
CGFloat w = UI_SCREEN_WIDTH;
CGFloat h = UI_SCREEN_WIDTH;
for( int i =0;i < imageCount;i++){
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i*w, 0, w, h)];
imageView.tag = i;
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.clipsToBounds = YES;
NSString *imageUrl = [KWMImageUtil getProductImageUrlByPosition:self.product ImageSize:BigImage Position:i];
[self.imageArr addObject:imageUrl];
NSURL *imageURL = [NSURL URLWithString:imageUrl];
UITapGestureRecognizer *imageTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickImage:)];
imageView.userInteractionEnabled = YES;
[imageView addGestureRecognizer:imageTap];
if(i + 1 == imageCount){
[imageView yy_setImageWithURL:imageURL placeholder:nil options:YYWebImageOptionProgressive completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
if(image && !error){
[self performSelector:@selector(addTimer) withObject:nil afterDelay:0.5f];
}
}];
}else{
[imageView yy_setImageWithURL:imageURL options:YYWebImageOptionProgressive];
}
[self.imageScrollView addSubview:imageView];
}
self.pageControl.numberOfPages = imageCount;
self.pageControl.currentPage = 0;
// [self.pageControl setValue:[UIImage imageNamed:@"ic_page_2"] forKey:@"_currentPageImage"];
// [self.pageControl setValue:[UIImage imageNamed:@"ic_page_1"] forKey:@"_pageImage"];
self.pageControl.defaultImage = [UIImage imageNamed:@"ic_page_1"];
self.pageControl.currentImage = [UIImage imageNamed:@"ic_page_2"];
self.imageScrollView.contentSize = CGSizeMake(w*imageCount,0);
self.imageScrollView.pagingEnabled = YES;
}
-(void)initView:(BUYProduct *)product{
if(product == nil){
return;
}
[self.btnBrand setTitle:product.vendor forState:UIControlStateNormal];
self.lbName.text = product.title;
BUYProductVariant *productVariant= product.variants.firstObject;
NSAttributedString *detailAttr = [[NSAttributedString alloc] initWithData:[self.product.htmlDescription dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
self.lbDetail.attributedText = detailAttr;
self.lbPrice.text = [KWMStringUtil price:productVariant.price];
if (productVariant.compareAtPrice) {
NSString *priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil price:productVariant.compareAtPrice]];
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic];
self.lbOldPrice.attributedText = attribtStr;
}else{
self.lbOldPrice.hidden = YES;
}
UITapGestureRecognizer *priceTap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickPrice:)];
UITapGestureRecognizer *priceTap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickPrice:)];
UITapGestureRecognizer *priceTap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onClickPrice:)];
[self.lbUnit addGestureRecognizer:priceTap1];
[self.lbPrice addGestureRecognizer:priceTap2];
[self.lbOldPrice addGestureRecognizer:priceTap3];
self.lbUnit.userInteractionEnabled = YES;
self.lbPrice.userInteractionEnabled = YES;
self.lbOldPrice.userInteractionEnabled = YES;
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
NSInteger index = fabs(scrollView.contentOffset.x)/scrollView.frame.size.width;
[self.pageControl setCurrentPage:index];
}
-(void)onClickImage:(UITapGestureRecognizer *)tapGesture{
if(self.delegate!=nil){
UIView *view = [tapGesture view];
[self.delegate kwm_onClickImage:self.imageArr currentIndex:view.tag];
}
}
-(void)onClickPrice:(UITapGestureRecognizer *)tapGesture{
if(self.product == nil){
return;
}
self.isShowCNY = !self.isShowCNY;
BUYProductVariant *productVariant= self.product.variants.firstObject;
if(self.isShowCNY){
self.lbUnit.text = @"¥";
self.lbPrice.text = [KWMStringUtil price:productVariant.price];
if (productVariant.compareAtPrice) {
NSString *priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil price:productVariant.compareAtPrice]];
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic];
self.lbOldPrice.attributedText = attribtStr;
}
}else{
self.lbUnit.text = @"€";
self.lbPrice.text = productVariant.price.stringValue;
if (productVariant.compareAtPrice) {
NSString *priceString = [NSString stringWithFormat:@"€%@",productVariant.compareAtPrice.stringValue];
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic];
self.lbOldPrice.attributedText = attribtStr;
}
}
}
-(void)onClickSizeBtn:(id)sender{
if(self.delegate!=nil){
[self.delegate kwm_onClickSizeBtn];
}
}
-(void)onClickBlandBtn:(id)sender{
if(self.delegate!=nil){
[self.delegate kwm_goToBrandVC];
}
}
@end
//
// KWMSizeCell.h
// iCemarose
//
// Created by HouWeiBin on 16/9/1.
// Copyright © 2016年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Buy/Buy.h"
@interface KWMProductColorCell : UICollectionViewCell
@property(nonatomic) BOOL isSelect;
@end
//
// KWMSizeCell.m
// iCemarose
//
// Created by HouWeiBin on 16/9/1.
// Copyright © 2016年 kollway. All rights reserved.
//
#import "KWMProductColorCell.h"
#import "UIColor+SAMAdditions.h"
#import "UIView+Prettify.h"
@interface KWMProductColorCell()
@property(nonatomic,weak) IBOutlet UIImageView *ivProduct;
@property(nonatomic,weak) IBOutlet UIImageView *ivSelected;
@property(nonatomic,weak) IBOutlet UIView *vProduct;
@end
@implementation KWMProductColorCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
[self.ivProduct setBorder:1 cornerRadius:1 borderColor:[UIColor sam_colorWithHex:@"D8DBDE"]];
}
-(void)setIsSelect:(BOOL)isSelect{
_isSelect = isSelect;
[self.ivProduct setBorder:1 cornerRadius:1 borderColor:isSelect?[UIColor sam_colorWithHex:@"F1929A"]:[UIColor sam_colorWithHex:@"D8DBDE"]];
self.ivSelected.hidden = !isSelect;
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" restorationIdentifier="KWMSizeCell" reuseIdentifier="KWMProductColorCell" id="gTV-IL-0wX" customClass="KWMProductColorCell">
<rect key="frame" x="0.0" y="0.0" width="50" height="71"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="50" height="71"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="LIy-sM-Sa7" userLabel="vView">
<rect key="frame" x="0.0" y="0.0" width="50" height="71"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YTc-7g-reg">
<rect key="frame" x="0.0" y="0.0" width="50" height="71"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="5sQ-H3-h9f">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="test_home_cloth_2" translatesAutoresizingMaskIntoConstraints="NO" id="m0M-BD-5Uv">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
</imageView>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_selected_color" translatesAutoresizingMaskIntoConstraints="NO" id="PXf-2y-qN1">
<rect key="frame" x="32" y="32" width="18" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="18" id="Agg-r9-9GB"/>
<constraint firstAttribute="width" constant="18" id="EUa-N1-Wxk"/>
</constraints>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="m0M-BD-5Uv" firstAttribute="leading" secondItem="5sQ-H3-h9f" secondAttribute="leading" id="7Bz-6x-aIi"/>
<constraint firstAttribute="width" secondItem="5sQ-H3-h9f" secondAttribute="height" multiplier="1:1" id="AzC-sE-H0H"/>
<constraint firstAttribute="bottom" secondItem="PXf-2y-qN1" secondAttribute="bottom" id="Dx6-u8-hyY"/>
<constraint firstItem="m0M-BD-5Uv" firstAttribute="top" secondItem="5sQ-H3-h9f" secondAttribute="top" id="FzR-wu-qtq"/>
<constraint firstAttribute="bottom" secondItem="m0M-BD-5Uv" secondAttribute="bottom" id="HCT-H9-Fmi"/>
<constraint firstAttribute="trailing" secondItem="m0M-BD-5Uv" secondAttribute="trailing" id="Y1a-27-8k3"/>
<constraint firstAttribute="trailing" secondItem="PXf-2y-qN1" secondAttribute="trailing" id="ofP-9e-h7Q"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="粉红色" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iFV-Ut-KXO">
<rect key="frame" x="0.0" y="54" width="50" height="18.5"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="13"/>
<color key="textColor" red="0.22352941176470587" green="0.22352941176470587" blue="0.22352941176470587" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="iFV-Ut-KXO" firstAttribute="top" secondItem="5sQ-H3-h9f" secondAttribute="bottom" constant="4" id="4pJ-pB-JfD"/>
<constraint firstAttribute="trailing" secondItem="iFV-Ut-KXO" secondAttribute="trailing" id="DC4-97-QBY"/>
<constraint firstItem="iFV-Ut-KXO" firstAttribute="leading" secondItem="YTc-7g-reg" secondAttribute="leading" id="Lhk-cd-r40"/>
<constraint firstItem="5sQ-H3-h9f" firstAttribute="leading" secondItem="YTc-7g-reg" secondAttribute="leading" id="OA4-bt-zUG"/>
<constraint firstItem="5sQ-H3-h9f" firstAttribute="top" secondItem="YTc-7g-reg" secondAttribute="top" id="plR-Nw-yN0"/>
<constraint firstAttribute="trailing" secondItem="5sQ-H3-h9f" secondAttribute="trailing" id="xFp-3U-itD"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="YTc-7g-reg" firstAttribute="leading" secondItem="LIy-sM-Sa7" secondAttribute="leading" id="K1Q-Ga-TFp"/>
<constraint firstAttribute="bottom" secondItem="YTc-7g-reg" secondAttribute="bottom" id="T7t-9G-sg0"/>
<constraint firstAttribute="trailing" secondItem="YTc-7g-reg" secondAttribute="trailing" id="rcu-u8-MfN"/>
<constraint firstItem="YTc-7g-reg" firstAttribute="top" secondItem="LIy-sM-Sa7" secondAttribute="top" id="sO8-jk-Hgj"/>
</constraints>
</view>
</subviews>
</view>
<constraints>
<constraint firstAttribute="trailing" secondItem="LIy-sM-Sa7" secondAttribute="trailing" id="3Dt-XH-3Dk"/>
<constraint firstItem="LIy-sM-Sa7" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="Gv2-S8-RjJ"/>
<constraint firstItem="LIy-sM-Sa7" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="R3f-Un-k6I"/>
<constraint firstAttribute="bottom" secondItem="LIy-sM-Sa7" secondAttribute="bottom" id="SCB-9p-0lM"/>
</constraints>
<connections>
<outlet property="ivProduct" destination="m0M-BD-5Uv" id="WFe-t0-yhM"/>
<outlet property="ivSelected" destination="PXf-2y-qN1" id="ei9-v0-z6q"/>
<outlet property="vProduct" destination="5sQ-H3-h9f" id="fkM-xP-spq"/>
</connections>
</collectionViewCell>
</objects>
<resources>
<image name="ic_selected_color" width="19" height="19"/>
<image name="test_home_cloth_2" width="140" height="140"/>
</resources>
</document>
//
// KWMSizeCell.h
// iCemarose
//
// Created by HouWeiBin on 16/9/1.
// Copyright © 2016年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Buy/Buy.h"
@interface KWMProductSizeCell : UICollectionViewCell
//sdk
@property(nonatomic) BUYProductVariant *productVariant;
@property(nonatomic) BOOL isSelect;
@property(nonatomic) BOOL isSellOut;
@end
//
// KWMSizeCell.m
// iCemarose
//
// Created by HouWeiBin on 16/9/1.
// Copyright © 2016年 kollway. All rights reserved.
//
#import "KWMProductSizeCell.h"
#import "UIColor+SAMAdditions.h"
#import "UIView+Prettify.h"
@interface KWMProductSizeCell()
@property(nonatomic,weak) IBOutlet UILabel *lbSize;
@property(nonatomic,weak) IBOutlet UILabel *lbSellOutSize;
@property(nonatomic,weak) IBOutlet UIView *vContent;
@property(nonatomic,weak) IBOutlet UIView *vSellOut;
@end
@implementation KWMProductSizeCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
[self.lbSize setBorder:1 cornerRadius:1 borderColor:[UIColor sam_colorWithHex:@"393939"]];
[self.vSellOut setBorder:1 cornerRadius:1 borderColor:[UIColor sam_colorWithHex:@"393939"]];
}
-(void)setIsSelect:(BOOL)isSelect{
_isSelect = isSelect;
self.lbSize.textColor = isSelect?[UIColor whiteColor]:[UIColor sam_colorWithHex:@"393939"];
self.lbSize.backgroundColor = isSelect?[UIColor sam_colorWithHex:@"393939"]:[UIColor whiteColor];
}
-(void)setIsSellOut:(BOOL)isSellOut{
_isSelect = isSellOut;
self.vSellOut.hidden = isSellOut?NO:YES;
}
-(void)setProductVariant:(BUYProductVariant *)productVariant{
_productVariant = productVariant;
if(productVariant){
self.lbSize.text = productVariant.title;
self.lbSellOutSize.text = productVariant.title;
}
}
@end
//
// KWMSecondDetailView.h
// iCemarose
//
// Created by 陈荣科 on 16/9/6.
// Copyright © 2016年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "KWMNewGoodsCell.h"
@class KWMSecondDetailView;
@protocol KWMSecondDetailViewDelegate <NSObject>
-(void)kwm_clickCollectionCell:(BUYProduct *)product;
-(void)kwm_loadNewPage:(BOOL)isSameBrand;
@end
@interface KWMSecondDetailView : UIView<UITableViewDataSource,UITableViewDelegate,KWMNewGoodsCellDelegate>
@property (weak, nonatomic) id<KWMSecondDetailViewDelegate>delegate;
@property (nonatomic) BOOL isLoadingSameBrand;
@property (nonatomic) BOOL isLoadingSameType;
@property (nonatomic) NSInteger pageSameBrand;
@property (nonatomic) NSInteger pageSameType;
@property (nonatomic) NSArray *sameBrandProducts;
@property (nonatomic) NSArray *sameTypeProducts;
@property (nonatomic) NSString *brand;
@property (nonatomic) NSInteger count;
//isSameBrand 是否同一品牌商品
-(void)setData:(NSArray *)products isSameBrand:(BOOL)isSameBrand;
-(void)setBrandString:(NSString *)brand;
-(void)clear;
@end
//
// KWMSecondDetailView.m
// iCemarose
//
// Created by 陈荣科 on 16/9/6.
// Copyright © 2016年 kollway. All rights reserved.
//
#import "KWMSecondDetailView.h"
#import "KWMTBVSectionHeardView.h"
@interface KWMSecondDetailView ()
@property(nonatomic,weak) IBOutlet UIView *vView;
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property(nonatomic,weak) IBOutlet UIPageControl *pageControl;
@end
@implementation KWMSecondDetailView
#define sclHeight (UI_SCREEN_HEITHT-20-20-40-90-64)
static NSString *idStr = @"KWMNewGoodsCell";
- (id)init{
if (self=[super init]){
[self addView];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self addView];
}
return self;
}
-(instancetype)initWithFrame:(CGRect)frame{
if (self =[super initWithFrame:frame]) {
[self addView];
}
return self;
}
-(void)awakeFromNib{
[super awakeFromNib];
}
-(void) addView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
self.vView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vView];
[self initView];
}
- (void)initView{
self.isLoadingSameBrand = NO;
self.isLoadingSameType = NO;
[self.tableView registerNib:[UINib nibWithNibName:idStr bundle:nil] forCellReuseIdentifier:idStr];
}
- (void)setCount:(NSInteger)count{
_count = count+1;
if(count>0){
self.pageControl.numberOfPages = count;
//需要放在设置图片之前,不然会发生crash
self.pageControl.currentPage = self.count-1;
[self.pageControl setValue:[UIImage imageNamed:@"ic_page_3"] forKey:@"_currentPageImage"];
[self.pageControl setValue:[UIImage imageNamed:@"ic_page_1"] forKey:@"_pageImage"];
}
}
#pragma mark -- UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.01f;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
KWMNewGoodsCell *newGoodsCell = [tableView dequeueReusableCellWithIdentifier:idStr forIndexPath:indexPath];
if(!newGoodsCell){
[tableView registerNib:[UINib nibWithNibName:idStr bundle:nil] forCellReuseIdentifier:idStr];
newGoodsCell = [tableView dequeueReusableCellWithIdentifier:idStr forIndexPath:indexPath];
}
newGoodsCell.isDetail = YES;
newGoodsCell.delegate = self;
newGoodsCell.isSameBrand = indexPath.section == 0;
if(newGoodsCell.isSameBrand){//同品牌推荐
if(self.pageSameBrand <= 1){
[newGoodsCell setData:self.sameBrandProducts];
}else{
[newGoodsCell addData:self.sameBrandProducts];
}
}else{//同类型商品推荐
if(self.pageSameType <= 1){
[newGoodsCell setData:self.sameTypeProducts];
}else{
[newGoodsCell addData:self.sameTypeProducts];
}
}
return newGoodsCell;
}
#pragma mark -- KWMNewGoodsCellDelegate
- (void)kwm_selectCollectionCell:(BUYProduct *)product{
if ([self.delegate respondsToSelector:@selector(kwm_clickCollectionCell:)]) {
[self.delegate kwm_clickCollectionCell:(BUYProduct *)product];
}
}
-(void)kwm_onNexPage:(BOOL)isNewBrand{
if ([self.delegate respondsToSelector:@selector(kwm_loadNewPage:)]) {
[self.delegate kwm_loadNewPage:isNewBrand];
}
}
#pragma mark - UITableViewDataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 173.0f;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
KWMTBVSectionHeardView *vTBVSectionHeard = [[KWMTBVSectionHeardView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 60)];
if (section == 0) {
NSString *title;
if(self.brand == nil){
vTBVSectionHeard = [[KWMTBVSectionHeardView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 40)];
title = @"其他商品";
}else{
title = [NSString stringWithFormat: @"%@\n其他商品", self.brand];
}
vTBVSectionHeard.lbSectionTitel.text = title;
}else{
vTBVSectionHeard = [[KWMTBVSectionHeardView alloc] initWithFrame:CGRectMake(0, 0, UI_SCREEN_WIDTH, 40)];
vTBVSectionHeard.lbSectionTitel.text = @"同类商品";
}
vTBVSectionHeard.ivMore.hidden = YES;
return vTBVSectionHeard;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if(section == 0 && self.brand != nil){
return 60;
}else{
return 40;
}
}
-(void)setData:(NSArray *)products isSameBrand:(BOOL)isSameBrand{
if(products == nil || products.count == 0){
return;
}
if(isSameBrand){
self.sameBrandProducts = products;
}else{
self.sameTypeProducts = products;
}
[self.tableView reloadData];
}
-(void)setBrandString:(NSString *)brand{
if(brand == nil){
return;
}
self.brand = brand;
}
-(void)clear{
self.brand = @"";
self.pageSameBrand = 0;
self.pageSameType = 0;
self.sameTypeProducts = nil;
self.sameBrandProducts = nil;
[self.tableView reloadData];
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMSecondDetailView">
<connections>
<outlet property="pageControl" destination="BwV-ZY-R8O" id="okW-Mg-odg"/>
<outlet property="tableView" destination="ucu-il-bL5" id="B8R-bv-NfL"/>
<outlet property="vView" destination="iN0-l3-epB" id="XUL-L9-zWr"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" bounces="NO" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="ucu-il-bL5">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<connections>
<outlet property="dataSource" destination="-1" id="5bl-79-mux"/>
<outlet property="delegate" destination="-1" id="KC1-U2-sJv"/>
</connections>
</tableView>
<pageControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" numberOfPages="3" translatesAutoresizingMaskIntoConstraints="NO" id="BwV-ZY-R8O" customClass="KWMPageControl">
<rect key="frame" x="168" y="627" width="39" height="10"/>
<constraints>
<constraint firstAttribute="height" constant="10" id="X2h-EH-VAs"/>
</constraints>
</pageControl>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="ucu-il-bL5" secondAttribute="bottom" id="6gL-Fu-UjZ"/>
<constraint firstItem="ucu-il-bL5" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="W8b-3w-t0w"/>
<constraint firstItem="BwV-ZY-R8O" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="aQS-gK-Dpy"/>
<constraint firstAttribute="trailing" secondItem="ucu-il-bL5" secondAttribute="trailing" id="cbe-Rz-Esu"/>
<constraint firstAttribute="bottom" secondItem="BwV-ZY-R8O" secondAttribute="bottom" constant="30" id="r41-Hr-Dx6"/>
<constraint firstItem="ucu-il-bL5" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="uCH-Vx-Jt8"/>
</constraints>
</view>
</objects>
</document>
//
// KWMThirdDetailView.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/23.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface KWMThirdDetailView : UIView
@end
//
// KWMThirdDetailView.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/23.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMThirdDetailView.h"
@interface KWMThirdDetailView()
@property (weak, nonatomic) IBOutlet UIView *vView;
@end
@implementation KWMThirdDetailView
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self initView];
}
return self;
}
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder:aDecoder];
if (self) {
[self initView];
}
return self;
}
-(void)awakeFromNib{
[super awakeFromNib];
}
-(void)initView{
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
self.vView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);
[self addSubview:self.vView];
}
@end
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16F73" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="KWMThirdDetailView">
<connections>
<outlet property="vView" destination="iN0-l3-epB" id="jbE-sN-LZF"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="375" height="530"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="phf-Yh-r1z">
<rect key="frame" x="0.0" y="0.0" width="375" height="530"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="TopLeft" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="test_product_detail" translatesAutoresizingMaskIntoConstraints="NO" id="uQ5-LY-iWo">
<rect key="frame" x="0.0" y="20" width="375" height="510"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wfB-x3-Yg3">
<rect key="frame" x="0.0" y="0.0" width="375" height="40"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cRM-ik-mZ1" userLabel="vLine">
<rect key="frame" x="50" y="19" width="275" height="1"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="lEz-sk-YTa"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="商品详情" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aOi-sB-YXp">
<rect key="frame" x="112" y="10" width="150" height="20"/>
<color key="backgroundColor" red="0.99607843139999996" green="0.99607843139999996" blue="0.99607843139999996" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="150" id="LGk-89-dnF"/>
<constraint firstAttribute="height" constant="20" id="nGt-cs-4Ts"/>
</constraints>
<fontDescription key="fontDescription" name="PingFangSC-Light" family="PingFang SC" pointSize="14"/>
<color key="textColor" red="0.25863381410000003" green="0.25863381410000003" blue="0.25863381410000003" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
<variation key="default">
<mask key="constraints">
<exclude reference="nGt-cs-4Ts"/>
</mask>
</variation>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="40" id="4wL-Lc-vYc"/>
<constraint firstItem="aOi-sB-YXp" firstAttribute="centerX" secondItem="wfB-x3-Yg3" secondAttribute="centerX" id="6si-bK-rmk"/>
<constraint firstItem="cRM-ik-mZ1" firstAttribute="leading" secondItem="wfB-x3-Yg3" secondAttribute="leading" constant="50" id="MYj-rD-ToW"/>
<constraint firstAttribute="trailing" secondItem="cRM-ik-mZ1" secondAttribute="trailing" constant="50" id="bbe-zy-vGP"/>
<constraint firstItem="aOi-sB-YXp" firstAttribute="centerY" secondItem="wfB-x3-Yg3" secondAttribute="centerY" id="hzp-4O-sWn"/>
<constraint firstItem="cRM-ik-mZ1" firstAttribute="centerY" secondItem="wfB-x3-Yg3" secondAttribute="centerY" id="nbm-hB-C01"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="wfB-x3-Yg3" firstAttribute="leading" secondItem="phf-Yh-r1z" secondAttribute="leading" id="FBm-GK-tHj"/>
<constraint firstItem="wfB-x3-Yg3" firstAttribute="top" secondItem="phf-Yh-r1z" secondAttribute="top" id="Nql-eH-b43"/>
<constraint firstAttribute="bottom" secondItem="uQ5-LY-iWo" secondAttribute="bottom" id="X2e-xf-iXK"/>
<constraint firstAttribute="trailing" secondItem="uQ5-LY-iWo" secondAttribute="trailing" id="bcI-Xc-CAy"/>
<constraint firstItem="uQ5-LY-iWo" firstAttribute="top" secondItem="phf-Yh-r1z" secondAttribute="top" constant="20" id="rC7-ik-Dfr"/>
<constraint firstItem="uQ5-LY-iWo" firstAttribute="leading" secondItem="phf-Yh-r1z" secondAttribute="leading" id="xwA-Ce-VsC"/>
<constraint firstAttribute="trailing" secondItem="wfB-x3-Yg3" secondAttribute="trailing" id="yGC-ga-jQO"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="phf-Yh-r1z" secondAttribute="trailing" id="4Wq-hy-RLx"/>
<constraint firstItem="phf-Yh-r1z" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="ebd-yK-Tec"/>
<constraint firstAttribute="bottom" secondItem="phf-Yh-r1z" secondAttribute="bottom" id="nDT-2t-8XL"/>
<constraint firstItem="phf-Yh-r1z" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="u0Z-64-52c"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</view>
</objects>
<resources>
<image name="test_product_detail" width="375" height="534"/>
</resources>
</document>
//
// KWMNewProductVC.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/23.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Buy/Buy.h>
#import "KWMBaseVC.h"
#import "KWMVariantsVC.h"
#import "KWMFirstDetailView.h"
#import "KWMSecondDetailView.h"
@interface KWMNewProductVC : KWMBaseVC<KWMFirstDetailViewDelegate,KWMVariantsVCDelegate>
@property(nonatomic) BUYProduct *product;
@property(nonatomic) NSNumber *productId;
@end
//
// KWMNewProductVC.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/23.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMNewProductVC.h"
#import "KWMLoginVC.h"
#import "KWMBeforePayVC.h"
#import "KWMBrandCaramelVC.h"
#import "KWMShareVC.h"
#import "PhotoBroswerVC.h"
#import "KWMUserModel.h"
#import "KWMShoppingCart.h"
#import "KWMImageUtil.h"
#import "KWMStringUtil.h"
@interface KWMNewProductVC ()
@property (weak, nonatomic) IBOutlet KWMFirstDetailView *detailView1;
@property (weak, nonatomic) IBOutlet KWMSecondDetailView *detailView2;
@end
@implementation KWMNewProductVC
- (void)viewDidLoad {
[super viewDidLoad];
[self initView];
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:YES];
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController setNavigationBarHidden:NO];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
-(void)initView{
self.productId = @(4746085766);
self.detailView1.delegate = self;
[self requestProductDetail];
[self requestBrandProducts:1];
[self requestCategoryProducts:1];
}
-(IBAction)onClickClose:(id)sender{
[self.navigationController popViewControllerAnimated:YES];
}
-(IBAction)onClickShare:(id)sender{
if(self.product){
KWMShareVC *shareVC = (KWMShareVC *)[KWMBaseVC findControllerBy:[KWMShareVC kwmTag] fromStoryboard:@"New"];
shareVC.shareUrl = [NSString stringWithFormat:@"https://www.cemarose.com/products/%@",self.product.handle];
shareVC.imageUrl = [KWMImageUtil getProductImageUrl:self.product ImageSize:SmallImage];
shareVC.productName = self.product.title;
CGSize size = [UIScreen mainScreen].bounds.size;
[self showPresentation:shareVC size:size tapOutsideClose:YES style:MZFormSheetPresentationTransitionStyleFade];
}
}
-(IBAction)onClickLike:(id)sender{
[self showToast:@"LIKE"];
}
#pragma mark -- KWMFirstDetailViewDelegate
-(void)kwm_onClickSizeBtn{
KWMVariantsVC *variantsVC = (KWMVariantsVC *)[KWMVariantsVC findControllerBy:[KWMVariantsVC kwmTag] fromStoryboard:@"NewProduct"];
variantsVC.product = self.product;
variantsVC.delegate = self;
CGSize size = [UIScreen mainScreen].bounds.size;
[self showPresentation:variantsVC size:size tapOutsideClose:YES style:MZFormSheetPresentationTransitionStyleFade];
}
-(void)kwm_goToBrandVC{
if(self.product && self.product.vendor){
KWMBrandCaramelVC *brandCaramelVC = (KWMBrandCaramelVC *)[KWMBrandCaramelVC findControllerBy:[KWMBrandCaramelVC kwmTag] fromStoryboard:@"Brand"];
NSString *brand = self.product.vendor;
brandCaramelVC.brand = brand;
brandCaramelVC.handle = [KWMStringUtil deleteOtherCharExceptLetterWithLine:brand];
brandCaramelVC.isSale = NO;
[self.navigationController pushViewController:brandCaramelVC animated:YES];
}
}
-(void)kwm_onClickImage:(NSMutableArray *)imageArr currentIndex:(NSInteger)currentIndex{
__weak KWMNewProductVC *weakSelf=self;
NSArray<NSString *> *imags = imageArr;
[PhotoBroswerVC show:self type:PhotoBroswerVCTypePush index:currentIndex isShowSaveBtn:YES photoModelBlock:^NSArray *{
NSArray *localImages = imags;
NSMutableArray *modelsM = [NSMutableArray arrayWithCapacity:localImages.count];
for (NSUInteger i = 0; i< localImages.count; i++) {
PhotoModel *pbModel=[[PhotoModel alloc] init];
pbModel.mid = i + 1;
//源frame
UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, weakSelf.view.frame.size.width, weakSelf.view.frame.size.height)];
pbModel.sourceImageView = imageV;
pbModel.image_HD_U = [[KWMAPIManager sharedManager] toAbsoluteUrl:localImages[i]];
[modelsM addObject:pbModel];
}
return modelsM;
}];
}
#pragma mark - KWMVariantsVCDelegate
- (void)kwm_addShopWithVariantId:(NSNumber *)identifier quantity:(NSInteger)quantity variant:(BUYProductVariant *) variant buyNow:(BOOL)buyNow callback:(void (^)(BOOL))callback {
__weak KWMNewProductVC *this = self;
if (!buyNow) {
[[KWMShoppingCart sharedInstance] increaseProductWithVariantId:identifier quantity:quantity callback:^(NSError *error, KWMCartResult *cart) {
if (cart.items.firstObject && !cart.items.firstObject.product_id) {
KWMShopCartModel *model = cart.items.firstObject;
BUYImageLink *il = this.product.images.firstObject;
// model.imageStr = [KWMImageUtil getProductImageUrl:this.product.identifier ImageSize:NormalImage];
model.imageStr = [KWMImageUtil getProductImageUrlByOriginalUrl:il.sourceURL.absoluteString ImageSize:NormalImage];
model.name = this.product.title;
model.brand = this.product.vendor;
model.size = variant.title;
// model.price = variant.price.floatValue;
model.price = variant.price;
model.product_id = this.product.identifier;
}
if (!error) {
[this showToast:@"添加成功"];
callback(YES);
}else{
[this showError:error];
callback(NO);
}
}];
return;
}
callback(YES);
KWMUserModel *useModel = [KWMUserModel shareUser];
if (!useModel.status) {
//登录
KWMLoginVC *loginVc = (KWMLoginVC *)[KWMBaseVC findControllerBy:[KWMLoginVC kwmTag] fromStoryboard:@"Login"];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVc];
[self presentViewController:nav animated:YES completion:nil];
return;
}
[self showLoading];
[self.api tmpCartWithVariantId:identifier quantity:quantity success:^(NSURLSessionDataTask *task, NSString *cartCookie) {
[this hideLoading];
KWMBeforePayVC *beforePayVC = (KWMBeforePayVC *)[KWMBaseVC findControllerBy:[KWMBeforePayVC kwmTag] fromStoryboard:@"ShopCart"];
beforePayVC.cartCookie = cartCookie;
[this.navigationController pushViewController:beforePayVC animated:YES];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
[this showError:error];
}];
}
#pragma mark - API BUYClient+Storefront
-(void)requestProductDetail{
if(!self.productId && !self.product){
return;
}
[self showLoading];
__weak KWMNewProductVC *weakSelf = self;
[self.client getProductById:self.productId?:self.product.identifier completion:^(BUYProduct * _Nullable product, NSError * _Nullable error) {
[weakSelf hideLoading];
if(error){
[weakSelf showError:error];
}else if(product){
weakSelf.product = product;
[weakSelf.detailView1 setData:product];
}
}];
}
-(void)requestBrandProducts:(NSInteger)page{
// if(!self.product){
// return;
// }
NSString *handle = @"girls";
self.detailView2.isLoadingSameBrand = YES;
__weak KWMNewProductVC *weakSelf = self;
[self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) {
if(collection && !error){
[weakSelf.client getProductsPage:page inCollection:collection.identifier completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) {
weakSelf.detailView2.isLoadingSameBrand = NO;
[weakSelf.detailView2 setData:products isSameBrand:YES];
}];
}else{
weakSelf.detailView2.isLoadingSameBrand = NO;
}
}];
}
-(void)requestCategoryProducts:(NSInteger)page{
// if(!self.product){
// return;
// }
NSString *handle = @"girls";
self.detailView2.isLoadingSameType = YES;
__weak KWMNewProductVC *weakSelf = self;
[self.client getCollectionByHandle:handle completion:^(BUYCollection * _Nullable collection, NSError * _Nullable error) {
if(collection && !error){
[weakSelf.client getProductsPage:page inCollection:collection.identifier completion:^(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error) {
weakSelf.detailView2.isLoadingSameType = NO;
[weakSelf.detailView2 setData:products isSameBrand:NO];
}];
}else{
weakSelf.detailView2.isLoadingSameType = NO;
}
}];
}
@end
//
// KWMSelectSizeViewController.h
// iCemarose
//
// Created by HouWeiBin on 17/6/26.
// Copyright © 2017年 kollway. All rights reserved.
//
// 原来的有点乱,重新整理一下,逻辑不复杂,还是跟原来一样,选完存好,然后回调到delegate.因为原selectSizeVC的逻辑到时候可能会再次被修改,所以,这个页面的版本时,需要注意下,逻辑是否需要更新。
#import "KWMBaseVC.h"
#import "Buy/Buy.h"
#import "KWMSizeCell.h"
#import "KWMShopCartData.h"
#import "KWMVariants.h"
@protocol KWMVariantsVCDelegate <NSObject>
- (void)kwm_addShopWithVariantId:(NSNumber *) identifier quantity:(NSInteger) quantity variant:(BUYProductVariant *) variant buyNow:(BOOL) buyNow callback:(void(^)(BOOL)) callback;
@end
@interface KWMVariantsVC : KWMBaseVC<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
@property (weak, nonatomic) id<KWMVariantsVCDelegate> delegate;
//請求api拿到的admin 規格列表,主要使用到其中的庫存剩餘字段
@property (nonatomic) NSArray<KWMVariants *> *adminVariantArray;
@property (nonatomic) NSArray<BUYProductVariant *> *variantArray;
@property (nonatomic) KWMShopCartModel *shopCartModel;
@property (nonatomic) BUYProduct *product;
@end
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