123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- //
- // MyWalletViewController.swift
- // xingchuangke
- //
- // Created by Virgil on 2019/4/11.
- // Copyright © 2019 Virgil. All rights reserved.
- //
- import UIKit
- class MyWalletViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate, WalletHeaderViewDelegate {
- @IBOutlet weak var view4: UIView!
- @IBOutlet weak var view3: UIView!
- @IBOutlet weak var viewLine2: UIView!
- @IBOutlet weak var viewLine1: UIView!
- @IBOutlet weak var tableView: UITableView!
- @IBOutlet weak var viewTop: UIView!
- @IBOutlet weak var lblSumMoney: UILabel!
- @IBOutlet weak var lblMoney1: UILabel!
- @IBOutlet weak var lblMoney2: UILabel!
- @IBOutlet weak var lblMoney3: UILabel!
- @IBOutlet weak var lblMoney4: UILabel!
- @IBOutlet weak var lblYE: UILabel!
- @IBOutlet weak var viewTopContent: UIView!
- var machineType: NSString = "2"
- var headerView: MyWalletTableViewHeaderView?
- override func viewDidLoad() {
- super.viewDidLoad()
- self.title = "我的钱包"
- initNavLeftBackButton()
- initNavRightButtonForTitle(title: "提现记录", color: UIColor.white)
- if CommonValue.checkIsAS() {
- viewTopContent.setSizeHeight(height: 155)
- viewTop.setSizeHeight(height: 170)
- view3.isHidden = true
- view4.isHidden = true
- viewLine1.setSizeHeight(height: 40)
- viewLine2.isHidden = true
- }
- tableView.register(UINib(nibName: "MyWalletListTableViewCell", bundle: nil), forCellReuseIdentifier: "MyWalletListTableViewCell")
- 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()
- })
- tableView.mj_header?.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf7f7f9, alpha: 1.0)
- viewTop.removeFromSuperview()
- tableView.tableHeaderView = viewTop
- loadData()
- }
- override func btnRightMenuClick() {
- toViewController(viewController: TiXianRecordListViewController())
- }
- func reloadMoney() {
- lblYE.text = "可提现余额:\(CommonValue.getUserProfitBalance())"
- lblSumMoney.text = "\(CommonValue.getUserProfitTotal())"
- lblMoney1.text = "\(CommonValue.getUserProfitPos())"
- lblMoney2.text = "\(CommonValue.getUserProfitCard())"
- lblMoney3.text = "\(CommonValue.getUserProfitIntegral())"
- lblMoney4.text = "\(CommonValue.getUserProfitActivation())"
- }
- //btnAddTarget(view: self.view, selector: #selector(self.btnMenuClick))
- @IBAction func btnMenuClick(_ sender: AnyObject) {
- switch (sender as! UIButton).tag {
- case 1001: // 提现
- ///先查检是否有结算卡
- checkSettlementCard()
- break
- case 1002: // pos机收益
- let vc = MyWalletListViewController()
- vc.type = 0
- self.toViewController(viewController: vc)
- break
- case 1003: // 办卡收益
- let vc = MyWalletListViewController()
- vc.type = 2
- self.toViewController(viewController: vc)
- break
- case 1004: // 积分收益
- let vc = MyWalletListViewController()
- vc.type = 3
- self.toViewController(viewController: vc)
- break
- case 1005: // 激活奖励
- let vc = MyWalletListViewController()
- vc.type = 1
- self.toViewController(viewController: vc)
- break
- case 1006: // 代理商户交易产生的分润
- let vc = MyWalletListViewController()
- vc.type = 0
- self.toViewController(viewController: vc)
- break
- case 1007: // 开票规则
- let viewWeb = CommonWebViewViewController()
- viewWeb.strTitle = "开票规则"
- viewWeb.url = "\(RequestURL.sysConfigWeb)?type=invoice_rules"
- viewWeb.sourceType = 0
- appDelegate.navController.pushViewController(viewWeb, animated: true)
- break
- default:
- break
- }
- }
- // MARK: =============加载数据===============
- ///检查结算卡
- func checkSettlementCard() {
- let url = RequestURL.mySettlementCard
- let params = NSMutableDictionary()
- loadDataInfo(url: url, params: params, tag: 1001)
- }
- override func returnData(tag: Int) {
- if tag == 1001 {
- let vc = TiXianViewController()
- vc.dicData.setDic(dic: self.dicData["cardInfo"] as! NSDictionary)
- vc.isFaPiao = 1
- vc.cashFee = self.dicData.getDouble(key: "cashFee")
- self.toViewController(viewController: vc)
- // CommonUntils.AlertView(controller: self, title: nil, message: "是否开具发票?", buttons: ["是"], canCelButtonTitle: "否", style: .alert, actionHandler: {[weak self] (type, str) in
- // let vc = TiXianViewController()
- // vc.dicData.setDic(dic: self!.dicData["cardInfo"] as! NSDictionary)
- // vc.isFaPiao = 1;
- // self!.toViewController(viewController: vc);
- // }) {[weak self] in
- // let vc = TiXianViewController()
- // vc.isFaPiao = 0;
- // vc.dicData.setDic(dic: self!.dicData["cardInfo"] as! NSDictionary)
- // self!.toViewController(viewController: vc);
- // }
- } else if tag == 1002 {
- tableView.reloadData()
- }
- }
- override func returnError(tag: Int, type: String) {
- if tag == 1001 {
- if type == "010" {
- let vc = ModBankCardViewController()
- toViewController(viewController: vc)
- }
- }
- }
- // MARK: =============加载数据===============
- func loadData() {
- let url = RequestURL.walletList
- let params = NSMutableDictionary()
- params.setValue("999", forKey: "type")
- params.setValue(self.machineType, forKey: "machineTypeId")
- loadDataList(url: url, params: params, tableView: tableView, tag: 1002)
- }
- // MARK: TABLEVLEW 实现
- func numberOfSections(in tableView: UITableView) -> Int {
- return 1
- }
- func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
- return 100
- }
- func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
- if headerView == nil {
- headerView = (CommonViewUntils.getViewForXIB(xibName: "MyWalletTableViewHeaderView") as! MyWalletTableViewHeaderView)
- headerView!.delegate = self
- headerView!.initView(section: section)
- }
- return headerView
- }
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return self.arrData.count
- }
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 68
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "MyWalletListTableViewCell", for: indexPath as IndexPath) as! MyWalletListTableViewCell
- cell.lblName.text = getString(current: indexPath.row, key: "name")
- cell.lblMoney.text = "+\(getDoubleValue(current: indexPath.row, key: "wallet_amount", defaultValue: 0.0))"
- cell.lblDate.text = getString(current: indexPath.row, key: "createtime")
- cell.lblAmountMoney.text = "交易总额:\(getDoubleValue(current: indexPath.row, key: "amount_total", defaultValue: 0.0))"
- cell.lblAmountMoney.isHidden = false
- cell.lblMoney.marginTop(top: 20)
- 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)
- }
- func segmentDidClickedWithIndex(index: NSInteger) {
- if index == 0 {
- self.machineType = "2"
- } else if index == 1 {
- self.machineType = "300595e17ed94b5f8c2b3f437ce26116"
- } else if index == 2 {
- self.machineType = "f391406346e04510ab6b3be081b2e4aa"
- } else if index == 3 {
- self.machineType = "4"
- }
- self.currentPage = 1
- loadData()
- }
- override func notiReloadUser(noti: NSNotification) {
- reloadMoney()
- }
- override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- reloadMoney()
- appDelegate.reloadUserInfo()
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: "MyWalletViewController", bundle: nil)
- }
- required init?(coder aDecoder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- }
|