From 88512c6a48e9bd85d1674c4dc00f5e7d03c763a2 Mon Sep 17 00:00:00 2001 From: liyuhua <15626451870@163.com> Date: Fri, 22 Mar 2024 11:54:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E6=8E=92=E5=90=8D=E5=92=8C?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=90=9C=E7=B4=A2=E6=88=BF=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RoomTopView/{ => View}/RoomTopView.swift | 46 +++++++++- .../View/YinRoomRankItemView.swift | 84 +++++++++++++++++++ .../RoomTopView/View/YinRoomRankView.swift | 67 +++++++++++++++ 3 files changed, 195 insertions(+), 2 deletions(-) rename yinmeng-ios/Modules/Room/View/RoomTopView/{ => View}/RoomTopView.swift (86%) create mode 100644 yinmeng-ios/Modules/Room/View/RoomTopView/View/YinRoomRankItemView.swift create mode 100644 yinmeng-ios/Modules/Room/View/RoomTopView/View/YinRoomRankView.swift diff --git a/yinmeng-ios/Modules/Room/View/RoomTopView/RoomTopView.swift b/yinmeng-ios/Modules/Room/View/RoomTopView/View/RoomTopView.swift similarity index 86% rename from yinmeng-ios/Modules/Room/View/RoomTopView/RoomTopView.swift rename to yinmeng-ios/Modules/Room/View/RoomTopView/View/RoomTopView.swift index d53bcb5..c343a75 100644 --- a/yinmeng-ios/Modules/Room/View/RoomTopView/RoomTopView.swift +++ b/yinmeng-ios/Modules/Room/View/RoomTopView/View/RoomTopView.swift @@ -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.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) diff --git a/yinmeng-ios/Modules/Room/View/RoomTopView/View/YinRoomRankItemView.swift b/yinmeng-ios/Modules/Room/View/RoomTopView/View/YinRoomRankItemView.swift new file mode 100644 index 0000000..695f50c --- /dev/null +++ b/yinmeng-ios/Modules/Room/View/RoomTopView/View/YinRoomRankItemView.swift @@ -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 + }() + +} diff --git a/yinmeng-ios/Modules/Room/View/RoomTopView/View/YinRoomRankView.swift b/yinmeng-ios/Modules/Room/View/RoomTopView/View/YinRoomRankView.swift new file mode 100644 index 0000000..7f3ee8e --- /dev/null +++ b/yinmeng-ios/Modules/Room/View/RoomTopView/View/YinRoomRankView.swift @@ -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 + }() +}