Bläddra i källkod

修改一批 bug,先提交

100Years 2 dagar sedan
förälder
incheckning
aa3738e5c3
27 ändrade filer med 256 tillägg och 191 borttagningar
  1. 3 1
      AIEmoji/AppDelegate.swift
  2. 0 1
      AIEmoji/Business/TSPurchaseMembershipVC/TSPurchaseVideoTimesVC/TSPurchaseVideoTimesVC.swift
  3. 141 8
      AIEmoji/Business/TSPurchaseMembershipVC/TSPurchaseVideoTimesVC/View/TSPurchaseVideoTimesAlertView.swift
  4. 0 4
      AIEmoji/Business/TSPurchaseMembershipVC/View/PurchaseView.swift
  5. 6 2
      AIEmoji/Business/TSSetingVC/SetingVC/TSSetingVC.swift
  6. 1 1
      AIEmoji/Business/TSSetingVC/SetingVC/View/TSSetingListView.swift
  7. 18 9
      AIEmoji/Business/TSSetingVC/TSChangeLanguageVC/TSChangeLanguageVC.swift
  8. 10 10
      AIEmoji/Business2/DIYVideo/TSAIDiyVideoVC.swift
  9. 9 0
      AIEmoji/Business2/DisCover/Data/TSFuncStyle.swift
  10. 1 1
      AIEmoji/Business2/DisCover/TSDiscoverVC/Cell/TSDiscoverStyleMoreCell.swift
  11. 3 133
      AIEmoji/Business2/DisCover/TSDiscoverVC/TSDiscoverVC.swift
  12. 6 0
      AIEmoji/Business2/DisCover/TSGenerateHistoryVC/TSGenerateHistoryVC.swift
  13. 4 7
      AIEmoji/Business2/DisCover/TSPTPUploadImageVC/TSPTPUploadImageVC+View.swift
  14. 7 1
      AIEmoji/Common/Purchase/TSPurchaseManager+Free.swift
  15. 21 4
      AIEmoji/Common/Purchase/TSPurchaseManager+Judge.swift
  16. 0 8
      AIEmoji/Common/Purchase/TSPurchaseManager+Limit.swift
  17. 7 0
      AIEmoji/Common/Purchase/TSPurchaseManager.swift
  18. 10 1
      AIEmoji/Common/View/TSTextToastView.swift
  19. 1 0
      AIEmoji/de.lproj/Localizable.strings
  20. 1 0
      AIEmoji/en.lproj/Localizable.strings
  21. 1 0
      AIEmoji/es.lproj/Localizable.strings
  22. 1 0
      AIEmoji/ja.lproj/Localizable.strings
  23. 1 0
      AIEmoji/ko.lproj/Localizable.strings
  24. 1 0
      AIEmoji/pt-BR.lproj/Localizable.strings
  25. 1 0
      AIEmoji/pt-PT.lproj/Localizable.strings
  26. 1 0
      AIEmoji/zh-Hans.lproj/Localizable.strings
  27. 1 0
      AIEmoji/zh-Hant.lproj/Localizable.strings

+ 3 - 1
AIEmoji/AppDelegate.swift

@@ -64,7 +64,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     }
     }
 
 
     func initPlatform() {
     func initPlatform() {
-//        handleKingfisher()//迁移 kf 的图片资源从 cache 到 document 永久保存
+        handleKingfisher()//迁移 kf 的图片资源从 cache 到 document 永久保存
+        _ = LanguageManager.shared//多语言设置切换
+        TSRTLManage.setUpInit() //阿拉伯语适配
         TSCrashReporterTool.shared.setup()
         TSCrashReporterTool.shared.setup()
         TSCrashReporterTool.shared.printCrashReports()
         TSCrashReporterTool.shared.printCrashReports()
         TSColorConfigShared.naviMianTextColor = .white
         TSColorConfigShared.naviMianTextColor = .white

+ 0 - 1
AIEmoji/Business/TSPurchaseMembershipVC/TSPurchaseVideoTimesVC/TSPurchaseVideoTimesVC.swift

@@ -205,7 +205,6 @@ extension TSPurchaseVideoTimesVC {
     }
     }
     
     
     @objc func closePage(){
     @objc func closePage(){
-        TSToastShared.hideLoading()
         self.dismiss(animated: true)
         self.dismiss(animated: true)
         NotificationCenter.default.post(name: .kCloseTSPurchaseVC, object: nil)
         NotificationCenter.default.post(name: .kCloseTSPurchaseVC, object: nil)
     }
     }

+ 141 - 8
AIEmoji/Business/TSPurchaseMembershipVC/TSPurchaseVideoTimesVC/View/TSPurchaseVideoTimesAlertView.swift

@@ -8,6 +8,147 @@
 import SwiftUI
 import SwiftUI
 import SwiftUIX
 import SwiftUIX
 
 
+//struct TSPurchaseVideoTimesAlertView :View {
+//    @ObservedObject var viewModel: TSPurchaseVideoTimesVM
+//    @State var isExpand: Bool = false
+//    @State private var scrollProxy: ScrollViewProxy? = nil
+//    private let bottomID = "BOTTOM_ID" // 底部标识符
+//    
+//    var body: some View {
+//        VStack {
+//            let limit = "No effect uses left. Get more to keep creating.".localized
+//            let alertHeight:CGFloat = 468.0
+//            Spacer()
+//            ZStack(alignment: .topTrailing) {
+//                
+//                
+//                ZStack(alignment: .top) {
+//                    
+//                   Image(.purchaseVideoTimesAlertBj)
+//                       .resizable()
+//                       .scaledToFill()
+//                       .frame(height: alertHeight)
+//                       .clipped()
+//                    
+//                    // 内容层(可滚动)
+//                    ScrollViewReader { proxy in
+//                        ScrollView {
+//                            VStack {
+//                                Spacer().frame(height: 24)
+//                                Text("Limit Reached".localized)
+//                                    .multilineTextAlignment(.center)
+//                                    .font(.font(size: 22,weight: .medium))
+//                                    .foregroundColor(.white)
+//                                    .padding(EdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10))
+//                                
+//                                Spacer().frame(height: 16)
+//                                Text(limit)
+//                                    .font(.font(size: 14,weight: .regular))
+//                                    .multilineTextAlignment(.center)
+//                                    .foregroundColor(.white.opacity(0.7))
+//                                    .padding(EdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10))
+//                                
+//                                Spacer().frame(height: 15)
+//                                VStack(alignment: .leading, spacing: 20, content: {
+//                                    TSPurchaseVideoTimesCellView(type: .purchase(.videoNum1), selectedType: $viewModel.selectedType)
+//                                        .onTapGesture {
+//                                            viewModel.selectedType = .purchase(.videoNum1)
+//                                        }
+//                                    ZStack(alignment: .topTrailing) {
+//                                        TSPurchaseVideoTimesCellView(type: .purchase(.videoNum2), selectedType: $viewModel.selectedType)
+//                                            .onTapGesture {
+//                                                viewModel.selectedType = .purchase(.videoNum2)
+//                                            }
+//                                        TSPurchaseVideoTimesRecView()
+//                                            .offset(x:-12,y:-14)
+//                                    }
+//                                    TSPurchaseVideoTimesCellView(type: .purchase(.videoNum3), selectedType: $viewModel.selectedType)
+//                                        .onTapGesture {
+//                                            viewModel.selectedType = .purchase(.videoNum3)
+//                                        }
+//                                }).multilineTextAlignment(.center).font(.font(size: 16,weight:.regular)).foregroundColor(.white)
+//                                
+//                                Spacer().frame(height: 28)
+//                                
+//                                
+//                                Button {
+//                                    viewModel.buyPublisher.send(true)
+//                                } label: {
+//                                    ZStack {
+//                                        Image(.purchaseVideoTimesBtnbg)
+//                                        Text("Purchase".localized)
+//                                            .font(.font(size: 16,weight: .medium))
+//                                            .foregroundColor(.white)
+//                                    }.frame(maxWidth: .infinity ,minHeight: 48.0,maxHeight: 48.0)
+//                                }
+//                                
+//                                
+//                                VStack{
+//                                    Spacer().frame(height: 15)
+//                                    Button {
+//                                        withAnimation(.easeInOut(duration: 0.3)) {
+//                                            isExpand.toggle()
+//                                            
+//                                            if isExpand == true {
+//                                                scrollProxy?.scrollTo(bottomID, anchor: .bottom)
+//                                            }
+//
+//                                        }
+//                                    } label: {
+//                                        HStack(spacing: 4) {
+//                                            Text("View Usage Rules".localized)
+//                                                .font(.font(size: 12,weight: .regular))
+//                                                .foregroundColor(.white.opacity(0.7))
+//                                            Image(isExpand ? .chatUpArrow : .chatDownArrow)
+//                                        }
+//                                    }
+//                                }
+//                                
+//                                if isExpand {
+//                                    
+//                                    Spacer().frame(height: 10)
+//                                    
+//                                    VStack(alignment: .leading, spacing: 8, content: {
+//                                        TSPurchaseVideoTextLineView(image: .purchaseVideoTimesCheck, text: "Only VIP can purchase video effect uses".localized)
+//                                        TSPurchaseVideoTextLineView(image: .purchaseVideoTimesCheck, text: "Uses can be applied to all video generations".localized)
+//                                        TSPurchaseVideoTextLineView(image: .purchaseVideoTimesCheck, text: "Uses never expire and can be purchased repeatedly".localized)
+//                                        TSPurchaseVideoTextLineView(image: .purchaseVideoTimesCheck, text: "All unused uses will be lost if the app is uninstalled".localized)
+//                                    })
+//                                    .foregroundColor(Color.hex("#FCE5FF").opacity(0.8))
+//                                    .padding(EdgeInsets(top: 0, leading: 10, bottom: 0, trailing: 10))
+//                                    
+//                                    Spacer().frame(height: 24 + k_Height_safeAreaInsetsBottom())
+//                                }else{
+//                                    Spacer().frame(height: k_Height_safeAreaInsetsBottom())
+//                                }
+//                                
+//                                // 关键:透明的底部定位Spacer
+//                                Color.clear
+//                                    .frame(height: 1)
+//                                    .id(bottomID) // 设置唯一标识符
+//                            }
+//                            .padding(.horizontal,16)
+//                            .onAppear {
+//                                self.scrollProxy = proxy
+//                            }
+//                        }.frame(height: alertHeight)
+//                        
+//                        
+//                    }
+//                }
+//
+//                Button {
+//                    viewModel.closePagePublisher.send(true)
+//                } label: {
+//                    Image(.closeClear).resizable().frame(width: 24, height: 24)
+//                }.offset(x:-8,y:8)
+//            }
+//        }
+//        .ignoresSafeArea()
+//    }
+//}
+
+
 struct TSPurchaseVideoTimesAlertView :View {
 struct TSPurchaseVideoTimesAlertView :View {
     @ObservedObject var viewModel: TSPurchaseVideoTimesVM
     @ObservedObject var viewModel: TSPurchaseVideoTimesVM
     @State var isExpand: Bool = false
     @State var isExpand: Bool = false
@@ -104,14 +245,6 @@ struct TSPurchaseVideoTimesAlertView :View {
                 }
                 }
                 .padding(.horizontal,16)
                 .padding(.horizontal,16)
                 .background(
                 .background(
-//                    GeometryReader { geometry in
-//                          Image(.purchaseVideoTimesAlertBj)
-//                              .resizable()
-//                              .scaledToFill()
-//                              .frame(width: geometry.size.width)
-//                              // 关键:限制高度不超过内容高度
-//                              .frame(height: geometry.size.height)
-//                      }
                     Color.hex("#261840").cornerRadius([.topLeading,.topTrailing], 20)
                     Color.hex("#261840").cornerRadius([.topLeading,.topTrailing], 20)
                 )
                 )
                 
                 

+ 0 - 4
AIEmoji/Business/TSPurchaseMembershipVC/View/PurchaseView.swift

@@ -61,8 +61,6 @@ struct PurchaseView :View {
 //                            viewModel.selectedType = .month
 //                            viewModel.selectedType = .month
                     PurchaseItemView(title: "One Year".localized, type: .year, selectedType: $viewModel.selectedType).onTapGesture {
                     PurchaseItemView(title: "One Year".localized, type: .year, selectedType: $viewModel.selectedType).onTapGesture {
                         viewModel.selectedType = .year
                         viewModel.selectedType = .year
-
-                            viewModel.buyPublisher.send(true)
                         }
                         }
                         TSVipRecView(save: vipType.saveString)
                         TSVipRecView(save: vipType.saveString)
                             .offset(x:-30,y:-14)
                             .offset(x:-30,y:-14)
@@ -70,12 +68,10 @@ struct PurchaseView :View {
                     
                     
                     PurchaseItemView(title: "One Week".localized, type: .week(.week), selectedType: $viewModel.selectedType).onTapGesture {
                     PurchaseItemView(title: "One Week".localized, type: .week(.week), selectedType: $viewModel.selectedType).onTapGesture {
                         viewModel.selectedType = .week(.week)
                         viewModel.selectedType = .week(.week)
-                        viewModel.buyPublisher.send(true)
                     }
                     }
                 }else{
                 }else{
                     PurchaseItemTypeOneView(title: "One Year".localized, type: .year, selectedType: $viewModel.selectedType).onTapGesture {
                     PurchaseItemTypeOneView(title: "One Year".localized, type: .year, selectedType: $viewModel.selectedType).onTapGesture {
                         viewModel.selectedType = .year
                         viewModel.selectedType = .year
-                        viewModel.buyPublisher.send(true)
                     }
                     }
                 }
                 }
                 
                 

+ 6 - 2
AIEmoji/Business/TSSetingVC/SetingVC/TSSetingVC.swift

@@ -91,7 +91,10 @@ class TSSetingVC: TSBaseVC {
                 viewModel.changeLanguageVC(parent: self)
                 viewModel.changeLanguageVC(parent: self)
             case .videoPackage:
             case .videoPackage:
                 viewModel.purchaseVideoTimesVC(parent: self)
                 viewModel.purchaseVideoTimesVC(parent: self)
-#if DEBUG
+
+                
+                
+            //===========测试区域===========//
             case .deleteAllData:
             case .deleteAllData:
                 viewModel.deleteAllData(parent: self)
                 viewModel.deleteAllData(parent: self)
             case .lookAllData:
             case .lookAllData:
@@ -100,7 +103,8 @@ class TSSetingVC: TSBaseVC {
                 viewModel.videoTimesAdd(num: 1)
                 viewModel.videoTimesAdd(num: 1)
             case .videoTimesReduce:
             case .videoTimesReduce:
                 viewModel.videoTimesReduce(num: -1)
                 viewModel.videoTimesReduce(num: -1)
-#endif
+
+                
             default:
             default:
                 dePrint("不处理点击")
                 dePrint("不处理点击")
             }
             }

+ 1 - 1
AIEmoji/Business/TSSetingVC/SetingVC/View/TSSetingListView.swift

@@ -52,7 +52,7 @@ struct TSSettingListView: View {
                 VStack(spacing:0) {
                 VStack(spacing:0) {
                     SettingListItemView(type: .deleteAllData, publisher: publisher, rightView: EmptyView(), rightArrow: true)
                     SettingListItemView(type: .deleteAllData, publisher: publisher, rightView: EmptyView(), rightArrow: true)
                     SettingListItemView(type: .lookAllData, publisher: publisher,rightView: EmptyView(), rightArrow: true)
                     SettingListItemView(type: .lookAllData, publisher: publisher,rightView: EmptyView(), rightArrow: true)
-//                    SettingListItemView(type: .videoTimesAdd, publisher: publisher,rightView: EmptyView(), rightArrow: true)
+                    SettingListItemView(type: .videoTimesAdd, publisher: publisher,rightView: EmptyView(), rightArrow: true)
                     SettingListItemView(type: .videoTimesReduce, publisher: publisher,rightView: EmptyView(), rightArrow: true)
                     SettingListItemView(type: .videoTimesReduce, publisher: publisher,rightView: EmptyView(), rightArrow: true)
                 }.cornerRadius(16)
                 }.cornerRadius(16)
 //#endif
 //#endif

+ 18 - 9
AIEmoji/Business/TSSetingVC/TSChangeLanguageVC/TSChangeLanguageVC.swift

@@ -12,8 +12,7 @@ class TSChangeLanguageVC: TSBaseVC {
         simpleTableView.register(TSChangeLanguageCell.self, forCellReuseIdentifier: "TSChangeLanguageCell")
         simpleTableView.register(TSChangeLanguageCell.self, forCellReuseIdentifier: "TSChangeLanguageCell")
         simpleTableView.delegate = self
         simpleTableView.delegate = self
         simpleTableView.dataSource = self
         simpleTableView.dataSource = self
-        simpleTableView.cornerRadius = 16
-        simpleTableView.backgroundColor = .white.withAlphaComponent(0.05)
+//        simpleTableView.cornerRadius = 16
         return simpleTableView
         return simpleTableView
     }()
     }()
     
     
@@ -54,6 +53,7 @@ class TSChangeLanguageVC: TSBaseVC {
         TSRTLManage.setUpInit()
         TSRTLManage.setUpInit()
         AppDelegate.shared?.goToTab()
         AppDelegate.shared?.goToTab()
     }
     }
+
 }
 }
 
 
 extension TSChangeLanguageVC : UITableViewDataSource, UITableViewDelegate {
 extension TSChangeLanguageVC : UITableViewDataSource, UITableViewDelegate {
@@ -80,6 +80,15 @@ extension TSChangeLanguageVC : UITableViewDataSource, UITableViewDelegate {
                 }
                 }
                 cell.textLab.text = language.displayName
                 cell.textLab.text = language.displayName
                 cell.rightImageView.image = selectedIndex ==  indexPath.row ? .check : .unCheck
                 cell.rightImageView.image = selectedIndex ==  indexPath.row ? .check : .unCheck
+         
+                kMainAsync {
+                    if indexPath.row == 0 {
+                        cell.bgContentView.cornersRound(radius: 16, corner: [.topLeft,.topRight])
+                    }else if indexPath.row == (self.dataArray.count - 1) {
+                        cell.bgContentView.cornersRound(radius: 16, corner: [.bottomLeft,.bottomRight])
+                    }
+                }
+              
             }
             }
             return cell
             return cell
         }
         }
@@ -95,13 +104,7 @@ extension TSChangeLanguageVC : UITableViewDataSource, UITableViewDelegate {
 }
 }
 
 
 class TSChangeLanguageCell: UITableViewCell {
 class TSChangeLanguageCell: UITableViewCell {
-    
-    open lazy var bgContentView:UIView = {
-        let view = UIView()
-        view.backgroundColor = .white.withAlphaComponent(0.1)
-        return view
-    }()
-    
+
     public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
     public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
         super.init(style: style, reuseIdentifier: reuseIdentifier)
         super.init(style: style, reuseIdentifier: reuseIdentifier)
         self.selectionStyle = .none
         self.selectionStyle = .none
@@ -117,6 +120,12 @@ class TSChangeLanguageCell: UITableViewCell {
         fatalError("init(coder:) has not been implemented")
         fatalError("init(coder:) has not been implemented")
     }
     }
     
     
+    open lazy var bgContentView:UIView = {
+        let view = UIView()
+        view.backgroundColor = .white.withAlphaComponent(0.05)
+        return view
+    }()
+    
     lazy var leftImageView: UIImageView = {
     lazy var leftImageView: UIImageView = {
         let leftImageView = UIImageView.createImageView()
         let leftImageView = UIImageView.createImageView()
         return leftImageView
         return leftImageView

+ 10 - 10
AIEmoji/Business2/DIYVideo/TSAIDiyVideoVC.swift

@@ -82,15 +82,7 @@ class TSAIDiyVideoVC: TSBaseVC {
         }
         }
         creatBtnView.setBtnEnabled(isEnabled: false)
         creatBtnView.setBtnEnabled(isEnabled: false)
         creatBtnView.isIconVipBlock = { [weak self] in
         creatBtnView.isIconVipBlock = { [weak self] in
-            guard let self = self else { return false }
-            var showVip = kPurchaseDefault.generateVipShow(type: vipFreeNumType)
-
-            return showVip
-        }
-        creatBtnView.isClickVipBlock = { [weak self] in
-            guard let self = self else { return false }
-            var isVip = kPurchaseDefault.freeNumAvailable(type: vipFreeNumType) == false
-            return isVip
+            return true
         }
         }
         return creatBtnView
         return creatBtnView
     }() // Button
     }() // Button
@@ -178,7 +170,15 @@ extension TSAIDiyVideoVC: JXSegmentedListContainerViewDataSource {
 
 
 extension TSAIDiyVideoVC {
 extension TSAIDiyVideoVC {
     func generateVideo() {
     func generateVideo() {
-        if kJudgeVip(externalBool: true, vc: self) { return }  //判断 vip,不给 diy 视频试用册书
+        //判断是否允许用户点生成按钮
+        guard kPurchaseDefault.isVip == true ||  (kPurchaseDefault.videoAvailableNum > 0)else {
+            //判断是否需要购买视频加油包
+            if kPurchaseDefault.judgePurchaseVideoPackage(vipFreeNumType: VipFreeNumType.videoV2,isCanFree: false, target: self){ return }
+            //否则弹 vip订阅提示
+            TSPurchaseVC.show(target: self, closePageBlock: nil)
+            return
+        }
+        
         if segmentedView.selectedIndex == 0 {
         if segmentedView.selectedIndex == 0 {
             guard let img = ptvVc.viewModel.uploadImage else {
             guard let img = ptvVc.viewModel.uploadImage else {
                 return
                 return

+ 9 - 0
AIEmoji/Business2/DisCover/Data/TSFuncStyle.swift

@@ -127,6 +127,15 @@ enum TSFuncStyle:Int,Equatable,CaseIterable {
             return false
             return false
         }
         }
     }
     }
+    
+    var isVideo:Bool{
+        switch self {
+        case .videoV2,.photoLive,.textToVideo,.pictureToVideo:
+            return true
+        default:
+            return false
+        }
+    }
 }
 }
 
 
 
 

+ 1 - 1
AIEmoji/Business2/DisCover/TSDiscoverVC/Cell/TSDiscoverStyleMoreCell.swift

@@ -149,7 +149,7 @@ extension UIScrollView {
 private let CellCornerRadius = 16.0
 private let CellCornerRadius = 16.0
 class TSDiscoverStyleMoreBaseCell: TSBaseCollectionCell {
 class TSDiscoverStyleMoreBaseCell: TSBaseCollectionCell {
     
     
-    static var collectionView:UICollectionView?
+    static weak var collectionView:UICollectionView?
     var model:TSDiscoverItemModel? {
     var model:TSDiscoverItemModel? {
         didSet {
         didSet {
             guard let model = model else { return }
             guard let model = model else { return }

+ 3 - 133
AIEmoji/Business2/DisCover/TSDiscoverVC/TSDiscoverVC.swift

@@ -9,64 +9,7 @@ class TSDiscoverVC: TSBaseVC {
 
 
     let viewModel:TSDiscoverViewModel = TSDiscoverViewModel()
     let viewModel:TSDiscoverViewModel = TSDiscoverViewModel()
     var hintBaseVC:TSAIListHintBaseVC = TSAIListHintBaseVC(config: .defaultConfig)
     var hintBaseVC:TSAIListHintBaseVC = TSAIListHintBaseVC(config: .defaultConfig)
-    lazy var photoPickerManager: TSPhotoPickerManager = TSPhotoPickerManager(viewController: self)
-    
-//    lazy var vipBtn: UIButton = {
-//        let vipBtn = UIButton.createButton(image: UIImage(named: "nav_vip")) { [weak self]  in
-//            guard let self = self else { return }
-//            if kPurchaseCountDownTime.isCountDown {
-//                kPresentModalVC(target: self, modelVC: TSPurchasePromotionalVC(isAnimation: false))
-//            }else{
-//                TSPurchaseVC.show(target: self)
-//            }
-//        }
-//        vipBtn.isHidden = true
-//       return vipBtn
-//   }()
-//    
-//    lazy var purchaseCountdownView : TSPurchaseCountdownView = {
-//       let purchaseCountdownView = TSPurchaseCountdownView()
-//        purchaseCountdownView.clickBlock = { [weak self]  in
-//            guard let self = self else { return }
-//            kPresentModalVC(target: self, modelVC: TSPurchasePromotionalVC(isAnimation: false))
-//        }
-//        purchaseCountdownView.isHidden = true
-//       return purchaseCountdownView
-//   }()
-//    lazy var navBarView: TSBaseNavContentBarView = {
-//        let navBarView = TSBaseNavContentBarView()
-//
-//        let label = UILabel.createLabel(text: "Discover".localized,font: .font(size: 22,weight: .semibold),textColor: .white)
-//        label.addShadow(shadowColor: UIColor.black.cgColor, shadowOffset: CGSize(width: 2, height: 2), shadowRadius: 2, shadowOpacity: 0.3)
-//        navBarView.barView.addSubview(label)
-//        label.snp.makeConstraints { make in
-//            make.centerY.equalToSuperview()
-//            make.leading.equalTo(17.0)
-//        }
-//        
-//
-//        let stackView:UIStackView = UIStackView()
-//        stackView.spacing = 8
-//        navBarView.barView.addSubview(stackView)
-//        stackView.addArrangedSubview(vipBtn)
-//        stackView.addArrangedSubview(purchaseCountdownView)
-//        stackView.snp.makeConstraints { make in
-//            make.centerY.equalToSuperview()
-//            make.trailing.equalTo(-16)
-//        }
-//        vipBtn.snp.makeConstraints { make in
-//            make.width.height.equalTo(24)
-//        }
-//        
-//        purchaseCountdownView.snp.makeConstraints { make in
-//            make.height.equalTo(24)
-//        }
-//
-//        
-//       return navBarView
-//    }()
-    
-    
+
     lazy var collectionView: TSBaseCollectionView = {
     lazy var collectionView: TSBaseCollectionView = {
         let collectionViewLayout = UICollectionViewFlowLayout()
         let collectionViewLayout = UICollectionViewFlowLayout()
         let collectionView = TSBaseCollectionView(frame: .zero, collectionViewLayout: collectionViewLayout)
         let collectionView = TSBaseCollectionView(frame: .zero, collectionViewLayout: collectionViewLayout)
@@ -88,11 +31,6 @@ class TSDiscoverVC: TSBaseVC {
     override func createView() {
     override func createView() {
         addNormalNavBarView()
         addNormalNavBarView()
 
 
-//        navBarContentView.addSubview(navBarView)
-//        navBarView.snp.makeConstraints { make in
-//            make.edges.equalToSuperview()
-//        }
-        
         contentView.snp.updateConstraints { make in
         contentView.snp.updateConstraints { make in
             make.top.equalTo(0)
             make.top.equalTo(0)
         }
         }
@@ -106,39 +44,11 @@ class TSDiscoverVC: TSBaseVC {
     }
     }
     
     
     override func dealThings() {
     override func dealThings() {
-//        NotificationCenter.default.addObserver(self, selector: #selector(updateVipView), name: .kPurchaseDidChanged, object: nil)
-//        updateVipView()
-//        NotificationCenter.default.addObserver(self, selector: #selector(checkkPurchaseCountDownTime), name: .kCloseTSPurchasePromotionalVC, object: nil)
-//        checkkPurchaseCountDownTime()
+
     }
     }
-    
-//    @objc func updateVipView() {
-//        kMainAsync{
-//            self.vipBtn.isHidden = PurchaseManager.default.isVip
-//            self.checkkPurchaseCountDownTime()
-//        }
-//    }
-//    
-//    @objc func checkkPurchaseCountDownTime(){
-//        if kPurchaseCountDownTime.isCountDown {
-//            self.purchaseCountdownView.isHidden = false
-//            kPurchaseCountDownTime.complete = { [weak self] minutes, seconds, end in
-//                guard let self = self else { return }
-//                if end {
-//                    self.purchaseCountdownView.isHidden = true
-//                }else{
-//                    self.purchaseCountdownView.minLabel.text = minutes
-//                    self.purchaseCountdownView.secLabel.text = seconds
-//                }
-//            }
-//        }else{
-//            self.purchaseCountdownView.isHidden = true
-//        }
-//    }
-    
+
     override func viewWillAppear(_ animated: Bool) {
     override func viewWillAppear(_ animated: Bool) {
         super.viewWillAppear(animated)
         super.viewWillAppear(animated)
-//        checkkPurchaseCountDownTime()
     }
     }
 }
 }
 
 
@@ -232,46 +142,6 @@ extension TSDiscoverVC: UICollectionViewDataSource ,UICollectionViewDelegate,UIC
         }
         }
     }
     }
 }
 }
-//extension TSDiscoverVC: UIScrollViewDelegate {
-//    // 开始拖拽(用户开始滚动)
-//    func scrollViewDidScroll(_ scrollView: UIScrollView) {
-////        dePrint("scrollView.contentOffset.y=\(scrollView.contentOffset.y)")
-//        
-//        let height:CGFloat = 50 + k_Nav_Height
-//        
-////        let alpha = scrollView.contentOffset.y/height
-////        navBarView.backgroundColor = .mainBg.withAlphaComponent(alpha)
-//        
-//        navBarView.backgroundColor = scrollView.contentOffset.y >= height ? .mainBg : .clear
-//    }
-//}
-//extension TSDiscoverVC: UIScrollViewDelegate {
-//    // 开始拖拽(用户开始滚动)
-//    func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
-//        print("滚动开始")
-//        NotificationCenter.default.post(name: .kDiscoverScrollViewWillBegin, object: nil)
-//    }
-//
-//    // 结束拖拽(用户手指离开屏幕)
-//    func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
-//        if !decelerate {
-//            print("滚动完全停止(无减速动画)")
-//            NotificationCenter.default.post(name: .kDiscoverScrollViewEndDecelerating, object: nil)
-//        }
-//    }
-//    
-//    // 结束减速(滚动完全停止)
-//    func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
-//        print("滚动完全停止")
-//        NotificationCenter.default.post(name: .kDiscoverScrollViewEndDecelerating, object: nil)
-//    }
-//    
-//    // 以下方法组合可以准确判断滚动是否真正结束
-//    func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
-//        print("编程触发的滚动动画结束")
-//        NotificationCenter.default.post(name: .kDiscoverScrollViewEndDecelerating, object: nil)
-//    }
-//}
 
 
 extension TSDiscoverVC {
 extension TSDiscoverVC {
     
     

+ 6 - 0
AIEmoji/Business2/DisCover/TSGenerateHistoryVC/TSGenerateHistoryVC.swift

@@ -239,7 +239,13 @@ extension TSGenerateHistoryVC: UICollectionViewDataSource ,UICollectionViewDeleg
     }
     }
 
 
     public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
     public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+
         guard let selectedModel = listModelArray.safeObj(At:indexPath.row) else { return }
         guard let selectedModel = listModelArray.safeObj(At:indexPath.row) else { return }
+        if selectedModel.status != "success"{
+            return
+        }
+        
+
         let filteredResults = listModelArray.filter({$0.status == "success"})
         let filteredResults = listModelArray.filter({$0.status == "success"})
         let startIndex = filteredResults.firstIndex(of: selectedModel) ?? 0
         let startIndex = filteredResults.firstIndex(of: selectedModel) ?? 0
         
         

+ 4 - 7
AIEmoji/Business2/DisCover/TSPTPUploadImageVC/TSPTPUploadImageVC+View.swift

@@ -52,15 +52,15 @@ extension TSPTPUploadImageVC {
         creatBtnView.isIconVipBlock = { [weak self] in
         creatBtnView.isIconVipBlock = { [weak self] in
             guard let self = self else { return false }
             guard let self = self else { return false }
             var showVip = kPurchaseDefault.generateVipShow(type: vipFreeNumType)
             var showVip = kPurchaseDefault.generateVipShow(type: vipFreeNumType)
-            if showVip == false,vipFreeNumType == .videoV2 {
+            if showVip == false,vipFreeNumType == .videoV2 {//只对视频做模型 vip 判断
                 showVip = self.viewModel.selectedPTPStyleModel.isVip
                 showVip = self.viewModel.selectedPTPStyleModel.isVip
             }
             }
             return showVip
             return showVip
         }
         }
         creatBtnView.isClickVipBlock = { [weak self] in
         creatBtnView.isClickVipBlock = { [weak self] in
             guard let self = self else { return false }
             guard let self = self else { return false }
-            var isVip = kPurchaseDefault.freeNumAvailable(type: vipFreeNumType) == false
-            if isVip == false,vipFreeNumType == .videoV2 {
+            var isVip = kPurchaseDefault.freeNumAvailable(type: vipFreeNumType)
+            if isVip == false,vipFreeNumType == .videoV2 {//只对视频做模型 vip 判断
                 isVip = self.viewModel.selectedPTPStyleModel.isVip
                 isVip = self.viewModel.selectedPTPStyleModel.isVip
             }
             }
             return isVip
             return isVip
@@ -107,10 +107,7 @@ extension TSPTPUploadImageVC {
 extension TSPTPUploadImageVC {
 extension TSPTPUploadImageVC {
     
     
     var isVideo:Bool{
     var isVideo:Bool{
-        if viewModel.style == .videoV2 ||  viewModel.style == .photoLive{
-            return true
-        }
-        return false
+        return viewModel.style.isVideo
     }
     }
     
     
     
     

+ 7 - 1
AIEmoji/Common/Purchase/TSPurchaseManager+Free.swift

@@ -100,10 +100,15 @@ extension PurchaseManager {
             return dict
             return dict
         }
         }
     }
     }
+    
+    //清空所有免费试用次数
+    func clearAllFreeTimes(){
+        saveForUserKeychain(data: [String:Int](),key: kFreeNumKey)
+    }
 
 
     /// 免费次数是否可用
     /// 免费次数是否可用
     func freeNumAvailable(type: VipFreeNumType) -> Bool {
     func freeNumAvailable(type: VipFreeNumType) -> Bool {
-        if isVip == true ||  (type.isVideo && videoAvailableNum > 0) {
+        if isVip == true {
             return true
             return true
         } else {
         } else {
             if freeNum(type: type) > 0 {
             if freeNum(type: type) > 0 {
@@ -120,5 +125,6 @@ extension PurchaseManager {
         }
         }
         return true
         return true
     }
     }
+
 }
 }
 
 

+ 21 - 4
AIEmoji/Common/Purchase/TSPurchaseManager+Judge.swift

@@ -86,11 +86,11 @@ extension PurchaseManager {
             return .aiGenerate
             return .aiGenerate
         }
         }
     }
     }
-
-    //判断视频是否超出限制
+    
+    //判断视频是否超出限制,return true 是拦截的意思
     func judgeVideoV2ExceedLimit(vipFreeNumType:VipFreeNumType) -> Bool{
     func judgeVideoV2ExceedLimit(vipFreeNumType:VipFreeNumType) -> Bool{
         if vipFreeNumType.isVideo {
         if vipFreeNumType.isVideo {
-            return isExceedsVipGeneratedNum(vipFreeNumType:VipFreeNumType.videoType)
+            return videoAvailableNum <= 0 //次数不够的,返回 true
         }
         }
         return false
         return false
     }
     }
@@ -129,7 +129,13 @@ extension PurchaseManager {
     }
     }
 
 
     //判断试用的视频次数,是否超出了最大数量,如果超出,提示用户购买加油宝
     //判断试用的视频次数,是否超出了最大数量,如果超出,提示用户购买加油宝
-    func judgePurchaseVideoPackage(vipFreeNumType:VipFreeNumType,target:UIViewController) -> Bool{
+    //isCanFree 是否可以免费试用
+    func judgePurchaseVideoPackage(vipFreeNumType:VipFreeNumType,isCanFree:Bool = true,target:UIViewController) -> Bool{
+        
+        //先判断非会员是否有免费的试用次数
+        if isCanFree,isVip == false,freeNum(type: vipFreeNumType) > 0 {
+            return false
+        }
         ///需要校验,是否超出了 vip 生成的次数,且需要判断是否超过最大次数
         ///需要校验,是否超出了 vip 生成的次数,且需要判断是否超过最大次数
         if judgeVideoV2ExceedLimit(vipFreeNumType: vipFreeNumType)  {
         if judgeVideoV2ExceedLimit(vipFreeNumType: vipFreeNumType)  {
             kPresentModalVC(target: target, modelVC: TSPurchaseVideoTimesVC(isShowAlertModel: true),transitionStyle:.crossDissolve)
             kPresentModalVC(target: target, modelVC: TSPurchaseVideoTimesVC(isShowAlertModel: true),transitionStyle:.crossDissolve)
@@ -137,4 +143,15 @@ extension PurchaseManager {
         }
         }
         return false
         return false
     }
     }
+    
+    
+    //判断是否可以生成,包含视频判断
+    func isCanGenerated(type: VipFreeNumType) -> Bool {
+        //视频类做另外的特殊判断
+        if (type.isVideo && videoAvailableNum > 0) {
+            return true
+        }
+        
+        return freeNumAvailable(type: type)
+    }
 }
 }

+ 0 - 8
AIEmoji/Common/Purchase/TSPurchaseManager+Limit.swift

@@ -55,14 +55,6 @@ extension PurchaseManager {
 
 
 extension PurchaseManager {
 extension PurchaseManager {
     
     
-    //是否超出Vip期间使用的次数
-    public func isExceedsVipGeneratedNum(vipFreeNumType:VipFreeNumType) -> Bool {
-        if isVip {
-            return videoAvailableNum <= 0 //次数不够的,返回 true
-        }
-        return false
-    }
-
     func saveForVipGeneratedNum(type: VipFreeNumType) {
     func saveForVipGeneratedNum(type: VipFreeNumType) {
         let type = getDayGeneratedNum(type: type)
         let type = getDayGeneratedNum(type: type)
         var num = loadVipGeneratedNum(type: type)
         var num = loadVipGeneratedNum(type: type)

+ 7 - 0
AIEmoji/Common/Purchase/TSPurchaseManager.swift

@@ -155,7 +155,14 @@ public class PurchaseManager: NSObject {
         dePrint("vipInformation = \(vipInformation)")
         dePrint("vipInformation = \(vipInformation)")
         UserDefaults.standard.set(vipInformation, forKey: kPremiumExpiredInfoKey)
         UserDefaults.standard.set(vipInformation, forKey: kPremiumExpiredInfoKey)
         UserDefaults.standard.synchronize()
         UserDefaults.standard.synchronize()
+        
+        //成为会员后,清空所有免费试用次数
+        if isVip {
+            clearAllFreeTimes()
+        }
+        
         NotificationCenter.default.post(name: .kPurchaseDidChanged, object: nil)
         NotificationCenter.default.post(name: .kPurchaseDidChanged, object: nil)
+  
     }
     }
 
 
     // 商品id对应的时间周期
     // 商品id对应的时间周期

+ 10 - 1
AIEmoji/Common/View/TSTextToastView.swift

@@ -31,7 +31,7 @@ open class TSTextToastView {
     }()
     }()
     
     
     
     
-    private lazy var viewButton:UIView = {
+    private lazy var viewButton:UIButton = {
         let color = UIColor.themeColor
         let color = UIColor.themeColor
         let viewButton = UIButton.createButton(title: "View".localized ,backgroundColor: color.withAlphaComponent(0.2),font: UIFont.font(size: 12),titleColor: color,corner: 14) { [weak self]  in
         let viewButton = UIButton.createButton(title: "View".localized ,backgroundColor: color.withAlphaComponent(0.2),font: UIFont.font(size: 12),titleColor: color,corner: 14) { [weak self]  in
             guard let self = self else { return }
             guard let self = self else { return }
@@ -117,6 +117,15 @@ open class TSTextToastView {
                 make.top.equalTo(k_Height_StatusBar + 20)
                 make.top.equalTo(k_Height_StatusBar + 20)
             }
             }
             
             
+            
+            self.viewButton.setTitle("View".localized, for: .normal)
+            self.viewButton.snp.remakeConstraints { make in
+                make.width.equalTo(self.viewButton.intrinsicContentSize.width)
+                make.height.equalTo(28)
+                make.trailing.equalTo(-8)
+                make.centerY.equalToSuperview()
+            }
+            
             self.loadingView.startRotating()
             self.loadingView.startRotating()
         }
         }
 
 

+ 1 - 0
AIEmoji/de.lproj/Localizable.strings

@@ -612,3 +612,4 @@
 "Video Effects Pack Activated!" = "Videoeffektpaket aktiviert!";
 "Video Effects Pack Activated!" = "Videoeffektpaket aktiviert!";
 "Photo Filter" = "Fotofilter";
 "Photo Filter" = "Fotofilter";
 "AI Videos" = "KI-Videos";
 "AI Videos" = "KI-Videos";
+"Invalid aspect ratio. Must be 1:2 to 1:1.2" = "Ungültiges Seitenverhältnis. Muss 1:2 bis 1:1,2 sein";

+ 1 - 0
AIEmoji/en.lproj/Localizable.strings

@@ -616,3 +616,4 @@ Small / Medium / Large: Manual amplitude selection ";
 "Video Effects Pack Activated!" = "Video Effects Pack Activated!";
 "Video Effects Pack Activated!" = "Video Effects Pack Activated!";
 "Photo Filter" = "Photo Filter";
 "Photo Filter" = "Photo Filter";
 "AI Videos" = "AI Videos";
 "AI Videos" = "AI Videos";
+"Invalid aspect ratio. Must be 1:2 to 1:1.2" = "Invalid aspect ratio. Must be 1:2 to 1:1.2";

+ 1 - 0
AIEmoji/es.lproj/Localizable.strings

@@ -610,3 +610,4 @@
 "Video Effects Pack Activated!" = "¡Paquete de efectos de vídeo activado!";
 "Video Effects Pack Activated!" = "¡Paquete de efectos de vídeo activado!";
 "Photo Filter" = "Filtro de fotos";
 "Photo Filter" = "Filtro de fotos";
 "AI Videos" = "Vídeos de IA";
 "AI Videos" = "Vídeos de IA";
+"Invalid aspect ratio. Must be 1:2 to 1:1.2" = "Relación de aspecto no válida. Debe ser de 1:2 a 1:1.2.";

+ 1 - 0
AIEmoji/ja.lproj/Localizable.strings

@@ -609,3 +609,4 @@
 "Video Effects Pack Activated!" = "ビデオエフェクトパックが有効化されました!";
 "Video Effects Pack Activated!" = "ビデオエフェクトパックが有効化されました!";
 "Photo Filter" = "写真フィルター";
 "Photo Filter" = "写真フィルター";
 "AI Videos" = "AI ビデオ";
 "AI Videos" = "AI ビデオ";
+"Invalid aspect ratio. Must be 1:2 to 1:1.2" = "アスペクト比が無効です。1:2~1:1.2 にする必要があります。";

+ 1 - 0
AIEmoji/ko.lproj/Localizable.strings

@@ -613,3 +613,4 @@
 "Video Effects Pack Activated!" = "비디오 효과 팩이 활성화되었습니다!";
 "Video Effects Pack Activated!" = "비디오 효과 팩이 활성화되었습니다!";
 "Photo Filter" = "사진 필터";
 "Photo Filter" = "사진 필터";
 "AI Videos" = "AI 비디오";
 "AI Videos" = "AI 비디오";
+"Invalid aspect ratio. Must be 1:2 to 1:1.2" = "잘못된 종횡비입니다. 1:2에서 1:1.2 사이여야 합니다.";

+ 1 - 0
AIEmoji/pt-BR.lproj/Localizable.strings

@@ -609,3 +609,4 @@
 "Video Effects Pack Activated!" = "Pacote de efeitos de vídeo ativado!";
 "Video Effects Pack Activated!" = "Pacote de efeitos de vídeo ativado!";
 "Photo Filter" = "Filtro de fotos";
 "Photo Filter" = "Filtro de fotos";
 "AI Videos" = "AI Videos";
 "AI Videos" = "AI Videos";
+"Invalid aspect ratio. Must be 1:2 to 1:1.2" = "Proporção de tela inválida. Deve ser de 1:2 a 1:1,2.";

+ 1 - 0
AIEmoji/pt-PT.lproj/Localizable.strings

@@ -608,3 +608,4 @@
 "Video Effects Pack Activated!" = "Pacote de efeitos de vídeo ativado!";
 "Video Effects Pack Activated!" = "Pacote de efeitos de vídeo ativado!";
 "Photo Filter" = "Filtro de fotos";
 "Photo Filter" = "Filtro de fotos";
 "AI Videos" = "AI Videos";
 "AI Videos" = "AI Videos";
+"Invalid aspect ratio. Must be 1:2 to 1:1.2" = "Proporção de tela inválida. Deve ser de 1:2 a 1:1,2.";

+ 1 - 0
AIEmoji/zh-Hans.lproj/Localizable.strings

@@ -611,3 +611,4 @@
 "Video Effects Pack Activated!" = "视频特效次数包已可用";
 "Video Effects Pack Activated!" = "视频特效次数包已可用";
 "Photo Filter" = "图片滤镜";
 "Photo Filter" = "图片滤镜";
 "AI Videos" = "AI 视频";
 "AI Videos" = "AI 视频";
+"Invalid aspect ratio. Must be 1:2 to 1:1.2" = "宽高比错误,必须在 1:2 到 1:1.2 之间";

+ 1 - 0
AIEmoji/zh-Hant.lproj/Localizable.strings

@@ -599,3 +599,4 @@
 "Video Effects Pack Activated!" = "視頻特效次數包已可用";
 "Video Effects Pack Activated!" = "視頻特效次數包已可用";
 "Photo Filter" = "圖片濾鏡";
 "Photo Filter" = "圖片濾鏡";
 "AI Videos" = "AI 視頻";
 "AI Videos" = "AI 視頻";
+"Invalid aspect ratio. Must be 1:2 to 1:1.2" = "寬高比錯誤,必須在 1:2 到 1:1.2 之間";