提交 81ece978 authored 作者: 逄仁秀's avatar 逄仁秀

no message

上级 4dadbd36
......@@ -31,6 +31,7 @@
88B5B91B2B35804500871A63 /* KJChooseBankTVCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B5B9192B35804500871A63 /* KJChooseBankTVCell.swift */; };
88B5B91C2B35804500871A63 /* KJChooseBankTVCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 88B5B91A2B35804500871A63 /* KJChooseBankTVCell.xib */; };
88B5B91E2B43BCEB00871A63 /* KJBannerCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B5B91D2B43BCEB00871A63 /* KJBannerCollectionViewCell.swift */; };
88B5B9212B454C2D00871A63 /* KJBannerModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88B5B9202B454C2D00871A63 /* KJBannerModel.swift */; };
88BE37D82AFCC15400D04877 /* KJHomeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88BE37D62AFCC15400D04877 /* KJHomeViewController.swift */; };
88BE37D92AFCC15400D04877 /* KJHomeViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 88BE37D72AFCC15400D04877 /* KJHomeViewController.xib */; };
88BE37DE2AFCC19F00D04877 /* KJChargeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88BE37DC2AFCC19F00D04877 /* KJChargeViewController.swift */; };
......@@ -119,6 +120,7 @@
88B5B9192B35804500871A63 /* KJChooseBankTVCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJChooseBankTVCell.swift; sourceTree = "<group>"; };
88B5B91A2B35804500871A63 /* KJChooseBankTVCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KJChooseBankTVCell.xib; sourceTree = "<group>"; };
88B5B91D2B43BCEB00871A63 /* KJBannerCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJBannerCollectionViewCell.swift; sourceTree = "<group>"; };
88B5B9202B454C2D00871A63 /* KJBannerModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJBannerModel.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>"; };
88BE37DC2AFCC19F00D04877 /* KJChargeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KJChargeViewController.swift; sourceTree = "<group>"; };
......@@ -210,6 +212,7 @@
88276FAC2B284AB0009BAE13 /* KJConfigParamModel.swift */,
88B5B9152B32D5EB00871A63 /* KJRechargeModel.swift */,
88B5B9172B34381000871A63 /* KJAddBankModel.swift */,
88B5B9202B454C2D00871A63 /* KJBannerModel.swift */,
);
path = model;
sourceTree = "<group>";
......@@ -599,6 +602,7 @@
files = (
88CCD53D2AD6720D00639473 /* KJHeaderObject.swift in Sources */,
88BE37EA2AFCC23300D04877 /* KJElectricityViewController.swift in Sources */,
88B5B9212B454C2D00871A63 /* KJBannerModel.swift in Sources */,
88BE37FA2AFCC28400D04877 /* KJAngsuranViewController.swift in Sources */,
88BE38172B0CB1B100D04877 /* KJAccountViewController.swift in Sources */,
88BE381F2B0DD83D00D04877 /* KJWithdrawViewController.swift in Sources */,
......
......@@ -23,47 +23,95 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "ADDC206C-E887-4FE3-97DD-9338A0232CA6"
uuid = "F524BDAE-1E1F-44D5-AE5C-66108272416D"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "iOS-2kj/home/KJHomeViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "88"
endingLineNumber = "88"
landmarkName = "getData()"
landmarkType = "7">
<Locations>
<Location
uuid = "F524BDAE-1E1F-44D5-AE5C-66108272416D - 3300ef1b5f41f446"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #1 @Sendable (Swift.Optional&lt;Foundation.Data&gt;, Swift.Optional&lt;__C.NSURLResponse&gt;, Swift.Optional&lt;Swift.Error&gt;) -&gt; () in iOS_2kj.KJHomeViewController.getData() -&gt; ()"
moduleName = "iOS-2kj"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/renxiupang/Documents/rire-tool/iOS-2kj/home/KJHomeViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "89"
endingLineNumber = "89"
offsetFromSymbolStart = "600">
</Location>
<Location
uuid = "F524BDAE-1E1F-44D5-AE5C-66108272416D - 3300ef1b5f41f439"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #1 @Sendable (Swift.Optional&lt;Foundation.Data&gt;, Swift.Optional&lt;__C.NSURLResponse&gt;, Swift.Optional&lt;Swift.Error&gt;) -&gt; () in iOS_2kj.KJHomeViewController.getData() -&gt; ()"
moduleName = "iOS-2kj"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/renxiupang/Documents/rire-tool/iOS-2kj/home/KJHomeViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "88"
endingLineNumber = "88"
offsetFromSymbolStart = "3632">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "076956BE-CDC8-4508-9747-1FBE13E562BF"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "iOS-2kj/home/subC/KJWithdrawViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "172"
endingLineNumber = "172"
landmarkName = "withdraw(param:)"
startingLineNumber = "207"
endingLineNumber = "207"
landmarkName = "checkCode(param:)"
landmarkType = "7">
<Locations>
<Location
uuid = "ADDC206C-E887-4FE3-97DD-9338A0232CA6 - b19baffa3554b0ca"
uuid = "076956BE-CDC8-4508-9747-1FBE13E562BF - 2e8e53d6c5875381"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "iOS_2kj.KJWithdrawViewController.tableView(_: __C.UITableView, heightForRowAt: Foundation.IndexPath) -&gt; CoreGraphics.CGFloat"
symbolName = "closure #1 @Sendable (Swift.Optional&lt;Foundation.Data&gt;, Swift.Optional&lt;__C.NSURLResponse&gt;, Swift.Optional&lt;Swift.Error&gt;) -&gt; () in iOS_2kj.KJWithdrawViewController.checkCode() -&gt; ()"
moduleName = "iOS-2kj"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/renxiupang/Documents/rire-tool/iOS-2kj/home/subC/KJWithdrawViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "173"
endingLineNumber = "173"
offsetFromSymbolStart = "36">
startingLineNumber = "207"
endingLineNumber = "207"
offsetFromSymbolStart = "1212">
</Location>
<Location
uuid = "ADDC206C-E887-4FE3-97DD-9338A0232CA6 - b781bef5ceda2f0a"
uuid = "076956BE-CDC8-4508-9747-1FBE13E562BF - bea152a112446c7c"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #1 @Sendable (Swift.Optional&lt;Foundation.Data&gt;, Swift.Optional&lt;__C.NSURLResponse&gt;, Swift.Optional&lt;Swift.Error&gt;) -&gt; () in iOS_2kj.KJWithdrawViewController.withdraw(param: Swift.Dictionary&lt;Swift.String, Swift.String&gt;) -&gt; ()"
symbolName = "closure #1 @Sendable (Swift.Optional&lt;Foundation.Data&gt;, Swift.Optional&lt;__C.NSURLResponse&gt;, Swift.Optional&lt;Swift.Error&gt;) -&gt; () in iOS_2kj.KJWithdrawViewController.checkCode(param: Swift.Dictionary&lt;Swift.String, Swift.String&gt;) -&gt; ()"
moduleName = "iOS-2kj"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/renxiupang/Documents/rire-tool/iOS-2kj/home/subC/KJWithdrawViewController.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "172"
endingLineNumber = "172"
offsetFromSymbolStart = "1200">
startingLineNumber = "207"
endingLineNumber = "207"
offsetFromSymbolStart = "1212">
</Location>
</Locations>
</BreakpointContent>
......
......@@ -10,6 +10,9 @@ import UIKit
class KJHomeViewController: KJBaseViewController {
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: kjWidth, height: kjHeight), collectionViewLayout: UICollectionViewFlowLayout())
var ratio = 0.0
var banner:[KJBannerModel?] = []
override func viewDidLoad() {
super.viewDidLoad()
......@@ -20,6 +23,7 @@ class KJHomeViewController: KJBaseViewController {
collectionView.dataSource = self
collectionView.register(UINib.init(nibName: "KJHomeHeaderCell", bundle: nil), forCellWithReuseIdentifier: "KJHomeHeaderCell")
collectionView.register(UINib(nibName: "KJHomeCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "KJHomeCollectionViewCell")
collectionView.register(KJBannerCollectionViewCell.self, forCellWithReuseIdentifier: "KJBannerCollectionViewCell")
if #available(iOS 11.0, *) {
self.collectionView.contentInsetAdjustmentBehavior = .never
......@@ -28,6 +32,7 @@ class KJHomeViewController: KJBaseViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
getData()
collectionView.reloadData()
}
......@@ -51,6 +56,53 @@ class KJHomeViewController: KJBaseViewController {
navigationController?.pushViewController(vc, animated: true)
}
}
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()
}
// 普通的网络请求
func getData() {
// 构建URL
let url:URL = URL(string: "https://www.danamudah.fun/kopisusu_server/user/get_home_service")!
// 发送HTTP请求的的session对象
let session = URLSession.shared
// 构建请求request
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue(UserDefaults.standard.string(forKey: "token") ?? "", forHTTPHeaderField: "Token")
// 发一个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)
if let arr = [KJBannerModel].deserialize(from: (dict["ret"] as! NSDictionary)["banner"] as! NSArray) {
self.banner = arr
DispatchQueue.main.async {
self.collectionView.reloadData()
}
}
self.ratio = (dict["ret"] as! NSDictionary)["ratio"] as! Double
}
task.resume()
}
/*
// MARK: - Navigation
......@@ -66,13 +118,19 @@ class KJHomeViewController: KJBaseViewController {
extension KJHomeViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 2
return 3
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if section == 0 {
return 1
}
if section == 1 {
if banner.count > 0 {
return 1
}
return 0
}
return 6
}
......@@ -88,6 +146,15 @@ extension KJHomeViewController: UICollectionViewDelegate, UICollectionViewDataSo
}
return cell
}
if indexPath.section == 1 {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "KJBannerCollectionViewCell", for: indexPath) as! KJBannerCollectionViewCell
var arr:[String] = []
for a in banner {
arr.append(a?.image ?? "")
}
cell.bannerView.imageURLStringsGroup = arr
return cell
}
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "KJHomeCollectionViewCell", for: indexPath) as! KJHomeCollectionViewCell
if indexPath.item == 0 {
cell.img.image = UIImage(named: "home_transfer")
......@@ -117,6 +184,12 @@ extension KJHomeViewController: UICollectionViewDelegate, UICollectionViewDataSo
if indexPath.section == 0 {
return CGSize(width: kjWidth, height: 246)
}
if indexPath.section == 1 {
if banner.count > 0 {
return CGSize(width: kjWidth - 30, height: (kjWidth - 30) / ratio)
}
return CGSize(width: kjWidth - 30, height: 0)
}
return CGSize(width: (kjWidth - 51) / 3.0, height: 120)
}
......@@ -124,6 +197,12 @@ extension KJHomeViewController: UICollectionViewDelegate, UICollectionViewDataSo
if section == 0 {
return .zero
}
if section == 1 {
if banner.count > 0 {
return UIEdgeInsets(top: 23, left: 15, bottom: 0, right: 15)
}
return UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15)
}
return UIEdgeInsets(top: 30, left: 15, bottom: 15, right: 15)
}
......@@ -132,7 +211,7 @@ extension KJHomeViewController: UICollectionViewDelegate, UICollectionViewDataSo
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if indexPath.section == 1 {
if indexPath.section == 2 {
if UserDefaults.standard.string(forKey: "token")?.count ?? 0 > 1 {
let vc = KJBigViewController()
vc.index = indexPath.row
......
//
// KJBannerModel.swift
// iOS-2kj
//
// Created by 仁秀逄 on 2024/1/3.
//
import UIKit
import HandyJSON
class KJBannerModel: HandyJSON {
var image: String?
var name: String?
var need_login: String?
var type: String?
var url: String?
required init() {}
}
......@@ -20,6 +20,7 @@ class KJAccountViewController: KJBaseViewController {
var accountModel: KJAccountModel?
var hasCode: Bool = false
// 普通的网络请求
func getData() {
// 构建URL
......@@ -154,7 +155,12 @@ extension KJAccountViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "KJAccountTableViewCell") as! KJAccountTableViewCell
let model = self.accountModel?.record_data?[indexPath.row]
cell.moneyL.text = model?.real_amount
if model?.type == "1" {
cell.typeL.text = "提现"
} else {
cell.typeL.text = "充值"
}
cell.moneyL.text = model?.amount
cell.timeL.text = model?.create_time
return cell
}
......
......@@ -170,10 +170,47 @@ class KJWithdrawViewController: KJBaseViewController {
let dict = self.getDictionaryFromJSONString(jsonString: dataString!)
print(dict)
DispatchQueue.main.async {
let dic = (dict["ret"] as! NSDictionary)["basic_data"] as! NSDictionary
self.checkCode(param: ["conv_no": dic["conv_no"] as! String, "prod_code": dic["prod_code"] as! String])
}
}
task.resume()
}
func checkCode(param: [String: String]) {
// 构建URL
let url:URL = URL(string: "https://www.danamudah.fun/kopisusu_server/convenience/pay_conv")!
// 发送HTTP请求的的session对象
let session = URLSession.shared
// 构建请求request
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue(UserDefaults.standard.string(forKey: "token") ?? "", forHTTPHeaderField: "Token")
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)
if (dict.allKeys as NSArray).contains("success") == true {
} else {
DispatchQueue.main.async {
}
}
}
task.resume()
}
......
......@@ -8,5 +8,15 @@
import UIKit
class KJBannerCollectionViewCell: UICollectionViewCell {
let bannerView = SDCycleScrollView()
override init(frame: CGRect) {
super.init(frame: frame)
bannerView.frame = CGRect(x: 0, y: 0, width: frame.size.width, height: frame.size.height)
contentView.addSubview(bannerView)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
......@@ -4,3 +4,4 @@
#import <Adjust.h>
#import <MBProgressHUD.h>
#import <SDCycleScrollView.h>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论