提交 25361c6f authored 作者: 逄仁秀's avatar 逄仁秀

no message

上级 24462bfb
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
88B5B9132B328F2400871A63 /* KJToRechargeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B5B9112B328F2400871A63 /* KJToRechargeViewController.swift */; }; 88B5B9132B328F2400871A63 /* KJToRechargeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B5B9112B328F2400871A63 /* KJToRechargeViewController.swift */; };
88B5B9142B328F2400871A63 /* KJToRechargeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 88B5B9122B328F2400871A63 /* KJToRechargeViewController.xib */; }; 88B5B9142B328F2400871A63 /* KJToRechargeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 88B5B9122B328F2400871A63 /* KJToRechargeViewController.xib */; };
88B5B9162B32D5EB00871A63 /* KJRechargeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B5B9152B32D5EB00871A63 /* KJRechargeModel.swift */; }; 88B5B9162B32D5EB00871A63 /* KJRechargeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B5B9152B32D5EB00871A63 /* KJRechargeModel.swift */; };
88B5B9182B34381000871A63 /* KJAddBankModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B5B9172B34381000871A63 /* KJAddBankModel.swift */; };
88BE37D82AFCC15400D04877 /* KJHomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88BE37D62AFCC15400D04877 /* KJHomeViewController.swift */; }; 88BE37D82AFCC15400D04877 /* KJHomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88BE37D62AFCC15400D04877 /* KJHomeViewController.swift */; };
88BE37D92AFCC15400D04877 /* KJHomeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 88BE37D72AFCC15400D04877 /* KJHomeViewController.xib */; }; 88BE37D92AFCC15400D04877 /* KJHomeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 88BE37D72AFCC15400D04877 /* KJHomeViewController.xib */; };
88BE37DE2AFCC19F00D04877 /* KJChargeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88BE37DC2AFCC19F00D04877 /* KJChargeViewController.swift */; }; 88BE37DE2AFCC19F00D04877 /* KJChargeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88BE37DC2AFCC19F00D04877 /* KJChargeViewController.swift */; };
...@@ -111,6 +112,7 @@ ...@@ -111,6 +112,7 @@
88B5B9112B328F2400871A63 /* KJToRechargeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJToRechargeViewController.swift; sourceTree = "<group>"; }; 88B5B9112B328F2400871A63 /* KJToRechargeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJToRechargeViewController.swift; sourceTree = "<group>"; };
88B5B9122B328F2400871A63 /* KJToRechargeViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KJToRechargeViewController.xib; sourceTree = "<group>"; }; 88B5B9122B328F2400871A63 /* KJToRechargeViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KJToRechargeViewController.xib; sourceTree = "<group>"; };
88B5B9152B32D5EB00871A63 /* KJRechargeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJRechargeModel.swift; sourceTree = "<group>"; }; 88B5B9152B32D5EB00871A63 /* KJRechargeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJRechargeModel.swift; sourceTree = "<group>"; };
88B5B9172B34381000871A63 /* KJAddBankModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJAddBankModel.swift; sourceTree = "<group>"; };
88BE37D62AFCC15400D04877 /* KJHomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJHomeViewController.swift; sourceTree = "<group>"; }; 88BE37D62AFCC15400D04877 /* KJHomeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJHomeViewController.swift; sourceTree = "<group>"; };
88BE37D72AFCC15400D04877 /* KJHomeViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KJHomeViewController.xib; sourceTree = "<group>"; }; 88BE37D72AFCC15400D04877 /* KJHomeViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KJHomeViewController.xib; sourceTree = "<group>"; };
88BE37DC2AFCC19F00D04877 /* KJChargeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJChargeViewController.swift; sourceTree = "<group>"; }; 88BE37DC2AFCC19F00D04877 /* KJChargeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJChargeViewController.swift; sourceTree = "<group>"; };
...@@ -201,6 +203,7 @@ ...@@ -201,6 +203,7 @@
880FF38D2B21A6C600872B34 /* KJAccountModel.swift */, 880FF38D2B21A6C600872B34 /* KJAccountModel.swift */,
88276FAC2B284AB0009BAE13 /* KJConfigParamModel.swift */, 88276FAC2B284AB0009BAE13 /* KJConfigParamModel.swift */,
88B5B9152B32D5EB00871A63 /* KJRechargeModel.swift */, 88B5B9152B32D5EB00871A63 /* KJRechargeModel.swift */,
88B5B9172B34381000871A63 /* KJAddBankModel.swift */,
); );
path = model; path = model;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -604,6 +607,7 @@ ...@@ -604,6 +607,7 @@
88B5B90A2B303F0800871A63 /* KJSingleChooseView.swift in Sources */, 88B5B90A2B303F0800871A63 /* KJSingleChooseView.swift in Sources */,
88BE37D82AFCC15400D04877 /* KJHomeViewController.swift in Sources */, 88BE37D82AFCC15400D04877 /* KJHomeViewController.swift in Sources */,
88BE382A2B1894F600D04877 /* KJPersonalViewController.swift in Sources */, 88BE382A2B1894F600D04877 /* KJPersonalViewController.swift in Sources */,
88B5B9182B34381000871A63 /* KJAddBankModel.swift in Sources */,
88BE380B2B0B2AC000D04877 /* KJHomeHeaderCell.swift in Sources */, 88BE380B2B0B2AC000D04877 /* KJHomeHeaderCell.swift in Sources */,
88BE38062B074D1900D04877 /* KJLoginPhoneViewController.swift in Sources */, 88BE38062B074D1900D04877 /* KJLoginPhoneViewController.swift in Sources */,
88BE38132B0C84CE00D04877 /* KJNoPayCodeViewController.swift in Sources */, 88BE38132B0C84CE00D04877 /* KJNoPayCodeViewController.swift in Sources */,
......
//
// KJAddBankModel.swift
// iOS-2kj
//
// Created by 仁秀逄 on 2023/12/21.
//
import UIKit
import HandyJSON
class KJAddBankModel: HandyJSON {
required init() {}
}
class KJBankCodeListModel: HandyJSON {
var bank_code: String?
var bank_name: String?
required init() {}
}
...@@ -61,6 +61,10 @@ class KJWithdrawViewController: KJBaseViewController { ...@@ -61,6 +61,10 @@ class KJWithdrawViewController: KJBaseViewController {
return NSDictionary() return NSDictionary()
} }
@IBAction func addNewCardAction(_ sender: Any) {
let alert = KJAddBankCodeAlert(frame: CGRect(x: 0, y: 0, width: kjWidth, height: kjHeight))
alert.show()
}
/* /*
// MARK: - Navigation // MARK: - Navigation
......
...@@ -114,6 +114,9 @@ ...@@ -114,6 +114,9 @@
<attributedString key="attributedSubtitle"/> <attributedString key="attributedSubtitle"/>
<color key="baseForegroundColor" red="0.96470588235294119" green="0.63529411764705879" blue="0.10588235294117647" alpha="1" colorSpace="calibratedRGB"/> <color key="baseForegroundColor" red="0.96470588235294119" green="0.63529411764705879" blue="0.10588235294117647" alpha="1" colorSpace="calibratedRGB"/>
</buttonConfiguration> </buttonConfiguration>
<connections>
<action selector="addNewCardAction:" destination="-1" eventType="touchUpInside" id="uDL-Um-nmx"/>
</connections>
</button> </button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vuv-J1-XqF"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vuv-J1-XqF">
<rect key="frame" x="17.666666666666657" y="759" width="358" height="49"/> <rect key="frame" x="17.666666666666657" y="759" width="358" height="49"/>
......
...@@ -20,8 +20,58 @@ class KJAddBankCodeAlert: UIView { ...@@ -20,8 +20,58 @@ class KJAddBankCodeAlert: UIView {
let whiteView = UIView(frame: CGRect(x: 25, y: (kjHeight - 287)/2.0, width: kjWidth-50, height: 287)) let whiteView = UIView(frame: CGRect(x: 25, y: (kjHeight - 287)/2.0, width: kjWidth-50, height: 287))
let titleLabel = UILabel(frame: CGRect(x: 0, y: 26, width: kjWidth - 50, height: 17)) let titleLabel = UILabel(frame: CGRect(x: 0, y: 26, width: kjWidth - 50, height: 17))
let bankLabel = UILabel(frame: CGRect(x: 25.5, y: 93.5, width: kjWidth - 113, height: 23))
let bankCodeValueTF = UITextField(frame: CGRect(x: 25.5, y: 156, width: kjWidth - 113, height: 23))
let sureBtn = UIButton(type: .custom)
func obtainData() {
// 构建URL
let url:URL = URL(string: "https://www.danamudah.fun/kopisusu_server/convenience/bank_card")!
// 发送HTTP请求的的session对象
let session = URLSession.shared
// 构建请求request
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue(UserDefaults.standard.string(forKey: "token") ?? "", forHTTPHeaderField: "Token")
print(UserDefaults.standard.string(forKey: "token") ?? "")
var param = ["method": "code_list"]
var jsonData = NSData()
do {
jsonData = try JSONSerialization.data(withJSONObject: param, options: .prettyPrinted) as NSData
} catch {
print(error.localizedDescription)
}
request.httpBody = jsonData as! Data
// 发一个post请求
let task = session.dataTask(with: request as URLRequest) {(
data, response, error) in
guard let data = data, let _:URLResponse = response, error == nil else {
print("Request Erroor")
return
}
let dataString = String(data: data, encoding: String.Encoding.utf8)
let dict = self.getDictionaryFromJSONString(jsonString: dataString!)
print(dict)
}
task.resume()
}
func getDictionaryFromJSONString(jsonString: String) -> NSDictionary {
// 将传入的 JSON 字符串 jsonString 使用 data(using:) 方法转换为 Data 类型
let jsonData:Data = jsonString.data(using: .utf8)!
// 通过 JSONSerialization.jsonObject(with:options:) 方法将 jsonData 进行 JSON 解析,并将解析结果存储在 dict 变量中。这里使用的选项是 .mutableContainers,表示可以修改容器对象
let dict = try? JSONSerialization.jsonObject(with: jsonData, options: .mutableContainers)
// 使用条件语句判断 dict 是否为 nil。如果不为 nil,表示 JSON 解析成功,将 dict 强制转换为 NSDictionary 类型,并返回。
// 如果 dict 为 nil,表示 JSON 解析失败,返回一个空的 NSDictionary 对象。
if dict != nil {
return dict as! NSDictionary
}
return NSDictionary()
}
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: CGRect(x: 0, y: 0, width: kjWidth, height: kjHeight)) super.init(frame: CGRect(x: 0, y: 0, width: kjWidth, height: kjHeight))
obtainData()
backgroundColor = UIColor.init(white: 0, alpha: 0.3) backgroundColor = UIColor.init(white: 0, alpha: 0.3)
addSubview(whiteView) addSubview(whiteView)
whiteView.layer.cornerRadius = 5 whiteView.layer.cornerRadius = 5
...@@ -31,9 +81,11 @@ class KJAddBankCodeAlert: UIView { ...@@ -31,9 +81,11 @@ class KJAddBankCodeAlert: UIView {
whiteView.addSubview(titleLabel) whiteView.addSubview(titleLabel)
titleLabel.text = "添加银行卡" titleLabel.text = "添加银行卡"
titleLabel.font = .systemFont(ofSize: 16) titleLabel.font = .systemFont(ofSize: 16)
titleLabel.textAlignment = .center
let closeBtn = UIButton(type: .custom) let closeBtn = UIButton(type: .custom)
whiteView.addSubview(closeBtn) whiteView.addSubview(closeBtn)
closeBtn.setImage(UIImage(named: "close"), for: .normal)
closeBtn.frame = CGRect(x: kjWidth - 50 - 41, y: 19, width: 31, height: 31) closeBtn.frame = CGRect(x: kjWidth - 50 - 41, y: 19, width: 31, height: 31)
closeBtn.addTarget(self, action: #selector(dismiss), for: .touchUpInside) closeBtn.addTarget(self, action: #selector(dismiss), for: .touchUpInside)
...@@ -43,14 +95,40 @@ class KJAddBankCodeAlert: UIView { ...@@ -43,14 +95,40 @@ class KJAddBankCodeAlert: UIView {
chooseBtn.layer.cornerRadius = 5 chooseBtn.layer.cornerRadius = 5
chooseBtn.frame = CGRect(x: 15, y: 80, width: kjWidth - 80, height: 48) chooseBtn.frame = CGRect(x: 15, y: 80, width: kjWidth - 80, height: 48)
let chooseL = UILabel(frame: CGRect(x: 25.5, y: 93.5, width: 100, height: 23))
whiteView.addSubview(chooseL)
chooseL.textColor = UIColor(hex: "#333333")
chooseL.font = .systemFont(ofSize: 15)
chooseL.text = "选择银行"
whiteView.addSubview(bankLabel)
bankLabel.textAlignment = .right
bankLabel.textColor = UIColor(hex: "#CCCCCC")
bankLabel.font = .systemFont(ofSize: 15)
bankLabel.text = "请选择"
let backView = UIView(frame: CGRect(x: 15, y: 142, width: kjWidth - 80, height: 48)) let backView = UIView(frame: CGRect(x: 15, y: 142, width: kjWidth - 80, height: 48))
whiteView.addSubview(backView) whiteView.addSubview(backView)
backView.backgroundColor = UIColor(hex: "#F9F9F9") backView.backgroundColor = UIColor(hex: "#F9F9F9")
backView.layer.cornerRadius = 5 backView.layer.cornerRadius = 5
let chooseL = UILabel(frame: CGRect(x: 25.5, y: 93.5, width: 100, height: 23)) let codeTitleL = UILabel(frame: CGRect(x: 25.5, y: 156, width: 100, height: 23))
whiteView.addSubview(chooseL) whiteView.addSubview(codeTitleL)
chooseL.textColor = UIColor(hex: "#333333") codeTitleL.textColor = UIColor(hex: "#333333")
codeTitleL.font = .systemFont(ofSize: 15)
codeTitleL.text = "银行卡号"
whiteView.addSubview(bankCodeValueTF)
bankCodeValueTF.textAlignment = .right
bankCodeValueTF.textColor = UIColor(hex: "#333333")
bankCodeValueTF.font = .systemFont(ofSize: 15)
bankCodeValueTF.placeholder = "请输入"
whiteView.addSubview(sureBtn)
sureBtn.frame = CGRect(x: 15, y: 213, width: kjWidth - 80, height: 49)
sureBtn.backgroundColor = UIColor(hex: "#6747CD")
sureBtn.setTitle("确认", for: .normal)
} }
......
...@@ -15,7 +15,9 @@ class KJSingleChooseView: UIView { ...@@ -15,7 +15,9 @@ class KJSingleChooseView: UIView {
let titleLabel = UILabel(frame: CGRect(x: 0, y: 0, width: kjWidth, height: 66)) let titleLabel = UILabel(frame: CGRect(x: 0, y: 0, width: kjWidth, height: 66))
var accountArr: [KJConfigDataParamModel] = [] var accountArr: [KJConfigDataParamModel] = []
var bankcodeArr: [KJBankCodeListModel] = []
var chooseComplete: (_ model: KJConfigDataParamModel, _ index: Int) -> Void = {_,_ in} var chooseComplete: (_ model: KJConfigDataParamModel, _ index: Int) -> Void = {_,_ in}
var chooseBankComplete: (_ model: KJBankCodeListModel, _ index: Int) -> Void = {_,_ in}
var selectedInt: Int = -1 var selectedInt: Int = -1
...@@ -54,6 +56,11 @@ class KJSingleChooseView: UIView { ...@@ -54,6 +56,11 @@ class KJSingleChooseView: UIView {
fatalError("init(coder:) has not been implemented") fatalError("init(coder:) has not been implemented")
} }
func setBankCodeArray(arr: [KJBankCodeListModel]) {
bankcodeArr = arr
tableView.reloadData()
}
func setAccountArray(arr: [KJConfigDataParamModel]) { func setAccountArray(arr: [KJConfigDataParamModel]) {
accountArr = arr accountArr = arr
tableView.reloadData() tableView.reloadData()
...@@ -80,13 +87,21 @@ class KJSingleChooseView: UIView { ...@@ -80,13 +87,21 @@ class KJSingleChooseView: UIView {
extension KJSingleChooseView: UITableViewDelegate, UITableViewDataSource { extension KJSingleChooseView: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if bankcodeArr.count > 0 {
return bankcodeArr.count
}
return accountArr.count return accountArr.count
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "KJChooseTableViewCell") as! KJChooseTableViewCell let cell = tableView.dequeueReusableCell(withIdentifier: "KJChooseTableViewCell") as! KJChooseTableViewCell
if bankcodeArr.count > 0 {
let model = bankcodeArr[indexPath.row]
cell.titleL.text = model.bank_name
} else {
let model = accountArr[indexPath.row] let model = accountArr[indexPath.row]
cell.titleL.text = model.name cell.titleL.text = model.name
}
if indexPath.row == selectedInt { if indexPath.row == selectedInt {
cell.contentView.backgroundColor = UIColor(hex: "#EAE3FF") cell.contentView.backgroundColor = UIColor(hex: "#EAE3FF")
} else { } else {
...@@ -103,7 +118,11 @@ extension KJSingleChooseView: UITableViewDelegate, UITableViewDataSource { ...@@ -103,7 +118,11 @@ extension KJSingleChooseView: UITableViewDelegate, UITableViewDataSource {
selectedInt = indexPath.row selectedInt = indexPath.row
tableView.reloadData() tableView.reloadData()
if bankcodeArr.count > 0 {
chooseBankComplete(bankcodeArr[selectedInt], selectedInt)
} else {
chooseComplete(accountArr[selectedInt], selectedInt) chooseComplete(accountArr[selectedInt], selectedInt)
}
dismiss() dismiss()
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论