|
|
@@ -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
|