2024-02-25 13:10:44 +08:00
|
|
|
|
//
|
|
|
|
|
// PlanetStarVC.swift
|
|
|
|
|
// yinmeng-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by MaiMang on 2024/2/25.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import UIKit
|
2024-02-28 19:23:44 +08:00
|
|
|
|
import NIMSDK
|
2024-03-01 16:54:46 +08:00
|
|
|
|
import Nuke
|
2024-02-28 19:01:10 +08:00
|
|
|
|
|
|
|
|
|
class PlanetStarVC: BaseViewController,HiddenNavigationBarProtocol {
|
|
|
|
|
var page:Int = 1
|
2024-02-25 13:10:44 +08:00
|
|
|
|
override func viewDidLoad() {
|
|
|
|
|
super.viewDidLoad()
|
2024-02-28 19:01:10 +08:00
|
|
|
|
yin_initUI()
|
|
|
|
|
requestData()
|
|
|
|
|
|
2024-02-25 13:10:44 +08:00
|
|
|
|
|
2024-02-28 19:01:10 +08:00
|
|
|
|
|
2024-02-25 13:10:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-02-28 19:01:10 +08:00
|
|
|
|
|
|
|
|
|
func requestData(){
|
|
|
|
|
|
|
|
|
|
RequestGet(path: "home/recommendUsers", parma: ["pageNum":"\(self.page)","pageSize":"30"]) { data in
|
|
|
|
|
if let list = Deserialized<PlanetStarModel>.toArray(with: data) {
|
|
|
|
|
var dataList:[PlanetStarModel] = []
|
|
|
|
|
guard list.isEmpty else {
|
|
|
|
|
|
|
|
|
|
for i in 0..<12 {
|
|
|
|
|
if i < list.count{
|
|
|
|
|
dataList.append(list[i])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
self.dataArray = dataList
|
|
|
|
|
|
|
|
|
|
self.dealWithViewData()
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
self.page = 1
|
|
|
|
|
}
|
|
|
|
|
} fail: { code, data in
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-01 16:54:46 +08:00
|
|
|
|
RequestGet(path: "special/gift/get", parma: [:]) { data in
|
2024-02-28 19:01:10 +08:00
|
|
|
|
if let model = Deserialized<PlanetStarModel>.toModel(with: data) {
|
|
|
|
|
self.giftModel = model
|
|
|
|
|
}
|
|
|
|
|
} fail: { code, data in
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func dealWithViewData(){
|
|
|
|
|
self.bgRadiusView.dataList = dataArray
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func yin_initUI(){
|
|
|
|
|
|
|
|
|
|
view.addSubview(backgroundView)
|
|
|
|
|
view.addSubview(bgRadiusView)
|
|
|
|
|
bgRadiusView.frame = self.view.frame
|
2024-03-01 16:54:46 +08:00
|
|
|
|
activityView.center = self.view.center
|
|
|
|
|
activityView.startAnimating()
|
2024-02-28 19:01:10 +08:00
|
|
|
|
backgroundView.snp.makeConstraints { make in
|
|
|
|
|
make.edges.equalTo(self.view)
|
|
|
|
|
}
|
2024-02-25 13:10:44 +08:00
|
|
|
|
|
2024-02-28 19:01:10 +08:00
|
|
|
|
|
2024-03-01 16:54:46 +08:00
|
|
|
|
bgRadiusView.refreshBlcok = {[weak self] (uid,type,name) in
|
|
|
|
|
if type == 0{
|
2024-02-28 19:23:44 +08:00
|
|
|
|
self?.page = (self?.page ?? 1) + 1
|
|
|
|
|
self?.requestData()
|
2024-03-01 16:54:46 +08:00
|
|
|
|
}else if type == 1{
|
|
|
|
|
guard let _uid = uid else {return}
|
|
|
|
|
let session = NIMSession.init(_uid, type: .P2P)
|
|
|
|
|
let chatVC = ChatVC.init(session: session)
|
|
|
|
|
self?.navigationController?.pushViewController(chatVC, animated: true)
|
|
|
|
|
}else{
|
|
|
|
|
guard let _uid = uid else {return}
|
|
|
|
|
let giftName = self?.giftModel?.giftName ?? ""
|
|
|
|
|
let giftNum = self?.giftModel?.goldPrice ?? "0"
|
|
|
|
|
let text = "确认赠送 \(giftName)(\(giftNum)钻石)给\(name)吗"
|
2024-03-01 21:03:59 +08:00
|
|
|
|
|
|
|
|
|
guard UserDefaults.standard.value(forKey: "kIsShowPopUp") == nil else{
|
|
|
|
|
RequestGet(path: "special/gift/get", parma: ["targetId":_uid]) { data in
|
|
|
|
|
self?.activityView.removeFromSuperview()
|
|
|
|
|
if let _ = Deserialized<PlanetStarModel>.toModel(with: data) {
|
|
|
|
|
HUDTool.show(with: "送礼成功")
|
|
|
|
|
let imageView = UIImageView(frame: CGRect(x: ScreenWidth/2-50, y: -100, width: 0, height: 0))
|
|
|
|
|
|
|
|
|
|
Nuke.loadImage(with: self?.giftModel?.picUrl ?? "", into: imageView)
|
|
|
|
|
self?.view.addSubview(imageView)
|
|
|
|
|
UIView.animate(withDuration: 2) {
|
|
|
|
|
imageView.frame = CGRect(x: ScreenWidth/2-50, y: ScreenHeight/3 * 2, width: 100, height: 100)
|
|
|
|
|
|
|
|
|
|
}completion: { isC in
|
|
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
|
|
|
|
UIView.animate(withDuration: 1) {
|
|
|
|
|
let x = self?.bgRadiusView.imageView.frame.origin.x ?? 0
|
|
|
|
|
let y = self?.bgRadiusView.imageView.frame.origin.y ?? 0
|
|
|
|
|
imageView.frame = CGRect(x: x + 50, y: y + 50, width: 10, height: 10)
|
|
|
|
|
|
|
|
|
|
}completion: { isC in
|
|
|
|
|
imageView.removeFromSuperview()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} fail: { code, data in
|
|
|
|
|
self?.activityView.removeFromSuperview()
|
|
|
|
|
if code == 31005{
|
|
|
|
|
self?.showPayVC()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
let popUpView = PlanetStarPopUpView.init(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: ScreenHeight))
|
|
|
|
|
self?.view.addSubview(popUpView)
|
|
|
|
|
popUpView.textView.text = text
|
|
|
|
|
popUpView.clickSendBlcok = {[weak self] in
|
2024-03-01 16:54:46 +08:00
|
|
|
|
self?.view.addSubview(self!.activityView)
|
|
|
|
|
RequestGet(path: "special/gift/get", parma: ["targetId":_uid]) { data in
|
|
|
|
|
self?.activityView.removeFromSuperview()
|
|
|
|
|
if let _ = Deserialized<PlanetStarModel>.toModel(with: data) {
|
|
|
|
|
HUDTool.show(with: "送礼成功")
|
|
|
|
|
let imageView = UIImageView(frame: CGRect(x: ScreenWidth/2-50, y: -100, width: 0, height: 0))
|
|
|
|
|
|
|
|
|
|
Nuke.loadImage(with: self?.giftModel?.picUrl ?? "", into: imageView)
|
|
|
|
|
self?.view.addSubview(imageView)
|
|
|
|
|
UIView.animate(withDuration: 2) {
|
|
|
|
|
imageView.frame = CGRect(x: ScreenWidth/2-50, y: ScreenHeight/3 * 2, width: 100, height: 100)
|
|
|
|
|
|
|
|
|
|
}completion: { isC in
|
|
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
|
|
|
|
UIView.animate(withDuration: 1) {
|
|
|
|
|
let x = self?.bgRadiusView.imageView.frame.origin.x ?? 0
|
|
|
|
|
let y = self?.bgRadiusView.imageView.frame.origin.y ?? 0
|
|
|
|
|
imageView.frame = CGRect(x: x + 50, y: y + 50, width: 10, height: 10)
|
|
|
|
|
|
|
|
|
|
}completion: { isC in
|
|
|
|
|
imageView.removeFromSuperview()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} fail: { code, data in
|
|
|
|
|
self?.activityView.removeFromSuperview()
|
|
|
|
|
if code == 31005{
|
2024-03-01 21:03:59 +08:00
|
|
|
|
self?.showPayVC()
|
2024-03-01 16:54:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-01 21:03:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-28 19:23:44 +08:00
|
|
|
|
}
|
2024-03-01 16:54:46 +08:00
|
|
|
|
|
2024-02-28 19:23:44 +08:00
|
|
|
|
|
2024-02-28 19:01:10 +08:00
|
|
|
|
}
|
2024-02-25 13:10:44 +08:00
|
|
|
|
}
|
2024-03-01 21:03:59 +08:00
|
|
|
|
func showPayVC(){
|
|
|
|
|
let popUpView = PlanetStarPopUpView.init(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: ScreenHeight))
|
|
|
|
|
self.view.addSubview(popUpView)
|
|
|
|
|
popUpView.textView.text = "钻石余额不足"
|
|
|
|
|
popUpView.senderView.setTitle("去充值", for: .normal)
|
|
|
|
|
popUpView.bgPointView.isHidden = true
|
|
|
|
|
popUpView.pointTextView.isHidden = true
|
|
|
|
|
popUpView.clickSendBlcok = {[weak self] in
|
|
|
|
|
let vc = UserPayViewController()
|
|
|
|
|
self?.navigationController?.pushViewController(vc, animated: true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-03-01 16:54:46 +08:00
|
|
|
|
let activityView:UIActivityIndicatorView = UIActivityIndicatorView(style: .medium)
|
2024-02-28 19:01:10 +08:00
|
|
|
|
var giftModel:PlanetStarModel?
|
|
|
|
|
private lazy var backgroundView:UIImageView = {
|
|
|
|
|
let _backgroundView = UIImageView()
|
|
|
|
|
_backgroundView.image = UIImage(named: "yin_plane_star_bg")
|
|
|
|
|
_backgroundView.isUserInteractionEnabled = true
|
|
|
|
|
return _backgroundView
|
|
|
|
|
}()
|
|
|
|
|
private var bgRadiusView:PlanetStarClickItemView = {
|
|
|
|
|
|
|
|
|
|
let _bgRadiusView = PlanetStarClickItemView.init(frame: CGRect(x: 0, y: 0, width: ScreenWidth , height: ScreenHeight))
|
|
|
|
|
_bgRadiusView.isUserInteractionEnabled = true
|
|
|
|
|
return _bgRadiusView
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
private var dataArray:[PlanetStarModel] = []
|
|
|
|
|
|
|
|
|
|
|
2024-02-25 13:10:44 +08:00
|
|
|
|
}
|
2024-02-28 19:01:10 +08:00
|
|
|
|
|
|
|
|
|
|