QSLGuideusersToCommentManager.swift 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. //
  2. // QSLGuideusersToCommentManager.swift
  3. // QuickSearchLocation
  4. //
  5. // Created by Destiny on 2025/7/31.
  6. //
  7. import Foundation
  8. import UIKit
  9. enum QSLGuideusersToCommentType : Int{
  10. case member //会员
  11. case nonMember // 非会员
  12. }
  13. class QSLGuideusersToCommentManager: NSObject {
  14. static let commentShare = QSLGuideusersToCommentManager()
  15. var guideGobalModel : QSLGuideIsTriggeredModel = QSLGuideIsTriggeredModel()
  16. var commentType : QSLGuideusersToCommentType = .member
  17. //管理处理是否触发好评引导弹窗
  18. func manageWhetherTriggerPopUpWindow(_ showType : QSLGuideusersToCommentType) {
  19. //print("showTypesdfsdfs---\(showType)")
  20. QSLNetwork().request(.guideIsTriggered(dict: [String : Any]())) { response in
  21. //print("responsesfsdfsf-----\(response)")
  22. let guideIsModel : QSLGuideIsTriggeredModel = response.mapObject(QSLGuideIsTriggeredModel.self, modelKey: "data")
  23. self.commentType = showType
  24. self.guideGobalModel = guideIsModel
  25. if (!guideIsModel.triggerStatus && guideIsModel.isTrigger) {
  26. if showType == .member {
  27. DispatchQueue.main.async {
  28. self.memberPositiveReviewPopWindow()
  29. }
  30. } else {
  31. DispatchQueue.main.async {
  32. self.noMemberPositiveReviewPopWindow()
  33. }
  34. }
  35. }
  36. } fail: { code, msg in
  37. }
  38. }
  39. ///领取好评引导奖励请求
  40. func requestForReceivingGoodReviewGuidance() {
  41. QSLNetwork().request(.guideReceiveReward(dict: [String : Any]())) { response in
  42. if self.commentType == .member {
  43. DispatchQueue.main.async {
  44. self.popUpWindowForMemberReview()
  45. }
  46. } else {
  47. DispatchQueue.main.async {
  48. self.popUpWindowForNonMemberReviews()
  49. }
  50. }
  51. } fail: { code, msg in
  52. }
  53. }
  54. }
  55. //管理各种类型的痰喘
  56. extension QSLGuideusersToCommentManager {
  57. ///会员的好评弹窗
  58. @MainActor func memberPositiveReviewPopWindow() {
  59. // 创建深灰色文本样式
  60. let darkGrayAttributes: [NSAttributedString.Key: Any] = [
  61. .foregroundColor: UIColor(red: 51/255.0, green: 51/255.0, blue: 51/255.0, alpha: 1.0),
  62. .font: UIFont(name: "Noto Sans SC", size: 20)?.withTraits(traits: .traitBold) ?? UIFont.systemFont(ofSize: 20, weight: .black),
  63. .paragraphStyle: {
  64. let paragraphStyle = NSMutableParagraphStyle()
  65. paragraphStyle.alignment = .center
  66. return paragraphStyle
  67. }(),
  68. .kern: -1
  69. ]
  70. // 创建绿色文本样式
  71. let greenAttributes: [NSAttributedString.Key: Any] = [
  72. .foregroundColor: UIColor(red: 17/255.0, green: 186/255.0, blue: 152/255.0, alpha: 1.0),
  73. .font: UIFont(name: "Noto Sans SC", size: 20)?.withTraits(traits: .traitBold) ?? UIFont.systemFont(ofSize: 20, weight: .black),
  74. .paragraphStyle: {
  75. let paragraphStyle = NSMutableParagraphStyle()
  76. paragraphStyle.alignment = .center
  77. return paragraphStyle
  78. }(),
  79. .kern: -1
  80. ]
  81. let inputtr = NSMutableAttributedString()
  82. let titleOneAttr = NSAttributedString(string: "五星好评,", attributes: darkGrayAttributes)
  83. let titleTwoAttr = NSAttributedString(string: "多送\(self.guideGobalModel.extraMemberDays)天会员", attributes: greenAttributes)
  84. inputtr.append(titleOneAttr)
  85. inputtr.append(titleTwoAttr)
  86. if let currentWindow = UIApplication.keyWindow {
  87. QSLVipAlertView.alert(view: currentWindow, title: "", titleAttring: inputtr, content: "你的一条五星好评是我们前进的动力", isOneBtn: true, oneBtnText: "立即好评", oneBtnClosure: { [weak self] in
  88. // 同步调用
  89. QSLInAppReviewmanager.requestReview()
  90. DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
  91. self?.requestForReceivingGoodReviewGuidance()
  92. }
  93. })
  94. }
  95. }
  96. ///非会员的好评弹窗
  97. @MainActor func noMemberPositiveReviewPopWindow() {
  98. // 创建深灰色文本样式
  99. let darkGrayAttributes: [NSAttributedString.Key: Any] = [
  100. .foregroundColor: UIColor(red: 51/255.0, green: 51/255.0, blue: 51/255.0, alpha: 1.0),
  101. .font: UIFont(name: "Noto Sans SC", size: 20)?.withTraits(traits: .traitBold) ?? UIFont.systemFont(ofSize: 20, weight: .black),
  102. .paragraphStyle: {
  103. let paragraphStyle = NSMutableParagraphStyle()
  104. paragraphStyle.alignment = .center
  105. return paragraphStyle
  106. }(),
  107. .kern: -1
  108. ]
  109. let inputtr = NSMutableAttributedString()
  110. let titleOneAttr = NSAttributedString(string: "给我们一个好评呗~", attributes: darkGrayAttributes)
  111. inputtr.append(titleOneAttr)
  112. if let currentWindow = UIApplication.keyWindow {
  113. QSLVipAlertView.alert(view: currentWindow, title: "", titleAttring: inputtr, content: "我们将回馈用户更多的优惠福利", isOneBtn: true, oneBtnText: "立即好评", oneBtnClosure: { [weak self] in
  114. // 同步调用
  115. QSLInAppReviewmanager.requestReview()
  116. // 延迟1秒执行
  117. DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
  118. self?.requestForReceivingGoodReviewGuidance()
  119. }
  120. //self?.requestAddFri()
  121. })
  122. }
  123. }
  124. ///会员好评的结果弹窗
  125. @MainActor func popUpWindowForMemberReview() {
  126. // 创建深灰色文本样式
  127. let darkGrayAttributes: [NSAttributedString.Key: Any] = [
  128. .foregroundColor: UIColor(red: 51/255.0, green: 51/255.0, blue: 51/255.0, alpha: 1.0),
  129. .font: UIFont(name: "Noto Sans SC", size: 20)?.withTraits(traits: .traitBold) ?? UIFont.systemFont(ofSize: 20, weight: .black),
  130. .paragraphStyle: {
  131. let paragraphStyle = NSMutableParagraphStyle()
  132. paragraphStyle.alignment = .center
  133. return paragraphStyle
  134. }(),
  135. .kern: -1
  136. ]
  137. // 创建绿色文本样式
  138. let greenAttributes: [NSAttributedString.Key: Any] = [
  139. .foregroundColor: UIColor(red: 17/255.0, green: 186/255.0, blue: 152/255.0, alpha: 1.0),
  140. .font: UIFont(name: "Noto Sans SC", size: 28)?.withTraits(traits: .traitBold) ?? UIFont.systemFont(ofSize: 28, weight: .black),
  141. .paragraphStyle: {
  142. let paragraphStyle = NSMutableParagraphStyle()
  143. paragraphStyle.alignment = .center
  144. return paragraphStyle
  145. }(),
  146. .kern: -1
  147. ]
  148. let inputtr = NSMutableAttributedString()
  149. let titleOneAttr = NSAttributedString(string: "你已成功增加", attributes: darkGrayAttributes)
  150. let titleTwoAttr = NSAttributedString(string: " \(self.guideGobalModel.extraMemberDays) ", attributes: greenAttributes)
  151. let titleThreeAttr = NSAttributedString(string: "天会员", attributes: darkGrayAttributes)
  152. inputtr.append(titleOneAttr)
  153. inputtr.append(titleTwoAttr)
  154. inputtr.append(titleThreeAttr)
  155. if let currentWindow = UIApplication.keyWindow {
  156. QSLVipResultsAlertView.alert(view: currentWindow, title: "", titleAttring: inputtr, content: "恭喜你,领取成功!", isOneBtn: true, oneBtnText: "我知道了", oneBtnClosure: { [weak self] in
  157. //self?.requestAddFri()
  158. })
  159. }
  160. }
  161. ///非会员好评的结果弹窗
  162. @MainActor func popUpWindowForNonMemberReviews() {
  163. ///标题
  164. let titleDarkGrayAttributes: [NSAttributedString.Key: Any] = [
  165. .foregroundColor: UIColor(red: 51/255.0, green: 51/255.0, blue: 51/255.0, alpha: 1.0),
  166. .font: UIFont(name: "Noto Sans SC", size: 20)?.withTraits(traits: .traitBold) ?? UIFont.systemFont(ofSize: 20, weight: .black),
  167. .paragraphStyle: {
  168. let paragraphStyle = NSMutableParagraphStyle()
  169. paragraphStyle.alignment = .center
  170. return paragraphStyle
  171. }(),
  172. .kern: -1
  173. ]
  174. // 创建深灰色文本样式
  175. let darkGrayAttributes: [NSAttributedString.Key: Any] = [
  176. .foregroundColor: UIColor(red: 255/255.0, green: 230/255.0, blue: 192/255.0, alpha: 1.0),
  177. .font: UIFont(name: "Noto Sans SC", size: 16)?.withTraits(traits: .traitBold) ?? UIFont.systemFont(ofSize: 20, weight: .black),
  178. .paragraphStyle: {
  179. let paragraphStyle = NSMutableParagraphStyle()
  180. paragraphStyle.alignment = .center
  181. return paragraphStyle
  182. }(),
  183. .kern: -1
  184. ]
  185. // 创建绿色文本样式
  186. let greenAttributes: [NSAttributedString.Key: Any] = [
  187. .foregroundColor: UIColor(red: 255/255.0, green: 230/255.0, blue: 192/255.0, alpha: 1.0),
  188. .font: UIFont(name: "Noto Sans SC", size: 20)?.withTraits(traits: .traitBold) ?? UIFont.systemFont(ofSize: 28, weight: .black),
  189. .paragraphStyle: {
  190. let paragraphStyle = NSMutableParagraphStyle()
  191. paragraphStyle.alignment = .center
  192. return paragraphStyle
  193. }(),
  194. .kern: -1
  195. ]
  196. let inputtr = NSMutableAttributedString()
  197. let titleOneAttr = NSAttributedString(string: "感谢支持~", attributes: titleDarkGrayAttributes)
  198. inputtr.append(titleOneAttr)
  199. let contentAtter = NSMutableAttributedString()
  200. let contentAtterOne = NSAttributedString(string: "会员套餐体验", attributes: darkGrayAttributes)
  201. contentAtter.append(contentAtterOne)
  202. let contentAtterTwo = NSAttributedString(string: " \(self.guideGobalModel.returnDaysBasedOnRegistration())+\(self.guideGobalModel.extraMemberDays) ", attributes: greenAttributes)
  203. contentAtter.append(contentAtterTwo)
  204. let contentAtterTherr = NSAttributedString(string: "天", attributes: darkGrayAttributes)
  205. contentAtter.append(contentAtterTherr)
  206. if let currentWindow = UIApplication.keyWindow {
  207. QSLVipResultsNoMemberAlertView.alert(view: currentWindow, title: "", titleAttring: inputtr, content: "已解锁会员套餐体验7+3福利套餐",bottomContentAttring: contentAtter, isOneBtn: true, oneBtnText: "立即查看", oneBtnClosure: { [weak self] in
  208. QSLJumpManager.shared.pushToVip(type: .guideComments)
  209. })
  210. }
  211. }
  212. }