MyWalletViewController.swift 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. //
  2. // MyWalletViewController.swift
  3. // xingchuangke
  4. //
  5. // Created by Virgil on 2019/4/11.
  6. // Copyright © 2019 Virgil. All rights reserved.
  7. //
  8. import UIKit
  9. class MyWalletViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate, WalletHeaderViewDelegate {
  10. @IBOutlet weak var view4: UIView!
  11. @IBOutlet weak var view3: UIView!
  12. @IBOutlet weak var viewLine2: UIView!
  13. @IBOutlet weak var viewLine1: UIView!
  14. @IBOutlet weak var tableView: UITableView!
  15. @IBOutlet weak var viewTop: UIView!
  16. @IBOutlet weak var lblSumMoney: UILabel!
  17. @IBOutlet weak var lblMoney1: UILabel!
  18. @IBOutlet weak var lblMoney2: UILabel!
  19. @IBOutlet weak var lblMoney3: UILabel!
  20. @IBOutlet weak var lblMoney4: UILabel!
  21. @IBOutlet weak var lblYE: UILabel!
  22. @IBOutlet weak var viewTopContent: UIView!
  23. var machineType: NSString = "2"
  24. var headerView: MyWalletTableViewHeaderView?
  25. override func viewDidLoad() {
  26. super.viewDidLoad()
  27. self.title = "我的钱包"
  28. initNavLeftBackButton()
  29. initNavRightButtonForTitle(title: "提现记录", color: UIColor.white)
  30. if CommonValue.checkIsAS() {
  31. viewTopContent.setSizeHeight(height: 155)
  32. viewTop.setSizeHeight(height: 170)
  33. view3.isHidden = true
  34. view4.isHidden = true
  35. viewLine1.setSizeHeight(height: 40)
  36. viewLine2.isHidden = true
  37. }
  38. tableView.register(UINib(nibName: "MyWalletListTableViewCell", bundle: nil), forCellReuseIdentifier: "MyWalletListTableViewCell")
  39. tableView.delegate = self
  40. tableView.dataSource = self
  41. tableView.separatorStyle = .none
  42. tableView.showsVerticalScrollIndicator = false
  43. tableView.estimatedRowHeight = 100
  44. tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in
  45. self!.currentPage = 1
  46. self!.loadData()
  47. })
  48. tableView.mj_header?.lastUpdatedTimeKey = "ShowTableViewCell"
  49. tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in
  50. self!.currentPage += 1
  51. self!.loadData()
  52. })
  53. tableView.mj_header?.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf7f7f9, alpha: 1.0)
  54. viewTop.removeFromSuperview()
  55. tableView.tableHeaderView = viewTop
  56. loadData()
  57. }
  58. override func btnRightMenuClick() {
  59. toViewController(viewController: TiXianRecordListViewController())
  60. }
  61. func reloadMoney() {
  62. lblYE.text = "可提现余额:\(CommonValue.getUserProfitBalance())"
  63. lblSumMoney.text = "\(CommonValue.getUserProfitTotal())"
  64. lblMoney1.text = "\(CommonValue.getUserProfitPos())"
  65. lblMoney2.text = "\(CommonValue.getUserProfitCard())"
  66. lblMoney3.text = "\(CommonValue.getUserProfitIntegral())"
  67. lblMoney4.text = "\(CommonValue.getUserProfitActivation())"
  68. }
  69. //btnAddTarget(view: self.view, selector: #selector(self.btnMenuClick))
  70. @IBAction func btnMenuClick(_ sender: AnyObject) {
  71. switch (sender as! UIButton).tag {
  72. case 1001: // 提现
  73. ///先查检是否有结算卡
  74. checkSettlementCard()
  75. break
  76. case 1002: // pos机收益
  77. let vc = MyWalletListViewController()
  78. vc.type = 0
  79. self.toViewController(viewController: vc)
  80. break
  81. case 1003: // 办卡收益
  82. let vc = MyWalletListViewController()
  83. vc.type = 2
  84. self.toViewController(viewController: vc)
  85. break
  86. case 1004: // 积分收益
  87. let vc = MyWalletListViewController()
  88. vc.type = 3
  89. self.toViewController(viewController: vc)
  90. break
  91. case 1005: // 激活奖励
  92. let vc = MyWalletListViewController()
  93. vc.type = 1
  94. self.toViewController(viewController: vc)
  95. break
  96. case 1006: // 代理商户交易产生的分润
  97. let vc = MyWalletListViewController()
  98. vc.type = 0
  99. self.toViewController(viewController: vc)
  100. break
  101. case 1007: // 开票规则
  102. let viewWeb = CommonWebViewViewController()
  103. viewWeb.strTitle = "开票规则"
  104. viewWeb.url = "\(RequestURL.sysConfigWeb)?type=invoice_rules"
  105. viewWeb.sourceType = 0
  106. appDelegate.navController.pushViewController(viewWeb, animated: true)
  107. break
  108. default:
  109. break
  110. }
  111. }
  112. // MARK: =============加载数据===============
  113. ///检查结算卡
  114. func checkSettlementCard() {
  115. let url = RequestURL.mySettlementCard
  116. let params = NSMutableDictionary()
  117. loadDataInfo(url: url, params: params, tag: 1001)
  118. }
  119. override func returnData(tag: Int) {
  120. if tag == 1001 {
  121. let vc = TiXianViewController()
  122. vc.dicData.setDic(dic: self.dicData["cardInfo"] as! NSDictionary)
  123. vc.isFaPiao = 1
  124. vc.cashFee = self.dicData.getDouble(key: "cashFee")
  125. self.toViewController(viewController: vc)
  126. // CommonUntils.AlertView(controller: self, title: nil, message: "是否开具发票?", buttons: ["是"], canCelButtonTitle: "否", style: .alert, actionHandler: {[weak self] (type, str) in
  127. // let vc = TiXianViewController()
  128. // vc.dicData.setDic(dic: self!.dicData["cardInfo"] as! NSDictionary)
  129. // vc.isFaPiao = 1;
  130. // self!.toViewController(viewController: vc);
  131. // }) {[weak self] in
  132. // let vc = TiXianViewController()
  133. // vc.isFaPiao = 0;
  134. // vc.dicData.setDic(dic: self!.dicData["cardInfo"] as! NSDictionary)
  135. // self!.toViewController(viewController: vc);
  136. // }
  137. } else if tag == 1002 {
  138. tableView.reloadData()
  139. }
  140. }
  141. override func returnError(tag: Int, type: String) {
  142. if tag == 1001 {
  143. if type == "010" {
  144. let vc = ModBankCardViewController()
  145. toViewController(viewController: vc)
  146. }
  147. }
  148. }
  149. // MARK: =============加载数据===============
  150. func loadData() {
  151. let url = RequestURL.walletList
  152. let params = NSMutableDictionary()
  153. params.setValue("999", forKey: "type")
  154. params.setValue(self.machineType, forKey: "machineTypeId")
  155. loadDataList(url: url, params: params, tableView: tableView, tag: 1002)
  156. }
  157. // MARK: TABLEVLEW 实现
  158. func numberOfSections(in tableView: UITableView) -> Int {
  159. return 1
  160. }
  161. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  162. return 100
  163. }
  164. func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
  165. if headerView == nil {
  166. headerView = (CommonViewUntils.getViewForXIB(xibName: "MyWalletTableViewHeaderView") as! MyWalletTableViewHeaderView)
  167. headerView!.delegate = self
  168. headerView!.initView(section: section)
  169. }
  170. return headerView
  171. }
  172. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  173. return self.arrData.count
  174. }
  175. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  176. return 68
  177. }
  178. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  179. let cell = tableView.dequeueReusableCell(withIdentifier: "MyWalletListTableViewCell", for: indexPath as IndexPath) as! MyWalletListTableViewCell
  180. cell.lblName.text = getString(current: indexPath.row, key: "name")
  181. cell.lblMoney.text = "+\(getDoubleValue(current: indexPath.row, key: "wallet_amount", defaultValue: 0.0))"
  182. cell.lblDate.text = getString(current: indexPath.row, key: "createtime")
  183. cell.lblAmountMoney.text = "交易总额:\(getDoubleValue(current: indexPath.row, key: "amount_total", defaultValue: 0.0))"
  184. cell.lblAmountMoney.isHidden = false
  185. cell.lblMoney.marginTop(top: 20)
  186. return cell
  187. }
  188. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  189. // let view = UIViewController()
  190. // view.oneGoId = self.arrData[indexPath.row]["ItemId"] as! Int
  191. // self.navigationController?.pushViewController(view, animated: true)
  192. }
  193. func segmentDidClickedWithIndex(index: NSInteger) {
  194. if index == 0 {
  195. self.machineType = "2"
  196. } else if index == 1 {
  197. self.machineType = "300595e17ed94b5f8c2b3f437ce26116"
  198. } else if index == 2 {
  199. self.machineType = "f391406346e04510ab6b3be081b2e4aa"
  200. } else if index == 3 {
  201. self.machineType = "4"
  202. }
  203. self.currentPage = 1
  204. loadData()
  205. }
  206. override func notiReloadUser(noti: NSNotification) {
  207. reloadMoney()
  208. }
  209. override func viewWillAppear(_ animated: Bool) {
  210. super.viewWillAppear(animated)
  211. reloadMoney()
  212. appDelegate.reloadUserInfo()
  213. }
  214. override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
  215. super.init(nibName: "MyWalletViewController", bundle: nil)
  216. }
  217. required init?(coder aDecoder: NSCoder) {
  218. fatalError("init(coder:) has not been implemented")
  219. }
  220. }