123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- //
- // SBTLeftMenuVCtr.swift
- // SolarBT
- //
- // Created by weclouds on 2019/4/22.
- // Copyright © 2019 weclouds. All rights reserved.
- //
- import UIKit
- import PPNetworkHelper
- import AFNetworking
- import GYSide
- class SBTLeftMenuVCtr: UIViewController {
-
- var tempCell : TempSwitchCell?
-
- lazy var tableView: UITableView = {
- let tableView = UITableView(frame: CGRect(x: 0, y: 44-KNavBarHeight , width: KSCREENWIDTH / 2, height: KSCREENHEIGHT + KNavBarHeight - 44 ), style: .plain)
- // tableView.backgroundColor = UIColor(hexString: "F8F8F8")
- tableView.delegate = self
- tableView.dataSource = self
- tableView.register(UINib(nibName: "SBTHomeCell", bundle: nil), forCellReuseIdentifier: "cell")
- return tableView
- }()
- override func viewDidLoad() {
- super.viewDidLoad()
- createUI()
- checkTheBlueToothWasActivity()
- }
-
- }
- extension SBTLeftMenuVCtr {
-
-
- func createUI(){
- view.addSubview(self.tableView)
- tableView.separatorStyle = .none
- tableView.register(VersionCell.self, forCellReuseIdentifier: "version")
- tableView.register(LeftItemCell.self, forCellReuseIdentifier: "item")
- tableView.register(TempSwitchCell.self, forCellReuseIdentifier: "tempswitch")
-
- }
- }
- extension SBTLeftMenuVCtr : UITableViewDelegate,UITableViewDataSource{
-
- func numberOfSections(in tableView: UITableView) -> Int {
- return 1
- }
-
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return 6
- }
-
-
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 50
- }
-
-
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
- return 184
- }
-
- func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
- let header = UIImageView(frame: CGRect(x: 0, y: 0, width: KSCREENWIDTH / 2 , height: 184))
-
- header.image = UIImage(named: "侧滑背景图")
-
- let iconImageV = UIImageView(image: UIImage(named: "headerIcon"))
- header.addSubview(iconImageV)
- iconImageV.layer.masksToBounds = true
- iconImageV.layer.cornerRadius = 30
- iconImageV.layer.borderColor = UIColor.white.cgColor
- iconImageV.layer.borderWidth = 1
- iconImageV.snp.makeConstraints { (make) in
- make.center.equalToSuperview()
- make.width.height.equalTo(60)
- }
-
- let versionLabel = UILabel()
- let infoDictionary = Bundle.main.infoDictionary
- let majorVersion :String? = (infoDictionary! ["CFBundleShortVersionString"] as! String)//主程序版本号
- versionLabel.text = "V" + majorVersion!
- versionLabel.textColor = UIColor.white
- versionLabel.font = UIFont(name: PingFangSC_Semibold, size: 19)
- header.addSubview(versionLabel)
- versionLabel.snp.makeConstraints { (make) in
- make.centerX.equalToSuperview()
- make.bottom.equalToSuperview().offset(-20)
- }
- return header
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- if indexPath.row == 0 {
- let cell = tableView.dequeueReusableCell(withIdentifier: "tempswitch") as! TempSwitchCell
-
- let userDef = UserDefaults.standard
- let isCentigrade = userDef.value(forKey: TEMPISCENTIGRADE) as? String
- if isCentigrade != nil{
- if isCentigrade == "1"{
- cell.isCentigrade = true
- }else if isCentigrade == "0"{
- cell.isCentigrade = false
- }
- }else{
- cell.isCentigrade = true
- }
-
- cell.selectionStyle = .none
- self.tempCell = cell
- return cell
-
- }else if indexPath.row == 2{
- let cell = tableView.dequeueReusableCell(withIdentifier: "version") as! VersionCell
-
- cell.selectionStyle = .none
- return cell
- }else {
- let cell = tableView.dequeueReusableCell(withIdentifier: "item") as! LeftItemCell
- if indexPath.row == 4 {
- cell.titleLabel.text = "Privacy_Policy".da_localizedStr()
- }else if (indexPath.row == 1){
- cell.titleLabel.text = "Client_language".da_localizedStr()
- }else if indexPath.row == 3{
- cell.titleLabel.text = "Customer_feedback".da_localizedStr()
- }else if indexPath.row == 5 {
- cell.titleLabel.text = "Simulation_experience".da_localizedStr()
- }
- cell.selectionStyle = .none
- return cell
- }
- }
-
- /*
- 温度转换 0
- 客户端语言 1
- 客户版本 2
- 用户反馈 3
- 演示设备 4
- */
-
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- if indexPath.row == 0 {
- self.tempCell?.isCentigrade = !self.tempCell!.isCentigrade!
-
-
- if self.tempCell?.isCentigrade == true{
- let userdef = UserDefaults.standard
- userdef.set("1", forKey: TEMPISCENTIGRADE)
-
- }else{// 华氏度
- let userdef = UserDefaults.standard
- userdef.set("0", forKey: TEMPISCENTIGRADE)
- }
-
-
-
- }else if indexPath.row == 1 {
- // self.gy_sidePushViewController(viewController: SBTLanguageVCtr())
- self.cw_push(SBTLanguageVCtr())
- }else if indexPath.row == 2 {
-
- }else if indexPath.row == 3 {
- // self.gy_sidePushViewController(viewController: SBTFeedbackVCtr())
- self.cw_push(SBTFeedbackVCtr())
- }else if indexPath.row == 4{
- let vc = SBTPrivacyPolicyVCtr()
- self.cw_push(vc)
- //self.gy_sidePushViewController(viewController: vc)
-
- }else{
- let vc = SBTDeviceDetaiVCtr()
- vc.isDemo = true
- // self.gy_sidePushViewController(viewController: vc)
- self.cw_push(vc)
- }
- }
-
-
- func createBody2(_ dict : [String : String])-> Data{
- var body = Data()
- //添加参数数据
- for (key,value) in dict {
- body.append("Content-Disposition: form-data; name=\"\(key)\"\r\n\r\n")
- body.append("\(value)\r\n")
- }
- return body
- }
-
- func createBody1(_ dict : [String : [Data]])-> Data{
- var body = Data()
- //添加参数数据
- for (key,value) in dict {
- body.append("Content-Disposition: form-data; name=\"\(key)\"\r\n\r\n")
- // for data in value{
- // body.append("\(data)\r\n")
- // }
- body.append("\(value)\r\n")
- }
- return body
- }
- }
|