123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- //
- // MyDelegateDetailViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/4/21.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- import BetterSegmentedControl
- class MyDelegateDetailViewController: BaseViewController, UITableViewDelegate, UITableViewDataSource {
- @IBOutlet var control2: BetterSegmentedControl!
- @IBOutlet weak var lblAmountMoney: UILabel!
- @IBOutlet weak var lblShopCount: UILabel!
- @IBOutlet weak var tableView: UITableView!
- @IBOutlet weak var lblDate: UILabel!
- @IBOutlet weak var lblNo: UILabel!
- @IBOutlet weak var lblName: UILabel!
- @IBOutlet weak var imgIcon: UIImageView!
- var id = ""
- override func viewDidLoad() {
- super.viewDidLoad()
- self.title = "代理详情"
- initNavLeftBackButton()
- lblName.text = getString(key: "realName")
- lblNo.text = "推荐码:\(getString(key: "recCode"))"
- let isAuth = getIntValue(key: "isAuthentication")
- if isAuth == 2 {
- lblDate.text = "认证时间:\(getString(key: "auditTime"))"
- } else {
- lblDate.text = "认证时间:未认证"
- }
- imgIcon.loadImage(imgUrl: getString(key: "headPortrait"), defaultImage: "ion_index_01")
- imgIcon.setCornerRadius()
- tableView.register(UINib(nibName: "MyDelegateDetailTableViewCell", bundle: nil), forCellReuseIdentifier: "MyDelegateDetailTableViewCell")
- tableView.delegate = self
- tableView.dataSource = self
- tableView.separatorStyle = .none
- tableView.showsVerticalScrollIndicator = false
- tableView.estimatedRowHeight = 100
- tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in
- self!.currentPage = 1
- self!.loadData()
- })
- tableView.mj_header?.lastUpdatedTimeKey = "ShowTableViewCell"
- tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in
- self!.currentPage += 1
- self!.loadData()
- })
- control2.segments = LabelSegment.segments(withTitles: ["代理", "伙伴"],
- normalTextColor: .gray,
- selectedTextColor: .white)
- let userType = getIntValue(key: "userType")
- control2.index = userType == 1 ? 1 : 0
- let dicUser = CommonValue.getLoginUserInfo()
- var userTypeUser = dicUser!.getInt(key: "userType")
- control2.isHidden = userTypeUser == 1 ? true : false
- loadDataInfo()
- }
- // MARK: =============加载数据===============
- func loadData() {
- let url = RequestURL.sumTransactionListPage
- let params = NSMutableDictionary()
- params.setValue(id, forKey: "userId")
- loadDataList(url: url, params: params, tableView: tableView, tag: 1001)
- }
- func loadDataInfo() {
- let url = RequestURL.agentXMInfo
- let params = NSMutableDictionary()
- params.setValue(id, forKey: "userId")
- params.setValue(id, forKey: "id")
- loadDataInfo(url: url, params: params, tag: 1002)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- tableView.reloadData()
- } else if tag == 1002 {
- lblShopCount.text = "\(getIntValue(key: "num"))"
- lblAmountMoney.text = "¥\(getDoubleValue(key: "total", defaultValue: 0.00))"
- tableView.mj_header?.beginRefreshing()
- }else if tag == 1003 {
- let userType = getIntValue(key: "userType")
- control2.index = userType == 1 ? 1 : 0
- SVProgressHUD.showSuccess(withStatus: "操作成功")
- tableView.reloadData()
- }
- }
- override func returnError(tag: Int, type: String) {
- if tag == 1002 {
- tableView.mj_header?.beginRefreshing()
- }
- }
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
- return 8
- }
- func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
- let view = UIView(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: 8))
- view.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf0f0f2, alpha: 1.0)
- return view
- }
- // MARK: TABLEVLEW 实现
- func numberOfSections(in tableView: UITableView) -> Int {
- return 1
- }
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return self.arrData.count
- }
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 45
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "MyDelegateDetailTableViewCell", for: indexPath as IndexPath) as! MyDelegateDetailTableViewCell
- //cell.lblTitle.text = getString(indexPath.row, key: "Name")
- cell.lblLeft.text = getString(current: indexPath.row, key: "sum_month")
- let str = "交易额\(getDoubleValue(current: indexPath.row, key: "amount", defaultValue: 0.00))"
- cell.lblRight.attributedText = CommonViewUntils.getAttributedStringForFont(str: str, rangs: [NSRange.init(location: 0, length: 3), NSRange.init(location: 3, length: str.length() - 3)], fonts: [UIFont.systemFont(ofSize: 10), UIFont.systemFont(ofSize: 14)])
- return cell
- }
- func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
- // let view = UIViewController()
- // view.oneGoId = self.arrData[indexPath.row]["ItemId"] as! Int
- // self.navigationController?.pushViewController(view, animated: true)
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "MyDelegateDetailViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- @IBAction func segmentedControl1ValueChanged(_ sender: BetterSegmentedControl) {
- print("The selected index is \(sender.index)")
- let url = RequestURL.editUserType
- let params = NSMutableDictionary()
- params.setValue(id, forKey: "userId")
- params.setValue(sender.index, forKey: "userType")
- loadDataInfo(url: url, params: params, tag: 1003)
- }
- }
|