房间排名和首页搜索房间
This commit is contained in:
@@ -43,7 +43,7 @@ class RoomTopView: UIView {
|
||||
textStackView.addArrangedSubview(textView)
|
||||
textStackView.addArrangedSubview(giftIconView)
|
||||
textStackView.addArrangedSubview(lockIconView)
|
||||
|
||||
addSubview(rankView)
|
||||
addSubview(quitView)
|
||||
|
||||
superStackView.snp.makeConstraints { make in
|
||||
@@ -58,6 +58,12 @@ class RoomTopView: UIView {
|
||||
make.centerY.equalTo(nameStackView)
|
||||
make.width.height.equalTo(UIDevice.scaleWidth(width: 25))
|
||||
}
|
||||
rankView.snp.makeConstraints { make in
|
||||
make.width.equalTo(UIDevice.scaleWidth(width: 87))
|
||||
make.height.equalTo(UIDevice.scaleWidth(width: 37))
|
||||
make.centerY.equalTo(settingBnt)
|
||||
make.trailing.equalTo(settingBnt.snp.leading).offset(-UIDevice.scaleWidth(width:10))
|
||||
}
|
||||
avatarView.snp.makeConstraints { make in
|
||||
make.leading.top.equalTo(UIDevice.scaleWidth(width: 0))
|
||||
|
||||
@@ -96,8 +102,25 @@ class RoomTopView: UIView {
|
||||
lockIconView.snp.makeConstraints { make in
|
||||
make.width.height.equalTo(UIDevice.scaleWidth(width: 18))
|
||||
}
|
||||
let tap = UITapGestureRecognizer(target: self, action: #selector(clickRankListAction))
|
||||
rankView.addGestureRecognizer(tap)
|
||||
}
|
||||
@objc func clickRankListAction(){
|
||||
var url = ""
|
||||
if let clientInfoModel = AuthViewModel.authVM.clientInfoModel,clientInfoModel.h5Uris.count > 0,let roomUid = roomData?.uid{
|
||||
for obj in clientInfoModel.h5Uris {
|
||||
if obj.code == "roomRank"{
|
||||
url = obj.uri
|
||||
break
|
||||
}
|
||||
}
|
||||
url = url.isEmpty ? "yinmeng/\(H5Utils.rank.rawValue)" : url
|
||||
let getUrl = url + "?roomUid=" + roomUid
|
||||
if let _didClickTypeBlcok = didClickTypeBlcok{
|
||||
_didClickTypeBlcok(2,getUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - bntTarget
|
||||
var roomData:RoomDataModel? = nil{
|
||||
didSet{
|
||||
@@ -124,8 +147,22 @@ class RoomTopView: UIView {
|
||||
make.width.equalTo(UIDevice.scaleWidth(width: 40))
|
||||
}
|
||||
}
|
||||
getRankList()
|
||||
}
|
||||
}
|
||||
func getRankList(){
|
||||
guard let roomUid = roomData?.uid else { return }
|
||||
let params = ["type":"day","roomUid":roomUid,"page":"1","pageSize":"20"]
|
||||
RequestGet(path: "room/rankings", parma: params ) { data in
|
||||
|
||||
if let _data = data as? [String:Any], let list = Deserialized<YinRoomRankModel>.toArray(with: _data["rankings"]) {
|
||||
self.rankView.rankList = list
|
||||
}
|
||||
} fail: { code, message in
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@objc func colectRoomAction(){
|
||||
colectRoomBtn.isHidden = true
|
||||
|
||||
@@ -163,6 +200,11 @@ class RoomTopView: UIView {
|
||||
|
||||
return _quitView
|
||||
}()
|
||||
private lazy var rankView:YinRoomRankView = {
|
||||
let _rankView = YinRoomRankView(frame: .zero)
|
||||
|
||||
return _rankView
|
||||
}()
|
||||
private lazy var settingBnt:UIButton = {
|
||||
let _settingBtn = UIButton.getCustomBtn(image: UIImage(named: "yin_room_top_right"))
|
||||
_settingBtn.setBtnClickRadius = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8)
|
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// YinRoomRankItemView.swift
|
||||
// yinmeng-ios
|
||||
//
|
||||
// Created by duoban on 2024/3/22.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Nuke
|
||||
class YinRoomRankItemView: UIView {
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setUILayout()
|
||||
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
private func setUILayout(){
|
||||
addSubview(wearView)
|
||||
wearView.addSubview(avatarView)
|
||||
wearView.addSubview(numView)
|
||||
wearView.snp.makeConstraints { make in
|
||||
make.top.leading.equalTo(0)
|
||||
make.width.equalTo(UIDevice.scaleWidth(width: 29))
|
||||
make.height.equalTo(UIDevice.scaleWidth(width: 33))
|
||||
}
|
||||
avatarView.snp.makeConstraints { make in
|
||||
make.width.height.equalTo(UIDevice.scaleWidth(width: 22))
|
||||
make.centerX.equalTo(wearView.snp.centerX).offset(UIDevice.scaleWidth(width: 2.5))
|
||||
make.centerY.equalTo(wearView.snp.centerY).offset(UIDevice.scaleWidth(width: 4.5))
|
||||
}
|
||||
|
||||
numView.snp.makeConstraints { make in
|
||||
make.width.equalTo(UIDevice.scaleWidth(width: 22))
|
||||
make.height.equalTo(UIDevice.scaleWidth(width: 8))
|
||||
make.centerX.equalTo(wearView.snp.centerX).offset(UIDevice.scaleWidth(width: 3))
|
||||
make.centerY.equalTo(wearView.snp.bottom)
|
||||
}
|
||||
}
|
||||
func setColor(color:UIColor,backgroundColor:UIColor,image:UIImage?){
|
||||
numView.textColor = color
|
||||
numView.backgroundColor = backgroundColor
|
||||
wearView.image = image
|
||||
}
|
||||
|
||||
var model:YinRoomRankModel? = nil{
|
||||
didSet{
|
||||
guard let _model = model else {
|
||||
numView.text = "0"
|
||||
avatarView.image = nil
|
||||
return
|
||||
}
|
||||
Nuke.loadImage(with: _model.avatar, into:avatarView , completion: nil)
|
||||
let amount = _model.goldAmount
|
||||
var text = "\(amount)"
|
||||
if amount >= 10000{
|
||||
text = String(format: "%.1fw", amount / 10000)
|
||||
}
|
||||
numView.text = text
|
||||
}
|
||||
}
|
||||
//MARK: - 懒加载
|
||||
private lazy var wearView:UIImageView = {
|
||||
let _wearView = UIImageView()
|
||||
|
||||
return _wearView
|
||||
}()
|
||||
|
||||
private lazy var avatarView:UIImageView = {
|
||||
let _avatarView = UIImageView()
|
||||
_avatarView.layer.cornerRadius = UIDevice.scaleWidth(width: 22)/2
|
||||
_avatarView.layer.masksToBounds = true
|
||||
return _avatarView
|
||||
}()
|
||||
private lazy var numView:UILabel = {
|
||||
let _numVie = UILabel.getCustomLabel(text: "0",font: UIFont.getScaleFont(ofSize: 7, weight: .medium),color: ThemeColor(hexStr: "#2E527A"),textAlignment: .center,backgroundColor: ThemeColor(hexStr: "#91C8FA"),masksToBounds: true,cornerRadius: UIDevice.scaleWidth(width: 4))
|
||||
|
||||
return _numVie
|
||||
}()
|
||||
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// YinRoomRankView.swift
|
||||
// yinmeng-ios
|
||||
//
|
||||
// Created by duoban on 2024/3/22.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
|
||||
class YinRoomRankView: UIView {
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setUILayout()
|
||||
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
private func setUILayout(){
|
||||
addSubview(rankFirstView)
|
||||
addSubview(rankSecondView)
|
||||
addSubview(rankThirdView)
|
||||
rankFirstView.snp.makeConstraints { make in
|
||||
make.leading.top.equalTo(UIDevice.scaleWidth(width: 0))
|
||||
make.width.equalTo(UIDevice.scaleWidth(width: 29))
|
||||
make.height.equalTo(UIDevice.scaleWidth(width: 37))
|
||||
}
|
||||
rankSecondView.snp.makeConstraints { make in
|
||||
make.leading.equalTo(rankFirstView.snp.trailing).offset((UIDevice.scaleWidth(width: 0)))
|
||||
make.top.equalTo(UIDevice.scaleWidth(width: 0))
|
||||
make.width.equalTo(UIDevice.scaleWidth(width: 29))
|
||||
make.height.equalTo(UIDevice.scaleWidth(width: 37))
|
||||
}
|
||||
rankThirdView.snp.makeConstraints { make in
|
||||
make.leading.equalTo(rankSecondView.snp.trailing).offset((UIDevice.scaleWidth(width: 0)))
|
||||
make.top.equalTo(UIDevice.scaleWidth(width: 0))
|
||||
make.width.equalTo(UIDevice.scaleWidth(width: 29))
|
||||
make.height.equalTo(UIDevice.scaleWidth(width: 37))
|
||||
}
|
||||
}
|
||||
var rankList:[YinRoomRankModel] = [] {
|
||||
didSet{
|
||||
rankFirstView.model = rankList[safe: 0]
|
||||
rankSecondView.model = rankList[safe: 1]
|
||||
rankThirdView.model = rankList[safe: 2]
|
||||
}
|
||||
}
|
||||
//MARK: - 懒加载
|
||||
private lazy var rankFirstView:YinRoomRankItemView = {
|
||||
let _rankFirstView = YinRoomRankItemView(frame: .zero)
|
||||
_rankFirstView.setColor(color: ThemeColor(hexStr: "#8E461A"), backgroundColor: ThemeColor(hexStr: "#F5CD57"),image: UIImage(named: "yin_room_rank_first"))
|
||||
return _rankFirstView
|
||||
}()
|
||||
private lazy var rankSecondView:YinRoomRankItemView = {
|
||||
let _rankSecondView = YinRoomRankItemView(frame: .zero)
|
||||
_rankSecondView.setColor(color: ThemeColor(hexStr: "#2E527A"), backgroundColor: ThemeColor(hexStr: "#91C8FA"),image: UIImage(named: "yin_room_rank_second"))
|
||||
return _rankSecondView
|
||||
}()
|
||||
private lazy var rankThirdView:YinRoomRankItemView = {
|
||||
let _rankThirdView = YinRoomRankItemView(frame: .zero)
|
||||
_rankThirdView.setColor(color: ThemeColor(hexStr: "#824B2C"), backgroundColor: ThemeColor(hexStr: "#F0A47B"),image: UIImage(named: "yin_room_rank_third"))
|
||||
return _rankThirdView
|
||||
}()
|
||||
}
|
Reference in New Issue
Block a user