QSLGuideusersToCommentManager.swift 11 KB

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