Commit cb8feab5 authored by pete谢兆麟's avatar pete谢兆麟

预约直播

parent f56cfa9a
...@@ -12,7 +12,6 @@ class YHlifeCollectionReusableView: UICollectionReusableView { ...@@ -12,7 +12,6 @@ class YHlifeCollectionReusableView: UICollectionReusableView {
static let reuseIdentifier = "YHlifeCollectionReusableView" static let reuseIdentifier = "YHlifeCollectionReusableView"
var tableView: UITableView! var tableView: UITableView!
var sectionView: YHlifeCollectionReusableViewHeadView! var sectionView: YHlifeCollectionReusableViewHeadView!
var dataSource: [YHLiveListModel]? { var dataSource: [YHLiveListModel]? {
didSet { didSet {
self.tableView.reloadData() self.tableView.reloadData()
...@@ -163,6 +162,8 @@ class YHlifeCollectionReusableViewTableViewCell: UITableViewCell { ...@@ -163,6 +162,8 @@ class YHlifeCollectionReusableViewTableViewCell: UITableViewCell {
var flagLabel: UILabel! var flagLabel: UILabel!
var timelabel: UILabel! var timelabel: UILabel!
var actionButton: UIButton! var actionButton: UIButton!
var viewModel: YHLiveSalesViewModel = YHLiveSalesViewModel()
var dataSource: YHLiveListModel? { var dataSource: YHLiveListModel? {
didSet { didSet {
guard let dataSource = dataSource else { return } guard let dataSource = dataSource else { return }
...@@ -325,5 +326,13 @@ class YHlifeCollectionReusableViewTableViewCell: UITableViewCell { ...@@ -325,5 +326,13 @@ class YHlifeCollectionReusableViewTableViewCell: UITableViewCell {
@objc func actionClick() { @objc func actionClick() {
actionButton.isSelected = true actionButton.isSelected = true
viewModel.postLiveBook(id: dataSource?.live_id ?? 0) { success, error in
if success {
YHHUD.flash(message: "预约成功")
} else {
YHHUD.flash(message: "预约失败")
}
}
} }
} }
...@@ -234,6 +234,25 @@ extension YHLiveSalesViewModel { ...@@ -234,6 +234,25 @@ extension YHLiveSalesViewModel {
callback(nil, err) callback(nil, err)
} }
} }
func postLiveBook(id: Int, callback: @escaping (_ livePeople: Bool, _ error: YHErrorModel?) -> Void) {
let params: [String: Any] = ["live_id": id, "source_type": 1]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.LiveSales.liveBook
_ = YHNetRequest.postRequest(url: strUrl, params: params) { [weak self] json, _ in
// 1. json字符串 转 对象
printLog("model 是 ==> \(json)")
if json.code == 200 {
callback(true, nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callback(false, err)
}
} failBlock: { err in
callback(false, err)
}
}
} }
private extension String { private extension String {
......
...@@ -722,6 +722,8 @@ class YHAllApiName { ...@@ -722,6 +722,8 @@ class YHAllApiName {
// APP直播间人数 // APP直播间人数
static let livePeople = "super-app/live/live-people" static let livePeople = "super-app/live/live-people"
static let schedulLiveList = "super-app/live/schedule-live-list" static let schedulLiveList = "super-app/live/schedule-live-list"
static let liveBook = "super-app/live/live-book"
} }
struct AIChat { struct AIChat {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment