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

预约直播

parent f56cfa9a
......@@ -12,7 +12,6 @@ class YHlifeCollectionReusableView: UICollectionReusableView {
static let reuseIdentifier = "YHlifeCollectionReusableView"
var tableView: UITableView!
var sectionView: YHlifeCollectionReusableViewHeadView!
var dataSource: [YHLiveListModel]? {
didSet {
self.tableView.reloadData()
......@@ -163,6 +162,8 @@ class YHlifeCollectionReusableViewTableViewCell: UITableViewCell {
var flagLabel: UILabel!
var timelabel: UILabel!
var actionButton: UIButton!
var viewModel: YHLiveSalesViewModel = YHLiveSalesViewModel()
var dataSource: YHLiveListModel? {
didSet {
guard let dataSource = dataSource else { return }
......@@ -325,5 +326,13 @@ class YHlifeCollectionReusableViewTableViewCell: UITableViewCell {
@objc func actionClick() {
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 {
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 {
......
......@@ -722,6 +722,8 @@ class YHAllApiName {
// APP直播间人数
static let livePeople = "super-app/live/live-people"
static let schedulLiveList = "super-app/live/schedule-live-list"
static let liveBook = "super-app/live/live-book"
}
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