|
|
@@ -19,6 +19,12 @@ enum QSLVipJumpType: Int {
|
|
|
|
|
|
class QSLVipController: QSLBaseController {
|
|
|
|
|
|
+ struct UX {
|
|
|
+ static let mostCellHeight = 113.0.rpx
|
|
|
+ static let collectionRowHeight = 137.0.rpx
|
|
|
+ static let goodsBgHeight = 54.rpx + UX.mostCellHeight + 20.rpx
|
|
|
+ }
|
|
|
+
|
|
|
var type: QSLVipJumpType?
|
|
|
|
|
|
var goodList: [QSLGoodModel] = [QSLGoodModel]()
|
|
|
@@ -117,7 +123,7 @@ class QSLVipController: QSLBaseController {
|
|
|
lazy var goodsBgView: UIView = {
|
|
|
|
|
|
let view = UIView()
|
|
|
- view.gradientBackgroundColor(color1: .hexStringColor(hexString: "#FFF8F2"), color2: .hexStringColor(hexString: "#FFFFFF"), width: QSLConst.qsl_kScreenW, height: 255.rpx, direction: .vertical)
|
|
|
+ view.gradientBackgroundColor(color1: .hexStringColor(hexString: "#FFF8F2"), color2: .hexStringColor(hexString: "#FFFFFF"), width: QSLConst.qsl_kScreenW, height: UX.goodsBgHeight, direction: .vertical)
|
|
|
return view
|
|
|
}()
|
|
|
|
|
|
@@ -140,11 +146,22 @@ class QSLVipController: QSLBaseController {
|
|
|
return button
|
|
|
}()
|
|
|
|
|
|
+ lazy var mostCell: QSLVipMostGoodCell = {
|
|
|
+
|
|
|
+ let cell = QSLVipMostGoodCell()
|
|
|
+
|
|
|
+ cell.isUserInteractionEnabled = true
|
|
|
+ let tap = UITapGestureRecognizer(target: self, action: #selector(firstCellClickAction))
|
|
|
+ cell.addGestureRecognizer(tap)
|
|
|
+
|
|
|
+ return cell
|
|
|
+ }()
|
|
|
+
|
|
|
lazy var goodsCollectionView: UICollectionView = {
|
|
|
|
|
|
let layout = UICollectionViewFlowLayout()
|
|
|
layout.minimumLineSpacing = 0
|
|
|
- layout.scrollDirection = .horizontal
|
|
|
+ layout.scrollDirection = .vertical
|
|
|
|
|
|
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
|
|
|
collectionView.backgroundColor = .clear
|
|
|
@@ -176,12 +193,12 @@ class QSLVipController: QSLBaseController {
|
|
|
let attr = NSMutableAttributedString()
|
|
|
|
|
|
let firstAttr = NSMutableAttributedString(string: "购买即同意")
|
|
|
- firstAttr.font(12)
|
|
|
+ firstAttr.font(10)
|
|
|
firstAttr.color(.hexStringColor(hexString: "#A7A7A7"))
|
|
|
attr.append(firstAttr)
|
|
|
|
|
|
let blankAttr = NSMutableAttributedString(string: " ")
|
|
|
- blankAttr.font(12)
|
|
|
+ blankAttr.font(10)
|
|
|
attr.append(blankAttr)
|
|
|
|
|
|
let privacyHL = YYTextHighlight()
|
|
|
@@ -189,7 +206,7 @@ class QSLVipController: QSLBaseController {
|
|
|
|
|
|
let privacyText = NSMutableAttributedString(string: privacyStr)
|
|
|
|
|
|
- privacyText.font(12)
|
|
|
+ privacyText.font(10)
|
|
|
privacyText.color(.hexStringColor(hexString: "#E7B983"))
|
|
|
privacyText.yy_setTextHighlight(privacyHL, range: NSRange(location: 0, length: privacyStr.count))
|
|
|
privacyHL.tapAction = { [weak self] containerView, text, range, rect in
|
|
|
@@ -203,7 +220,7 @@ class QSLVipController: QSLBaseController {
|
|
|
var serviceStr = "《用户协议》"
|
|
|
|
|
|
let serviceText = NSMutableAttributedString(string: serviceStr)
|
|
|
- serviceText.font(12)
|
|
|
+ serviceText.font(10)
|
|
|
serviceText.color(.hexStringColor(hexString: "#E7B983"))
|
|
|
serviceText.yy_setTextHighlight(serviceHL, range: NSRange(location: 0, length: serviceStr.count))
|
|
|
serviceHL.tapAction = { [weak self] containerView, text, range, rect in
|
|
|
@@ -215,7 +232,7 @@ class QSLVipController: QSLBaseController {
|
|
|
attr.append(blankAttr)
|
|
|
|
|
|
let andAttr = NSMutableAttributedString(string: "和")
|
|
|
- andAttr.font(12)
|
|
|
+ andAttr.font(10)
|
|
|
andAttr.color(.hexStringColor(hexString: "#A7A7A7"))
|
|
|
attr.append(andAttr)
|
|
|
|
|
|
@@ -225,7 +242,7 @@ class QSLVipController: QSLBaseController {
|
|
|
var subcribeStr = "《续订说明》"
|
|
|
|
|
|
let subcribeText = NSMutableAttributedString(string: subcribeStr)
|
|
|
- subcribeText.font(12)
|
|
|
+ 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
|
|
|
@@ -457,6 +474,7 @@ extension QSLVipController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 支付按钮点击
|
|
|
@objc func unlockBtnAction() {
|
|
|
|
|
|
switch self.selectGood?.level {
|
|
|
@@ -482,10 +500,10 @@ extension QSLVipController {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if !selectBtn.isSelected {
|
|
|
- self.view.toast(text: "请先同意《隐私权政策》和《用户协议》")
|
|
|
- return
|
|
|
- }
|
|
|
+// if !selectBtn.isSelected {
|
|
|
+// self.view.toast(text: "请先同意《隐私权政策》和《用户协议》")
|
|
|
+// return
|
|
|
+// }
|
|
|
|
|
|
let memberModel = QSLBaseManager.shared.userModel.memberModel
|
|
|
|
|
|
@@ -500,18 +518,6 @@ extension QSLVipController {
|
|
|
QSLVipManager.shared.isPaying = false
|
|
|
if status == .success {
|
|
|
QSLLoading.success(text: "支付成功")
|
|
|
-// NSLocalizedString("Payment successful", comment: "支付成功")
|
|
|
-
|
|
|
-// if let payType = self.payType {
|
|
|
-// geInstance?.track(HolaGravityConst.vip_open_success, properties: ["id": payType])
|
|
|
-//
|
|
|
-// if payType == 1004 {
|
|
|
-// geInstance?.track(HolaGravityConst.vip_alert_pay, properties: ["id": 1002])
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// let val: Float = 0.1
|
|
|
-// HolaSaManager.shared.addEventAttribution(eventDict: ["event_name": "pay", "event_val": val])
|
|
|
|
|
|
// 引力传递支付事件
|
|
|
if let selectGood = self.selectGood {
|
|
|
@@ -556,23 +562,60 @@ extension QSLVipController {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
|
|
|
self.navigationController?.popViewController(animated: true)
|
|
|
NotificationCenter.default.post(name: QSLNotification.QSLRefreshMember, object: nil)
|
|
|
}
|
|
|
+
|
|
|
} else if status == .cancel {
|
|
|
QSLLoading.error(text: "支付取消")
|
|
|
} else if status == .fail {
|
|
|
gravityInstance?.track(QSLGravityConst.vip_fail)
|
|
|
QSLLoading.error(text: "支付失败")
|
|
|
} else if status == .searchFail {
|
|
|
-
|
|
|
QSLLoading.error(text: "查询订单失败,请稍后重试")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @objc func firstCellClickAction() {
|
|
|
+
|
|
|
+ for i in 0..<self.goodList.count {
|
|
|
+ self.goodList[i].isSelect = false
|
|
|
+ }
|
|
|
+
|
|
|
+ if self.goodList.count > 0 {
|
|
|
+ self.goodList[0].isSelect = true
|
|
|
+ self.selectGood = self.goodList[0]
|
|
|
+ self.mostCell.config(model: self.goodList[0])
|
|
|
+ }
|
|
|
+
|
|
|
+ switch self.selectGood?.level {
|
|
|
+ case 100 :
|
|
|
+ gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1006])
|
|
|
+ break
|
|
|
+ case 700:
|
|
|
+ gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1005])
|
|
|
+ break;
|
|
|
+ case 3100:
|
|
|
+ gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1004])
|
|
|
+ break;
|
|
|
+ case 9200:
|
|
|
+ gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1003])
|
|
|
+ break;
|
|
|
+ case 36600:
|
|
|
+ gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1002])
|
|
|
+ break;
|
|
|
+ case 3660000:
|
|
|
+ gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1001])
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ self.goodsCollectionView.reloadData()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
extension QSLVipController {
|
|
|
@@ -583,9 +626,23 @@ extension QSLVipController {
|
|
|
QSLNetwork().request(.vipItemList(dict: ["itemListType": 2])) { response in
|
|
|
let list = response.mapArray(QSLGoodModel.self, modelKey: "data>list")
|
|
|
self.goodList = list
|
|
|
+
|
|
|
if self.goodList.count > 0 {
|
|
|
self.goodList[0].isSelect = true
|
|
|
self.selectGood = self.goodList[0]
|
|
|
+ self.mostCell.config(model: self.goodList[0])
|
|
|
+
|
|
|
+ let row = ceil(Double(self.goodList.count - 1) / 3.0)
|
|
|
+ let height = UX.goodsBgHeight + (row * UX.collectionRowHeight)
|
|
|
+ self.goodsBgView.gradientBackgroundColor(color1: .hexStringColor(hexString: "#FFF8F2"), color2: .hexStringColor(hexString: "#FFFFFF"), width: QSLConst.qsl_kScreenW, height: height, direction: .vertical)
|
|
|
+
|
|
|
+ self.goodsBgView.snp.updateConstraints { make in
|
|
|
+ make.height.equalTo(height)
|
|
|
+ }
|
|
|
+
|
|
|
+ self.scrollView.snp.makeConstraints { make in
|
|
|
+ make.bottom.equalTo(self.mainView)
|
|
|
+ }
|
|
|
}
|
|
|
self.goodsCollectionView.reloadData()
|
|
|
} fail: { code, error in
|
|
|
@@ -612,14 +669,20 @@ extension QSLVipController {
|
|
|
extension QSLVipController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
|
|
- return goodList.count
|
|
|
+ return goodList.count - 1
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
|
|
|
|
let cell = collectionView.dequeueReusableCell(cellType: QSLVipGoodCollectionViewCell.self, cellForRowAt: indexPath)
|
|
|
- let model = self.goodList[indexPath.row]
|
|
|
- cell.config(model: model)
|
|
|
+ let model = self.goodList[indexPath.row + 1]
|
|
|
+
|
|
|
+ if self.goodList.count - 1 == 2 {
|
|
|
+ cell.config(model: model, type: .big)
|
|
|
+ } else {
|
|
|
+ cell.config(model: model, type: .small)
|
|
|
+ }
|
|
|
+
|
|
|
return cell
|
|
|
}
|
|
|
|
|
|
@@ -629,8 +692,11 @@ extension QSLVipController: UICollectionViewDelegate, UICollectionViewDataSource
|
|
|
self.goodList[i].isSelect = false
|
|
|
}
|
|
|
|
|
|
- self.goodList[indexPath.row].isSelect = true
|
|
|
- self.selectGood = self.goodList[indexPath.row]
|
|
|
+ if self.goodList.count > 0 {
|
|
|
+ self.goodList[indexPath.row + 1].isSelect = true
|
|
|
+ self.selectGood = self.goodList[indexPath.row + 1]
|
|
|
+ self.mostCell.config(model: self.goodList[0])
|
|
|
+ }
|
|
|
|
|
|
switch self.selectGood?.level {
|
|
|
case 100 :
|
|
|
@@ -660,15 +726,21 @@ extension QSLVipController: UICollectionViewDelegate, UICollectionViewDataSource
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
|
|
|
|
|
- return CGSize(width: 104.rpx, height: 143.rpx)
|
|
|
+ var width = (QSLConst.qsl_kScreenW - 42.0.rpx) / 3.0
|
|
|
+
|
|
|
+ if self.goodList.count - 1 == 2 {
|
|
|
+ width = (QSLConst.qsl_kScreenW - 36.0.rpx) / 2.0
|
|
|
+ }
|
|
|
+
|
|
|
+ return CGSize(width: width, height: 134.0.rpx)
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
|
|
|
- return 4.rpx
|
|
|
+ return 6.rpx
|
|
|
}
|
|
|
|
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
|
|
|
- return 0
|
|
|
+ return 3.rpx
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -780,17 +852,18 @@ extension QSLVipController {
|
|
|
|
|
|
scrollView.addSubview(mainView)
|
|
|
mainView.snp.makeConstraints { make in
|
|
|
- make.left.right.bottom.equalTo(0)
|
|
|
+ make.left.right.equalTo(0)
|
|
|
make.top.equalTo(funcBannerImageView.snp.bottom).offset(-24.rpx)
|
|
|
make.width.equalTo(QSLConst.qsl_kScreenW)
|
|
|
- make.height.equalTo(800.rpx)
|
|
|
+// make.height.equalTo(800.rpx)
|
|
|
}
|
|
|
|
|
|
+ let goodsBgHeight = 54.rpx + UX.mostCellHeight
|
|
|
mainView.addSubview(goodsBgView)
|
|
|
goodsBgView.snp.makeConstraints { make in
|
|
|
make.top.left.right.equalTo(0)
|
|
|
make.width.equalTo(QSLConst.qsl_kScreenW)
|
|
|
- make.height.equalTo(255.rpx)
|
|
|
+ make.height.equalTo(goodsBgHeight)
|
|
|
}
|
|
|
|
|
|
goodsBgView.addSubview(vipGoodsTitleIcon)
|
|
|
@@ -807,31 +880,40 @@ extension QSLVipController {
|
|
|
make.centerY.equalTo(vipGoodsTitleIcon.snp.centerY)
|
|
|
}
|
|
|
|
|
|
- goodsBgView.addSubview(goodsCollectionView)
|
|
|
- goodsCollectionView.snp.makeConstraints { make in
|
|
|
- make.left.equalTo(18.rpx)
|
|
|
- make.right.equalTo(-22.rpx)
|
|
|
- make.height.equalTo(143.rpx)
|
|
|
+ goodsBgView.addSubview(mostCell)
|
|
|
+ mostCell.snp.makeConstraints { make in
|
|
|
+ make.left.equalTo(12.rpx)
|
|
|
+ make.right.equalTo(-16.rpx)
|
|
|
+ make.height.equalTo(113.rpx)
|
|
|
make.top.equalTo(vipGoodsTitleIcon.snp.bottom).offset(10.rpx)
|
|
|
}
|
|
|
|
|
|
- goodsBgView.addSubview(selectBtn)
|
|
|
- selectBtn.snp.makeConstraints { make in
|
|
|
- make.size.equalTo(CGSize(width: 12.rpx, height: 12.rpx))
|
|
|
- make.left.equalTo(23.rpx)
|
|
|
- make.top.equalTo(goodsCollectionView.snp.bottom).offset(16.rpx)
|
|
|
- }
|
|
|
-
|
|
|
- goodsBgView.addSubview(serviceLabel)
|
|
|
- serviceLabel.snp.makeConstraints { make in
|
|
|
- make.left.equalTo(selectBtn.snp.right).offset(2.rpx)
|
|
|
- make.centerY.equalTo(selectBtn.snp.centerY)
|
|
|
- }
|
|
|
+ goodsBgView.addSubview(goodsCollectionView)
|
|
|
+ goodsCollectionView.snp.makeConstraints { make in
|
|
|
+ make.left.equalTo(12.rpx)
|
|
|
+ make.right.equalTo(-18.rpx)
|
|
|
+ make.bottom.equalTo(-20.rpx)
|
|
|
+ make.top.equalTo(mostCell.snp.bottom).offset(3.rpx)
|
|
|
+ }
|
|
|
+
|
|
|
+// goodsBgView.addSubview(selectBtn)
|
|
|
+// selectBtn.snp.makeConstraints { make in
|
|
|
+// make.size.equalTo(CGSize(width: 12.rpx, height: 12.rpx))
|
|
|
+// make.left.equalTo(23.rpx)
|
|
|
+// make.top.equalTo(goodsCollectionView.snp.bottom).offset(16.rpx)
|
|
|
+// }
|
|
|
+//
|
|
|
+// goodsBgView.addSubview(serviceLabel)
|
|
|
+// serviceLabel.snp.makeConstraints { make in
|
|
|
+// make.left.equalTo(selectBtn.snp.right).offset(2.rpx)
|
|
|
+// make.centerY.equalTo(selectBtn.snp.centerY)
|
|
|
+// }
|
|
|
|
|
|
mainView.addSubview(commentView)
|
|
|
commentView.snp.makeConstraints { make in
|
|
|
make.left.right.equalTo(0)
|
|
|
make.top.equalTo(goodsBgView.snp.bottom).offset(8.rpx)
|
|
|
+ make.height.equalTo(525.rpx + QSLConst.qsl_kTabbarBottom)
|
|
|
make.bottom.equalTo(0)
|
|
|
}
|
|
|
|
|
|
@@ -879,6 +961,12 @@ extension QSLVipController {
|
|
|
make.top.equalTo(tipTitleLabel.snp.bottom).offset(11)
|
|
|
}
|
|
|
|
|
|
+ commentView.addSubview(serviceLabel)
|
|
|
+ serviceLabel.snp.makeConstraints { make in
|
|
|
+ make.left.equalTo(16)
|
|
|
+ make.top.equalTo(tipContentLabel.snp.bottom).offset(5.rpx)
|
|
|
+ }
|
|
|
+
|
|
|
scrollView.snp.makeConstraints { make in
|
|
|
make.bottom.equalTo(mainView)
|
|
|
}
|