Commit af1531be by houweibin

1,商品详情完善

2,fix error
parent 97e77983
......@@ -230,6 +230,8 @@
C04834561F13590500A5BFB4 /* KWMClothingSetsCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C04834521F13590500A5BFB4 /* KWMClothingSetsCell.xib */; };
C048B8E21EF3C04B000DA7AF /* KWMBeforePayData.m in Sources */ = {isa = PBXBuildFile; fileRef = C048B8E11EF3C04B000DA7AF /* KWMBeforePayData.m */; };
C048B8E51EF3F20B000DA7AF /* KWMCollectionRefreshUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = C048B8E41EF3F20B000DA7AF /* KWMCollectionRefreshUtil.m */; };
C057C77D1F172D4C00B95034 /* KWMMidDetailView.m in Sources */ = {isa = PBXBuildFile; fileRef = C057C77C1F172D4C00B95034 /* KWMMidDetailView.m */; };
C057C77F1F172D8E00B95034 /* KWMMidDetailView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C057C77E1F172D8E00B95034 /* KWMMidDetailView.xib */; };
C05910941E34A729002990B3 /* KWMNewGiftCardCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C05910921E34A729002990B3 /* KWMNewGiftCardCell.m */; };
C05910951E34A729002990B3 /* KWMNewGiftCardCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C05910931E34A729002990B3 /* KWMNewGiftCardCell.xib */; };
C06665091D75A2E500F02EF4 /* KWMOrderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = C06665041D75A2E500F02EF4 /* KWMOrderCell.m */; };
......@@ -260,8 +262,6 @@
C0A6B3C31F01FC5300D85673 /* KWMProductSizeCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0A6B3B21F01FC5300D85673 /* KWMProductSizeCell.xib */; };
C0A6B3C41F01FC5300D85673 /* KWMSecondDetailView.m in Sources */ = {isa = PBXBuildFile; fileRef = C0A6B3B41F01FC5300D85673 /* KWMSecondDetailView.m */; };
C0A6B3C51F01FC5300D85673 /* KWMSecondDetailView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0A6B3B51F01FC5300D85673 /* KWMSecondDetailView.xib */; };
C0A6B3C61F01FC5300D85673 /* KWMThirdDetailView.m in Sources */ = {isa = PBXBuildFile; fileRef = C0A6B3B71F01FC5300D85673 /* KWMThirdDetailView.m */; };
C0A6B3C71F01FC5300D85673 /* KWMThirdDetailView.xib in Resources */ = {isa = PBXBuildFile; fileRef = C0A6B3B81F01FC5300D85673 /* KWMThirdDetailView.xib */; };
C0A6B3C81F01FC5300D85673 /* KWMNewProductVC.m in Sources */ = {isa = PBXBuildFile; fileRef = C0A6B3BA1F01FC5300D85673 /* KWMNewProductVC.m */; };
C0A6B3C91F01FC5300D85673 /* KWMVariantsVC.m in Sources */ = {isa = PBXBuildFile; fileRef = C0A6B3BC1F01FC5300D85673 /* KWMVariantsVC.m */; };
C0A6B3CA1F01FC5300D85673 /* NewProduct.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C0A6B3BD1F01FC5300D85673 /* NewProduct.storyboard */; };
......@@ -768,6 +768,9 @@
C048B8E11EF3C04B000DA7AF /* KWMBeforePayData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMBeforePayData.m; sourceTree = "<group>"; };
C048B8E31EF3F20B000DA7AF /* KWMCollectionRefreshUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMCollectionRefreshUtil.h; sourceTree = "<group>"; };
C048B8E41EF3F20B000DA7AF /* KWMCollectionRefreshUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMCollectionRefreshUtil.m; sourceTree = "<group>"; };
C057C77B1F172D4C00B95034 /* KWMMidDetailView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMMidDetailView.h; sourceTree = "<group>"; };
C057C77C1F172D4C00B95034 /* KWMMidDetailView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMMidDetailView.m; sourceTree = "<group>"; };
C057C77E1F172D8E00B95034 /* KWMMidDetailView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMMidDetailView.xib; sourceTree = "<group>"; };
C05910911E34A729002990B3 /* KWMNewGiftCardCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KWMNewGiftCardCell.h; path = ../../ShopCart/Cell/KWMNewGiftCardCell.h; sourceTree = "<group>"; };
C05910921E34A729002990B3 /* KWMNewGiftCardCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = KWMNewGiftCardCell.m; path = ../../ShopCart/Cell/KWMNewGiftCardCell.m; sourceTree = "<group>"; };
C05910931E34A729002990B3 /* KWMNewGiftCardCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = KWMNewGiftCardCell.xib; path = ../../ShopCart/Cell/KWMNewGiftCardCell.xib; sourceTree = "<group>"; };
......@@ -819,9 +822,6 @@
C0A6B3B31F01FC5300D85673 /* KWMSecondDetailView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMSecondDetailView.h; sourceTree = "<group>"; };
C0A6B3B41F01FC5300D85673 /* KWMSecondDetailView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMSecondDetailView.m; sourceTree = "<group>"; };
C0A6B3B51F01FC5300D85673 /* KWMSecondDetailView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMSecondDetailView.xib; sourceTree = "<group>"; };
C0A6B3B61F01FC5300D85673 /* KWMThirdDetailView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMThirdDetailView.h; sourceTree = "<group>"; };
C0A6B3B71F01FC5300D85673 /* KWMThirdDetailView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMThirdDetailView.m; sourceTree = "<group>"; };
C0A6B3B81F01FC5300D85673 /* KWMThirdDetailView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KWMThirdDetailView.xib; sourceTree = "<group>"; };
C0A6B3B91F01FC5300D85673 /* KWMNewProductVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMNewProductVC.h; sourceTree = "<group>"; };
C0A6B3BA1F01FC5300D85673 /* KWMNewProductVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KWMNewProductVC.m; sourceTree = "<group>"; };
C0A6B3BB1F01FC5300D85673 /* KWMVariantsVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWMVariantsVC.h; sourceTree = "<group>"; };
......@@ -2007,18 +2007,18 @@
C0A6B3AA1F01FC5300D85673 /* KWMFirstDetailView.h */,
C0A6B3AB1F01FC5300D85673 /* KWMFirstDetailView.m */,
C0A6B3AC1F01FC5300D85673 /* KWMFirstDetailView.xib */,
C0A6B3B31F01FC5300D85673 /* KWMSecondDetailView.h */,
C0A6B3B41F01FC5300D85673 /* KWMSecondDetailView.m */,
C0A6B3B51F01FC5300D85673 /* KWMSecondDetailView.xib */,
C057C77B1F172D4C00B95034 /* KWMMidDetailView.h */,
C057C77C1F172D4C00B95034 /* KWMMidDetailView.m */,
C057C77E1F172D8E00B95034 /* KWMMidDetailView.xib */,
C0A6B3AD1F01FC5300D85673 /* KWMProductColorCell.h */,
C0A6B3AE1F01FC5300D85673 /* KWMProductColorCell.m */,
C0A6B3AF1F01FC5300D85673 /* KWMProductColorCell.xib */,
C0A6B3B01F01FC5300D85673 /* KWMProductSizeCell.h */,
C0A6B3B11F01FC5300D85673 /* KWMProductSizeCell.m */,
C0A6B3B21F01FC5300D85673 /* KWMProductSizeCell.xib */,
C0A6B3B31F01FC5300D85673 /* KWMSecondDetailView.h */,
C0A6B3B41F01FC5300D85673 /* KWMSecondDetailView.m */,
C0A6B3B51F01FC5300D85673 /* KWMSecondDetailView.xib */,
C0A6B3B61F01FC5300D85673 /* KWMThirdDetailView.h */,
C0A6B3B71F01FC5300D85673 /* KWMThirdDetailView.m */,
C0A6B3B81F01FC5300D85673 /* KWMThirdDetailView.xib */,
C029868C1F0F2663002EB25F /* KWMWishCell.h */,
C029868D1F0F2663002EB25F /* KWMWishCell.m */,
C029868E1F0F2663002EB25F /* KWMWishCell.xib */,
......@@ -2384,6 +2384,7 @@
C0392DBA1DCC38450051AC8E /* KWMShippingCell.xib in Resources */,
C0CCB3D01EEA765B00BC2FB8 /* KWMFilterTabItem.xib in Resources */,
80DD275B1DC2FE6800CDC5B5 /* Home.storyboard in Resources */,
C057C77F1F172D8E00B95034 /* KWMMidDetailView.xib in Resources */,
80A611AF1D6DB0CD00709E09 /* ShopCart.storyboard in Resources */,
C02C7D811E640D82008DC29C /* README.txt in Resources */,
C0DD531F1EE54F5D002D1E0C /* KWMMineTitleView.xib in Resources */,
......@@ -2413,7 +2414,6 @@
C0CCB3BA1EEA579900BC2FB8 /* KWMFilterView.xib in Resources */,
C0CCB3C21EEA59A200BC2FB8 /* KWMFilterViewCell.xib in Resources */,
C0CC14171D79826F007B5986 /* KWMAddressCell.xib in Resources */,
C0A6B3C71F01FC5300D85673 /* KWMThirdDetailView.xib in Resources */,
804771821D6D32A70086B4DC /* Login.storyboard in Resources */,
C0DD53241EE55062002D1E0C /* KWMCarCountView.xib in Resources */,
C0A6B3C51F01FC5300D85673 /* KWMSecondDetailView.xib in Resources */,
......@@ -2520,7 +2520,6 @@
C04834411F13350F00A5BFB4 /* KWMRecommendHeader.m in Sources */,
C0F586951E25C17A001248E2 /* KWMProductDetailVC.m in Sources */,
C0F586871E24F820001248E2 /* KWMNewTypeSelectedVC.m in Sources */,
C0A6B3C61F01FC5300D85673 /* KWMThirdDetailView.m in Sources */,
80598D471D99193400BF0F97 /* KWMInformationVC.m in Sources */,
C034E7B91D6B0A8D006EE129 /* KWMHomeVC.m in Sources */,
C0CCB3BD1EEA589200BC2FB8 /* KWMFilter.m in Sources */,
......@@ -2629,6 +2628,7 @@
C066650F1D7675FC00F02EF4 /* KWMAboutUsVC.m in Sources */,
807AF4A31DC984950000A326 /* KWMBlogResult.m in Sources */,
C0CC14081D7823B0007B5986 /* KWMSizeCell.m in Sources */,
C057C77D1F172D4C00B95034 /* KWMMidDetailView.m in Sources */,
DAB6431A1F04CFE5002CD7FE /* AppDelegate+Deeplink.m in Sources */,
C06665121D767A0A00F02EF4 /* KWMContactUsVC.m in Sources */,
C034E6CF1D6AEE39006EE129 /* KWMUserDao.m in Sources */,
......
......@@ -870,7 +870,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
- (NSURLSessionDataTask *) saveWish:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist-save",@"chris.tofnews.com"];
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist-save",@"test.cemarose.com"];
return [self startSessionTask:KWMHTTPMethodPOST
apiPath:apiPath
parameters:parameters
......@@ -890,7 +890,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
- (NSURLSessionDataTask *) getWishList:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist",@"chris.tofnews.com"];
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist",@"test.cemarose.com"];
return [self startSessionTask:KWMHTTPMethodGET
apiPath:apiPath
parameters:parameters
......@@ -910,7 +910,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
- (NSURLSessionDataTask *) removeWish:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist-prune",@"chris.tofnews.com"];
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist-prune",@"test.cemarose.com"];
return [self startSessionTask:KWMHTTPMethodPOST
apiPath:apiPath
parameters:parameters
......@@ -929,7 +929,7 @@ static NSString *const passwordTest = @"9e84aae218c57cdf0762763c4cf5a651";
- (NSURLSessionDataTask *) clearWishList:(NSDictionary *)parameters
success:(void(^)(NSURLSessionDataTask *task,KWMAdditionalListResult *result))success
failure:(void(^)(NSURLSessionDataTask *task,NSError *error))failure{
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist-delete",@"chris.tofnews.com"];
NSString *apiPath = [NSString stringWithFormat:@"https://%@/app/wishlist-delete",@"test.cemarose.com"];
return [self startSessionTask:KWMHTTPMethodPOST
apiPath:apiPath
parameters:parameters
......
......@@ -14,7 +14,7 @@
modelClass:(Class)modelClass
error:(NSError **)err {
self = [super initWithDictionary:dict error:err];
if (self) {
if (self && modelClass) {
NSArray *dataArray = dict[@"data"];
if(dataArray){
self.data = [self buildListData:modelClass jsonDictionary:dataArray];
......
......@@ -19,7 +19,7 @@
@property (nonatomic) NSString *handle;
//颜色代表的商品
@property (nonatomic) BUYProduct *prodcut;
@property (nonatomic) BUYProduct *product;
//admin拿到的商品,在选择规格的页面才会去请求拿到给它赋值
@property (nonatomic) KWMProduct *adminProduct;
......
......@@ -7,6 +7,7 @@
//
#import "Buy/Buy.h"
#import "KWMColor.h"
@protocol KWMFirstDetailViewDelegate <NSObject>
......@@ -20,7 +21,13 @@
@property (weak, nonatomic) id<KWMFirstDetailViewDelegate>delegate;
@property (nonatomic) BUYProductVariant *variant;
@property (nonatomic,readonly) BUYProductVariant *variant;
@property (nonatomic,readonly) KWMColor *color;
@property (nonatomic,readonly) NSInteger count;
-(void)setSelect:(BUYProductVariant *)variant color:(KWMColor *)color count:(NSInteger)count;
-(void)setData:(BUYProduct *)product;
......
......@@ -26,8 +26,6 @@
@property(nonatomic,weak) IBOutlet UILabel *lbOldPrice;
@property(nonatomic,weak) IBOutlet UILabel *lbDetail;
@property(nonatomic,weak) IBOutlet UILabel *lbVariant;
//单位label
......@@ -49,6 +47,10 @@
- (IBAction)onClickBlandBtn:(id)sender;
- (IBAction)onClickBuyNow:(id)sender;
- (IBAction)onClickAddToShopCart:(id)sender;
@end
@implementation KWMFirstDetailView
......@@ -139,6 +141,7 @@
if(product == nil){
return;
}
[self.imageScrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
NSInteger imageCount = product.imagesArray == nil? 0:product.imagesArray.count;
self.imageArr = [NSMutableArray array];
CGFloat w = UI_SCREEN_WIDTH;
......@@ -168,8 +171,6 @@
}
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);
......@@ -184,11 +185,11 @@
[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];
// self.lbPrice.text = [KWMStringUtil price:productVariant.price];
self.lbPrice.text = productVariant.price.priceValueFormatted;
if (productVariant.compareAtPrice) {
NSString *priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil price:productVariant.compareAtPrice]];
// NSString *priceString = [NSString stringWithFormat:@"¥%@",[KWMStringUtil price:productVariant.compareAtPrice]];
NSString *priceString = productVariant.compareAtPrice.priceValueFormatted;
NSDictionary *attribtDic = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:priceString attributes:attribtDic];
self.lbOldPrice.attributedText = attribtStr;
......@@ -248,24 +249,34 @@
-(void)onClickSizeBtn:(id)sender{
if(self.delegate!=nil){
if(self.delegate){
[self.delegate kwm_onClickSizeBtn];
}
}
-(void)onClickBlandBtn:(id)sender{
if(self.delegate!=nil){
if(self.delegate){
[self.delegate kwm_goToBrandVC];
}
}
-(void)setVariant:(BUYProductVariant *)variant{
-(void)setSelect:(BUYProductVariant *)variant color:(KWMColor *)color count:(NSInteger)count{
_variant = variant;
if(variant){
self.lbVariant.text = variant.title;
_color = color;
_count = count;
if(!variant){
self.lbVariant.text = @"选择尺码/颜色";
}else{
NSString *colorString = color?[NSString stringWithFormat:@"%@ /",color.title]:@"";
self.lbVariant.text = [NSString stringWithFormat:@"已选择 %@ %@ / %ld",colorString,variant.title,count];
}
}
@end
//
// KWMThirdDetailView.h
// KWMMidDetailView.h
// iCemarose
//
// Created by HouWeiBin on 2017/6/23.
// Created by HouWeiBin on 2017/7/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Buy/Buy.h>
@interface KWMThirdDetailView : UIView
@interface KWMMidDetailView : UIView
@property(nonatomic,weak) IBOutlet UIView *vView;
@property (nonatomic,weak) BUYProduct *product;
@end
//
// KWMThirdDetailView.m
// KWMMidDetailView.m
// iCemarose
//
// Created by HouWeiBin on 2017/6/23.
// Created by HouWeiBin on 2017/7/13.
// Copyright © 2017年 kollway. All rights reserved.
//
#import "KWMThirdDetailView.h"
@interface KWMThirdDetailView()
@property (weak, nonatomic) IBOutlet UIView *vView;
#import "KWMMidDetailView.h"
#import "KWMStringUtil.h"
@interface KWMMidDetailView()
@property(nonatomic,weak) IBOutlet UILabel *lbDetail;
@end
@implementation KWMThirdDetailView
@implementation KWMMidDetailView
-(id)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self initView];
- (id)init{
if (self=[super init]){
[self addView];
}
return self;
}
-(instancetype)initWithCoder:(NSCoder *)aDecoder{
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self initView];
[self addView];
}
return self;
}
-(instancetype)initWithFrame:(CGRect)frame{
if (self =[super initWithFrame:frame]) {
[self addView];
}
return self;
}
......@@ -36,12 +42,23 @@
[super awakeFromNib];
}
-(void)initView{
-(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];
}
-(void)setProduct:(BUYProduct *)product{
_product = product;
if(product && ![KWMStringUtil isEmpty:product.stringDescription]){
self.lbDetail.text = product.stringDescription;
}else{
self.lbDetail.text = @"暂无商品描述";
}
}
@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="KWMMidDetailView">
<connections>
<outlet property="lbDetail" destination="16V-pg-zWo" id="GaV-86-xP9"/>
<outlet property="vView" destination="iN0-l3-epB" id="P0V-Yf-qbm"/>
</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="86.5"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="0zT-PT-urZ" userLabel="商品详情">
<rect key="frame" x="0.0" y="0.0" width="375" height="86.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="商品详情" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pqF-X5-Xhf">
<rect key="frame" x="20" y="20" width="56" height="20"/>
<fontDescription key="fontDescription" name="PingFangSC-Light" family="PingFang SC" pointSize="14"/>
<color key="textColor" red="0.1529411765" green="0.14901960780000001" blue="0.21176470589999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="暂无商品描述" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="16V-pg-zWo">
<rect key="frame" x="20" y="55" width="335" height="15.5"/>
<fontDescription key="fontDescription" name="PingFangSC-Light" family="PingFang SC" pointSize="11"/>
<color key="textColor" red="0.1529411765" green="0.14901960780000001" blue="0.21176470589999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XNJ-x6-2qP" userLabel="line">
<rect key="frame" x="0.0" y="80.5" width="375" height="1"/>
<color key="backgroundColor" red="0.84705882349999995" green="0.85882352939999995" blue="0.87058823529999996" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="NJy-G1-cyA"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PrI-2Q-iZo">
<rect key="frame" x="0.0" y="81.5" width="375" height="5"/>
<color key="backgroundColor" red="0.95294117647058818" green="0.95686274509803915" blue="0.96078431372549022" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="5" id="sZO-dU-qbA"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="XNJ-x6-2qP" firstAttribute="leading" secondItem="0zT-PT-urZ" secondAttribute="leading" id="8BE-D2-yFW"/>
<constraint firstItem="16V-pg-zWo" firstAttribute="leading" secondItem="0zT-PT-urZ" secondAttribute="leading" constant="20" id="9FX-pD-wNv"/>
<constraint firstAttribute="trailing" secondItem="PrI-2Q-iZo" secondAttribute="trailing" id="D3a-eK-daj"/>
<constraint firstItem="pqF-X5-Xhf" firstAttribute="leading" secondItem="0zT-PT-urZ" secondAttribute="leading" constant="20" id="EzD-gc-lvx"/>
<constraint firstItem="pqF-X5-Xhf" firstAttribute="top" secondItem="0zT-PT-urZ" secondAttribute="top" constant="20" id="LEK-UP-dRE"/>
<constraint firstItem="PrI-2Q-iZo" firstAttribute="top" secondItem="XNJ-x6-2qP" secondAttribute="bottom" id="NNY-sX-Xqu"/>
<constraint firstItem="16V-pg-zWo" firstAttribute="top" secondItem="pqF-X5-Xhf" secondAttribute="bottom" constant="15" id="OZP-o7-VsQ"/>
<constraint firstItem="XNJ-x6-2qP" firstAttribute="leading" secondItem="0zT-PT-urZ" secondAttribute="leading" id="PcD-dE-uqp"/>
<constraint firstAttribute="trailing" secondItem="XNJ-x6-2qP" secondAttribute="trailing" id="QPz-Pw-Kko"/>
<constraint firstAttribute="bottom" secondItem="PrI-2Q-iZo" secondAttribute="bottom" id="YMF-oS-bPV"/>
<constraint firstAttribute="trailing" secondItem="XNJ-x6-2qP" secondAttribute="trailing" id="gfW-re-x8M"/>
<constraint firstItem="PrI-2Q-iZo" firstAttribute="leading" secondItem="0zT-PT-urZ" secondAttribute="leading" id="kX3-oP-46q"/>
<constraint firstAttribute="trailing" secondItem="16V-pg-zWo" secondAttribute="trailing" constant="20" id="nfa-gQ-E5a"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="0zT-PT-urZ" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="BdH-DG-45e"/>
<constraint firstAttribute="trailing" secondItem="0zT-PT-urZ" secondAttribute="trailing" id="Sff-qk-tGd"/>
<constraint firstItem="0zT-PT-urZ" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="g9K-fG-ixC"/>
<constraint firstAttribute="bottom" secondItem="0zT-PT-urZ" secondAttribute="bottom" id="iyD-4z-nH4"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
</view>
</objects>
</document>
......@@ -42,7 +42,7 @@
-(void)setData:(KWMColor *)data{
_data = data;
if(data){
BUYProduct *product = data.prodcut;
BUYProduct *product = data.product;
NSString *imageUrl = [KWMImageUtil getProductImageUrl:product ImageSize:SmallImage];
NSURL *imageURL = [NSURL URLWithString:imageUrl];
[self.ivColor sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
......
......@@ -6,7 +6,6 @@
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
......@@ -36,50 +35,39 @@
<rect key="frame" x="0.0" y="0.0" width="91" height="36"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cGu-OY-P4R" userLabel="size">
<rect key="frame" x="0.0" y="0.0" width="91" height="18"/>
<rect key="frame" x="0.0" y="0.0" width="91" height="36"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3A" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="whv-2v-7Jq">
<rect key="frame" x="0.0" y="0.0" width="91" height="18.5"/>
<rect key="frame" x="0.0" y="0.0" width="91" height="36.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>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dZq-jJ-iEe" userLabel="line">
<rect key="frame" x="22.5" y="8.5" width="45.5" height="1"/>
<color key="backgroundColor" red="0.94509803921568625" green="0.50980392156862742" blue="0.54117647058823526" alpha="1" colorSpace="calibratedRGB"/>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_sell_out" translatesAutoresizingMaskIntoConstraints="NO" id="TdD-fg-gGm">
<rect key="frame" x="32" y="10" width="26" height="15"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="fKL-jv-avn"/>
<constraint firstAttribute="width" constant="26" id="Sem-we-wai"/>
<constraint firstAttribute="height" constant="15" id="ldd-Tb-DUK"/>
</constraints>
</view>
</imageView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="TdD-fg-gGm" firstAttribute="centerY" secondItem="cGu-OY-P4R" secondAttribute="centerY" id="9YG-wq-dD4"/>
<constraint firstItem="TdD-fg-gGm" firstAttribute="centerX" secondItem="cGu-OY-P4R" secondAttribute="centerX" id="Dba-69-acf"/>
<constraint firstItem="whv-2v-7Jq" firstAttribute="top" secondItem="cGu-OY-P4R" secondAttribute="top" id="F83-Wt-SEu"/>
<constraint firstItem="whv-2v-7Jq" firstAttribute="leading" secondItem="cGu-OY-P4R" secondAttribute="leading" id="Jyt-in-reE"/>
<constraint firstItem="dZq-jJ-iEe" firstAttribute="centerX" secondItem="cGu-OY-P4R" secondAttribute="centerX" id="bqk-63-7jb"/>
<constraint firstAttribute="trailing" secondItem="whv-2v-7Jq" secondAttribute="trailing" id="diD-GC-atf"/>
<constraint firstAttribute="bottom" secondItem="whv-2v-7Jq" secondAttribute="bottom" id="maJ-HX-Qwr"/>
<constraint firstItem="dZq-jJ-iEe" firstAttribute="width" secondItem="cGu-OY-P4R" secondAttribute="width" multiplier="0.5" id="n2f-kj-OSA"/>
<constraint firstItem="dZq-jJ-iEe" firstAttribute="centerY" secondItem="cGu-OY-P4R" secondAttribute="centerY" id="rYK-at-zcZ"/>
</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="a1x-nK-a5r">
<rect key="frame" x="0.0" y="18" width="91" height="18"/>
<fontDescription key="fontDescription" name="PingFangSC-Regular" family="PingFang SC" pointSize="10"/>
<color key="textColor" red="0.22352941176470587" green="0.22352941176470587" blue="0.22352941176470587" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="cGu-OY-P4R" firstAttribute="leading" secondItem="0cT-rD-xfN" secondAttribute="leading" id="6OR-DW-ehn"/>
<constraint firstAttribute="trailing" secondItem="cGu-OY-P4R" secondAttribute="trailing" id="9Xe-7j-CVp"/>
<constraint firstItem="cGu-OY-P4R" firstAttribute="height" secondItem="0cT-rD-xfN" secondAttribute="height" multiplier="0.5" id="P32-P7-2sr"/>
<constraint firstAttribute="trailing" secondItem="a1x-nK-a5r" secondAttribute="trailing" id="Thr-BQ-S1n"/>
<constraint firstAttribute="bottom" secondItem="cGu-OY-P4R" secondAttribute="bottom" id="MR2-a7-hda"/>
<constraint firstItem="cGu-OY-P4R" firstAttribute="top" secondItem="0cT-rD-xfN" secondAttribute="top" id="UlT-El-Qs2"/>
<constraint firstAttribute="bottom" secondItem="a1x-nK-a5r" secondAttribute="bottom" id="WfI-SI-Zh4"/>
<constraint firstItem="a1x-nK-a5r" firstAttribute="top" secondItem="cGu-OY-P4R" secondAttribute="bottom" id="uvz-SI-Sqb"/>
<constraint firstItem="a1x-nK-a5r" firstAttribute="leading" secondItem="0cT-rD-xfN" secondAttribute="leading" id="vEN-Ay-DEB"/>
</constraints>
</view>
</subviews>
......@@ -120,4 +108,7 @@
</connections>
</collectionViewCell>
</objects>
<resources>
<image name="ic_sell_out" width="26" height="16"/>
</resources>
</document>
......@@ -15,6 +15,7 @@
-(void)kwm_clickCollectionCell:(BUYProduct *)product;
@optional
-(void)kwm_loadNewPage:(BOOL)isSameBrand;
@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>
......@@ -12,8 +12,9 @@
#import "KWMVariantsVC.h"
#import "KWMFirstDetailView.h"
#import "KWMSecondDetailView.h"
#import "KWMMidDetailView.h"
@interface KWMNewProductVC : KWMBaseVC<KWMFirstDetailViewDelegate,KWMVariantsVCDelegate>
@interface KWMNewProductVC : KWMBaseVC<KWMFirstDetailViewDelegate,KWMVariantsVCDelegate,KWMSecondDetailViewDelegate>
@property(nonatomic) BUYProduct *product;
......
......@@ -18,9 +18,11 @@
@class KWMVariantsVC;
@protocol KWMVariantsVCDelegate <NSObject>
@optional
- (void)kwm_addShopWithVariantId:(NSNumber *) identifier quantity:(NSInteger) quantity variant:(BUYProductVariant *) variant buyNow:(BOOL) buyNow callback:(void(^)(BOOL)) callback;
- (void)kwm_setVariant:(KWMVariantsVC *)variantsVC variant:(BUYProductVariant *)variant color:(KWMColor *)color;
@optional
- (void)kwm_setVariant:(KWMVariantsVC *)variantsVC variant:(BUYProductVariant *)variant color:(KWMColor *)color count:(NSInteger)count;
@end
@interface KWMVariantsVC : KWMBaseVC<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
......@@ -31,6 +33,9 @@
//required 商品模型,必须有
@property (nonatomic) BUYProduct *product;
//optional 可以传也可以不传,与product对应,用于填充库存显示
@property (nonatomic) KWMProduct *adminProduct;
//optional 有颜色可选时,需要赋值该字段.
@property (nonatomic) NSArray<KWMColor *> *colorArray;
......@@ -40,4 +45,6 @@
//optional 购物车页跳转来时,需要赋值该字段。
@property (nonatomic) KWMShopCartModel *shopCartModel;
-(void)setDefaultSelect:(BUYProductVariant *)variant color:(KWMColor *)color count:(NSInteger)count;
@end
......@@ -12,6 +12,7 @@
#import "KWMProductSizeCell.h"
#import "KWMProductColorCell.h"
#import "KWMCurrencyUtil.h"
#import "KWMStringUtil.h"
#import "BUYProductVariant+Currency.h"
#import "UIColor+SAMAdditions.h"
......@@ -25,8 +26,6 @@
@property(nonatomic) IBOutlet UILabel *lbCount;
@property(nonatomic) NSInteger count;
@property(nonatomic) NSDecimalNumber *totalPrice;
......@@ -69,6 +68,12 @@
return [NSArray array];
}
-(void)setDefaultSelect:(BUYProductVariant *)variant color:(KWMColor *)color count:(NSInteger)count{
self.selectColor = color;
self.selectVariant = variant;
self.count = count;
}
-(void)setAdminVariantArray:(NSArray<KWMVariants *> *)adminVariantArray{
_adminVariantArray = adminVariantArray;
if(adminVariantArray && self.selectVariant){
......@@ -82,11 +87,18 @@
-(void)setProduct:(BUYProduct *)product{
_product = product;
if(!_variantArray && product){
if(product){
self.variantArray = product.variantsArray;
}
}
-(void)setAdminProduct:(KWMProduct *)adminProduct{
_adminProduct = adminProduct;
if(adminProduct){
self.adminVariantArray = adminProduct.variants;
}
}
-(void)setShopCartModel:(KWMShopCartModel *)shopCartModel{
_shopCartModel = shopCartModel;
if(shopCartModel && self.variantArray){
......@@ -100,17 +112,28 @@
}
-(void)initView{
if(self.product && self.colorArray){
[self initDefaultColor];
[self initUI];
[self initCollectionView];
[self initContentHeight];
if(!self.adminProduct){
[self requestAdminProduct:self.product.identifier];
}
}
-(void)initDefaultColor{
if(self.product && self.colorArray && !self.selectColor){
for(KWMColor *color in self.colorArray){
if([color.handle isEqual:self.product.handle]){
self.selectColor = color;
break;
self.selectColor.adminProduct = self.adminProduct;
return;
}
}
}else if(self.selectColor && self.selectColor.product){
self.variantArray = self.selectColor.product.variantsArray;
}
[self initUI];
[self initCollectionView];
[self initContentHeight];
}
-(void)initUI{
......@@ -135,32 +158,9 @@
//初始化佈局高度
-(void)initContentHeight{
if(self.product != nil && self.product.variantsArray!=nil){
NSInteger sizesHeight = 0;
{
NSInteger cellCount = self.product.variantsArray.count;
if(cellCount <=0){
return;
}
NSInteger cellWidth = (UI_SCREEN_WIDTH - (30 + 30) - (10*3)) / 3;
NSInteger cellHeight = cellWidth * 0.4;
NSInteger lineCount = (cellCount +2) / 3;
sizesHeight = lineCount * cellHeight + 12 *(lineCount - 1) + 45;
}
NSInteger colorsHeight = 0;
{
NSInteger cellCount = 8;
NSInteger cellWidth = 50;
NSInteger cellHeight = 70;
NSInteger lineItmesNum = (UI_SCREEN_WIDTH - 70 - 12) / (12 + cellWidth);
NSInteger lineCount = (cellCount + lineItmesNum -1) / lineItmesNum;
colorsHeight = lineCount * cellHeight + 12 *(lineCount - 1) + 45;
}
NSInteger contentHeight = 173 + sizesHeight + colorsHeight;
NSInteger maxHeight = UI_SCREEN_HEITHT * 0.8;
self.vContentHeight.constant = fminl(contentHeight,maxHeight);
}
CGFloat height = self.cvVariants.collectionViewLayout.collectionViewContentSize.height;
self.vContentHeight.constant = height + 173;
[self.view layoutIfNeeded];
}
-(IBAction)onClickAdd:(id)sender{
......@@ -197,25 +197,25 @@
[self showToast:@"请选择您想要的规格"];
return;
}
// if (self.product && !self.product.JSONDictionary){
// [self showToast:@"该商品信息缺失"];
// return;
// }
// BOOL buyNow = sender.tag == 1;
// __weak id this = self;
// [self showLoading];
// if (self.delegate) {
// [self.delegate kwm_addShopWithVariantId:self.selectVariant.identifier quantity:self.count variant:self.selectVariant buyNow:buyNow callback:^(BOOL success) {
// [self hideLoading];
// if(success) {
// [this dismissViewControllerAnimated:YES completion:nil];
// }
// }];
// }
//商品详情页现在不是添加到购物车了,而是先显示。
//所以现在是回调出去。各个页面需要干嘛自己干嘛。
[self.delegate kwm_setVariant:self variant:self.selectVariant color:self.selectColor];
//购物车页面
if ([self.delegate respondsToSelector:@selector(kwm_addShopWithVariantId:quantity:variant:buyNow:callback:)]){
__weak id this = self;
[self showLoading];
if (self.delegate) {
[self.delegate kwm_addShopWithVariantId:self.selectVariant.identifier quantity:self.count variant:self.selectVariant buyNow:false callback:^(BOOL success) {
[self hideLoading];
if(success) {
[this dismissViewControllerAnimated:YES completion:nil];
}
}];
}
}
//商品详情页.愿望单页
//商品详情页现在不是添加到购物车了,而是先显示。所以现在是回调出去。
if ([self.delegate respondsToSelector:@selector(kwm_setVariant:variant:color:count:)]){
[self.delegate kwm_setVariant:self variant:self.selectVariant color:self.selectColor count:self.count];
[self dismissViewControllerAnimated:YES completion:nil];
}
}
-(IBAction)onClickBg:(id)sender{
......@@ -270,7 +270,7 @@
BUYProductVariant *variant = [self.variantArray objectAtIndex:indexPath.row];
KWMVariants *adminVariant = nil;
if(self.adminVariantArray && self.adminVariantArray.count>indexPath.row){
if(self.adminVariantArray){
for(KWMVariants *mAdminVariant in self.adminVariantArray){
if([variant.identifier isEqualToNumber:mAdminVariant.id]){
adminVariant = mAdminVariant;
......@@ -308,9 +308,9 @@
if(indexPath.section == 0){
BUYProductVariant *variant = [self.variantArray objectAtIndex:indexPath.row];
KWMVariants *adminVariant = nil;
if(self.adminVariantArray && self.adminVariantArray.count>indexPath.row){
if(self.adminVariantArray){
for(KWMVariants *mAdminVariant in self.adminVariantArray){
if(variant.identifier.integerValue == mAdminVariant.id.integerValue){
if([variant.identifier isEqualToNumber:mAdminVariant.id]){
adminVariant = mAdminVariant;
}
}
......@@ -328,10 +328,19 @@
[self initUI];
}else if(indexPath.section == 1){
KWMColor *color = [self.colorArray objectAtIndex:indexPath.row];
if(!color.product){
return;
}
self.selectColor = color;
self.variantArray = self.selectColor.prodcut.variantsArray;
self.selectVariant = nil;
self.selectAdminVariant = nil;
self.variantArray = color.product.variantsArray;
self.adminVariantArray = color.adminProduct?color.adminProduct.variants:nil;
[self.cvVariants reloadData];
//TODO 这里还需要更新页面高度。
[self initContentHeight];
if(!self.adminVariantArray){
[self requestAdminProduct:self.selectColor.product.identifier];
}
}
}
......@@ -350,6 +359,13 @@
NSArray<KWMVariants *> *adminVariants = adminProduct.variants;
weakSelf.adminVariantArray = adminVariants;
[weakSelf.cvVariants reloadData];
if(weakSelf.colorArray){
for(KWMColor *color in weakSelf.colorArray){
if(color.product && [color.product.identifier isEqualToNumber:productId]){
color.adminProduct = adminProduct;
}
}
}
}
};
[self.api getAdminProduct:nil productId:productId success:success failure:failure];
......@@ -362,7 +378,7 @@
isSellOut = variant.availableValue;
}
if(adminVariant && !isSellOut){
isSellOut = adminVariant.inventoryQuantity.integerValue == 0;
isSellOut = adminVariant.inventoryQuantity.integerValue <= 0;
}
return isSellOut;
}
......
......@@ -193,7 +193,6 @@
[weakSelf.tbvWish reloadData];
[weakSelf requestProductsApi];
}
};
[self.api getWishList:parament success:success failure:failure];
[self showLoading];
......
......@@ -9,8 +9,10 @@
#import "KWMBaseVC.h"
#import "KWMShopCarCell.h"
#import "KWMDeleteView.h"
#import "KWMVariantsVC.h"
@interface KWMShopCartVC : KWMBaseVC<KWMShopCarDelegate,KWMDeleteDelegate,UITableViewDelegate,UITableViewDataSource>
@interface KWMShopCartVC : KWMBaseVC<KWMShopCarDelegate,KWMDeleteDelegate,KWMVariantsVCDelegate,UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tbvCart;
......
......@@ -17,7 +17,7 @@
#import "KWMStringUtil.h"
#import "KWMShoppingCart.h"
@interface KWMShopCartVC ()<KWMSelectSizeVCDelegate>
@interface KWMShopCartVC ()
@property (nonatomic) NSMutableArray *shopCartList;
@end
......@@ -125,39 +125,31 @@
[self showLoading];
[self.client getProductById:shopCartModel.product_id completion:^(BUYProduct * _Nullable product, NSError * _Nullable error) {
[this hideLoading];
this.definesPresentationContext = YES;
KWMSelectSizeVC *editVC = (KWMSelectSizeVC *)[KWMBaseVC findControllerBy:[KWMSelectSizeVC kwmTag] fromStoryboard:@"ShopCart"];
editVC.delegate = this;
// BUYProduct * product = [[BUYProduct alloc] initWithModelManager:self.client.modelManager JSONDictionary:shopCartModel.shopCartDict];
editVC.isShopcart = YES;
editVC.product = product;
editVC.shopCartModel = shopCartModel;
editVC.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
editVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
editVC.providesPresentationContextTransitionStyle = YES;
editVC.definesPresentationContext = YES;
[this presentViewController:editVC animated:YES completion:nil];
}];
if(product){
KWMVariantsVC *variantsVC = (KWMVariantsVC *)[KWMVariantsVC findControllerBy:[KWMVariantsVC kwmTag] fromStoryboard:@"NewProduct"];
variantsVC.product = product;
variantsVC.delegate = self;
variantsVC.shopCartModel = shopCartModel;
CGSize size = [UIScreen mainScreen].bounds.size;
[self showPresentation:variantsVC size:size tapOutsideClose:YES style:MZFormSheetPresentationTransitionStyleFade];
}
//設置背景為透明
// if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
// this.definesPresentationContext = YES;
// KWMSelectSizeVC *editVC = (KWMSelectSizeVC *)[KWMBaseVC findControllerBy:[KWMSelectSizeVC kwmTag] fromStoryboard:@"ShopCart"];
// editVC.delegate = this;
// editVC.isShopcart = YES;
// editVC.product = product;
// editVC.shopCartModel = shopCartModel;
//
// editVC.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
// editVC.modalPresentationStyle = UIModalPresentationOverCurrentContext;
// editVC.providesPresentationContextTransitionStyle = YES;
// editVC.definesPresentationContext = YES;
// [self presentViewController:editVC animated:YES completion:nil];
// [this presentViewController:editVC animated:YES completion:nil];
}];
//下面這個方法在9.0的模擬器上嘗試發現失敗,8.0以下沒試過,不過官方模擬器都沒有8.0以下的可以下載了,也沒有支持的必要。
// }else{
// editVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
// self.view.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
// [self presentViewController:editVC animated:NO completion:nil];
// self.view.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen;
// }
}
#pragma mark -- KWMSelectSizeVCDelegate
......
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