123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- //
- // FKRefundDetailViewModel.m
- // FirstLink
- //
- // Created by ascii on 16/3/15.
- // Copyright © 2016年 FirstLink. All rights reserved.
- //
- #import "FKRefundDetailViewModel.h"
- #import "FKRefundDetailItem.h"
- #import "FKRefundPriceItem.h"
- int const FKRefundRequestDetail = 100;
- @implementation FKRefundDetailViewModel
- - (NSInteger)numberOfSectionsInTableView {
- return self.refundGoodsArray.count;
- }
- - (NSInteger)numberOfRowsInSection:(NSInteger)section {
- if (section < self.refundGoodsArray.count) {
- FKRefundDetailItem *item = self.refundGoodsArray[section];
- return (item.goodsArray.count + 7);
- }
- return 0;
- }
- - (kRefundDetailCellType)refundCellTypeAtIndexPath:(NSIndexPath *)indexPath {
- FKRefundDetailItem *item = self.refundGoodsArray[indexPath.section];
- if (indexPath.row == 0) {
- return kRefundDetailCellTypeStatus;
- } else if (indexPath.row > 0 && indexPath.row < (item.goodsArray.count + 1)) {
- return kRefundDetailCellTypeProduct;
- } else {
- if (indexPath.row == (item.goodsArray.count + 1) ) {
- return kRefundDetailCellTypeChargeClear;
- } else {
- return kRefundDetailCellTypeEntry;
- }
- }
- return kRefundDetailCellTypeNone;
- }
- - (FKRefundDetailItem *)refundDetailItemAtIndex:(NSInteger)index {
- if (index < self.refundGoodsArray.count) {
- return self.refundGoodsArray[index];
- }
- return nil;
- }
- + (NSString *)getRefundStatusText:(int)status {
- switch (status) {
- case 0:
- return @"已取消";
- case 1:
- return @"待退款";
- case 2:
- return @"已退款";
- default:
- break;
- }
- return @"";
- }
- - (NSAttributedString *)chargeClearTitle {
- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"退款明细"];
- [attributedString addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0x999999) range:NSMakeRange(0, attributedString.length)];
- [attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:NSMakeRange(0, attributedString.length)];
-
- return attributedString;
- }
- - (NSAttributedString *)priceDetailTitle:(NSIndexPath *)indexPath {
- NSString *title = @"";
- NSString *subTitle = @"";
-
- UIColor *titleColor = UIColorFromRGB(0x333333);
- UIColor *subTitleColor = UIColorFromRGB(0x999999);
-
- FKRefundDetailItem *item = self.refundGoodsArray[indexPath.section];
- NSInteger index = (indexPath.row - item.goodsArray.count - 2);
-
- switch (index) {
- case 0: {
- title = @"商品总价";
- break;
- }
- case 1: {
- title = @"官网运费";
- break;
- }
- case 2: {
- title = @"国际运费";
- break;
- }
- case 3: {
- title = @"关税";
- break;
- }
- case 4: {
- title = @"代金券";
- break;
- }
- default:
- break;
- }
-
- NSString *string = [NSString stringWithFormat:@"%@%@", title, subTitle];
- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:string];
- [attributedString addAttribute:NSForegroundColorAttributeName
- value:titleColor
- range:NSMakeRange(0, title.length)];
- [attributedString addAttribute:NSForegroundColorAttributeName
- value:subTitleColor
- range:NSMakeRange(title.length, subTitle.length)];
-
- return attributedString;
- }
- - (NSAttributedString *)priceDetailText:(NSIndexPath *)indexPath {
- NSString *text = @"¥-.--";
- UIColor *textColor = UIColorFromRGB(0x333333);
-
- FKRefundDetailItem *item = self.refundGoodsArray[indexPath.section];
- NSInteger index = (indexPath.row - item.goodsArray.count - 2);
-
- switch (index) {
- case 0: {
- text = [NSString stringWithFormat:@"¥%.2f", item.refundPriceItem.totalPrice.floatValue / 100.0f];
- break;
- }
- case 1: {
- text = [NSString stringWithFormat:@"¥%.2f", item.refundPriceItem.officialPostage.floatValue / 100.0f];
- break;
- }
- case 2: {
- text = [NSString stringWithFormat:@"¥%.2f", item.refundPriceItem.internationalPostage.floatValue / 100.0f];
- break;
- }
- case 3: {
- text = [NSString stringWithFormat:@"¥%.2f", item.refundPriceItem.taxFee.floatValue / 100.0f];
- break;
- }
- case 4: {
- text = [NSString stringWithFormat:@"-¥%.2f", item.refundPriceItem.derateFee.floatValue / 100.0f];
- break;
- }
- default:
- break;
- }
-
- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];
- [attributedString addAttribute:NSForegroundColorAttributeName
- value:textColor
- range:NSMakeRange(0, text.length)];
-
- return attributedString;
- }
- @end
|