宠物店修改

This commit is contained in:
kai60
2020-05-02 14:56:49 +08:00
parent 8fca79324a
commit 53f06fcf43
100 changed files with 2672 additions and 198 deletions
@@ -0,0 +1,19 @@
//
// PetStoresViewController.h
// Ifish
//
// Created by 祝发冬 on 2020/4/19.
// Copyright © 2020 lianlian. All rights reserved.
//
#import "BaseViewController.h"
#import "FormatTankAddCamera.h"
NS_ASSUME_NONNULL_BEGIN
@interface PetStoresViewController : BaseViewController<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) FormatTankAddCamera *store;//一个商店的
@end
NS_ASSUME_NONNULL_END
@@ -0,0 +1,134 @@
//
// PetStoresViewController.m
// Ifish
//
// Created by 祝发冬 on 2020/4/19.
// Copyright © 2020 lianlian. All rights reserved.
//
#import "PetStoresViewController.h"
#import "IfishDataUnity.h"
#import "IfishDeviceInfo.h"
@interface PetStoresViewController ()
@end
@implementation PetStoresViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self addTitleViewWithTitle:self.store.deviceName];
// Do any additional setup after loading the view from its nib.
}
-(void)addTitleViewWithTitle:(NSString *)title
{
UIButton*button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(0, 0, kSizeFrom750(300), 44);
[button setTitle:title forState:UIControlStateNormal];
button.titleLabel.font=[UIFont systemFontOfSize:19];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(changeStoreName:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.titleView=button;
}
-(void)changeStoreName:(UIButton*)button
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"修改名称" message:nil preferredStyle:UIAlertControllerStyleAlert];
//增加确定按钮;
[alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//获取第1个输入框;
UITextField *passTextField = alertController.textFields.firstObject;
NSString*name=passTextField.text;
if (name.length)
{
NSString*url=[NSString stringWithFormat:@"%@/api/user/updatePetStore.do",JIEKOUPORT];
UserModel*model=[dataContorl getUserInfo];
[AFHttpTool requestWihtMethod:RequestMethodTypePost url:url params:@{@"userId":model.userId,@"oldName":self.store.deviceName,@"newName":name} success:^(id response) {
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
NSLog(@"data:%@",resultDic[@"data"]);
;
if ([resultDic[@"result"] isEqualToString:@"100"]) {
[self.view makeToast:@"修改成功"];
self.store.deviceName=name;
[self addTitleViewWithTitle:name];
[[NSNotificationCenter defaultCenter]postNotificationName:@"updateUserInfobyValidation" object:nil];
}
else
{
[self.view makeToast:@"修改失败"];
}
} failure:^(NSError *err) {
[self.view makeToast:@"修改失败"];
}];
}
else
{
[self.view makeToast:@"名字不能为空"];
}
}]];
[alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]];
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.text = self.store.deviceName;
}];
[self presentViewController:alertController animated:true completion:nil];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.store.list.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"pets"];
DeviceModel*model= self.store.list[indexPath.row];
if (!cell)
{
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"pets"];
}
cell.textLabel.text=model.showName;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DeviceModel*model= self.store.list[indexPath.row];
[[Socketsingleton sharedInstance] cutOffSocket];
[[IfishDataUnity shareDataInstance] initAppCenterVcWith:model addWithdissMisVc:nil];
[[DataCenter defaultDtacenter].cache setString:model.macAddress forKey:@"currentPetDevice"];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="PetStoresViewController">
<connections>
<outlet property="tableView" destination="dhT-8j-hrA" id="VhX-4j-Uvk"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<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" alwaysBounceVertical="YES" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="dhT-8j-hrA">
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="dataSource" destination="-1" id="UHm-GH-hbe"/>
<outlet property="delegate" destination="-1" id="Ys8-LQ-Ktl"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Q5M-cg-NOt" firstAttribute="bottom" secondItem="dhT-8j-hrA" secondAttribute="bottom" id="DcW-H0-oBU"/>
<constraint firstItem="dhT-8j-hrA" firstAttribute="top" secondItem="Q5M-cg-NOt" secondAttribute="top" id="NkU-Tn-cRf"/>
<constraint firstItem="dhT-8j-hrA" firstAttribute="leading" secondItem="Q5M-cg-NOt" secondAttribute="leading" id="PqU-7d-pW9"/>
<constraint firstItem="Q5M-cg-NOt" firstAttribute="trailing" secondItem="dhT-8j-hrA" secondAttribute="trailing" id="W0H-iW-gLe"/>
</constraints>
<viewLayoutGuide key="safeArea" id="Q5M-cg-NOt"/>
</view>
</objects>
</document>