ActivationSchoolCardViewController.swift 3.45 KB
//
//  ActivationSchoolCardViewController.swift
//  ParentAssistant
//
//  Created by 葛建军 on 2018/4/11.
//  Copyright © 2018年 HANGZHOUTEAM. All rights reserved.
//

import UIKit
//校卡激活页面
class ActivationSchoolCardViewController: UIViewController,UITextFieldDelegate {
    var info:StudentClassInfo!//孩子信息
    
    lazy var showView = {()-> UIView in
        let view = UIView.init(frame: CGRect.init(x: 10, y: 10, width: screenWidth-20, height: 110))
        view.backgroundColor = UIColor.white
       
        return view
    }()
    lazy var nameLable = {()-> UILabel in
        let label = UILabel.init(frame: CGRect.init(x: 100, y: 20, width: 180, height: 30))
        label.text = info.studentName
        label.textAlignment = .center
        return label
    }()
    lazy var cardNumberTextField = {()->UITextField in
        let field = UITextField.init(frame: CGRect.init(x: 100, y: 70, width:180, height: 30))
        field.delegate = self
        field.textAlignment = .center
        field.placeholder = "请输入卡号"
        return field
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = backGroundColor
        self.view.addSubview(self.showView)
        
        drawUI()
    }
    
    func drawUI(){
        
        let nameTitle = UILabel.init(frame: CGRect.init(x: 20, y: 20, width: 100, height: 30))
        nameTitle.text = "持卡人:"
        
        let cardTitle = UILabel.init(frame: CGRect.init(x: 20, y: 70, width: 100, height: 30))
        cardTitle.text = "卡号:"
        
        let btn = UIButton.init(frame: CGRect.init(x: 10, y: screenHeight-66-80, width: screenWidth-20, height: 40))
        btn.setTitle("确定", for: UIControlState.normal)
        btn.backgroundColor = Theme.topBarColor()
        btn.layer.cornerRadius = 5
        btn.clipsToBounds = true
        btn.addTarget(self, action: #selector(activationAction(_:)), for: .touchUpInside)
        
        showView.addSubview(nameTitle)
        showView.addSubview(self.nameLable)
        showView.addSubview(cardTitle)
        showView.addSubview(self.cardNumberTextField)
        
        self.view.addSubview(btn)
    }
    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
        return cardNumberTextField.resignFirstResponder()
    }
    
    // MARK: - 确定按钮
    @objc func activationAction(_ sender: UIButton) {
        if cardNumberTextField.text == "" {
            self.view.makeToast("卡号不能为空")
        }
        
        let alert = UIAlertController.init(title: "卡号:\(cardNumberTextField.text!)", message: "已成功激活!", preferredStyle: UIAlertControllerStyle.alert)
        let action = UIAlertAction.init(title: "返回", style: UIAlertActionStyle.default) { (action) in
            self.dismiss(animated: true, completion: nil)
        }
        alert.addAction(action)
        self.present(alert, animated: true, completion: nil)
    }
    
    
    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.
    }
    */

}