Commit 63ab92f3 authored by David黄金龙's avatar David黄金龙

注册 环信用户

parent 5f9a7b2a
...@@ -24,7 +24,6 @@ class YHLiveDetailModel: SmartCodable { ...@@ -24,7 +24,6 @@ class YHLiveDetailModel: SmartCodable {
required init() { required init() {
} }
} }
class YHLiveGoodsItem: SmartCodable { class YHLiveGoodsItem: SmartCodable {
...@@ -40,5 +39,12 @@ class YHLiveGoodsItem: SmartCodable { ...@@ -40,5 +39,12 @@ class YHLiveGoodsItem: SmartCodable {
required init() { required init() {
} }
}
class YHXuanXinUserModel: SmartCodable {
var nickname: String = ""
var avatarurl: String = ""
required init() {
}
} }
...@@ -9,6 +9,50 @@ ...@@ -9,6 +9,50 @@
import UIKit import UIKit
class YHLiveSalesViewModel: YHBaseViewModel { class YHLiveSalesViewModel: YHBaseViewModel {
//直播间详情
var liveDetailModel : YHLiveDetailModel?
//注册环信用户信息
var huanXinUserInfoModel : YHXuanXinUserModel?
}
extension YHLiveSalesViewModel {
/*
注册环信用户
*/
func registerHuanXinUser(id: Int, callBackBlock: @escaping (_ success: Bool,_ error: YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.LiveSales.registerHuanXinUserApi
_ = YHNetRequest.postRequest(url: strUrl) { json, _ in
// 1. json字符串 转 对象
printLog("model 是 ==> \(json)")
if json.code == 200 {
guard let dic = json.data?.peel as? [String: Any], let resultModel = YHXuanXinUserModel.deserialize(from: dic) else {
let err = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
callBackBlock(false, err)
return
}
self.huanXinUserInfoModel = resultModel
callBackBlock(true, nil)
} else {
let err = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg.isEmpty ? "" : json.msg)
callBackBlock(false, err)
}
} failBlock: { err in
callBackBlock(false, err)
}
}
/*
直播间详情
*/
func getLiveDetail(id: Int, callback: @escaping (_ liveDetail: YHLiveDetailModel?, _ error: YHErrorModel?) -> Void) { func getLiveDetail(id: Int, callback: @escaping (_ liveDetail: YHLiveDetailModel?, _ error: YHErrorModel?) -> Void) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.LiveSales.liveDetail let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.LiveSales.liveDetail
_ = YHNetRequest.getRequest(url: strUrl, params: ["id": id]) { json, _ in _ = YHNetRequest.getRequest(url: strUrl, params: ["id": id]) { json, _ in
......
...@@ -663,6 +663,9 @@ class YHAllApiName { ...@@ -663,6 +663,9 @@ class YHAllApiName {
struct LiveSales { struct LiveSales {
// 获取直播详情 // 获取直播详情
static let liveDetail = "super-app/live/app-live-detail" static let liveDetail = "super-app/live/app-live-detail"
// 注册环信用户
static let registerHuanXinUserApi = "super-app/live/register-user-to-huanxin"
} }
} }
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