Commit 4bd776d9e8a43543f7e4a983c7043ff56b330015

Authored by 张旭
1 parent d0fa5d6a

积分支付逻辑调整

metaCode.xcodeproj/project.pbxproj
@@ -92,6 +92,7 @@ @@ -92,6 +92,7 @@
92 1938BD412B4BEC6900390A34 /* CNLiveAlbumListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1938BD402B4BEC6900390A34 /* CNLiveAlbumListModel.swift */; }; 92 1938BD412B4BEC6900390A34 /* CNLiveAlbumListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1938BD402B4BEC6900390A34 /* CNLiveAlbumListModel.swift */; };
93 1938BD432B4E34B200390A34 /* CNHomepageDuanJuDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1938BD422B4E34B200390A34 /* CNHomepageDuanJuDetailViewController.swift */; }; 93 1938BD432B4E34B200390A34 /* CNHomepageDuanJuDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1938BD422B4E34B200390A34 /* CNHomepageDuanJuDetailViewController.swift */; };
94 1938BD452B4E49CA00390A34 /* CNLiveDuanjuTitleCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1938BD442B4E49CA00390A34 /* CNLiveDuanjuTitleCell.swift */; }; 94 1938BD452B4E49CA00390A34 /* CNLiveDuanjuTitleCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1938BD442B4E49CA00390A34 /* CNLiveDuanjuTitleCell.swift */; };
  95 + 1938BD472B4FD5A500390A34 /* CNLiveIntegralAlertTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1938BD462B4FD5A500390A34 /* CNLiveIntegralAlertTool.swift */; };
95 19565EC02AF4DE0E007D6727 /* CNLiveShopDetailBtnsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19565EBF2AF4DE0E007D6727 /* CNLiveShopDetailBtnsCell.swift */; }; 96 19565EC02AF4DE0E007D6727 /* CNLiveShopDetailBtnsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19565EBF2AF4DE0E007D6727 /* CNLiveShopDetailBtnsCell.swift */; };
96 19565EC22AF616CA007D6727 /* CNLiveShopDetailOrderAssetCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19565EC12AF616CA007D6727 /* CNLiveShopDetailOrderAssetCell.swift */; }; 97 19565EC22AF616CA007D6727 /* CNLiveShopDetailOrderAssetCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19565EC12AF616CA007D6727 /* CNLiveShopDetailOrderAssetCell.swift */; };
97 19565EC52AF8AD1F007D6727 /* CNLiveShopProductManagerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19565EC42AF8AD1F007D6727 /* CNLiveShopProductManagerController.swift */; }; 98 19565EC52AF8AD1F007D6727 /* CNLiveShopProductManagerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19565EC42AF8AD1F007D6727 /* CNLiveShopProductManagerController.swift */; };
@@ -346,6 +347,7 @@ @@ -346,6 +347,7 @@
346 1938BD402B4BEC6900390A34 /* CNLiveAlbumListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveAlbumListModel.swift; sourceTree = "<group>"; }; 347 1938BD402B4BEC6900390A34 /* CNLiveAlbumListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveAlbumListModel.swift; sourceTree = "<group>"; };
347 1938BD422B4E34B200390A34 /* CNHomepageDuanJuDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNHomepageDuanJuDetailViewController.swift; sourceTree = "<group>"; }; 348 1938BD422B4E34B200390A34 /* CNHomepageDuanJuDetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNHomepageDuanJuDetailViewController.swift; sourceTree = "<group>"; };
348 1938BD442B4E49CA00390A34 /* CNLiveDuanjuTitleCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveDuanjuTitleCell.swift; sourceTree = "<group>"; }; 349 1938BD442B4E49CA00390A34 /* CNLiveDuanjuTitleCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveDuanjuTitleCell.swift; sourceTree = "<group>"; };
  350 + 1938BD462B4FD5A500390A34 /* CNLiveIntegralAlertTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveIntegralAlertTool.swift; sourceTree = "<group>"; };
349 19565EBF2AF4DE0E007D6727 /* CNLiveShopDetailBtnsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopDetailBtnsCell.swift; sourceTree = "<group>"; }; 351 19565EBF2AF4DE0E007D6727 /* CNLiveShopDetailBtnsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopDetailBtnsCell.swift; sourceTree = "<group>"; };
350 19565EC12AF616CA007D6727 /* CNLiveShopDetailOrderAssetCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopDetailOrderAssetCell.swift; sourceTree = "<group>"; }; 352 19565EC12AF616CA007D6727 /* CNLiveShopDetailOrderAssetCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopDetailOrderAssetCell.swift; sourceTree = "<group>"; };
351 19565EC42AF8AD1F007D6727 /* CNLiveShopProductManagerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopProductManagerController.swift; sourceTree = "<group>"; }; 353 19565EC42AF8AD1F007D6727 /* CNLiveShopProductManagerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveShopProductManagerController.swift; sourceTree = "<group>"; };
@@ -982,6 +984,7 @@ @@ -982,6 +984,7 @@
982 children = ( 984 children = (
983 792E57D82A3AA2F2005834DB /* CNLiveCommonBaseModel.swift */, 985 792E57D82A3AA2F2005834DB /* CNLiveCommonBaseModel.swift */,
984 792E57DA2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift */, 986 792E57DA2A3AE9F4005834DB /* CNLiveCommonQiniuTool.swift */,
  987 + 1938BD462B4FD5A500390A34 /* CNLiveIntegralAlertTool.swift */,
985 ); 988 );
986 path = Util; 989 path = Util;
987 sourceTree = "<group>"; 990 sourceTree = "<group>";
@@ -1688,6 +1691,7 @@ @@ -1688,6 +1691,7 @@
1688 191732FE2B0B3EBF007BCC04 /* CNLiveShopGoodsDetailsViewController.swift in Sources */, 1691 191732FE2B0B3EBF007BCC04 /* CNLiveShopGoodsDetailsViewController.swift in Sources */,
1689 79E496E32AB9357000127BF8 /* UITableViewCell+CNLiveExtension.swift in Sources */, 1692 79E496E32AB9357000127BF8 /* UITableViewCell+CNLiveExtension.swift in Sources */,
1690 7C83B4422A541EBF004BF4A4 /* CALayer+CNLiveExtensions.swift in Sources */, 1693 7C83B4422A541EBF004BF4A4 /* CALayer+CNLiveExtensions.swift in Sources */,
  1694 + 1938BD472B4FD5A500390A34 /* CNLiveIntegralAlertTool.swift in Sources */,
1691 19565EC72AF8AD38007D6727 /* CNLiveShopNewProductController.swift in Sources */, 1695 19565EC72AF8AD38007D6727 /* CNLiveShopNewProductController.swift in Sources */,
1692 798A44F72A3077ED00815935 /* CNLiveHotButton.swift in Sources */, 1696 798A44F72A3077ED00815935 /* CNLiveHotButton.swift in Sources */,
1693 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */, 1697 7CD6753D2A2740B0008354C1 /* CNMainView.swift in Sources */,
metaCode/Classes/Common/Util/CNLiveIntegralAlertTool.swift 0 → 100644
  1 +//
  2 +// CNLiveIntegralAlertTool.swift
  3 +// metaCode
  4 +//
  5 +// Created by zx on 2024/1/11.
  6 +// 积分支付弹窗
  7 +
  8 +import Foundation
  9 +import QMUIKit
  10 +import SnapKit
  11 +
  12 +///积分支付状态类型
  13 +enum CNLiveIntegralPayStatus {
  14 + ///积分充足
  15 + case integralEnough
  16 + ///积分不足
  17 + case integralNotEnough
  18 + ///支付中
  19 + case paying
  20 + ///支付成功
  21 + case paySuccess
  22 + ///支付失败
  23 + case payFailed
  24 +
  25 +}
  26 +
  27 +class CNLiveIntegralAlertTool:NSObject{
  28 + static let shared = CNLiveIntegralAlertTool()
  29 +
  30 + var homePageNeedReloadActionBlock:homePageNeedReloadBlockActionBlock?
  31 +
  32 + ///当前积分支付状态
  33 + var currentIntegralPayStatus: CNLiveIntegralPayStatus = .integralEnough
  34 +
  35 + let delegate = UIApplication.shared.delegate as! AppDelegate
  36 + /// 专辑名称
  37 + var title:String = ""
  38 +
  39 + /// 专辑积分值
  40 + var integralCount:String = "0"
  41 + /// 支付的商品id
  42 + var productId:String = ""
  43 + /// 用户积分值
  44 + var point:Int = 0
  45 + /// 用户积分model
  46 + var checkInModel:MinePointCheckInModel?
  47 +
  48 + lazy var bgBtnView: UIButton = {
  49 + let bgBtnView = UIButton(frame: self.delegate.window!.bounds)
  50 + bgBtnView.backgroundColor = HexColor("#000000")
  51 + bgBtnView.alpha = 0.6
  52 + bgBtnView.addTarget(self, action: #selector(bgBtnViewAction), for: .touchUpInside)
  53 + return bgBtnView
  54 + }()
  55 +
  56 + lazy var bottomBgView :UIView = {
  57 + let bottomBgView = UIView(frame: CGRect(x: 0, y: KSreenHeight-267, width: KSreenWidth, height: 267))
  58 + bottomBgView.backgroundColor = HexColor("#FFFFFF")
  59 + bottomBgView.layer.cornerRadius = 9
  60 + bottomBgView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
  61 + bottomBgView.tag = 10000
  62 + return bottomBgView
  63 + }()
  64 +
  65 + ///专辑标题
  66 + lazy var albumTitleLabel: UILabel = {
  67 + let titleLabel = UILabel.init(frame: CGRectMake(15, 15, KSreenWidth-15-60, 20))
  68 + titleLabel.textColor = HexColor("#333333")
  69 + titleLabel.textAlignment = .left
  70 + titleLabel.font = Font_16
  71 + titleLabel.text = "剧集名称45集"
  72 + return titleLabel
  73 + }()
  74 +
  75 + lazy var closeBtn: UIButton = {
  76 + let closeBtn = UIButton(type: .custom)
  77 + closeBtn.frame = CGRect(x: self.albumTitleLabel.right, y: 0, width: 50, height: 50)
  78 + closeBtn.setImage(UIImage(named: "point_alert_close"), for: .normal)
  79 + closeBtn.addTarget(self, action: #selector(closeBtnAction), for: .touchUpInside)
  80 + return closeBtn
  81 + }()
  82 +
  83 + lazy var bottomLineView :UIView = {
  84 + let bottomLineView = UIView(frame: CGRect(x: 0, y: self.closeBtn.bottom+2, width: KSreenWidth, height: 1))
  85 + bottomLineView.backgroundColor = HexColor("#E4E4E4")
  86 + return bottomLineView
  87 + }()
  88 +
  89 + ///积分数量
  90 + lazy var integralCountLabel: UILabel = {
  91 + let titleLabel = UILabel.init(frame: CGRectMake(0, self.bottomLineView.bottom+30, 100, 66))
  92 + titleLabel.textColor = HexColor("#333333")
  93 + titleLabel.textAlignment = .left
  94 + titleLabel.font = UIFont.boldSystemFont(ofSize: 55)
  95 + titleLabel.text = "8000"
  96 + return titleLabel
  97 + }()
  98 + ///余额XXX积分
  99 + lazy var balanceIntegralLabel: UILabel = {
  100 + let titleLabel = UILabel.init(frame: CGRectMake(0, 0, 100, 20))
  101 + titleLabel.textColor = HexColor("#696969")
  102 + titleLabel.textAlignment = .left
  103 + titleLabel.font = Font_14
  104 + return titleLabel
  105 + }()
  106 +
  107 + lazy var payBtn: UIButton = {
  108 + let payBtn = UIButton(type: .custom)
  109 + payBtn.frame = CGRect(x: 15, y: self.bottomBgView.height-15-44, width: KSreenWidth-30, height: 44)
  110 + payBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
  111 + // fillCode
  112 + let bgLayer1 = CAGradientLayer()
  113 + bgLayer1.colors = [UIColor(red: 0.4, green: 0.77, blue: 1, alpha: 1).cgColor, UIColor(red: 0.38, green: 0.6, blue: 1, alpha: 1).cgColor]
  114 + bgLayer1.locations = [0, 1]
  115 + bgLayer1.frame = payBtn.bounds
  116 + bgLayer1.startPoint = CGPoint(x: 0, y: 0.5)
  117 + bgLayer1.endPoint = CGPoint(x: 0.5, y: 0.5)
  118 + payBtn.layer.addSublayer(bgLayer1)
  119 + payBtn.addTarget(self, action: #selector(payBtnAction), for: .touchUpInside)
  120 + return payBtn
  121 + }()
  122 +
  123 + ///支付中img
  124 + lazy var payingImgView :UIImageView = {
  125 + let payingImgView = UIImageView(frame: CGRect(x: (KSreenWidth-45)/2.0, y: self.bottomLineView.bottom+65, width: 45, height: 43))
  126 + payingImgView.image = UIImage(named: "jifen_paying")
  127 + return payingImgView
  128 + }()
  129 + ///支付成功img
  130 + lazy var paySuccessImgView :UIImageView = {
  131 + let paySuccessImgView = UIImageView(frame: CGRect(x: (KSreenWidth-78)/2.0, y: 60, width: 78, height: 78))
  132 + paySuccessImgView.image = UIImage(named: "jifen_paySuccess")
  133 + return paySuccessImgView
  134 + }()
  135 +
  136 + ///支付中
  137 + lazy var payingLabel: UILabel = {
  138 + let titleLabel = UILabel.init(frame: CGRectMake(0, self.payingImgView.bottom+15, KSreenWidth-40, 20))
  139 + titleLabel.centerX = self.payingImgView.centerX
  140 + titleLabel.textColor = HexColor("#333333")
  141 + titleLabel.textAlignment = .center
  142 + titleLabel.font = Font_14
  143 + return titleLabel
  144 + }()
  145 +
  146 + // MARK: - show
  147 + ///弹出积分购买弹窗
  148 + func showIntegralAlert(title:String,integralCount:String,productId:String){
  149 + self.title = title
  150 + self.integralCount = integralCount
  151 + self.productId = productId
  152 +
  153 + delegate.window?.addSubview(self.bgBtnView)
  154 + delegate.window?.addSubview(self.bottomBgView)
  155 +
  156 + //专辑所需积分值
  157 + let intIntegralCount = Int(integralCount)!
  158 + //用户积分值
  159 + self.getCheckIn { result, status in
  160 + let checkInModel = result as! MinePointCheckInModel
  161 + self.checkInModel = checkInModel
  162 + let pointStr = checkInModel.integral ?? "0"
  163 + let intPoint = Int(pointStr)!
  164 + self.point = intPoint
  165 + if intPoint > intIntegralCount{
  166 + //可以支付积分
  167 + self.currentIntegralPayStatus = .integralEnough
  168 +
  169 + }else{
  170 + //积分不足
  171 + self.currentIntegralPayStatus = .integralNotEnough
  172 + }
  173 + self.initUI()
  174 +
  175 + }
  176 + }
  177 +
  178 + //隐藏积分购买弹窗
  179 + func hiddenIntegralAlert(){
  180 + delegate.window?.subviews.forEach({ view in
  181 + if view.tag == 10000{
  182 + UIView.animate(withDuration: 0.25) {
  183 + view.removeFromSuperview()
  184 + self.bgBtnView.removeFromSuperview()
  185 + }
  186 + }
  187 + })
  188 + }
  189 +
  190 + func initUI(){
  191 + self.bottomBgView.subviews.forEach { view in
  192 + view.removeFromSuperview()
  193 + }
  194 +
  195 + if self.currentIntegralPayStatus == .integralEnough{
  196 + //积分充足
  197 + self.bottomBgView.addSubview(self.albumTitleLabel)
  198 + self.albumTitleLabel.text = self.title
  199 + self.bottomBgView.addSubview(self.closeBtn)
  200 + self.bottomBgView.addSubview(self.bottomLineView)
  201 + self.bottomBgView.addSubview(self.integralCountLabel)
  202 + let integralCountStr = "\(self.integralCount)积分"
  203 + let priceAttri = NSMutableAttributedString.init(string: integralCountStr)
  204 + priceAttri.addAttribute(.font, value: regular_adapt_font(pointSize: 55), range: NSMakeRange(0, integralCountStr.count-2))
  205 + priceAttri.addAttribute(.foregroundColor, value: HexColor("#333333")!, range: NSMakeRange(0, integralCountStr.count-2))
  206 + priceAttri.addAttribute(.font, value: regular_adapt_font(pointSize: 16), range: NSMakeRange(integralCountStr.count-2, 2))
  207 + priceAttri.addAttribute(.foregroundColor, value: HexColor("#333333")!, range: NSMakeRange(integralCountStr.count-2, 2))
  208 + self.integralCountLabel.attributedText = priceAttri
  209 +
  210 + self.bottomBgView.addSubview(self.balanceIntegralLabel)
  211 +
  212 + self.balanceIntegralLabel.text = String(format: "余额%d积分", self.point)
  213 +
  214 + self.bottomBgView.addSubview(self.payBtn)
  215 + self.payBtn.setTitle("确认支付", for: .normal)
  216 +
  217 + self.integralCountLabel.snp.makeConstraints { make in
  218 + make.centerX.equalTo(self.bottomBgView.snp.centerX)
  219 + make.top.equalTo(self.bottomLineView.snp.bottom).offset(30)
  220 + make.width.lessThanOrEqualToSuperview().offset(-10)
  221 + }
  222 + self.balanceIntegralLabel.snp.makeConstraints { make in
  223 + make.centerX.equalTo(self.bottomBgView.snp.centerX)
  224 + make.top.equalTo(self.integralCountLabel.snp.bottom).offset(5)
  225 + make.width.lessThanOrEqualToSuperview()
  226 + }
  227 +
  228 + }else if self.currentIntegralPayStatus == .integralNotEnough{
  229 + //积分不足
  230 + self.bottomBgView.addSubview(self.albumTitleLabel)
  231 + self.albumTitleLabel.text = self.title
  232 + self.bottomBgView.addSubview(self.closeBtn)
  233 + self.bottomBgView.addSubview(self.bottomLineView)
  234 + self.bottomBgView.addSubview(self.integralCountLabel)
  235 + let integralCountStr = "\(self.integralCount)积分"
  236 + let priceAttri = NSMutableAttributedString.init(string: integralCountStr)
  237 + priceAttri.addAttribute(.font, value: regular_adapt_font(pointSize: 55), range: NSMakeRange(0, integralCountStr.count-2))
  238 + priceAttri.addAttribute(.foregroundColor, value: HexColor("#333333")!, range: NSMakeRange(0, integralCountStr.count-2))
  239 + priceAttri.addAttribute(.font, value: regular_adapt_font(pointSize: 16), range: NSMakeRange(integralCountStr.count-2, 2))
  240 + priceAttri.addAttribute(.foregroundColor, value: HexColor("#333333")!, range: NSMakeRange(integralCountStr.count-2, 2))
  241 + self.integralCountLabel.attributedText = priceAttri
  242 +
  243 + self.bottomBgView.addSubview(self.balanceIntegralLabel)
  244 + self.balanceIntegralLabel.text = String(format: "余额%d积分 积分不足", self.point)
  245 +
  246 + self.bottomBgView.addSubview(self.payBtn)
  247 + self.payBtn.setTitle("去赚积分", for: .normal)
  248 +
  249 + self.integralCountLabel.snp.makeConstraints { make in
  250 + make.centerX.equalTo(self.bottomBgView.snp.centerX)
  251 + make.top.equalTo(self.bottomLineView.snp.bottom).offset(30)
  252 + make.width.lessThanOrEqualToSuperview().offset(-10)
  253 + }
  254 + self.balanceIntegralLabel.snp.makeConstraints { make in
  255 + make.centerX.equalTo(self.bottomBgView.snp.centerX)
  256 + make.top.equalTo(self.integralCountLabel.snp.bottom).offset(5)
  257 + make.width.lessThanOrEqualToSuperview()
  258 + }
  259 + }else if self.currentIntegralPayStatus == .paying{
  260 + //支付中
  261 + self.bottomBgView.addSubview(self.albumTitleLabel)
  262 + self.albumTitleLabel.text = self.title
  263 + self.bottomBgView.addSubview(self.closeBtn)
  264 + self.bottomBgView.addSubview(self.bottomLineView)
  265 + self.bottomBgView.addSubview(self.payingImgView)
  266 + self.payingImgView = UIImageView(frame: CGRect(x: (KSreenWidth-45)/2.0, y: self.bottomLineView.bottom+65, width: 45, height: 43))
  267 + self.payingImgView.image = UIImage(named: "jifen_paying")
  268 +
  269 + self.bottomBgView.addSubview(self.payingLabel)
  270 + self.payingLabel.text = "支付中..."
  271 +
  272 + }else if self.currentIntegralPayStatus == .paySuccess{
  273 + //支付成功
  274 + self.bottomBgView.addSubview(self.paySuccessImgView)
  275 + self.paySuccessImgView = UIImageView(frame: CGRect(x: (KSreenWidth-78)/2.0, y: 60, width: 78, height: 78))
  276 + self.paySuccessImgView.image = UIImage(named: "jifen_paySuccess")
  277 +
  278 + self.bottomBgView.addSubview(self.payingLabel)
  279 + self.payingLabel.text = "支付成功\(self.integralCount)积分"
  280 +
  281 + self.bottomBgView.addSubview(self.payBtn)
  282 + self.payBtn.setTitle("完成", for: .normal)
  283 +
  284 + }else if self.currentIntegralPayStatus == .payFailed{
  285 + //支付失败
  286 + }else{
  287 + //其他
  288 + }
  289 + }
  290 +
  291 + //获取用户积分
  292 + func getCheckIn(resultBlock: @escaping downSlideResultBlock){
  293 + CNLiveMineViewModel.requestWithCheckIn { result, respStatue in
  294 + if respStatue == .success {
  295 + let checkModel = result as! MinePointCheckInModel
  296 + resultBlock(checkModel, .success)
  297 + } else {
  298 + resultBlock(NSNull(), .failed)
  299 + }
  300 + }
  301 + }
  302 +
  303 + // MARK: - BtnAction
  304 + @objc func bgBtnViewAction(){
  305 + self.hiddenIntegralAlert()
  306 + }
  307 + @objc func closeBtnAction(){
  308 + self.hiddenIntegralAlert()
  309 + }
  310 + @objc func payBtnAction(){
  311 + if self.currentIntegralPayStatus == .integralEnough{
  312 + self.postOrderVideoByPoint()
  313 + }else if self.currentIntegralPayStatus == .integralNotEnough{
  314 + self.hiddenIntegralAlert()
  315 + //跳转任务中心
  316 + navigationViewController().pushViewController(CNLiveMineQuestViewController(checkModel: self.checkInModel!), animated: pushAnimated)
  317 +
  318 + }else if self.currentIntegralPayStatus == .paying{
  319 +
  320 + }else if self.currentIntegralPayStatus == .paySuccess{
  321 + self.hiddenIntegralAlert()
  322 + }else if self.currentIntegralPayStatus == .payFailed{
  323 + self.currentIntegralPayStatus = .integralEnough
  324 + self.initUI()
  325 + }else{
  326 +
  327 + }
  328 + }
  329 + // MARK: - 积分付费接口
  330 + func postOrderVideoByPoint(){
  331 + self.currentIntegralPayStatus = .paying
  332 + self.initUI()
  333 + //付费接口
  334 + CNLiveHomePageViewModel.orderVideoByPoint(prdId: self.productId) { result, status in
  335 + if status == .success{
  336 + //购买成功
  337 + self.currentIntegralPayStatus = .paySuccess
  338 + self.initUI()
  339 + //刷新短剧首页数据
  340 + self.homePageNeedReloadActionBlock!()
  341 + }else{
  342 + //购买失败
  343 + if self.point > Int(self.integralCount)!{
  344 + //可以支付积分
  345 + self.currentIntegralPayStatus = .integralEnough
  346 + }else{
  347 + //积分不足
  348 + self.currentIntegralPayStatus = .integralNotEnough
  349 + }
  350 + self.initUI()
  351 + let errMsg = result as! String
  352 + showMessage(message: errMsg)
  353 + }
  354 + }
  355 +
  356 + }
  357 +
  358 +
  359 +}
metaCode/Classes/Extensions/NSObject+CNLiveExtensions.swift
@@ -166,7 +166,6 @@ func hiddenLoading() { @@ -166,7 +166,6 @@ func hiddenLoading() {
166 MBProgressHUD.hide(for: delegate.window!, animated: true) 166 MBProgressHUD.hide(for: delegate.window!, animated: true)
167 } 167 }
168 168
169 -  
170 ///####模型转换######### 169 ///####模型转换#########
171 /** 170 /**
172 * Json转对象 171 * Json转对象
metaCode/Classes/Main/HomePages/View/HomepageDetail/CNLiveAlbumCell.swift
@@ -105,29 +105,30 @@ class CNLiveAlbumCell:UITableViewCell{ @@ -105,29 +105,30 @@ class CNLiveAlbumCell:UITableViewCell{
105 } 105 }
106 106
107 //获取专辑详情(简介等) 107 //获取专辑详情(简介等)
108 -// func getAlbumMsg(){  
109 -// var aid = ""  
110 -// if self.albumModel != nil{  
111 -// aid = self.albumModel!.contentId  
112 -// }else if self.albumMsgModel != nil{  
113 -// aid = self.albumMsgModel!.albumId  
114 -// }else{  
115 -// aid = ""  
116 -// }  
117 -// CNLiveHomePageViewModel.getAlbumMsg(aid: aid) { result, status in  
118 -// hiddenLoading()  
119 -// if status == .success{  
120 -// let model = result as! CNLiveAlbumMsgModel  
121 -// for listModel in self.albumModelArr! {  
122 -// listModel.albumMsgModel = model  
123 -// }  
124 -// print("暂时跳转主页")  
125 -// navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLivePlayletHomePageController(albumModelArr: self.albumModelArr!), animated: true)  
126 -// }else{  
127 -//  
128 -// }  
129 -// }  
130 -// } 108 + func getAlbumMsg(){
  109 + var aid = ""
  110 + if self.albumModel != nil{
  111 + aid = self.albumModel!.contentId
  112 + }else if self.albumMsgModel != nil{
  113 + aid = self.albumMsgModel!.albumId
  114 + }else{
  115 + aid = ""
  116 + }
  117 + CNLiveHomePageViewModel.getAlbumMsg(aid: aid) { result, status in
  118 + hiddenLoading()
  119 + if status == .success{
  120 + let model = result as! CNLiveAlbumMsgModel
  121 + for listModel in self.albumModelArr! {
  122 + listModel.albumMsgModel = model
  123 + }
  124 + navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLiveShortVideoViewController(), animated: pushAnimated)
  125 +
  126 + navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLivePlayletHomePageController(aid: aid), animated: true)
  127 + }else{
  128 +
  129 + }
  130 + }
  131 + }
131 //获取专辑视频列表详情(播放地址 ,点赞数等信息) 132 //获取专辑视频列表详情(播放地址 ,点赞数等信息)
132 func getAlbumList(){ 133 func getAlbumList(){
133 showLoading(message: "") 134 showLoading(message: "")
@@ -140,18 +141,15 @@ class CNLiveAlbumCell:UITableViewCell{ @@ -140,18 +141,15 @@ class CNLiveAlbumCell:UITableViewCell{
140 aid = "" 141 aid = ""
141 } 142 }
142 143
143 - navigationViewController().visibleViewController?.navigationController?.pushViewController(CNLivePlayletHomePageController(aid: aid), animated: true)  
144 - return  
145 -//  
146 -// CNLiveHomePageViewModel.getAlbumList(aid: aid){ result, status in  
147 -// hiddenLoading()  
148 -// if status == .success{  
149 -// let arr = result as! Array<CNLiveAlbumListModel>  
150 -// self.albumModelArr = Array(arr)  
151 -// self.getAlbumMsg()  
152 -// }else{  
153 -//  
154 -// }  
155 -// } 144 + CNLiveHomePageViewModel.getAlbumList(aid: aid){ result, status in
  145 + hiddenLoading()
  146 + if status == .success{
  147 + let arr = result as! Array<CNLiveAlbumListModel>
  148 + self.albumModelArr = Array(arr)
  149 + self.getAlbumMsg()
  150 + }else{
  151 +
  152 + }
  153 + }
156 } 154 }
157 } 155 }
metaCode/Classes/Main/HomePages/View/PlayletHomePage/CNLivePlayletHomePageHeaderCell.swift
@@ -311,11 +311,13 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{ @@ -311,11 +311,13 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{
311 button.isSelected = !button.isSelected 311 button.isSelected = !button.isSelected
312 if self.albumListModel?.product?.check == false{ 312 if self.albumListModel?.product?.check == false{
313 //未购买->购买 313 //未购买->购买
314 - //弹窗购买,再调用接口  
315 -  
316 -  
317 -// self.postOrderVideoByPoint()  
318 - 314 + CNLiveIntegralAlertTool.shared.showIntegralAlert(title: "\(self.albumListModel?.albumMsgModel?.albumName ?? "")共\(self.albumListModel?.albumMsgModel?.episodeNow ?? "1")集", integralCount: self.albumListModel?.albumMsgModel?.product?.point ?? "0", productId: self.albumListModel?.product?.productId ?? "")
  315 + CNLiveIntegralAlertTool.shared.homePageNeedReloadActionBlock = {
  316 + self.homePageNeedReloadActionBlock!()
  317 + DispatchQueue.main.asyncAfter(deadline: .now()+1.5) { [self] in
  318 + self.followChangeStatus(isFollowed: true)
  319 + }
  320 + }
319 } 321 }
320 } 322 }
321 func paymentChangeStatus(isPayed:Bool){ 323 func paymentChangeStatus(isPayed:Bool){
@@ -382,23 +384,6 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{ @@ -382,23 +384,6 @@ class CNLivePlayletHomePageHeaderCell:UITableViewCell{
382 } 384 }
383 } 385 }
384 386
385 - // MARK: - 积分付费接口  
386 - func postOrderVideoByPoint(){  
387 - //付费接口  
388 - CNLiveHomePageViewModel.orderVideoByPoint(prdId: self.albumListModel?.product?.productId ?? "") { result, status in  
389 - if status == .success{  
390 - //购买成功  
391 -  
392 - //刷新短剧首页数据  
393 - self.homePageNeedReloadActionBlock!()  
394 - }else{  
395 - //购买失败  
396 - let errMsg = result as! String  
397 - showMessage(message: errMsg)  
398 - }  
399 - }  
400 -  
401 - }  
402 // MARK: - 网络请求 追剧1/取消追剧2 387 // MARK: - 网络请求 追剧1/取消追剧2
403 func postAlbumCollect(type:NSInteger){ 388 func postAlbumCollect(type:NSInteger){
404 CNLiveHomePageViewModel.postAlbumCollect(aid: self.albumListModel?.albumMsgModel?.albumId ?? "", type: type) { result, status in 389 CNLiveHomePageViewModel.postAlbumCollect(aid: self.albumListModel?.albumMsgModel?.albumId ?? "", type: type) { result, status in
metaCode/Classes/Main/HomePages/ViewModel/CNLiveHomePageViewModel.swift
@@ -182,16 +182,18 @@ class CNLiveHomePageViewModel:NSObject{ @@ -182,16 +182,18 @@ class CNLiveHomePageViewModel:NSObject{
182 static func orderVideoByPoint(prdId:String,resultBlock: @escaping downSlideResultBlock) { 182 static func orderVideoByPoint(prdId:String,resultBlock: @escaping downSlideResultBlock) {
183 let param = NSMutableDictionary() 183 let param = NSMutableDictionary()
184 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid") 184 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid")
185 - param.setValue(APPId, forKey: "sp_id") 185 + param.setValue(APPId_wjj, forKey: "sp_id")
186 param.setValue(prdId, forKey: "prdId") 186 param.setValue(prdId, forKey: "prdId")
187 param.setValue("apple", forKey: "frmId") 187 param.setValue("apple", forKey: "frmId")
188 param.setValue(CNLiveHomePageViewModel.getRandomOrderId(), forKey: "srvOrderId") 188 param.setValue(CNLiveHomePageViewModel.getRandomOrderId(), forKey: "srvOrderId")
189 - 189 + let customParam = NSMutableDictionary()
  190 + customParam.setValue(APPId, forKey: "appId")
  191 + customParam.setValue(APPKey, forKey: "appKey")
  192 +
190 CNLiveNetworking.setupShowResult(true) 193 CNLiveNetworking.setupShowResult(true)
191 CNLiveNetworking.setAllowRequestDefaultArgument(true) 194 CNLiveNetworking.setAllowRequestDefaultArgument(true)
192 CNLiveNetworking.setupShowDataResult(false) 195 CNLiveNetworking.setupShowDataResult(false)
193 - CNLiveNetworking.setupSignRequestKey(APPKey)//APPKey_wjj APPKey  
194 - 196 + CNLiveNetworking.setupCustomParam(customParam as? [String : String])
195 CNLiveNetworking.requestNetwork(with: .POST, urlString: "\(CNLiveEnvironmentManager.shared.img_token_url)/pom/orderVideoByPoint", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in 197 CNLiveNetworking.requestNetwork(with: .POST, urlString: "\(CNLiveEnvironmentManager.shared.img_token_url)/pom/orderVideoByPoint", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
196 hiddenLoading() 198 hiddenLoading()
197 if (error == nil) { 199 if (error == nil) {
@@ -222,7 +224,7 @@ class CNLiveHomePageViewModel:NSObject{ @@ -222,7 +224,7 @@ class CNLiveHomePageViewModel:NSObject{
222 //取毫秒时间戳 224 //取毫秒时间戳
223 let timestamp13 = String(format: "%ld",self.getNow13Timestamp())//timeStamp) 225 let timestamp13 = String(format: "%ld",self.getNow13Timestamp())//timeStamp)
224 //拼接 226 //拼接
225 - randomOrderId = String(format: "%@%@%@%d", APPId, currentDateString, timestamp13, Int.random(in: 0..<10)) 227 + randomOrderId = String(format: "%@%@%@%d", APPId_wjj, currentDateString, timestamp13, Int.random(in: 0..<10))
226 228
227 return randomOrderId 229 return randomOrderId
228 } 230 }
metaCode/Supporting Files/Assets.xcassets/HomePage/jifen_paySuccess.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "jifen_paySuccess@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "jifen_paySuccess@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
metaCode/Supporting Files/Assets.xcassets/HomePage/jifen_paySuccess.imageset/jifen_paySuccess@2x.png 0 → 100644

12.4 KB

metaCode/Supporting Files/Assets.xcassets/HomePage/jifen_paySuccess.imageset/jifen_paySuccess@3x.png 0 → 100644

27.2 KB

metaCode/Supporting Files/Assets.xcassets/HomePage/jifen_paying.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "jifen_paying@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "jifen_paying@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
metaCode/Supporting Files/Assets.xcassets/HomePage/jifen_paying.imageset/jifen_paying@2x.png 0 → 100644

3.01 KB

metaCode/Supporting Files/Assets.xcassets/HomePage/jifen_paying.imageset/jifen_paying@3x.png 0 → 100644

5.57 KB

metaCode/Supporting Files/Assets.xcassets/HomePage/point_alert_close.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "scale" : "1x"
  6 + },
  7 + {
  8 + "filename" : "point_alert_close@2x.png",
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "filename" : "point_alert_close@3x.png",
  14 + "idiom" : "universal",
  15 + "scale" : "3x"
  16 + }
  17 + ],
  18 + "info" : {
  19 + "author" : "xcode",
  20 + "version" : 1
  21 + }
  22 +}
metaCode/Supporting Files/Assets.xcassets/HomePage/point_alert_close.imageset/point_alert_close@2x.png 0 → 100644

977 Bytes

metaCode/Supporting Files/Assets.xcassets/HomePage/point_alert_close.imageset/point_alert_close@3x.png 0 → 100644

1.73 KB