MoralViewController.swift 3.28 KB
//
//  MoralViewController.swift
//  ParentAssistant
//
//  Created by Cao yang on 2018/3/22.
//  Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
//

import UIKit

class MoralViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {

    @IBOutlet weak var tableView: UITableView!
    var data = Array<JSON>()
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "德育报告"
        tableView.delegate = self
        tableView.dataSource = self
        
        
        downLoadDataFromNet()
    }
    
    private func downLoadDataFromNet(){
    
        
        let params = ["screenId":1,"startDate":"2018-03-08","endDate":"2018-04-08","classId":"70","schoolId":1] as [String : Any]
    
        HTTPServer.shared.getEvaluationSceneAnalysis(parameters: params as [String : AnyObject]) { (backData, error) in
            print(backData!)
            if error == nil && JSON.fromString(backData)!["status"].intValue == 1 {
                
//                self.data = SceneEvaluate(j: JSON.fromString(backData)!.contentData())
//                if self.data != nil{
//                    print(self.data)
//                }
            }
        }
    }
    
    
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 3
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        if section == 2 {
            return 3
        }else{
            return 1
        }
    }
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        switch indexPath.section {
        case 0:
            return 240
        case 1:
            return 240
        case 2:
            return 70
        default:
            return 0
        }
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = UITableViewCell.init()
        switch indexPath.section {
        case 0:
            cell = tableView.dequeueReusableCell(withIdentifier: "moralDetail", for: indexPath)
            return cell
        case 1:
            cell = tableView.dequeueReusableCell(withIdentifier: "educationDetail", for: indexPath)
            return cell
        case 2:
            cell = tableView.dequeueReusableCell(withIdentifier: "behaviorDetail", for: indexPath)
            return cell
        default:
            return cell
        }
    }
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if indexPath.section == 2 {
            let scene = Story.instantiateViewControllerWithIdentifier("SceneDetailViewController", storyName: "Main") as! SceneDetailViewController
            self.navigationController?.pushViewController(scene, animated: true)
        }
    }
    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.
    }
    */

}