ProgramViewController.swift
5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
//
// ProgramViewController.swift
// ParentAssistant
//
// Created by Cao yang on 2018/4/10.
// Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
//
import UIKit
class ProgramViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
lazy var tableView = {()->UITableView in
let table = UITableView.init()
table.backgroundColor = UIColor.white
table.delegate = self
table.dataSource = self
table.tableFooterView = UIView.init()
return table
}()
lazy var empty = {()->UIView in
let emptyView = UIView.init(frame: self.view.bounds)
emptyView.backgroundColor = backGroundColor
let label1 = UILabel.init(frame: CGRect.init(x: 0, y: 50, width: screenWidth, height: 30))
label1.text = "如需使用该模块,请前往"
label1.textAlignment = .center
let label2 = UILabel.init(frame: CGRect.init(x: 0, y: 80, width: screenWidth, height: 30))
label2.text = "个人中心-我的孩子"
label2.textAlignment = .center
label2.textColor = UIColor.blue
let tapGest = UITapGestureRecognizer.init(target: self, action: #selector(gotoChildView))
label2.isUserInteractionEnabled = true
label2.addGestureRecognizer(tapGest)
let label3 = UILabel.init(frame: CGRect.init(x: 0, y: 110, width: screenWidth, height: 30))
label3.textAlignment = .center
label3.text = "绑定孩子账号"
emptyView.addSubview(label1)
emptyView.addSubview(label2)
emptyView.addSubview(label3)
return emptyView
}()
//Data
var tableData = Array<String>()
var titleImage = Array<String>()
override func viewWillAppear(_ animated: Bool) {
let array = AccountManager.shared.getChildClassInfo()
if array.isEmpty {
self.view.addSubview(self.empty)
self.tableView.isHidden = true
}else{
self.empty.removeFromSuperview()
self.tableView.isHidden = false
}
}
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = backGroundColor
self.view.addSubview(self.tableView)
tableView.snp.makeConstraints { (maker) in
maker.width.height.equalToSuperview()
maker.center.equalToSuperview()
}
self.tableData = ["考勤","补卡","请假"]
self.titleImage = ["program_check","program_card","program_leave"]
// Do any additional setup after loading the view.
}
@objc func gotoChildView () {
let vc = Story.instantiateViewControllerWithIdentifier("MyChildrenViewController", storyName: "My") as! MyChildrenViewController
self.navigationController?.pushViewController(vc, animated: true)
}
//MARK: - UITableView Delegate & DataSource
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.tableData.count
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 40
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let title = UILabel.init(frame: CGRect.init(x: 0, y: 0, width: tableView.bounds.size.width, height: 40))
title.textAlignment = .center
title.text = "智能校卫"
title.backgroundColor = UIColor.white
return title
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell.init()
cell.selectionStyle = .none
cell.textLabel?.text = self.tableData[indexPath.row]
cell.imageView?.image = UIImage.init(named: self.titleImage[indexPath.row])
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 60
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
switch indexPath.row {
case 0:
let vc = ProgramCheckViewController()
vc.title = "考勤"
self.navigationController?.pushViewController(vc, animated: true)
case 1:
let vc = ProgramCardViewController()
vc.title = "补卡"
self.navigationController?.pushViewController(vc, animated: true)
case 2:
let vc = ProgramVacateViewController()
vc.title = "请假"
self.navigationController?.pushViewController(vc, animated: true)
default:
break
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}