Commit cc4d5b26 authored by Alex朱枝文's avatar Alex朱枝文

跳直播预约页面增加直播状态获取,未开始直播的跳预约页面,否则跳直播间

parent f0741d82
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
04307BB02D215D1C00ED8E8D /* YHRecommendedLiveHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04307BAF2D215D1C00ED8E8D /* YHRecommendedLiveHeader.swift */; }; 04307BB02D215D1C00ED8E8D /* YHRecommendedLiveHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04307BAF2D215D1C00ED8E8D /* YHRecommendedLiveHeader.swift */; };
04307BB42D21623300ED8E8D /* YHRecommendedAppointmentLiveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04307BB32D21623300ED8E8D /* YHRecommendedAppointmentLiveView.swift */; }; 04307BB42D21623300ED8E8D /* YHRecommendedAppointmentLiveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04307BB32D21623300ED8E8D /* YHRecommendedAppointmentLiveView.swift */; };
04307BB62D2180C300ED8E8D /* YHRecommendedOnLiveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04307BB52D2180C300ED8E8D /* YHRecommendedOnLiveView.swift */; }; 04307BB62D2180C300ED8E8D /* YHRecommendedOnLiveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04307BB52D2180C300ED8E8D /* YHRecommendedOnLiveView.swift */; };
04307BBC2D22A21E00ED8E8D /* YHLiveStatusModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04307BBB2D22A21E00ED8E8D /* YHLiveStatusModel.swift */; };
045C0F7F2D12CA5F00BD2DC0 /* submit_page_scroll.gif in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F4F2D12CA5E00BD2DC0 /* submit_page_scroll.gif */; }; 045C0F7F2D12CA5F00BD2DC0 /* submit_page_scroll.gif in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F4F2D12CA5E00BD2DC0 /* submit_page_scroll.gif */; };
045C0F802D12CA5F00BD2DC0 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F762D12CA5E00BD2DC0 /* Localizable.xcstrings */; }; 045C0F802D12CA5F00BD2DC0 /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F762D12CA5E00BD2DC0 /* Localizable.xcstrings */; };
045C0F812D12CA5F00BD2DC0 /* img_0.png in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F5E2D12CA5E00BD2DC0 /* img_0.png */; }; 045C0F812D12CA5F00BD2DC0 /* img_0.png in Resources */ = {isa = PBXBuildFile; fileRef = 045C0F5E2D12CA5E00BD2DC0 /* img_0.png */; };
...@@ -1278,6 +1279,7 @@ ...@@ -1278,6 +1279,7 @@
04307BAF2D215D1C00ED8E8D /* YHRecommendedLiveHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHRecommendedLiveHeader.swift; sourceTree = "<group>"; }; 04307BAF2D215D1C00ED8E8D /* YHRecommendedLiveHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHRecommendedLiveHeader.swift; sourceTree = "<group>"; };
04307BB32D21623300ED8E8D /* YHRecommendedAppointmentLiveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHRecommendedAppointmentLiveView.swift; sourceTree = "<group>"; }; 04307BB32D21623300ED8E8D /* YHRecommendedAppointmentLiveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHRecommendedAppointmentLiveView.swift; sourceTree = "<group>"; };
04307BB52D2180C300ED8E8D /* YHRecommendedOnLiveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHRecommendedOnLiveView.swift; sourceTree = "<group>"; }; 04307BB52D2180C300ED8E8D /* YHRecommendedOnLiveView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHRecommendedOnLiveView.swift; sourceTree = "<group>"; };
04307BBB2D22A21E00ED8E8D /* YHLiveStatusModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHLiveStatusModel.swift; sourceTree = "<group>"; };
045C0A142D12CA5E00BD2DC0 /* YHBaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBaseViewController.swift; sourceTree = "<group>"; }; 045C0A142D12CA5E00BD2DC0 /* YHBaseViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBaseViewController.swift; sourceTree = "<group>"; };
045C0A152D12CA5E00BD2DC0 /* YHBaseViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBaseViewModel.swift; sourceTree = "<group>"; }; 045C0A152D12CA5E00BD2DC0 /* YHBaseViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHBaseViewModel.swift; sourceTree = "<group>"; };
045C0A162D12CA5E00BD2DC0 /* YHNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHNavigationController.swift; sourceTree = "<group>"; }; 045C0A162D12CA5E00BD2DC0 /* YHNavigationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHNavigationController.swift; sourceTree = "<group>"; };
...@@ -5449,6 +5451,7 @@ ...@@ -5449,6 +5451,7 @@
045C0E932D12CA5E00BD2DC0 /* YHRecordedDetailModel.swift */, 045C0E932D12CA5E00BD2DC0 /* YHRecordedDetailModel.swift */,
04307BA92D1FF74500ED8E8D /* YHRecommendLiveListModel.swift */, 04307BA92D1FF74500ED8E8D /* YHRecommendLiveListModel.swift */,
04307BAB2D1FFC1C00ED8E8D /* YHShareLiveInfoModel.swift */, 04307BAB2D1FFC1C00ED8E8D /* YHShareLiveInfoModel.swift */,
04307BBB2D22A21E00ED8E8D /* YHLiveStatusModel.swift */,
); );
path = M; path = M;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -6921,6 +6924,7 @@ ...@@ -6921,6 +6924,7 @@
045C10222D12CA5F00BD2DC0 /* YHMyFileListViewController.swift in Sources */, 045C10222D12CA5F00BD2DC0 /* YHMyFileListViewController.swift in Sources */,
045C10232D12CA5F00BD2DC0 /* YHClipperView.swift in Sources */, 045C10232D12CA5F00BD2DC0 /* YHClipperView.swift in Sources */,
045C10242D12CA5F00BD2DC0 /* YHAddressViewController.swift in Sources */, 045C10242D12CA5F00BD2DC0 /* YHAddressViewController.swift in Sources */,
04307BBC2D22A21E00ED8E8D /* YHLiveStatusModel.swift in Sources */,
045C10252D12CA5F00BD2DC0 /* YHPeopleSuccessView.swift in Sources */, 045C10252D12CA5F00BD2DC0 /* YHPeopleSuccessView.swift in Sources */,
045C10262D12CA5F00BD2DC0 /* YHLookResignAlertView.swift in Sources */, 045C10262D12CA5F00BD2DC0 /* YHLookResignAlertView.swift in Sources */,
045C10272D12CA5F00BD2DC0 /* YHUploadCertificateDetailModel.swift in Sources */, 045C10272D12CA5F00BD2DC0 /* YHUploadCertificateDetailModel.swift in Sources */,
......
...@@ -17,6 +17,8 @@ class YHlifeCollectionReusableView: UICollectionReusableView { ...@@ -17,6 +17,8 @@ class YHlifeCollectionReusableView: UICollectionReusableView {
self.tableView.reloadData() self.tableView.reloadData()
} }
} }
private let viewModel = YHLiveSalesViewModel()
override init(frame: CGRect) { override init(frame: CGRect) {
super.init(frame: frame) super.init(frame: frame)
setupView() setupView()
...@@ -93,8 +95,23 @@ extension YHlifeCollectionReusableView: UITableViewDelegate, UITableViewDataSour ...@@ -93,8 +95,23 @@ extension YHlifeCollectionReusableView: UITableViewDelegate, UITableViewDataSour
return return
} }
let model = dataSource[indexPath.row] let model = dataSource[indexPath.row]
let ctl = YHLiveAppointmentViewController(liveId: model.live_id) YHHUD.show(.progress(message: "加载中..."))
UIViewController.current?.navigationController?.pushViewController(ctl) viewModel.getLiveStatus(liveId: model.live_id) { liveInfo, error in
YHHUD.hide()
guard let liveInfo = liveInfo else {
let ctl = YHLiveAppointmentViewController(liveId: model.live_id)
UIViewController.current?.navigationController?.pushViewController(ctl)
return
}
if liveInfo.status == 2 {
let ctl = YHLiveAppointmentViewController(liveId: model.live_id)
UIViewController.current?.navigationController?.pushViewController(ctl)
} else {
let playbackInfo = YHPlayerManager.PlaybackInfo(id: model.live_id, url: nil, title: nil, roomId: nil, uid: nil, isLive: true, scene: .fullscreen)
YHPlayerManager.shared.enterLive(from: nil, playbackInfo: playbackInfo)
}
}
} }
} }
......
...@@ -325,9 +325,26 @@ class YHLiveStateViewController: YHBaseViewController { ...@@ -325,9 +325,26 @@ class YHLiveStateViewController: YHBaseViewController {
self.bookLive(liveId: model.live_id, liveView: view) self.bookLive(liveId: model.live_id, liveView: view)
} }
view.buttonClickEvent = { view.buttonClickEvent = { [weak self] in
let ctl = YHLiveAppointmentViewController(liveId: model.live_id) guard let self = self else {
UIViewController.current?.navigationController?.pushViewController(ctl) return
}
YHHUD.show(.progress(message: "加载中..."))
self.viewModel.getLiveStatus(liveId: model.live_id) { liveInfo, error in
YHHUD.hide()
guard let liveInfo = liveInfo else {
let ctl = YHLiveAppointmentViewController(liveId: model.live_id)
UIViewController.current?.navigationController?.pushViewController(ctl)
return
}
if liveInfo.status == 2 {
let ctl = YHLiveAppointmentViewController(liveId: model.live_id)
UIViewController.current?.navigationController?.pushViewController(ctl)
} else {
let playbackInfo = YHPlayerManager.PlaybackInfo(id: model.live_id, url: nil, title: nil, roomId: nil, uid: nil, isLive: true, scene: .fullscreen)
YHPlayerManager.shared.enterLive(from: nil, playbackInfo: playbackInfo)
}
}
} }
self.bottomView.addSubview(view) self.bottomView.addSubview(view)
view.snp.makeConstraints { make in view.snp.makeConstraints { make in
...@@ -348,10 +365,7 @@ class YHLiveStateViewController: YHBaseViewController { ...@@ -348,10 +365,7 @@ class YHLiveStateViewController: YHBaseViewController {
private func bookLive(liveId: Int, liveView: YHRecommendedAppointmentLiveView) { private func bookLive(liveId: Int, liveView: YHRecommendedAppointmentLiveView) {
YHHUD.show(.progress(message: "加载中...")) YHHUD.show(.progress(message: "加载中..."))
viewModel.postLiveBook(id: liveId) { [weak self] success, error in viewModel.postLiveBook(id: liveId) { success, error in
guard let self = self else {
return
}
YHHUD.hide() YHHUD.hide()
if success { if success {
liveView.updateAppointmentButton(isAppointmented: true) liveView.updateAppointmentButton(isAppointmented: true)
......
//
// YHLiveStatusModel.swift
// galaxy
//
// Created by alexzzw on 2024/12/30.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import Foundation
import SmartCodable
class YHLiveStatusModel: SmartCodable {
var status: Int = 0
var stream_status: Int = 0
required init() {
}
}
...@@ -302,6 +302,32 @@ extension YHLiveSalesViewModel { ...@@ -302,6 +302,32 @@ extension YHLiveSalesViewModel {
callback(nil, err) callback(nil, err)
} }
} }
func getLiveStatus(liveId: Int, callback: @escaping (_ liveInfo: YHLiveStatusModel?, _ error: YHErrorModel?) -> Void) {
// 分享类型 1:直播 2录播
let param: [String: Any] = ["live_id": liveId]
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.LiveSales.liveStatus
_ = YHNetRequest.getRequest(url: strUrl, params: param) { json, _ in
// 1. json字符串 转 对象
printLog("model 是 ==> \(json)")
if json.code == 200 {
guard let dic = json.data?.peel as? [String: Any], let resultModel = YHLiveStatusModel.deserialize(from: dic) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callback(nil, err)
return
}
callback(resultModel, nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callback(nil, err)
}
} failBlock: { err in
callback(nil, err)
}
}
} }
......
...@@ -728,6 +728,8 @@ class YHAllApiName { ...@@ -728,6 +728,8 @@ class YHAllApiName {
static let recommendLiveList = "super-app/live/recommend-live-list" static let recommendLiveList = "super-app/live/recommend-live-list"
// APP分享直播间 // APP分享直播间
static let shareLive = "super-app/live/share-live" static let shareLive = "super-app/live/share-live"
// app直播间状态
static let liveStatus = "super-app/live/live-status"
} }
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