188 lines
6.2 KiB
Objective-C
188 lines
6.2 KiB
Objective-C
//
|
|
// MaskTestResultVC.m
|
|
// GIGA
|
|
//
|
|
// Created by lianxiang on 2018/9/13.
|
|
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
|
//
|
|
|
|
#import "MaskTestResultVC.h"
|
|
#import "MaskResultMinViewCell.h"
|
|
#import "MaskResultPercentCell.h"
|
|
#import "MaskResultShareViewCell.h"
|
|
#import "GIGaUserFileHelper.h"
|
|
#import "UIImage+ShotImage.h"
|
|
#import "GiGaBaseAPiRequest.h"
|
|
#import "GiGaFileNanager.h"
|
|
#import <WXApi.h>
|
|
#import "MaskTestResult.h"
|
|
|
|
@interface MaskTestResultVC ()
|
|
|
|
@end
|
|
|
|
@implementation MaskTestResultVC
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
|
|
[self addNavTitile:@"测试结果"];
|
|
// Do any additional setup after loading the view.
|
|
[self.view addSubview:self.tableView];
|
|
self.tableView.delegate = self;
|
|
self.tableView.dataSource = self;
|
|
self.tableView.backgroundColor = [UIColor whiteColor];
|
|
self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
|
|
self.tableView.sectionFooterHeight = 0;
|
|
self.tableView.estimatedSectionFooterHeight= 0;
|
|
self.tableView.estimatedSectionHeaderHeight = 0;
|
|
//self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width, 30)];
|
|
self.tableView.frame = CGRectMake(0,0,KMainW, self.view.frame.size.height);
|
|
[self.tableView registerClass:[MaskResultPercentCell class] forCellReuseIdentifier:@"MaskResultPercentCell"];
|
|
[self.tableView registerClass:[MaskResultMinViewCell class] forCellReuseIdentifier:@"MaskResultMinViewCell"];
|
|
[self.tableView registerClass:[MaskResultShareViewCell class] forCellReuseIdentifier:@"MaskResultShareViewCell"];
|
|
|
|
if (!self.model) {
|
|
[self addNavTitile:@"历史测试"];
|
|
[self requstLatestTestData];
|
|
}
|
|
|
|
}
|
|
|
|
-(void)requstLatestTestData{
|
|
|
|
[self.view makeToastActivity:CSToastPositionCenter];
|
|
GiGaBaseAPiRequest *api = [GiGaBaseAPiRequest initWithRequestPath:kApiGetLatestTest method:RequestPostMethod parms:@{}];
|
|
[api requstDataWithResult:^(GiGaAPIResult *result) {
|
|
[self.view hideToastActivity];
|
|
if (result.success) {
|
|
NSDictionary *dic = result.dic;
|
|
NSDictionary *reult = dic[@"result"];
|
|
MaskTestResult *resultMode = [[MaskTestResult alloc] initWithDictionary:reult error:nil];
|
|
self.model = resultMode;
|
|
[self.tableView reloadData];
|
|
|
|
}else{
|
|
|
|
GIGA_ShowToast(result.message);
|
|
}
|
|
}];
|
|
|
|
}
|
|
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
|
return 1;
|
|
}
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
return 3;
|
|
}
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
|
|
if (indexPath.row == 0) {
|
|
static NSString *cellID = @"MaskResultPercentCell";
|
|
MaskResultPercentCell *cell =[tableView dequeueReusableCellWithIdentifier:cellID];
|
|
if (!cell) {
|
|
cell = [[MaskResultPercentCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];;
|
|
}
|
|
|
|
[cell loadCellData:self.model];
|
|
return cell;
|
|
|
|
}else if (indexPath.row == 1){
|
|
static NSString *cellID = @"MaskResultMinViewCell";
|
|
MaskResultMinViewCell *cell =[tableView dequeueReusableCellWithIdentifier:cellID];
|
|
if (!cell) {
|
|
cell = [[MaskResultMinViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];;
|
|
}
|
|
[cell loadMineWith:self.model.minute];
|
|
return cell;
|
|
}else if (indexPath.row == 2){
|
|
static NSString *cellID = @"MaskResultShareViewCell";
|
|
MaskResultShareViewCell *cell =[tableView dequeueReusableCellWithIdentifier:cellID];
|
|
if (!cell) {
|
|
cell = [[MaskResultShareViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];;
|
|
}
|
|
[cell.shareBtn addTarget:self action:@selector(shareBtnAciton) forControlEvents:UIControlEventTouchUpInside];
|
|
[cell kidTitle:self.model];
|
|
|
|
return cell;
|
|
}
|
|
return nil;
|
|
|
|
}
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
|
CGFloat viewH = KMainH - SAFE_NAV_HEIGHT;
|
|
CGFloat cellH = viewH / 3 ;
|
|
return cellH;
|
|
}
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
|
return 0.1;
|
|
}
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
|
|
|
{ return 0.1;
|
|
|
|
}
|
|
|
|
-(void)shareBtnAciton{
|
|
|
|
if (![WXApi isWXAppInstalled]) {
|
|
GIGA_ShowToast(@"未安装微信");
|
|
return;
|
|
}
|
|
|
|
UIImage *image = [UIImage saveLongImage:self.tableView];
|
|
//[[GiGaFileNanager shareInstance] saveImaeToAlBum:image];
|
|
[self jxt_showActionSheetWithTitle:@"分享微信" message:@"" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
|
|
|
|
alertMaker.addActionDefaultTitle(@"朋友");
|
|
alertMaker.addActionDefaultTitle(@"朋友圈");
|
|
alertMaker.addActionCancelTitle(@"取消");
|
|
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
|
|
|
|
if (buttonIndex==0) {
|
|
//好友
|
|
[self shareImagToWX:image scene:WXSceneSession];
|
|
|
|
|
|
}else if (buttonIndex==1){
|
|
// 朋友圈
|
|
[self shareImagToWX:image scene:WXSceneTimeline];
|
|
}
|
|
}];
|
|
}
|
|
|
|
-(void)shareImagToWX:(UIImage *)image scene:(int)scene{
|
|
WXMediaMessage *msg = [WXMediaMessage message];
|
|
UIImage * masllThumb = [GIGaUserFileHelper scaleFromImage:image toSize:CGSizeMake(100, 100)];
|
|
msg.title = @"面膜时间";
|
|
msg.description= @"极迦面膜";
|
|
[msg setThumbImage:masllThumb];
|
|
|
|
WXImageObject *imageObject = [WXImageObject object];
|
|
NSData *imageData = UIImagePNGRepresentation(image);
|
|
imageObject.imageData = imageData;
|
|
msg.mediaObject = imageObject;
|
|
|
|
SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init];
|
|
req.message = msg;
|
|
req.scene = scene;
|
|
req.bText = NO;
|
|
[WXApi sendReq:req];
|
|
|
|
}
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
|
|
@end
|