1. 优化首页语言的播放效果
2. 优化首页收藏行为后,收藏列表的更新效果 3. 修复充值时的 crash
This commit is contained in:
@@ -182,10 +182,18 @@ class HomeVoiceVC: BaseViewController,HiddenNavigationBarProtocol {
|
||||
}
|
||||
let userInfoView:HomeVoiceUserInfoView = HomeVoiceUserInfoView.init(frame: .zero)
|
||||
userInfoView.clickBtnBlock = {[weak self] (type,uid) in
|
||||
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
let session = NIMSession(uid, type: .P2P)
|
||||
let chatVC = ChatVC.init(session: session)
|
||||
self?.navigationController?.pushViewController(chatVC, animated: true)
|
||||
self.navigationController?.pushViewController(chatVC, animated: true)
|
||||
}
|
||||
userInfoView.followActionBlock = { [weak self] (isFollow, value) in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.requestFansListData()
|
||||
}
|
||||
userInfoView.model = model
|
||||
userInfoView.type = 0
|
||||
|
@@ -10,14 +10,24 @@ import Nuke
|
||||
|
||||
|
||||
typealias ClickPublishBlock = ()->Void
|
||||
typealias PlayVoiceEndBlock = ()->Void
|
||||
|
||||
|
||||
class HomeVoicePublishView: UIView {
|
||||
var clickPublishBlock:ClickPublishBlock?
|
||||
var playVoiceEndBlock:PlayVoiceEndBlock?
|
||||
|
||||
var currentAngle: CGFloat = 0.0
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setUILayout()
|
||||
loadSVGA()
|
||||
|
||||
let tap = UITapGestureRecognizer(target: self, action: #selector(publishViewAction))
|
||||
publishView.addGestureRecognizer(tap)
|
||||
}
|
||||
|
||||
func setUILayout(){
|
||||
addSubview(backgroundView)
|
||||
addSubview(discView)
|
||||
@@ -56,30 +66,35 @@ class HomeVoicePublishView: UIView {
|
||||
make.height.equalTo(52)
|
||||
make.right.equalTo(-20)
|
||||
}
|
||||
}
|
||||
|
||||
func loadSVGA() {
|
||||
discParser.parse(withNamed: "RecordPlayer", in: Bundle.main) {[weak self] videoItem in
|
||||
|
||||
self?.discView.videoItem = videoItem
|
||||
self?.discView.loops = 100000;
|
||||
self?.discView.clearsAfterStop = false
|
||||
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.discView.videoItem = videoItem
|
||||
self.discView.loops = 100000;
|
||||
self.discView.clearsAfterStop = false
|
||||
} failureBlock: { error in
|
||||
|
||||
}
|
||||
publishParser.parse(withNamed: "PublishVoice", in: Bundle.main) {[weak self] videoItem in
|
||||
|
||||
self?.publishView.videoItem = videoItem
|
||||
self?.publishView.loops = 100000;
|
||||
self?.publishView.startAnimation()
|
||||
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.publishView.videoItem = videoItem
|
||||
self.publishView.loops = 100000;
|
||||
self.publishView.startAnimation()
|
||||
} failureBlock: { error in
|
||||
|
||||
}
|
||||
let tap = UITapGestureRecognizer(target: self, action: #selector(publishViewAction))
|
||||
publishView.addGestureRecognizer(tap)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
@objc func publishViewAction(){
|
||||
guard let _clickPublishBlock = self.clickPublishBlock else {
|
||||
return
|
||||
@@ -90,8 +105,30 @@ class HomeVoicePublishView: UIView {
|
||||
playBtn.isSelected = false
|
||||
PlayVoiceManager.shared.stopPlayVoice()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func playAvatarAnimation() {
|
||||
let rotation = CABasicAnimation(keyPath: "transform.rotation")
|
||||
rotation.fromValue = currentAngle
|
||||
rotation.toValue = currentAngle + Double.pi * 2
|
||||
rotation.duration = 4
|
||||
rotation.repeatCount = Float.infinity
|
||||
avatarView.layer.add(rotation, forKey: "rotationAnimation")
|
||||
}
|
||||
|
||||
func stopAvatarAnimation() {
|
||||
if let presentationLayer = avatarView.layer.presentation() {
|
||||
let currentTransform = presentationLayer.transform
|
||||
// 移除动画
|
||||
avatarView.layer.removeAnimation(forKey: "rotationAnimation")
|
||||
// 应用当前状态
|
||||
avatarView.layer.transform = currentTransform
|
||||
currentAngle = atan2(currentTransform.m12, currentTransform.m11)
|
||||
} else {
|
||||
avatarView.layer.removeAnimation(forKey: "rotationAnimation")
|
||||
}
|
||||
}
|
||||
|
||||
@objc func playBtnAction(){
|
||||
guard let _model = self.model else {
|
||||
HUDTool.show(with: "把头像拖至唱片机才可播放")
|
||||
@@ -101,9 +138,11 @@ class HomeVoicePublishView: UIView {
|
||||
if (self.playBtn.isSelected){
|
||||
discView.startAnimation()
|
||||
PlayVoiceManager.shared.downloadVoice(url: _model.userVoice)
|
||||
playAvatarAnimation()
|
||||
return
|
||||
}
|
||||
discView.stopAnimation()
|
||||
stopAvatarAnimation()
|
||||
PlayVoiceManager.shared.stopPlayVoice()
|
||||
}
|
||||
|
||||
@@ -111,6 +150,7 @@ class HomeVoicePublishView: UIView {
|
||||
avatarView.image = nil
|
||||
model = nil
|
||||
discView.stopAnimation()
|
||||
stopAvatarAnimation()
|
||||
PlayVoiceManager.shared.stopPlayVoice()
|
||||
}
|
||||
|
||||
@@ -173,6 +213,7 @@ class HomeVoicePublishView: UIView {
|
||||
}
|
||||
Nuke.loadImage(with: _model.avatar, into:avatarView)
|
||||
discView.startAnimation()
|
||||
playAvatarAnimation()
|
||||
PlayVoiceManager.shared.downloadVoice(url: _model.userVoice)
|
||||
playBtn.isSelected = true
|
||||
}
|
||||
|
@@ -19,8 +19,10 @@ class UserPayViewController: BaseViewController, HiddenNavigationBarProtocol{
|
||||
}
|
||||
|
||||
func requestData(){
|
||||
RequestGet(path: "chargeprod/list", parma: ["channelType":"8"]) { data in
|
||||
|
||||
RequestGet(path: "chargeprod/list", parma: ["channelType":"8"]) { [weak self] data in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if let list = Deserialized<UserPayViewModel>.toArray(with: data) {
|
||||
for (i,view) in self.viewList.enumerated() {
|
||||
if i < list.count{
|
||||
@@ -31,15 +33,15 @@ class UserPayViewController: BaseViewController, HiddenNavigationBarProtocol{
|
||||
}else{
|
||||
view.isHidden = true
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} fail: { code, data in
|
||||
print(code)
|
||||
}
|
||||
RequestGet(path: "purse/query", parma: ["channelType":"8"]) { data in
|
||||
|
||||
RequestGet(path: "purse/query", parma: ["channelType":"8"]) { [weak self] data in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if let model = Deserialized<UserPayViewModel>.toModel(with: data) {
|
||||
self.pricView.text = model.diamonds
|
||||
}
|
||||
@@ -160,6 +162,7 @@ class UserPayViewController: BaseViewController, HiddenNavigationBarProtocol{
|
||||
let y = publishBtn.y + publishBtn.frame.height
|
||||
self.scrollView.contentSize = CGSize(width: ScreenWidth, height: y)
|
||||
}
|
||||
|
||||
@objc func publishBtnAction(){
|
||||
guard let chargeProdId = self.chooseModel?.chargeProdId else{
|
||||
return
|
||||
@@ -169,32 +172,36 @@ class UserPayViewController: BaseViewController, HiddenNavigationBarProtocol{
|
||||
let ticket = AuthManager.ticket
|
||||
let deviceInfo = UIDevice.current.identifierForVendor?.uuidString ?? ""
|
||||
let clientIp = "0.0.0.0"
|
||||
RequestPost(path: "storeKitV2/placeOrder", parma: ["chargeProdId":chargeProdId,"uid":uid,"ticket":ticket,"deviceInfo":deviceInfo]) { data in
|
||||
|
||||
|
||||
RequestPost(path: "storeKitV2/placeOrder", parma: ["chargeProdId":chargeProdId,"uid":uid,"ticket":ticket,"deviceInfo":deviceInfo]) { [weak self] data in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if let _data = data as? [String:Any],let recordId = _data["recordId"] as? String,let appAccountToken = _data["appAccountToken"] as? String{
|
||||
self.initiatePaymentAction(recordId: recordId, appAccountToken: appAccountToken)
|
||||
}else{
|
||||
HUDTool.show(with: "购买失败")
|
||||
MBProgressHUD.hide(for: keyWindow, animated: true)
|
||||
}
|
||||
|
||||
|
||||
} fail: { code, data in
|
||||
HUDTool.show(with: data)
|
||||
MBProgressHUD.hide(for: keyWindow, animated: true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
deinit{
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
}
|
||||
|
||||
func initiatePaymentAction(recordId:String,appAccountToken:String) {
|
||||
self.orderId = recordId
|
||||
if #available(iOS 15.0, *) {
|
||||
UserPayViewManager.shared._ConditionBlock = {[weak self] (state , result) in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
DispatchQueue.main.async {
|
||||
if state == .Pay || state == .Start || state == .VerifiedServer{
|
||||
ScreenWidth
|
||||
// ScreenWidth
|
||||
}else if state == .Unowned{
|
||||
HUDTool.show(with: "出现未知错误,请重新尝试")
|
||||
MBProgressHUD.hide(for: keyWindow , animated: true)
|
||||
@@ -203,31 +210,27 @@ class UserPayViewController: BaseViewController, HiddenNavigationBarProtocol{
|
||||
MBProgressHUD.hide(for: keyWindow, animated: true)
|
||||
}
|
||||
if state == .VerifiedServer{
|
||||
|
||||
|
||||
if let data = result,let transactionId = data["transactionId"]{
|
||||
self?.paySuccess(transactionId:"\(transactionId)")
|
||||
self.paySuccess(transactionId:"\(transactionId)")
|
||||
}else{
|
||||
HUDTool.show(with: "购买失败")
|
||||
MBProgressHUD.hide(for: keyWindow, animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Task {
|
||||
do {
|
||||
try await UserPayViewManager.shared._demandCommodityThing(productId: self.chooseModel?.chargeProdId ?? "", uuid: appAccountToken)
|
||||
|
||||
}catch{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
HUDTool.show(with: "充值失败。当前仅支持运行iOS15及以上系统的手机进行充值,请升级系统版本后重试。")
|
||||
}
|
||||
}
|
||||
|
||||
func paySuccess(transactionId:String){
|
||||
let uid = "\(AuthManager.userUid)"
|
||||
let ticket = AuthManager.ticket
|
||||
@@ -236,33 +239,28 @@ class UserPayViewController: BaseViewController, HiddenNavigationBarProtocol{
|
||||
|
||||
if #available(iOS 15.0, *) {
|
||||
Task {
|
||||
try await UserPayViewManager.shared._verifyBusinessAccomplish(transaction: transactionId)
|
||||
await UserPayViewManager.shared._verifyBusinessAccomplish(transaction: transactionId)
|
||||
self.orderId = ""
|
||||
RequestGet(path: "purse/query", parma: ["channelType":"8"]) { data in
|
||||
|
||||
RequestGet(path: "purse/query", parma: ["channelType":"8"]) { [weak self] data in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if let model = Deserialized<UserPayViewModel>.toModel(with: data) {
|
||||
self.pricView.text = model.diamonds
|
||||
}
|
||||
|
||||
} fail: { code, data in
|
||||
print(code)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} fail: { code, data in
|
||||
if code == 1444{
|
||||
Task {
|
||||
if #available(iOS 15.0, *) {
|
||||
try await UserPayViewManager.shared._verifyBusinessAccomplish(transaction: transactionId)
|
||||
await UserPayViewManager.shared._verifyBusinessAccomplish(transaction: transactionId)
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
HUDTool.show(with: data)
|
||||
|
@@ -15,28 +15,20 @@ class PlanetStarVC: BaseViewController,HiddenNavigationBarProtocol {
|
||||
super.viewDidLoad()
|
||||
yin_initUI()
|
||||
requestData()
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
func requestData(){
|
||||
|
||||
RequestGet(path: "home/recommendUsers", parma: ["pageNum":"\(self.page)","pageSize":"60"]) { 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
|
||||
@@ -52,19 +44,13 @@ class PlanetStarVC: BaseViewController,HiddenNavigationBarProtocol {
|
||||
} 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
|
||||
@@ -74,7 +60,6 @@ class PlanetStarVC: BaseViewController,HiddenNavigationBarProtocol {
|
||||
make.edges.equalTo(self.view)
|
||||
}
|
||||
|
||||
|
||||
bgRadiusView.refreshBlcok = {[weak self] (uid,type,name) in
|
||||
if type == 0{
|
||||
self?.page = (self?.page ?? 1) + 1
|
||||
@@ -123,6 +108,7 @@ class PlanetStarVC: BaseViewController,HiddenNavigationBarProtocol {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
let popUpView = PlanetStarPopUpView.init(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: ScreenHeight))
|
||||
self?.view.addSubview(popUpView)
|
||||
popUpView.textView.text = text
|
||||
@@ -159,14 +145,10 @@ class PlanetStarVC: BaseViewController,HiddenNavigationBarProtocol {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func showPayVC(){
|
||||
let popUpView = PlanetStarPopUpView.init(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: ScreenHeight))
|
||||
self.view.addSubview(popUpView)
|
||||
@@ -178,8 +160,8 @@ class PlanetStarVC: BaseViewController,HiddenNavigationBarProtocol {
|
||||
let vc = UserPayViewController()
|
||||
self?.navigationController?.pushViewController(vc, animated: true)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let activityView:UIActivityIndicatorView = UIActivityIndicatorView(style: .medium)
|
||||
var giftModel:PlanetStarModel?
|
||||
private lazy var backgroundView:UIImageView = {
|
||||
@@ -188,6 +170,7 @@ class PlanetStarVC: BaseViewController,HiddenNavigationBarProtocol {
|
||||
_backgroundView.isUserInteractionEnabled = true
|
||||
return _backgroundView
|
||||
}()
|
||||
|
||||
private var bgRadiusView:PlanetStarClickItemView = {
|
||||
|
||||
let _bgRadiusView = PlanetStarClickItemView.init(frame: CGRect(x: 0, y: 0, width: ScreenWidth , height: ScreenHeight))
|
||||
@@ -196,8 +179,6 @@ class PlanetStarVC: BaseViewController,HiddenNavigationBarProtocol {
|
||||
}()
|
||||
|
||||
private var dataArray:[PlanetStarModel] = []
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user