QSLVipController.swift 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. //
  2. // QSLVipController.swift
  3. // QuickSearchLocation
  4. //
  5. // Created by Destiny on 2024/11/27.
  6. //
  7. import UIKit
  8. import YYText
  9. enum QSLVipJumpType: Int {
  10. case homeRoad // 定位查看轨迹
  11. case add // 添加好友
  12. case friendRoad // 好友列表查看轨迹
  13. case contact // 添加紧急联系人
  14. case mine //
  15. }
  16. class QSLVipController: QSLBaseController {
  17. var type: QSLVipJumpType?
  18. var goodList: [QSLGoodModel] = [QSLGoodModel]()
  19. var selectGood: QSLGoodModel? {
  20. didSet {
  21. updateSelectGoodUI()
  22. }
  23. }
  24. lazy var vipBg: UIImageView = {
  25. let imageView = UIImageView()
  26. imageView.image = UIImage(named: "vip_bg")
  27. return imageView
  28. }()
  29. lazy var backButton: UIButton = {
  30. let button = UIButton()
  31. button.image(UIImage(named: "public_back_btn_white"))
  32. button.title("会员中心")
  33. button.mediumFont(17)
  34. button.textColor(.white)
  35. button.setImageTitleLayout(.imgLeft, spacing: 4.rpx)
  36. button.addTarget(self, action: #selector(backBtnAction), for: .touchUpInside)
  37. return button
  38. }()
  39. lazy var scrollView: UIScrollView = {
  40. let scrollView = UIScrollView()
  41. // scrollView.delegate = self
  42. scrollView.bounces = false
  43. scrollView.showsVerticalScrollIndicator = false
  44. scrollView.contentInsetAdjustmentBehavior = .never
  45. return scrollView
  46. }()
  47. lazy var cardBannerImageView: UIImageView = {
  48. let imageView = UIImageView()
  49. imageView.image = UIImage(named: "vip_banner_card")
  50. return imageView
  51. }()
  52. lazy var vipTimeLabel: UILabel = {
  53. let label = UILabel()
  54. label.text("升级VIP会员,解锁全部功能")
  55. label.font(13)
  56. label.textColor = .hexStringColor(hexString: "#AF7655")
  57. return label
  58. }()
  59. lazy var funcBannerImageView: UIImageView = {
  60. let imageView = UIImageView()
  61. imageView.image = UIImage(named: "vip_banner_func")
  62. return imageView
  63. }()
  64. lazy var mainView: UIView = {
  65. let view = UIView()
  66. view.backgroundColor = QSLColor.backGroundColor
  67. view.addRadius(radius: 12.rpx)
  68. return view
  69. }()
  70. lazy var goodsBgView: UIView = {
  71. let view = UIView()
  72. view.gradientBackgroundColor(color1: .hexStringColor(hexString: "#FFF8F2"), color2: .hexStringColor(hexString: "#FFFFFF"), width: QSLConst.qsl_kScreenW, height: 255.rpx, direction: .vertical)
  73. return view
  74. }()
  75. lazy var vipGoodsTitleIcon: UIImageView = {
  76. let imageView = UIImageView()
  77. imageView.image = UIImage(named: "vip_title_icon")
  78. return imageView
  79. }()
  80. lazy var goodsCollectionView: UICollectionView = {
  81. let layout = UICollectionViewFlowLayout()
  82. layout.minimumLineSpacing = 0
  83. layout.scrollDirection = .horizontal
  84. let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
  85. collectionView.backgroundColor = .clear
  86. collectionView.dataSource = self
  87. collectionView.delegate = self
  88. collectionView.showsHorizontalScrollIndicator = false
  89. collectionView.bounces = false
  90. collectionView.register(cellClass: QSLVipGoodCollectionViewCell.self)
  91. return collectionView
  92. }()
  93. lazy var selectBtn: UIButton = {
  94. let btn = UIButton()
  95. btn.image(UIImage(named: "public_select_btn_false"), .normal)
  96. btn.image(UIImage(named: "public_select_btn_true"), .selected)
  97. btn.addTarget(self, action: #selector(selectBtnAction), for: .touchUpInside)
  98. return btn
  99. }()
  100. lazy var serviceLabel: YYLabel = {
  101. let label = YYLabel()
  102. let attr = NSMutableAttributedString()
  103. let firstAttr = NSMutableAttributedString(string: "购买即同意")
  104. firstAttr.font(12)
  105. firstAttr.color(.hexStringColor(hexString: "#A7A7A7"))
  106. attr.append(firstAttr)
  107. let blankAttr = NSMutableAttributedString(string: " ")
  108. blankAttr.font(12)
  109. attr.append(blankAttr)
  110. let privacyHL = YYTextHighlight()
  111. var privacyStr = "《隐私权政策》"
  112. let privacyText = NSMutableAttributedString(string: privacyStr)
  113. privacyText.font(12)
  114. privacyText.color(.hexStringColor(hexString: "#E7B983"))
  115. privacyText.yy_setTextHighlight(privacyHL, range: NSRange(location: 0, length: privacyStr.count))
  116. privacyHL.tapAction = { [weak self] containerView, text, range, rect in
  117. self?.privacyAction()
  118. }
  119. attr.append(privacyText)
  120. attr.append(blankAttr)
  121. let andAttr = NSMutableAttributedString(string: "和")
  122. andAttr.font(12)
  123. andAttr.color(.hexStringColor(hexString: "#A7A7A7"))
  124. attr.append(andAttr)
  125. attr.append(blankAttr)
  126. let serviceHL = YYTextHighlight()
  127. var serviceStr = "《用户协议》"
  128. let serviceText = NSMutableAttributedString(string: serviceStr)
  129. serviceText.font(12)
  130. serviceText.color(.hexStringColor(hexString: "#E7B983"))
  131. serviceText.yy_setTextHighlight(serviceHL, range: NSRange(location: 0, length: serviceStr.count))
  132. serviceHL.tapAction = { [weak self] containerView, text, range, rect in
  133. self?.serviceAction()
  134. }
  135. attr.append(serviceText)
  136. label.attributedText = attr
  137. return label
  138. }()
  139. lazy var commentView: UIView = {
  140. let view = UIView()
  141. view.backgroundColor = .white
  142. return view
  143. }()
  144. lazy var commentTitleIcon: UIImageView = {
  145. let imageView = UIImageView()
  146. imageView.image = UIImage(named: "vip_comment_title_icon")
  147. return imageView
  148. }()
  149. lazy var comment1: QSLVipCommentCellView = {
  150. let view = QSLVipCommentCellView()
  151. view.config(name: "用户189****7913", comment: "上班没时间,远程遛娃,非常方便很好用。")
  152. return view
  153. }()
  154. lazy var comment2: QSLVipCommentCellView = {
  155. let view = QSLVipCommentCellView()
  156. view.config(name: "用户189****7913", comment: "用了之后,才发现真的可以找到他。")
  157. return view
  158. }()
  159. lazy var comment3: QSLVipCommentCellView = {
  160. let view = QSLVipCommentCellView()
  161. view.config(name: "用户189****7913", comment: "轨迹很准,一目了然,奶奶出门遇到危险直接一键报警,我就收到信息了")
  162. return view
  163. }()
  164. lazy var bottomView: UIView = {
  165. let view = UIView()
  166. view.gradientBackgroundColor(color1: .hexStringColor(hexString: "#00434E"), color2: .hexStringColor(hexString: "#0E5E61"), width: QSLConst.qsl_kScreenW - 24.rpx, height: 50.rpx, direction: .horizontal)
  167. view.addRadius(radius: 25.rpx)
  168. return view
  169. }()
  170. lazy var unlockBtn: UIButton = {
  171. let btn = UIButton()
  172. btn.setBackgroundImage(UIImage(named: "vip_unlock_btn_bg"), for: .normal)
  173. btn.title("立即解锁")
  174. btn.textColor(.hexStringColor(hexString: "#9B3800"))
  175. btn.mediumFont(18)
  176. btn.titleEdgeInsets = UIEdgeInsets(top: 0, left: 30.rpx, bottom: 0, right: 0)
  177. btn.addTarget(self, action: #selector(unlockBtnAction), for: .touchUpInside)
  178. return btn
  179. }()
  180. lazy var priceIconLabel: UILabel = {
  181. let label = UILabel()
  182. label.text("¥")
  183. label.textColor = .hexStringColor(hexString: "#FFF8EF")
  184. label.font(14)
  185. return label
  186. }()
  187. lazy var priceLabel: UILabel = {
  188. let label = UILabel()
  189. label.text("168")
  190. label.textColor = .hexStringColor(hexString: "#FFF8EF")
  191. label.font(24)
  192. return label
  193. }()
  194. lazy var goodTypeLabel: UILabel = {
  195. let label = UILabel()
  196. label.text("/ 永久会员")
  197. label.textColor = .hexStringColor(hexString: "#FFF8EF")
  198. label.font(12)
  199. return label
  200. }()
  201. override func viewDidLoad() {
  202. super.viewDidLoad()
  203. initializeView()
  204. updateUI()
  205. requestItemList()
  206. if let type = self.type {
  207. switch type {
  208. case .homeRoad:
  209. gravityInstance?.track(QSLGravityConst.vip_show, properties: ["id": 1001])
  210. case .add:
  211. gravityInstance?.track(QSLGravityConst.vip_show, properties: ["id": 1002])
  212. case .friendRoad:
  213. gravityInstance?.track(QSLGravityConst.vip_show, properties: ["id": 1003])
  214. case .contact:
  215. gravityInstance?.track(QSLGravityConst.vip_show, properties: ["id": 1004])
  216. case .mine:
  217. gravityInstance?.track(QSLGravityConst.vip_show, properties: ["id": 1006])
  218. }
  219. }
  220. }
  221. }
  222. extension QSLVipController {
  223. @objc func privacyAction() {
  224. let vc = QSLWebViewController()
  225. vc.webUrl = QSLConfig.AppPrivacyAgreementLink
  226. vc.title = "隐私政策"
  227. self.navigationController?.pushViewController(vc, animated: true)
  228. }
  229. @objc func serviceAction() {
  230. let vc = QSLWebViewController()
  231. vc.webUrl = QSLConfig.AppServiceAgreementLink
  232. vc.title = "服务协议"
  233. self.navigationController?.pushViewController(vc, animated: true)
  234. }
  235. @objc func selectBtnAction() {
  236. selectBtn.isSelected = !selectBtn.isSelected
  237. }
  238. @objc func unlockBtnAction() {
  239. switch self.selectGood?.level {
  240. case 100 :
  241. gravityInstance?.track(QSLGravityConst.vip_buy_click, properties: ["id": 1006])
  242. break
  243. case 700:
  244. gravityInstance?.track(QSLGravityConst.vip_buy_click, properties: ["id": 1005])
  245. break;
  246. case 3100:
  247. gravityInstance?.track(QSLGravityConst.vip_buy_click, properties: ["id": 1004])
  248. break;
  249. case 9200:
  250. gravityInstance?.track(QSLGravityConst.vip_buy_click, properties: ["id": 1003])
  251. break;
  252. case 36600:
  253. gravityInstance?.track(QSLGravityConst.vip_buy_click, properties: ["id": 1002])
  254. break;
  255. case 3660000:
  256. gravityInstance?.track(QSLGravityConst.vip_buy_click, properties: ["id": 1001])
  257. break;
  258. default:
  259. break;
  260. }
  261. if !selectBtn.isSelected {
  262. self.view.toast(text: "请先同意《隐私权政策》和《用户协议》")
  263. return
  264. }
  265. if goodList.count > 0, let selectGood = self.selectGood {
  266. QSLLoading.show()
  267. QSLVipManager.shared.startPay(goods: selectGood) { status, outTradeNo in
  268. QSLVipManager.shared.isPaying = false
  269. if status == .success {
  270. QSLLoading.success(text: "支付成功")
  271. // NSLocalizedString("Payment successful", comment: "支付成功")
  272. // if let payType = self.payType {
  273. // geInstance?.track(HolaGravityConst.vip_open_success, properties: ["id": payType])
  274. //
  275. // if payType == 1004 {
  276. // geInstance?.track(HolaGravityConst.vip_alert_pay, properties: ["id": 1002])
  277. // }
  278. // }
  279. // let val: Float = 0.1
  280. // HolaSaManager.shared.addEventAttribution(eventDict: ["event_name": "pay", "event_val": val])
  281. // 引力传递支付事件
  282. if let selectGood = self.selectGood {
  283. gravityInstance?.trackPayEvent(withAmount: Int32(selectGood.amount), withPayType: "CNY", withOrderId: outTradeNo, withPayReason: selectGood.name, withPayMethod: "apple")
  284. }
  285. if let type = self.type {
  286. switch type {
  287. case .homeRoad:
  288. gravityInstance?.track(QSLGravityConst.vip_success_page, properties: ["id": 1001])
  289. case .add:
  290. gravityInstance?.track(QSLGravityConst.vip_success_page, properties: ["id": 1002])
  291. case .friendRoad:
  292. gravityInstance?.track(QSLGravityConst.vip_success_page, properties: ["id": 1003])
  293. case .contact:
  294. gravityInstance?.track(QSLGravityConst.vip_success_page, properties: ["id": 1004])
  295. case .mine:
  296. gravityInstance?.track(QSLGravityConst.vip_success_page, properties: ["id": 1006])
  297. }
  298. }
  299. switch self.selectGood?.level {
  300. case 100 :
  301. gravityInstance?.track(QSLGravityConst.vip_success_good, properties: ["id": 1])
  302. break
  303. case 700:
  304. gravityInstance?.track(QSLGravityConst.vip_success_good, properties: ["id": 5])
  305. break;
  306. case 3100:
  307. gravityInstance?.track(QSLGravityConst.vip_success_good, properties: ["id": 9])
  308. break;
  309. case 9200:
  310. gravityInstance?.track(QSLGravityConst.vip_success_good, properties: ["id": 13])
  311. break;
  312. case 36600:
  313. gravityInstance?.track(QSLGravityConst.vip_success_good, properties: ["id": 17])
  314. break;
  315. case 3660000:
  316. gravityInstance?.track(QSLGravityConst.vip_success_good, properties: ["id": 21])
  317. break;
  318. default:
  319. break;
  320. }
  321. DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
  322. self.navigationController?.popViewController(animated: true)
  323. NotificationCenter.default.post(name: QSLNotification.QSLRefreshMember, object: nil)
  324. }
  325. } else if status == .cancel {
  326. QSLLoading.error(text: "支付取消")
  327. } else if status == .fail {
  328. gravityInstance?.track(QSLGravityConst.vip_fail)
  329. QSLLoading.error(text: "支付失败")
  330. } else if status == .searchFail {
  331. QSLLoading.error(text: "查询订单失败,请稍后重试")
  332. }
  333. }
  334. }
  335. }
  336. }
  337. extension QSLVipController {
  338. func requestItemList() {
  339. QSLNetwork().request(.vipItemList(dict: [:])) { response in
  340. let list = response.mapArray(QSLGoodModel.self, modelKey: "data>list")
  341. self.goodList = list
  342. if self.goodList.count > 0 {
  343. self.goodList[0].isSelect = true
  344. self.selectGood = self.goodList[0]
  345. }
  346. self.goodsCollectionView.reloadData()
  347. } fail: { code, error in
  348. self.view.toast(text: "加载商品列表失败")
  349. }
  350. }
  351. }
  352. // MARK: - 设置 CollectionView
  353. extension QSLVipController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
  354. func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
  355. return goodList.count
  356. }
  357. func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
  358. let cell = collectionView.dequeueReusableCell(cellType: QSLVipGoodCollectionViewCell.self, cellForRowAt: indexPath)
  359. let model = self.goodList[indexPath.row]
  360. cell.config(model: model)
  361. return cell
  362. }
  363. func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  364. for i in 0..<self.goodList.count {
  365. self.goodList[i].isSelect = false
  366. }
  367. self.goodList[indexPath.row].isSelect = true
  368. self.selectGood = self.goodList[indexPath.row]
  369. switch self.selectGood?.level {
  370. case 100 :
  371. gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1006])
  372. break
  373. case 700:
  374. gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1005])
  375. break;
  376. case 3100:
  377. gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1004])
  378. break;
  379. case 9200:
  380. gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1003])
  381. break;
  382. case 36600:
  383. gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1002])
  384. break;
  385. case 3660000:
  386. gravityInstance?.track(QSLGravityConst.vip_good_select, properties: ["id": 1001])
  387. break;
  388. default:
  389. break;
  390. }
  391. self.goodsCollectionView.reloadData()
  392. }
  393. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
  394. return CGSize(width: 104.rpx, height: 143.rpx)
  395. }
  396. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
  397. return 4.rpx
  398. }
  399. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
  400. return 0
  401. }
  402. }
  403. extension QSLVipController {
  404. func updateUI() {
  405. if QSLBaseManager.shared.isLogin() && QSLBaseManager.shared.isVip() {
  406. let model = QSLBaseManager.shared.userModel.memberModel
  407. if model.permanent {
  408. self.vipTimeLabel.text("您已是尊贵的永久会员")
  409. self.bottomView.isHidden = true
  410. } else {
  411. let level = model.memberLevelString()
  412. let endTime = model.endTimestampString()
  413. self.vipTimeLabel.text("\(level):\(endTime)到期")
  414. }
  415. } else {
  416. self.vipTimeLabel.text("升级VIP会员,解锁全部功能")
  417. }
  418. }
  419. func updateSelectGoodUI() {
  420. var priceText = ""
  421. if let selectGood = self.selectGood {
  422. if selectGood.amount.truncatingRemainder(dividingBy: 100) == 0 {
  423. priceText = "\(Int(selectGood.amount / 100))"
  424. } else {
  425. priceText = String(format: "%.2lf", selectGood.amount / 100 )
  426. }
  427. }
  428. self.priceLabel.text(priceText)
  429. self.goodTypeLabel.text("/ \(self.selectGood?.name ?? "")")
  430. }
  431. func initializeView() {
  432. self.view.addSubview(vipBg)
  433. vipBg.snp.makeConstraints { make in
  434. make.left.top.right.equalTo(0)
  435. }
  436. self.view.addSubview(backButton)
  437. backButton.snp.makeConstraints { make in
  438. make.size.equalTo(100.rpx)
  439. make.height.equalTo(25.rpx)
  440. make.left.equalTo(12.rpx)
  441. make.top.equalTo(QSLConst.qsl_kStatusBarFrameH)
  442. }
  443. self.view.addSubview(scrollView)
  444. scrollView.snp.makeConstraints { make in
  445. make.left.right.equalTo(0)
  446. make.top.equalTo(QSLConst.qsl_kNavFrameH)
  447. make.bottom.equalTo(0)
  448. }
  449. scrollView.addSubview(cardBannerImageView)
  450. cardBannerImageView.snp.makeConstraints { make in
  451. make.top.equalTo(0)
  452. make.centerX.equalToSuperview()
  453. make.width.equalTo(336.rpx)
  454. make.height.equalTo(108.rpx)
  455. }
  456. cardBannerImageView.addSubview(vipTimeLabel)
  457. vipTimeLabel.snp.makeConstraints { make in
  458. make.left.equalTo(23.rpx)
  459. make.bottom.equalTo(-19.rpx)
  460. }
  461. scrollView.addSubview(funcBannerImageView)
  462. funcBannerImageView.snp.makeConstraints { make in
  463. make.size.equalTo(CGSize(width: 336.rpx, height: 172.rpx))
  464. make.centerX.equalToSuperview()
  465. make.top.equalTo(cardBannerImageView.snp.bottom).offset(14.rpx)
  466. }
  467. scrollView.addSubview(mainView)
  468. mainView.snp.makeConstraints { make in
  469. make.left.right.bottom.equalTo(0)
  470. make.top.equalTo(funcBannerImageView.snp.bottom).offset(-24.rpx)
  471. make.width.equalTo(QSLConst.qsl_kScreenW)
  472. make.height.equalTo(700.rpx)
  473. }
  474. mainView.addSubview(goodsBgView)
  475. goodsBgView.snp.makeConstraints { make in
  476. make.top.left.right.equalTo(0)
  477. make.height.equalTo(255.rpx)
  478. }
  479. goodsBgView.addSubview(vipGoodsTitleIcon)
  480. vipGoodsTitleIcon.snp.makeConstraints { make in
  481. make.size.equalTo(CGSize(width: 117.rpx, height: 26.rpx))
  482. make.left.equalTo(20.rpx)
  483. make.top.equalTo(16.rpx)
  484. }
  485. goodsBgView.addSubview(goodsCollectionView)
  486. goodsCollectionView.snp.makeConstraints { make in
  487. make.left.equalTo(18.rpx)
  488. make.right.equalTo(-22.rpx)
  489. make.height.equalTo(143.rpx)
  490. make.top.equalTo(vipGoodsTitleIcon.snp.bottom).offset(10.rpx)
  491. }
  492. goodsBgView.addSubview(selectBtn)
  493. selectBtn.snp.makeConstraints { make in
  494. make.size.equalTo(CGSize(width: 12.rpx, height: 12.rpx))
  495. make.left.equalTo(23.rpx)
  496. make.top.equalTo(goodsCollectionView.snp.bottom).offset(16.rpx)
  497. }
  498. goodsBgView.addSubview(serviceLabel)
  499. serviceLabel.snp.makeConstraints { make in
  500. make.left.equalTo(selectBtn.snp.right).offset(2.rpx)
  501. make.centerY.equalTo(selectBtn.snp.centerY)
  502. }
  503. mainView.addSubview(commentView)
  504. commentView.snp.makeConstraints { make in
  505. make.left.right.equalTo(0)
  506. make.top.equalTo(goodsBgView.snp.bottom).offset(8.rpx)
  507. make.bottom.equalTo(0)
  508. }
  509. commentView.addSubview(commentTitleIcon)
  510. commentTitleIcon.snp.makeConstraints { make in
  511. make.size.equalTo(CGSize(width: 83.rpx, height: 26.rpx))
  512. make.top.equalTo(16.rpx)
  513. make.left.equalTo(12.rpx)
  514. }
  515. let commentHeight1 = "上班没时间,远程遛娃,非常方便很好用。".heightAccording(width: QSLConst.qsl_kScreenW - 52.rpx - 12.rpx, font: .textF(15), lineSpacing: 2) + 35.rpx
  516. commentView.addSubview(comment1)
  517. comment1.snp.makeConstraints { make in
  518. make.left.right.equalTo(0)
  519. make.top.equalTo(commentTitleIcon.snp.bottom).offset(16.rpx)
  520. make.height.equalTo(commentHeight1)
  521. }
  522. let commentHeight2 = "用了之后,才发现真的可以找到他。".heightAccording(width: QSLConst.qsl_kScreenW - 52.rpx - 12.rpx, font: .textF(15), lineSpacing: 2) + 35.rpx
  523. commentView.addSubview(comment2)
  524. comment2.snp.makeConstraints { make in
  525. make.left.right.equalTo(0)
  526. make.top.equalTo(comment1.snp.bottom).offset(30.rpx)
  527. make.height.equalTo(commentHeight2)
  528. }
  529. let commentHeight3 = "轨迹很准,一目了然,奶奶出门遇到危险直接一键报警,我就收到信息了".heightAccording(width: QSLConst.qsl_kScreenW - 52.rpx - 12.rpx, font: .textF(15), lineSpacing: 2) + 35.rpx
  530. commentView.addSubview(comment3)
  531. comment3.snp.makeConstraints { make in
  532. make.left.right.equalTo(0)
  533. make.top.equalTo(comment2.snp.bottom).offset(30.rpx)
  534. make.height.equalTo(commentHeight3)
  535. }
  536. scrollView.snp.makeConstraints { make in
  537. make.bottom.equalTo(mainView)
  538. }
  539. self.view.addSubview(bottomView)
  540. bottomView.snp.makeConstraints { make in
  541. make.left.equalTo(12.rpx)
  542. make.right.equalTo(-12.rpx)
  543. make.bottom.equalTo(-QSLConst.qsl_kTabbarBottom)
  544. make.height.equalTo(50.rpx)
  545. }
  546. bottomView.addSubview(unlockBtn)
  547. unlockBtn.snp.makeConstraints { make in
  548. make.right.top.bottom.equalTo(0)
  549. make.width.equalTo(165.rpx)
  550. }
  551. bottomView.addSubview(priceIconLabel)
  552. priceIconLabel.snp.makeConstraints { make in
  553. make.left.equalTo(20.rpx)
  554. make.bottom.equalTo(-12.rpx)
  555. }
  556. bottomView.addSubview(priceLabel)
  557. priceLabel.snp.makeConstraints { make in
  558. make.left.equalTo(priceIconLabel.snp.right).offset(2.rpx)
  559. make.bottom.equalTo(-10.rpx)
  560. }
  561. bottomView.addSubview(goodTypeLabel)
  562. goodTypeLabel.snp.makeConstraints { make in
  563. make.left.equalTo(priceLabel.snp.right).offset(2.rpx)
  564. make.bottom.equalTo(-14.rpx)
  565. }
  566. }
  567. }