12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- //
- // ASProductBaseModel.m
- // Asteria
- //
- // Created by iOS on 2023/6/1.
- //
- #import "ASProductBaseModel.h"
- @implementation ASProductBaseModel
- + (ASProductBaseModel*)demoModel {
- ASProductBaseModel *m = [[ASProductBaseModel alloc] init];
- m.img = @"https://marketplace.canva.cn/O0eQI/MADvnEO0eQI/1/screen_2x/canva-surprised-asian-girl-with-pretty-smile-in-pinup-makeup-style-MADvnEO0eQI.jpg";
- m.title = @"Transparent Wigs Brazilian Front Wigs Straight Hair Transparent Wigs Brazilian Front Wigs Straight Hair ";
- m.sketchy_app = @"Transparent Wigs Brazilian Front Wigs Straight Hair Body Wave…";
- m.discount_app = @"10%";
- if (arc4random()%2 == 1) {
- m.oldPrice = @"";
- } else {
- m.oldPrice = @"234.43";
- }
- if (arc4random()%2 == 1) {
- m.sketchy_app = @"";
- }
- m.Id = @(arc4random()%12130).stringValue;
- m.nowPrice = @"223.45";
- m.rate_star = [NSString stringWithFormat:@"%u",arc4random()%90 + 2];
- m.sale_num = @"324123";
- return m;
- }
- - (NSString *)currencySymbol {
- if (_currencySymbol == nil) {
- return @"";
- }
- return _currencySymbol;
- }
- - (NSString *)nowPrice {
- NSDecimalNumber *num = [NSDecimalNumber decimalNumberWithString:_nowPrice];
- if (num == [NSDecimalNumber decimalNumberWithString:@"NaN"]) {
- num = [NSDecimalNumber decimalNumberWithString:@"0"];
- }
- return [NSString stringWithFormat:@"%@%.2f",self.currencySymbol, num.doubleValue];
- }
- - (NSString *)oldPrice {
- NSDecimalNumber *num = [NSDecimalNumber decimalNumberWithString:_oldPrice];
- if (num == [NSDecimalNumber decimalNumberWithString:@"NaN"]) {
- num = [NSDecimalNumber decimalNumberWithString:@"0"];
- }
- return [NSString stringWithFormat:@"%@%.2f",self.currencySymbol, num.doubleValue];
- }
- - (NSString *)img {
- if ([_img hasPrefix:@"http"]) {
- return _img;
- }
- return [NSString stringWithFormat:@"https://%@%@%@",HostPath, ProductImgPath, _img];
- }
- - (NSString *)sale_num {
- return [NSString stringWithFormat:@"%ldK", _sale_num.integerValue/1000];
- }
- + (NSDictionary *)mj_replacedKeyFromPropertyName {
- return @{
- @"Id": @"entity_id",
- @"oldPrice": @"price",
- @"nowPrice":@"final_price",
- @"img":@"image",
- @"title":@"name",
- @"sketchy_app":@"short_description"
- };
- }
- @end
|