ソースを参照

add:添加苹果埋点归因和会员界面调整。

“HeShaoZe” 4 ヶ月 前
コミット
752a4b7093

BIN
.DS_Store


+ 19 - 3
QuickSearchLocation.xcodeproj/project.pbxproj

@@ -76,11 +76,11 @@
 		FE638ABB2D19631900858121 /* QSLGravityManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE638ABA2D19631900858121 /* QSLGravityManager.swift */; };
 		FE638AC02D19642B00858121 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = FE638ABF2D19642B00858121 /* libz.tbd */; };
 		FE638AC22D19649D00858121 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE638AC12D19649D00858121 /* Security.framework */; };
-		FE638AC42D1964A200858121 /* AdServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE638AC32D1964A200858121 /* AdServices.framework */; };
+		FE638AC42D1964A200858121 /* AdServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE638AC32D1964A200858121 /* AdServices.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
 		FE638AC62D1964A800858121 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE638AC52D1964A800858121 /* SystemConfiguration.framework */; };
 		FE638AC82D1964B000858121 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = FE638AC72D1964B000858121 /* libsqlite3.tbd */; };
 		FE638ACA2D1964C500858121 /* AppTrackingTransparency.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE638AC92D1964C500858121 /* AppTrackingTransparency.framework */; };
-		FE638ACC2D1964CA00858121 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE638ACB2D1964CA00858121 /* AdSupport.framework */; };
+		FE638ACC2D1964CA00858121 /* AdSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE638ACB2D1964CA00858121 /* AdSupport.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
 		FE638ACE2D19677200858121 /* GravityEngineSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FE638ACD2D19677200858121 /* GravityEngineSDK.framework */; };
 		FE638AD22D1AA6E800858121 /* QSLWebController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE638AD12D1AA6E800858121 /* QSLWebController.swift */; };
 		FE638AD42D1ABB9800858121 /* QSLJumpManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE638AD32D1ABB9800858121 /* QSLJumpManager.swift */; };
@@ -120,6 +120,8 @@
 		FE9139C92DE6B018001A8E42 /* QSLVipMostGoodCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE9139C82DE6B018001A8E42 /* QSLVipMostGoodCell.swift */; };
 		FE94B4F42D23F09100D2B001 /* LoadingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE94B4F32D23F09100D2B001 /* LoadingViewController.swift */; };
 		FEC010E72D9E8B06008B8B0A /* QSLSubscriptionModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEC010E62D9E8AFE008B8B0A /* QSLSubscriptionModel.swift */; };
+		FEEB37CA2E28CC8F00BFFD7D /* QSAppleAdHandle.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEEB37C92E28CC8F00BFFD7D /* QSAppleAdHandle.swift */; };
+		FEEB37CD2E28CD7A00BFFD7D /* QSWikiHandle.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEEB37CC2E28CD7A00BFFD7D /* QSWikiHandle.swift */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
@@ -242,6 +244,8 @@
 		FE9139C82DE6B018001A8E42 /* QSLVipMostGoodCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QSLVipMostGoodCell.swift; sourceTree = "<group>"; };
 		FE94B4F32D23F09100D2B001 /* LoadingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingViewController.swift; sourceTree = "<group>"; };
 		FEC010E62D9E8AFE008B8B0A /* QSLSubscriptionModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QSLSubscriptionModel.swift; sourceTree = "<group>"; };
+		FEEB37C92E28CC8F00BFFD7D /* QSAppleAdHandle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QSAppleAdHandle.swift; sourceTree = "<group>"; };
+		FEEB37CC2E28CD7A00BFFD7D /* QSWikiHandle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QSWikiHandle.swift; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -413,8 +417,8 @@
 				04F33BA72BC6367C003E2111 /* SceneDelegate.swift */,
 				04F33BA92BC6367C003E2111 /* ViewController.swift */,
 				04F33BC42BC64566003E2111 /* CustomTabBarController.swift */,
-				04F33BAB2BC6367C003E2111 /* Main.storyboard */,
 				FE8360992D004E3400978E03 /* QSLBaseManager.swift */,
+				04F33BAB2BC6367C003E2111 /* Main.storyboard */,
 			);
 			path = Main;
 			sourceTree = "<group>";
@@ -450,6 +454,7 @@
 		04F33BBD2BC63B2F003E2111 /* Classes */ = {
 			isa = PBXGroup;
 			children = (
+				FEEB37CB2E28CCF900BFFD7D /* AppleAD */,
 				FE8360912D00308E00978E03 /* Network */,
 				FE5B423D2CF45926000AACCB /* Common */,
 				04F33BBC2BC63B08003E2111 /* Category */,
@@ -843,6 +848,15 @@
 			path = QSLAppInfo;
 			sourceTree = "<group>";
 		};
+		FEEB37CB2E28CCF900BFFD7D /* AppleAD */ = {
+			isa = PBXGroup;
+			children = (
+				FEEB37C92E28CC8F00BFFD7D /* QSAppleAdHandle.swift */,
+				FEEB37CC2E28CD7A00BFFD7D /* QSWikiHandle.swift */,
+			);
+			path = AppleAD;
+			sourceTree = "<group>";
+		};
 /* End PBXGroup section */
 
 /* Begin PBXNativeTarget section */
@@ -1056,12 +1070,14 @@
 				FE8360982D0041F300978E03 /* QSLCacheManager.swift in Sources */,
 				FE8360AD2D01A04800978E03 /* QSLRequestModel.swift in Sources */,
 				04B6B5292BCE1D5C00777EB4 /* QSLMineFuncCollectionViewCell.swift in Sources */,
+				FEEB37CA2E28CC8F00BFFD7D /* QSAppleAdHandle.swift in Sources */,
 				FE638AB32D0ACA4D00858121 /* QSLContactModel.swift in Sources */,
 				04F33BD72BC67E90003E2111 /* QSLDeviceTool.swift in Sources */,
 				04B6B5202BCD1D2C00777EB4 /* QSLMineInfoView.swift in Sources */,
 				04F33BC72BC66F5C003E2111 /* UIColor+Extension.swift in Sources */,
 				FE8360C02D06D33500978E03 /* QSLAppInfoController.swift in Sources */,
 				FE638AA22D096E6600858121 /* QSLGoodModel.swift in Sources */,
+				FEEB37CD2E28CD7A00BFFD7D /* QSWikiHandle.swift in Sources */,
 				FE638AA62D097EDD00858121 /* QSLOrderModel.swift in Sources */,
 				FE8360A02D00813400978E03 /* QSLPopView.swift in Sources */,
 				04F33BCB2BC672E4003E2111 /* QSLConfig.swift in Sources */,

BIN
QuickSearchLocation/Classes/.DS_Store


+ 89 - 0
QuickSearchLocation/Classes/AppleAD/QSAppleAdHandle.swift

@@ -0,0 +1,89 @@
+//
+//  QSAppleAdHandle.swift
+//  QuickSearchLocation
+//
+//  Created by Destiny on 2025/7/17.
+//
+
+import Foundation
+import AdServices
+import AdSupport
+
+
+class QSAppleAdHandle {
+    
+    var retryRequestCount = 0
+    
+    static func initQSC() {
+        
+        if #available(iOS 14.3, *) {
+            do {
+                let appleAttributionToken = try AAAttribution.attributionToken()
+                // 尝试获取归因信息
+                QSAppleAdHandle().getQSC(token: appleAttributionToken)
+            } catch let error {
+                print("Error fetching attribution token: \(error.localizedDescription)")
+            }
+        }
+    }
+    
+    // 开始获取归因结果
+    private func getQSC(token: String) {
+        
+        guard retryRequestCount < 3 else { return }
+        
+        let configuration = URLSessionConfiguration.default
+        let session = URLSession(configuration: configuration, delegate: nil, delegateQueue: nil)
+        let asaUrl = URL(string: "https://api-adservices.apple.com/api/v1/")!
+        
+        var request = URLRequest(url: asaUrl)
+        request.httpMethod = "POST"
+        request.addValue("application/json", forHTTPHeaderField: "Content-Type")
+        request.httpBody = token.data(using: .utf8)
+        
+        let task = session.dataTask(with: request) { data, response, error in
+            if let error = error {
+                print("sendASAToken error = \(error)")
+                // 5秒后重试
+                DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
+                    self.getQSC(token: token)
+                }
+                return
+            }
+            
+            guard let data = data, let payloadDic = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else {
+                print("sendASAToken error payload = nil")
+                // 5秒后重试
+                DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
+                    self.getQSC(token: token)
+                }
+                return
+            }
+            
+            print("sendASAToken payload = \(payloadDic)")
+            
+            if let attributionObj = payloadDic["attribution"] {
+                UserDefaults.standard.set(payloadDic, forKey: "QS_ATTRIBUTION_PAYLOAD")
+                UserDefaults.standard.synchronize()
+                
+                ///调用奇异果数据上报接口
+                let wikiManager = QSWikiHandle.shared
+                
+                wikiManager.addAttributionResultReport { isSuccess in
+                    print("asaReportWithCompletion = ", isSuccess)
+    
+                    if isSuccess {
+                        let isRegister = UserDefaults.standard.bool(forKey: "areHaveRegisterKey")
+                        if !isRegister {
+                            QSWikiHandle.shared.addEventResultAttribution(eventDict: ["event_name": "active", "event_val": 1])
+                            QSWikiHandle.shared.addEventResultAttribution(eventDict: ["event_name": "register", "event_val": 1])
+                            UserDefaults.standard.setValue(true, forKey: "areHaveRegisterKey")
+                        }
+                    }
+                }
+            }
+        }
+        task.resume()
+        retryRequestCount += 1
+    }
+}

+ 168 - 0
QuickSearchLocation/Classes/AppleAD/QSWikiHandle.swift

@@ -0,0 +1,168 @@
+//
+//  QSWikiHandle.swift
+//  QuickSearchLocation
+//
+//  Created by Destiny on 2025/7/17.
+//
+
+import Foundation
+import Alamofire
+import SwiftyJSON
+import AdSupport
+
+class QSWikiHandle {
+    
+    static let shared = QSWikiHandle()
+    
+    var hostUrl = "http://asafrontend.mokiwi.com/api"
+    
+    var orgId = "8842660"
+    
+    var sign = "b14edba8e6ad47565f3d396e05c6560e&kiwi".md5
+    
+    var requestId : String = ""
+    
+    func addAttributionResultReport(completion:@escaping ((Bool) -> ())) {
+        
+        if self.payDataParameterNotExist() {
+            completion(false)
+            return
+        }
+        
+        var dict: [String: Any] = [String: Any]()
+        if let payLoad: [String: Any] = UserDefaults.standard.object(forKey: "QS_ATTRIBUTION_PAYLOAD") as? [String : Any] {
+            
+            if let campaignId = payLoad["campaignId"] as? Int {
+                dict["campaign_id"] = campaignId
+            }
+            
+            if let adGroupId = payLoad["adGroupId"] as? Int {
+                dict["ad_group_id"] = adGroupId
+            }
+
+            
+            if let keywordId = payLoad["keywordId"] as? Int {
+                dict["keyword_id"] = keywordId
+            }
+            
+            let date = Date()
+            let formatter = DateFormatter()
+            formatter.timeZone = TimeZone.autoupdatingCurrent
+            formatter.dateFormat = "yyyy-MM-dd"
+            let todayDate = formatter.string(from: date)
+            dict["date"] = todayDate
+            dict["timezone"] = "ORTZ"
+        }
+        
+        let urlString = String(format: "%@/asabackendData/add?org_id=%@&sign=%@",hostUrl,orgId,sign)
+        
+        let headers = ["Content-Type": "application/json"]
+        
+        // 使用Alamofire发送POST请求
+        AF.request(urlString, method: .post, parameters: dict, encoding: JSONEncoding.default, headers: HTTPHeaders(headers)).response { response in
+            switch response.result {
+            case .success(let value):
+                let json = try? JSON(data: value ?? Data())
+                print("QSWikiHandle responseObject: \(String(describing: json))")
+                if json?["code"] == 10000 {
+                    print("QSWikiHandle asa用户 提交成功")
+                    
+                    // 正确提取 request_id(根据实际类型调整)
+                    if let requestIdString = json?["request_id"].string {
+                        self.requestId = requestIdString  // 假设 requestId 是 String 类型
+                        print("提取到的 request_id: \(requestIdString)")
+                    } else if let requestIdInt = json?["request_id"].int {
+                        self.requestId = String(requestIdInt)  // 如果是 Int 类型,转换为 String
+                        print("提取到的 request_id: \(requestIdInt)")
+                    } else {
+                        print("警告: 无法解析 request_id")
+                    }
+                    
+                    completion(true)
+                } else {
+                    print("QSWikiHandle asa用户 提交失败")
+                    completion(false)
+                }
+            case .failure(let error):
+                print("QSWikiHandle asa用户 error: \(error)")
+                completion(false)
+            }
+        }
+    }
+    
+    func addEventResultAttribution(eventDict: [String: Any]) {
+        print("QSWikiHandle asa用户 参数输入\(eventDict)")
+        if self.payDataParameterNotExist() {
+            return
+        }
+        
+        var dict: [String: Any] = [String: Any]()
+        if let payLoad: [String: Any] = UserDefaults.standard.object(forKey:"QS_ATTRIBUTION_PAYLOAD") as? [String : Any] {
+        
+            if let campaignId = payLoad["campaignId"] as? Int {
+                dict["campaign_id"] = campaignId
+            }
+
+            if let adGroupId = payLoad["adGroupId"] as? Int {
+                dict["ad_group_id"] = adGroupId
+            }
+            
+            if let keywordId = payLoad["keywordId"] as? Int {
+                dict["keyword_id"] = keywordId
+            }
+            
+            dict["request_id"] = self.requestId
+            
+            let date = Date()
+            let formatter = DateFormatter()
+            formatter.timeZone = TimeZone.autoupdatingCurrent
+            formatter.dateFormat = "yyyy-MM-dd"
+            let todayDate = formatter.string(from: date)
+            dict["date"] = todayDate
+            dict["timezone"] = "ORTZ"
+            
+            // 用户已授权
+            let idfaStr = ASIdentifierManager.shared().advertisingIdentifier.uuidString
+            if idfaStr.count > 0 {
+                dict["unique_device"] = idfaStr
+            } else {
+                let idfv = UIDevice.current.identifierForVendor?.uuidString
+                dict["unique_device"] = idfv
+            }
+        }
+        
+        for (key, value) in eventDict {
+            dict[key] = value
+        }
+        
+        let urlString = String(format: "%@/asabackendDataDetail/add?org_id=%@&sign=%@",hostUrl,orgId,sign)
+        print("usdfStringgsdfs--\(urlString)");
+        
+        let headers = ["Content-Type": "application/json"]
+        
+        let parameters = ["backend_data_detail": dict]
+        
+        // 使用Alamofire发送POST请求
+        AF.request(urlString, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: HTTPHeaders(headers)).response { response in
+            switch response.result {
+            case .success(let value):
+                let json = try? JSON(data: value ?? Data())
+                print("QSWikiHandle responseObject: \(String(describing: json))")
+                if json?["code"] == 10000 {
+                    print("QSWikiHandle asa用户 提交成功")
+                } else {
+                    print("QSWikiHandle asa用户 提交失败 --- \(parameters)")
+                }
+            case .failure(let error):
+                print("QSWikiHandle asa用户 error: \(error)")
+            }
+        }
+    }
+    
+    func payDataParameterNotExist() -> Bool {
+        guard UserDefaults.standard.object(forKey:"QS_ATTRIBUTION_PAYLOAD") is [String: Any] else {
+            return true
+        }
+        return false
+    }
+}

+ 23 - 0
QuickSearchLocation/Classes/Category/String+Extension.swift

@@ -7,6 +7,7 @@
 
 import Foundation
 import UIKit
+import CommonCrypto
 
 // MARK: - 五、字符串UI的处理
 extension String {
@@ -218,3 +219,25 @@ extension String {
 //        return self.base64String(encode: false)
 //    }
 }
+
+extension String  {
+    /// 原生md5
+
+    public var md5 : String {
+        guard let data = data(using: .utf8) else {
+            return self
+        }
+        var digest = [UInt8](repeating: 0, count: Int(CC_MD5_DIGEST_LENGTH))
+        #if swift(>=5.0)
+
+        _ = data.withUnsafeBytes { (bytes: UnsafeRawBufferPointer) in
+            return CC_MD5(bytes.baseAddress, CC_LONG(data.count), &digest)
+        }
+        #else
+        _ = data.withUnsafeBytes { bytes in
+            return CC_MD5(bytes, CC_LONG(data.count), &digest)
+        }
+        #endif
+        return digest.map { String(format: "%02x", $0) }.joined()
+    }
+}

+ 2 - 0
QuickSearchLocation/Classes/Common/Model/QSLGoodModel.swift

@@ -36,6 +36,8 @@ struct QSLGoodModel: Modelable {
     
     var isSelect: Bool = false
     
+    var subscribable : Int = 0
+    
     mutating func mapping(_ json: JSON) {
         self.goodId = json["id"].intValue
         self.content = json["description"].stringValue

+ 4 - 0
QuickSearchLocation/Classes/Main/QSLBaseManager.swift

@@ -241,5 +241,9 @@ extension QSLBaseManager {
                 gravity.initGE()
             }
         }
+        
+        
+        //苹果初始化归因
+        QSAppleAdHandle.initQSC()
     }
 }

+ 92 - 50
QuickSearchLocation/Classes/Pages/QSLVip/Controller/QSLVipController.swift

@@ -29,6 +29,9 @@ class QSLVipController: QSLBaseController {
     
     var goodList: [QSLGoodModel] = [QSLGoodModel]()
     
+    ///是否是订阅的产品
+    //var is
+    
     var selectGood: QSLGoodModel? {
         didSet {
             updateSelectGoodUI()
@@ -187,11 +190,16 @@ class QSLVipController: QSLBaseController {
     }()
     
     lazy var serviceLabel: YYLabel = {
-       
         let label = YYLabel()
-        
+        //updateServiceLabelText(showSubscribe: true) // 默认显示所有内容
+        return label
+    }()
+
+    // 更新服务条款文本内容
+    func updateServiceLabelText(showSubscribe: Bool) {
         let attr = NSMutableAttributedString()
         
+        // 固定部分:购买即同意
         let firstAttr = NSMutableAttributedString(string: "购买即同意")
         firstAttr.font(10)
         firstAttr.color(.hexStringColor(hexString: "#A7A7A7"))
@@ -201,11 +209,10 @@ class QSLVipController: QSLBaseController {
         blankAttr.font(10)
         attr.append(blankAttr)
         
+        // 《隐私权政策》
         let privacyHL = YYTextHighlight()
-        var privacyStr = "《隐私权政策》"
-        
+        let privacyStr = "《隐私权政策》"
         let privacyText = NSMutableAttributedString(string: privacyStr)
-        
         privacyText.font(10)
         privacyText.color(.hexStringColor(hexString: "#E7B983"))
         privacyText.yy_setTextHighlight(privacyHL, range: NSRange(location: 0, length: privacyStr.count))
@@ -216,9 +223,9 @@ class QSLVipController: QSLBaseController {
         
         attr.append(blankAttr)
         
+        // 《用户协议》
         let serviceHL = YYTextHighlight()
-        var serviceStr = "《用户协议》"
-
+        let serviceStr = "《用户协议》"
         let serviceText = NSMutableAttributedString(string: serviceStr)
         serviceText.font(10)
         serviceText.color(.hexStringColor(hexString: "#E7B983"))
@@ -226,35 +233,43 @@ class QSLVipController: QSLBaseController {
         serviceHL.tapAction = { [weak self] containerView, text, range, rect in
             self?.serviceAction()
         }
-        
         attr.append(serviceText)
         
-//        attr.append(blankAttr)
-//        
-//        let andAttr = NSMutableAttributedString(string: "和")
-//        andAttr.font(10)
-//        andAttr.color(.hexStringColor(hexString: "#A7A7A7"))
-//        attr.append(andAttr)
-//        
-//        attr.append(blankAttr)
+        // 根据条件决定是否添加《续订说明》相关内容
+        if showSubscribe {
+            attr.append(blankAttr)
+            
+            let andAttr = NSMutableAttributedString(string: "和")
+            andAttr.font(10)
+            andAttr.color(.hexStringColor(hexString: "#A7A7A7"))
+            attr.append(andAttr)
+            
+            attr.append(blankAttr)
+            
+            let subcribeHL = YYTextHighlight()
+            let subcribeStr = "《续订说明》"
+            let subcribeText = NSMutableAttributedString(string: subcribeStr)
+            subcribeText.font(10)
+            subcribeText.color(.hexStringColor(hexString: "#E7B983"))
+            subcribeText.yy_setTextHighlight(subcribeHL, range: NSRange(location: 0, length: subcribeStr.count))
+            subcribeHL.tapAction = { [weak self] containerView, text, range, rect in
+                self?.subscibeAction()
+            }
+            attr.append(subcribeText)
+        }
         
-//        let subcribeHL = YYTextHighlight()
-//        var subcribeStr = "《续订说明》"
-//
-//        let subcribeText = NSMutableAttributedString(string: subcribeStr)
-//        subcribeText.font(10)
-//        subcribeText.color(.hexStringColor(hexString: "#E7B983"))
-//        subcribeText.yy_setTextHighlight(subcribeHL, range: NSRange(location: 0, length: subcribeStr.count))
-//        subcribeHL.tapAction = { [weak self] containerView, text, range, rect in
-//            self?.subscibeAction()
-//        }
-//        
-//        attr.append(subcribeText)
+        serviceLabel.attributedText = attr
+    }
 
-        label.attributedText = attr
-        
-        return label
-    }()
+    // 在需要隐藏《续订说明》时调用此方法
+    func hideSubscribeDescription() {
+        updateServiceLabelText(showSubscribe: false)
+    }
+
+    // 在需要显示《续订说明》时调用此方法
+    func showSubscribeDescription() {
+        updateServiceLabelText(showSubscribe: true)
+    }
     
     lazy var commentView: UIView = {
        
@@ -300,16 +315,16 @@ class QSLVipController: QSLBaseController {
         return label
     }()
     
-//    lazy var tipContentLabel: UILabel = {
-//       
-//        let label = UILabel()
-//        label.numberOfLines = 0
-//        label.text("1 订阅后会从您的iTunes账户中扣除相关费用。如需取消续订,请在当前订阅周期结束前,至少24小时内通过手机“账户设置”的订阅管理关闭自动续费功能。\n2 未成年人请在监护者的陪同下进行购买\n3 购买后不支持退款,请仔细审阅《隐私权政策》《用户协议》和《续订说明》")
-//        label.font(10)
-//        label.textColor = .hexStringColor(hexString: "#000000").withAlphaComponent(0.6)
-//        label.changeLineSpace(space: 5)
-//        return label
-//    }()
+    lazy var tipContentLabel: UILabel = {
+       
+        let label = UILabel()
+        label.numberOfLines = 0
+        label.text("1 订阅后会从您的iTunes账户中扣除相关费用。如需取消续订,请在当前订阅周期结束前,至少24小时内通过手机“账户设置”的订阅管理关闭自动续费功能。\n2 未成年人请在监护者的陪同下进行购买\n3 购买后不支持退款,请仔细审阅《隐私权政策》《用户协议》和《续订说明》")
+        label.font(10)
+        label.textColor = .hexStringColor(hexString: "#000000").withAlphaComponent(0.6)
+        label.changeLineSpace(space: 5)
+        return label
+    }()
     
     lazy var bottomView: UIView = {
        
@@ -524,6 +539,12 @@ extension QSLVipController {
                         gravityInstance?.trackPayEvent(withAmount: Int32(selectGood.amount), withPayType: "CNY", withOrderId: outTradeNo, withPayReason: selectGood.name, withPayMethod: "apple")
                     }
                     
+                    #if DEBUG
+                    #else
+                    //苹果广告奇异果传递支付事件
+                    QSWikiHandle.shared.addEventResultAttribution(eventDict: ["event_name": "pay", "event_val": selectGood.amount])
+                    #endif
+                    
                     if let type = self.type {
                         switch type {
                         case .homeRoad:
@@ -643,6 +664,8 @@ extension QSLVipController {
                 self.scrollView.snp.makeConstraints { make in
                     make.bottom.equalTo(self.mainView)
                 }
+                
+                self.checkRenewalOfProducts()
             }
             self.goodsCollectionView.reloadData()
         } fail: { code, error in
@@ -650,6 +673,26 @@ extension QSLVipController {
         }
     }
     
+    ///检查有没有续订的产品
+    func checkRenewalOfProducts() {
+        let hasSubscribable = self.goodList.contains(where: { model in
+            return model.subscribable == 1
+        })
+        
+        if hasSubscribable == false {
+            tipContentLabel.isHidden = true
+            hideSubscribeDescription()
+            serviceLabel.snp.removeConstraints()
+            serviceLabel.snp.makeConstraints { make in
+                make.left.equalTo(16)
+                make.top.equalTo(comment3.snp.bottom).offset(28.rpx)
+            }
+        } else {
+            tipContentLabel.isHidden = false
+            showSubscribeDescription()
+        }
+    }
+    
     // 计算购买人数
     func calculateBuyCount() {
         
@@ -949,22 +992,21 @@ extension QSLVipController {
         }
         
 //        commentView.addSubview(tipTitleLabel)
-//        commentView.addSubview(tipContentLabel)
 //        tipTitleLabel.snp.makeConstraints { make in
 //            make.left.equalTo(16)
 //            make.top.equalTo(comment3.snp.bottom).offset(28)
 //        }
-        
-//        tipContentLabel.snp.makeConstraints { make in
-//            make.left.equalTo(16)
-//            make.right.equalTo(-16)
-//            make.top.equalTo(tipTitleLabel.snp.bottom).offset(11)
-//        }
+        commentView.addSubview(tipContentLabel)
+        tipContentLabel.snp.makeConstraints { make in
+            make.left.equalTo(16)
+            make.right.equalTo(-16)
+            make.top.equalTo(comment3.snp.bottom).offset(11)
+        }
         
         commentView.addSubview(serviceLabel)
         serviceLabel.snp.makeConstraints { make in
             make.left.equalTo(16)
-            make.top.equalTo(comment3.snp.bottom).offset(28.rpx)
+            make.top.equalTo(tipContentLabel.snp.bottom).offset(28.rpx)
         }
         
         scrollView.snp.makeConstraints { make in