KMMemberCenterManager.swift 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577
  1. //
  2. // KMMemberCenterManager.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/10/21.
  6. //
  7. import Cocoa
  8. enum KMMemberCenterErrorCodeType: Int, CaseIterable {
  9. case UNKNOWN = 0 //未知
  10. case SUCCESS = 200 //正确
  11. case EXCEPTION_MSG_TOKEN_IS_INVALID = 304 // 无效的token或者token已过期
  12. case EXCEPTION_MSG_DEVICE_NUM_MAX = 305 // 您的登录设备已达上限,请退出其他设备重新登录
  13. case EXCEPTION_MSG_USER_NOT_LOGIN = 306 // 用户没有登录,请登录后再访问
  14. case EMAIL_VERIFY_CODE_KEY_ERROR = 309 // email code error!
  15. case EMAIL_REGISTER_ERROR = 310 // Register error!
  16. case EXCEPTION_MSG_PASSWORD_ERROR = 311 // 密码错误,您可以检查大小写状态
  17. case EXCEPTION_MSG_CODE_ACTION_ERROR = 312 // code action error
  18. case EXCEPTION_MSG_CODE_SEND_ERROR = 313 // code send error
  19. case EXCEPTION_MAIL_CODE_SEND_ERROR = 314 // mail send error
  20. case VERIFY_CODE_SEND_TOO_QUICKLY = 315 // code send too quickly
  21. case EXCEPTION_MSG_EMAIL_EXIST = 316 // 该邮箱已有账号,请前往登录
  22. case EXCEPTION_MSG_EMAIL_NOT_REGISTER = 317 // 当前账号未注册,点击下一步我们将为您注册账号
  23. case EXCEPTION_MSG_EMAIL_LOGOUT_ING = 318 // 注销中,无法登录,若有问题可联系客服
  24. case EXCEPTION_MSG_EMAIL_INVALID = 319 // 请输入正确的邮箱格式
  25. case EXCEPTION_MSG_PASSWORD_NOT_INCONSISTENT = 320 // 密码不一致,请重新输入
  26. case EXCEPTION_MSG_PASSWORD_SIZE_MIN = 321 // 密码请包含6~24个字符
  27. case EXCEPTION_MSG_PASSWORD_SIZE_MAX = 322 // 密码请包含6~24个字符
  28. case EXCEPTION_MSG_PLEASE_ADD_AUTH_CONFIG = 323 // please add auth config
  29. case EXCEPTION_MSG_USER_SUBSCRIPTION_IN_PROGRESS = 324 // 您目前还在订阅期内,暂时无法注销,请订阅期结束后再点击注销账号
  30. case EXCEPTION_TIME_TRANSFER_ERROR = 326 // 时间转换失败
  31. case EXCEPTION_MSG_PASSWORD_CONTAIN_EMPTY = 327 // 密码不能包含空格
  32. }
  33. @objc enum KMVerificationCodeType : Int {
  34. case login = 0 // 登录验证码
  35. case reset // 重置密码验证码
  36. case logout // 注销验证码
  37. }
  38. @objc enum KMBuyPlatformType : Int {
  39. case web = 0 // 官网
  40. case dmg // 重置密码验证码
  41. case macLite // Mac store免费版
  42. case exe
  43. case macPro // Mac store付费版
  44. case iOSLite // iOS免费版
  45. case iOSPro // iOS付费版
  46. case Android
  47. }
  48. typealias KMMemberCenterComplete = (_ success: Bool, _ result: KMMemberCenterResult?) -> Void
  49. typealias KMMemberProductComplete = (_ success: Bool, _ result: KMMemberProductResult?) -> Void
  50. typealias KMMemberRequestInfoComplete = (_ success: Bool, _ info: NSDictionary?) -> Void
  51. class KMMemberCenterManager: NSObject {
  52. static let manager = KMMemberCenterManager()
  53. private let configuration: KMMemberCenterConfig = KMMemberCenterConfig()
  54. // MARK: 判断有无网络
  55. func isConnectionAvailable() -> Bool {
  56. let reachability = Reachability(hostname: "www.apple.com")
  57. let state = reachability?.currentReachabilityStatus()
  58. if(state == NotReachable) {
  59. return false
  60. }
  61. return true
  62. }
  63. // MARK: 拼接URL(为Get类型)
  64. func constructURLString(baseURLString: String, parameters: [String: Any]) -> String? {
  65. // Ensure the base URL is valid
  66. guard var components = URLComponents(string: baseURLString) else {
  67. return nil
  68. }
  69. // Convert parameters to query items
  70. components.queryItems = parameters.map { key, value in
  71. URLQueryItem(name: key, value: "\(value)")
  72. }
  73. // Return the complete URL as a string
  74. return components.url?.absoluteString
  75. }
  76. // MARK: 登录模块
  77. /**
  78. @abstract 新会员系统重置密码
  79. @param email 邮箱
  80. @param verifyCode 验证码
  81. @param password 密码
  82. @param complete 回调
  83. */
  84. func resetPassword(email: String, verifyCode: String, password: String, _ complete: @escaping KMMemberCenterComplete) {
  85. let urlString = configuration.activityBaseURL() + "/member-system-sso/auth/memberResetPassword"
  86. // var escapedString = q
  87. // escapedString = String(data: escapedString.data(using: .utf8)!, encoding: .utf8)!
  88. let paraDict: [String: Any] = ["email": email,
  89. "verifyCode": verifyCode,
  90. "appId": "1",
  91. "password": password]
  92. let postData = try! JSONSerialization.data(withJSONObject: paraDict)
  93. var request = URLRequest(url: URL(string: urlString)!,timeoutInterval: Double.infinity)
  94. request.addValue("application/json", forHTTPHeaderField: "Content-Type")
  95. request.httpMethod = "POST"
  96. request.httpBody = postData
  97. let task = URLSession.shared.dataTask(with: request) { data, response, error in
  98. guard let data = data else {
  99. print(String(describing: error))
  100. return
  101. }
  102. let jsonObject = try? JSONSerialization.jsonObject(with: data, options: []) as? NSDictionary ?? [:]
  103. if jsonObject != nil {
  104. let code: Int = jsonObject!["code"] as? Int ?? 0
  105. let result_bool: Bool = jsonObject!["result"] as? Bool ?? false
  106. let message: String = jsonObject!["msg"] as? String ?? ""
  107. let result = KMMemberCenterResult(code: code, msg: message, result: result_bool)
  108. if code == 200 {
  109. complete(true, result)
  110. } else {
  111. complete(false, result)
  112. }
  113. } else {
  114. complete(false, KMMemberCenterResult(code: 0, msg: "unknown error", result: false))
  115. }
  116. }
  117. task.resume()
  118. // let urlString = configuration.activityBaseURL() + "/member-system-sso/auth/memberResetPassword"
  119. // let params: [String: Any] = ["email": email,
  120. // "verifyCode": verifyCode,
  121. // "appId": "1",
  122. // "password": password]
  123. // KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: params) { requestSerializer in
  124. //
  125. // } completion: { [weak self] (task, responseObject, error) in
  126. // var dic: NSDictionary = [:]
  127. // if error == nil, let responseObject = responseObject as? NSDictionary {
  128. // dic = responseObject
  129. // } else {
  130. // var info = responseObject
  131. // if let error = error {
  132. // if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  133. // info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  134. // }
  135. // }
  136. // dic = (info as? NSDictionary) ?? [:]
  137. // }
  138. //
  139. // let code: Int = dic["code"] as? Int ?? 0
  140. // let result_bool: Bool = dic["result"] as? Bool ?? false
  141. // let message: String = dic["msg"] as? String ?? ""
  142. //
  143. // let result = KMMemberCenterResult(code: code, msg: message, result: result_bool)
  144. //// let error = NSError(domain: message, code: code)
  145. // if code == 200 {
  146. // complete(true, result)
  147. // } else {
  148. // complete(false, result)
  149. // }
  150. // }
  151. }
  152. /**
  153. @abstract 验证邮箱(重置密码输入邮箱点击下一步时校验邮箱是否注册)
  154. @param email 邮箱
  155. @param complete 回调
  156. */
  157. func emailVerification(email: String, _ complete: @escaping KMMemberCenterComplete) {
  158. let urlString = String(format: "%@/member-system-sso/auth/validEmail?email=%@", configuration.activityBaseURL(), email)
  159. KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: nil) { requestSerializer in
  160. } completion: { (task, responseObject, error) in
  161. var dic: NSDictionary = [:]
  162. if error == nil, let responseObject = responseObject as? NSDictionary {
  163. dic = responseObject
  164. } else {
  165. var info = responseObject
  166. if let error = error {
  167. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  168. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  169. }
  170. }
  171. dic = (info as? NSDictionary) ?? [:]
  172. }
  173. let code: Int = dic["code"] as? Int ?? 0
  174. let result_bool: Bool = dic["result"] as? Bool ?? false
  175. let message: String = dic["msg"] as? String ?? ""
  176. let result = KMMemberCenterResult(code: code, msg: message, result: result_bool)
  177. if code == 200 {
  178. complete(true, result)
  179. } else {
  180. complete(false, result)
  181. }
  182. }
  183. }
  184. /**
  185. @abstract 获取邮箱验证码
  186. @param action 验证码用途
  187. @param receiver 邮箱号
  188. @param complete 回调
  189. */
  190. func getVerificationCode(action: KMVerificationCodeType, receiver: String, _ complete: @escaping KMMemberCenterComplete) {
  191. let urlString = configuration.activityBaseURL() + "/member-system-sso/auth/getVerifyCode"
  192. var actionType = "member_login"
  193. if action == .reset {
  194. actionType = "member_reset_password"
  195. } else if action == .logout {
  196. actionType = "member_log_off"
  197. }
  198. let params: [String: Any] = ["action": actionType,
  199. "type": 0,
  200. "receiver": receiver,
  201. "appId": "1"]
  202. KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
  203. } completion: { (task, responseObject, error) in
  204. var dic: NSDictionary = [:]
  205. if error == nil, let responseObject = responseObject as? NSDictionary {
  206. dic = responseObject
  207. } else {
  208. var info = responseObject
  209. if let error = error {
  210. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  211. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  212. }
  213. }
  214. dic = (info as? NSDictionary) ?? [:]
  215. }
  216. let code: Int = dic["code"] as? Int ?? 0
  217. let result_bool: Bool = dic["result"] as? Bool ?? false
  218. let message: String = dic["msg"] as? String ?? ""
  219. let result = KMMemberCenterResult(code: code, msg: message, result: result_bool)
  220. if code == 200 {
  221. complete(true, result)
  222. } else {
  223. complete(false, result)
  224. }
  225. }
  226. }
  227. /**
  228. @abstract 实时检查邮件验证码
  229. @param type 验证码用途
  230. @param account 账户
  231. @param code 验证码
  232. @param complete 回调
  233. */
  234. func checkVerificationCode(type: KMVerificationCodeType, account: String, code: String, _ complete: @escaping KMMemberCenterComplete) {
  235. let urlString = configuration.activityBaseURL() + "/member-system-sso/auth/isEmailCodeValid"
  236. var actionType = "member_login"
  237. if type == .reset {
  238. actionType = "member_reset_password"
  239. } else if type == .logout {
  240. actionType = "user_log_off"
  241. }
  242. let params: [String: Any] = ["type": actionType,
  243. "account": account,
  244. "code": code,
  245. "appId": "1"]
  246. KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
  247. } completion: { [weak self] (task, responseObject, error) in
  248. var dic: NSDictionary = [:]
  249. if error == nil, let responseObject = responseObject as? NSDictionary {
  250. dic = responseObject
  251. } else {
  252. var info = responseObject
  253. if let error = error {
  254. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  255. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  256. }
  257. }
  258. dic = (info as? NSDictionary) ?? [:]
  259. }
  260. let code: Int = dic["code"] as? Int ?? 0
  261. let result_bool: Bool = dic["result"] as? Bool ?? false
  262. let message: String = dic["msg"] as? String ?? ""
  263. let result = KMMemberCenterResult(code: code, msg: message, result: result_bool)
  264. if code == 200 {
  265. complete(true, result)
  266. } else {
  267. complete(false, result)
  268. }
  269. }
  270. }
  271. /**
  272. @abstract 邮箱验证码登录 & 密码登录
  273. @param email 邮箱
  274. @param code 验证码/密码
  275. @param type 密码类型(验证码?密码?)
  276. @param complete 回调
  277. */
  278. func emailLogin(email: String, code: String, type: KMSignUpState, _ complete: @escaping KMMemberCenterComplete) {
  279. let urlString = configuration.activityBaseURL() + "/member-system-sso/auth/memberLogin"
  280. let uuid: String = GetHardwareUUID() ?? ""
  281. var params: [String: Any] = [:]
  282. if type == .verificationCode {
  283. params = ["email": email,
  284. "code": code,
  285. "appId": "1",
  286. "deviceSign": uuid,
  287. "deviceName": NSFullUserName(),
  288. "model": "mac"]
  289. } else {
  290. params = ["email": email,
  291. "password": code,
  292. "appId": "1",
  293. "deviceSign": uuid,
  294. "deviceName": NSFullUserName(),
  295. "model": "mac"]
  296. }
  297. KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: params) { requestSerializer in
  298. // requestSerializer.setValue("Apifox/1.0.0 (https://www.apifox.cn)", forHTTPHeaderField: "User-Agent")
  299. } completion: { [weak self] (task, responseObject, error) in
  300. var dic: NSDictionary = [:]
  301. if error == nil, let responseObject = responseObject as? NSDictionary {
  302. dic = responseObject
  303. } else {
  304. var info = responseObject
  305. if let error = error {
  306. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  307. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  308. }
  309. }
  310. dic = (info as? NSDictionary) ?? [:]
  311. }
  312. let code: Int = dic["code"] as? Int ?? 0
  313. let result_dict: NSDictionary = dic["result"] as? NSDictionary ?? [:]
  314. let message: String = dic["msg"] as? String ?? ""
  315. var refresh_token = ""
  316. var access_token = ""
  317. var token_type = ""
  318. var expires_in = ""
  319. var scope = ""
  320. if let token = result_dict["refresh_token"] { refresh_token = token as! String }
  321. if let token = result_dict["access_token"] { access_token = token as! String }
  322. if let token = result_dict["token_type"] { token_type = token as! String }
  323. if let token = result_dict["expires_in"] { expires_in = token as! String }
  324. let loginResult = KMMemberLoginResult(refreshToken: refresh_token, accessToken: access_token, tokenType: token_type, expiresIn: expires_in)
  325. let result = KMMemberCenterResult(loginResult: loginResult)
  326. result.code = code
  327. result.msg = message
  328. // let error = NSError(domain: message, code: code)
  329. if code == 200 {
  330. complete(true, result)
  331. } else {
  332. complete(false, result)
  333. }
  334. }
  335. }
  336. /**
  337. @abstract 获取用户登录设备列表
  338. @param email 邮箱
  339. @param complete 回调
  340. */
  341. func getUserDeviceList(email: String, _ complete: @escaping KMMemberCenterComplete) {
  342. let urlString = configuration.activityBaseURL() + "/member-system-sso/auth/getLoginDeviceList?email=\(email)&appId=1"
  343. KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: [:]) { requestSerializer in
  344. } completion: { [weak self] (task, responseObject, error) in
  345. var dic: NSDictionary = [:]
  346. if error == nil, let responseObject = responseObject as? NSDictionary {
  347. dic = responseObject
  348. } else {
  349. var info = responseObject
  350. if let error = error {
  351. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  352. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  353. }
  354. }
  355. dic = (info as? NSDictionary) ?? [:]
  356. }
  357. let code: Int = dic["code"] as? Int ?? 0
  358. let result_dict: Dictionary = dic["result"] as? Dictionary ?? [:]
  359. let message: String = dic["msg"] as? String ?? ""
  360. let deviceList: [Dictionary] = result_dict["deviceList"] as? [Dictionary] ?? [[:]]
  361. var deviceLists: [KMMemberDeviceList] = []
  362. for dict in deviceList {
  363. var device_id = ""
  364. var productId = ""
  365. var uniqueSn = ""
  366. var deviceName = ""
  367. var id = ""
  368. if let token = dict["device_id"] {
  369. device_id = token as? String ?? ""
  370. }
  371. if let token = dict["productId"] {
  372. productId = token as? String ?? ""
  373. }
  374. if let token = dict["uniqueSn"] {
  375. uniqueSn = token as? String ?? ""
  376. }
  377. if let token = dict["deviceName"] {
  378. deviceName = token as? String ?? ""
  379. }
  380. if let token = dict["id"] {
  381. id = token as? String ?? ""
  382. }
  383. let list = KMMemberDeviceList(deviceId: device_id, productId: productId, uniqueSn: uniqueSn, appId: "", deviceName: deviceName)
  384. list.id = id
  385. deviceLists.append(list)
  386. }
  387. var maxDeviceNum = 0
  388. if let token = result_dict["maxDeviceNum"] {
  389. maxDeviceNum = token as! Int
  390. }
  391. let result = KMMemberCenterResult(deviceListResult: deviceLists, maxDeviceNum: maxDeviceNum)
  392. if code == 200 {
  393. complete(true, result)
  394. } else {
  395. complete(false, result)
  396. }
  397. }
  398. }
  399. /**
  400. @abstract 登出用户的指定设备
  401. @param deviceId 设备记录ID
  402. @param complete 回调
  403. */
  404. func logoutDevice(deviceId: String, complete: @escaping KMMemberCenterComplete) {
  405. let urlString = configuration.activityBaseURL() + "/member-system-sso/auth/logoutDevice?deviceId=\(deviceId)"
  406. KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: [:]) { requestSerializer in
  407. } completion: { [weak self] (task, responseObject, error) in
  408. var dic: NSDictionary = [:]
  409. if error == nil, let responseObject = responseObject as? NSDictionary {
  410. dic = responseObject
  411. } else {
  412. var info = responseObject
  413. if let error = error {
  414. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  415. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  416. }
  417. }
  418. dic = (info as? NSDictionary) ?? [:]
  419. }
  420. let code: Int = dic["code"] as? Int ?? 0
  421. let resultStr: String = dic["result"] as? String ?? ""
  422. let message: String = dic["msg"] as? String ?? ""
  423. let result = KMMemberCenterResult(code: code, msg: message, resultStr: resultStr)
  424. if code == 200 {
  425. complete(true, result)
  426. } else {
  427. complete(false, result)
  428. }
  429. }
  430. }
  431. // MARK: 个人信息模块
  432. /**
  433. @abstract 获取老带新已邀请人数
  434. @param complete 回调
  435. */
  436. func getInviteNum(_ complete: @escaping KMMemberCenterComplete) {
  437. let token: String = KMMemberInfo.shared.access_token
  438. if token == "" {
  439. complete(false, nil)
  440. return
  441. }
  442. let urlString = configuration.activityBaseURL() + "/member-system-sso/user/getInviteNum"
  443. KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: nil) { requestSerializer in
  444. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  445. } completion: { [weak self] (task, responseObject, error) in
  446. var dic: NSDictionary = [:]
  447. if error == nil, let responseObject = responseObject as? NSDictionary {
  448. dic = responseObject
  449. } else {
  450. var info = responseObject
  451. if let error = error {
  452. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  453. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  454. }
  455. }
  456. dic = (info as? NSDictionary) ?? [:]
  457. }
  458. let code: Int = dic["code"] as? Int ?? 0
  459. let resultInt: Int = dic["result"] as? Int ?? 0
  460. let message: String = dic["msg"] as? String ?? ""
  461. let result = KMMemberCenterResult(code: code, msg: message, resultInt: resultInt)
  462. if code == 200 {
  463. complete(true, result)
  464. } else {
  465. complete(false, result)
  466. }
  467. }
  468. }
  469. /**
  470. @abstract 获取用户个人信息
  471. @param complete 回调
  472. */
  473. func userInfo(_ complete: @escaping KMMemberCenterComplete) {
  474. let token: String = KMMemberInfo.shared.access_token
  475. if token == "" {
  476. complete(false, nil)
  477. return
  478. }
  479. let urlString = configuration.activityBaseURL() + "/member-system-sso/user/info"
  480. KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: nil) { requestSerializer in
  481. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  482. } completion: { [weak self] (task, responseObject, error) in
  483. var dic: NSDictionary = [:]
  484. if error == nil, let responseObject = responseObject as? NSDictionary {
  485. dic = responseObject
  486. } else {
  487. var info = responseObject
  488. if let error = error {
  489. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  490. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  491. }
  492. }
  493. dic = (info as? NSDictionary) ?? [:]
  494. }
  495. let code: Int = dic["code"] as? Int ?? 0
  496. let result_dict: NSDictionary = dic["result"] as? NSDictionary ?? [:]
  497. let message: String = dic["msg"] as? String ?? ""
  498. var userId = ""
  499. var email = ""
  500. var fullName = ""
  501. var activeVIP = KMMemberUserInfo()
  502. var aiPoint = 0
  503. var validFlag = ""
  504. var isHaveAIDiscount = ""
  505. var canTrail = ""
  506. if let token = result_dict["id"] { userId = token as! String }
  507. if let token = result_dict["email"] { email = token as! String }
  508. if let token = result_dict["fullName"] { fullName = token as! String }
  509. let activeVIP_dict: NSDictionary = result_dict["activeVIP"] as? NSDictionary ?? [:]
  510. var activeVIP_id = ""
  511. var activeVIP_userId = ""
  512. var activeVIP_status = 0
  513. var activeVIP_endDate = ""
  514. var activeVIP_payType = 0
  515. var activeVIP_productName = ""
  516. var activeVIP_levels = ""
  517. var activeVIP_platforms = ""
  518. var activeVIP_point = 0
  519. var activeVIP_maxDeviceNum = 0
  520. var activeVIP_paymentModel = ""
  521. var activeVIP_isAi = ""
  522. var activeVIP_cycle = 0
  523. if let token = activeVIP_dict["id"] as? String { activeVIP_id = token }
  524. if let token = activeVIP_dict["userId"] as? String { activeVIP_userId = token }
  525. if let token = activeVIP_dict["status"] as? Int { activeVIP_status = token }
  526. if let token = activeVIP_dict["endDate"] as? String { activeVIP_endDate = token }
  527. if let token = activeVIP_dict["payType"] as? Int { activeVIP_payType = token }
  528. if let token = activeVIP_dict["productName"] as? String { activeVIP_productName = token }
  529. if let token = activeVIP_dict["levels"] as? String { activeVIP_levels = token }
  530. if let token = activeVIP_dict["platforms"] as? String { activeVIP_platforms = token }
  531. if let token = activeVIP_dict["point"] as? Int { activeVIP_point = token }
  532. if let token = activeVIP_dict["maxDeviceNum"] as? Int { activeVIP_maxDeviceNum = token }
  533. if let token = activeVIP_dict["paymentModel"] as? String { activeVIP_paymentModel = token }
  534. if let token = activeVIP_dict["isAi"] as? String { activeVIP_isAi = token }
  535. if let token = activeVIP_dict["cycle"] as? Int { activeVIP_cycle = token }
  536. let userInfoActiveVIP = KMMemberUserInfoActiveVIP(id: activeVIP_id, userId: activeVIP_userId, status: activeVIP_status, endDate: activeVIP_endDate, payType: activeVIP_payType, productName: activeVIP_productName, levels: activeVIP_levels, platforms: activeVIP_platforms, point: activeVIP_point, maxDeviceNum: activeVIP_maxDeviceNum, paymentModel: activeVIP_paymentModel, isAi: activeVIP_isAi, cycle: activeVIP_cycle)
  537. let activeAI_dict: NSDictionary = result_dict["activeAI"] as? NSDictionary ?? [:]
  538. var activeAI_id = ""
  539. var activeAI_userId = ""
  540. var activeAI_status = 0
  541. var activeAI_endDate = ""
  542. var activeAI_payType = 0
  543. var activeAI_productName = ""
  544. var activeAI_levels = ""
  545. var activeAI_platforms = ""
  546. var activeAI_point = 0
  547. var activeAI_maxDeviceNum = 0
  548. var activeAI_paymentModel = ""
  549. var activeAI_isAi = ""
  550. var activeAI_cycle = 0
  551. if let token = activeAI_dict["id"] as? String { activeAI_id = token }
  552. if let token = activeAI_dict["userId"] as? String { activeAI_userId = token }
  553. if let token = activeAI_dict["status"] as? Int { activeAI_status = token }
  554. if let token = activeAI_dict["endDate"] as? String { activeAI_endDate = token }
  555. if let token = activeAI_dict["payType"] as? Int { activeAI_payType = token }
  556. if let token = activeAI_dict["productName"] as? String { activeAI_productName = token }
  557. if let token = activeAI_dict["levels"] as? String { activeAI_levels = token }
  558. if let token = activeAI_dict["platforms"] as? String { activeAI_platforms = token }
  559. if let token = activeAI_dict["point"] as? Int { activeAI_point = token }
  560. if let token = activeAI_dict["maxDeviceNum"] as? Int { activeAI_maxDeviceNum = token }
  561. if let token = activeAI_dict["paymentModel"] as? String { activeAI_paymentModel = token }
  562. if let token = activeAI_dict["isAi"] as? String { activeAI_isAi = token }
  563. if let token = activeAI_dict["cycle"] as? Int { activeAI_cycle = token }
  564. let userInfoActiveAI = KMMemberUserInfoActiveVIP(id: activeAI_id, userId: activeAI_userId, status: activeAI_status, endDate: activeAI_endDate, payType: activeAI_payType, productName: activeAI_productName, levels: activeAI_levels, platforms: activeAI_platforms, point: activeAI_point, maxDeviceNum: activeAI_maxDeviceNum, paymentModel: activeAI_paymentModel, isAi: activeAI_isAi, cycle: activeAI_cycle)
  565. if let token = result_dict["aiPoint"] { aiPoint = token as! Int }
  566. if let token = result_dict["validFlag"] { validFlag = token as! String }
  567. if let token = result_dict["isHaveAIDiscount"] { isHaveAIDiscount = token as! String }
  568. if let token = result_dict["canTrail"] { canTrail = token as! String }
  569. let userInfo = KMMemberUserInfo(id: userId, email: email, fullName: fullName, activeVIP: [userInfoActiveVIP], activeAI: [userInfoActiveAI], aiPoint: aiPoint, validFlag: validFlag, isHaveAIDiscount: isHaveAIDiscount, canTrail: canTrail)
  570. let result = KMMemberCenterResult(code: code, msg: message, userInfo: userInfo)
  571. if code == 200 {
  572. complete(true, result)
  573. } else {
  574. complete(false, result)
  575. }
  576. }
  577. }
  578. /**
  579. @abstract 退出登录
  580. @param complete 回调
  581. */
  582. func userLogout(_ complete: @escaping KMMemberCenterComplete) {
  583. let token: String = KMMemberInfo.shared.access_token
  584. if token == "" {
  585. complete(false, nil)
  586. return
  587. }
  588. let uuid: String = GetHardwareUUID() ?? ""
  589. let urlString = String(format: "%@/member-system-sso/user/logout?deviceSign=%@&appId=1", configuration.activityBaseURL(),uuid)
  590. KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: nil) { requestSerializer in
  591. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  592. } completion: { [weak self] (task, responseObject, error) in
  593. var dic: NSDictionary = [:]
  594. if error == nil, let responseObject = responseObject as? NSDictionary {
  595. dic = responseObject
  596. } else {
  597. var info = responseObject
  598. if let error = error {
  599. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  600. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  601. }
  602. }
  603. dic = (info as? NSDictionary) ?? [:]
  604. }
  605. let code: Int = dic["code"] as? Int ?? 0
  606. let result_bool: Bool = dic["result"] as? Bool ?? false
  607. let message: String = dic["msg"] as? String ?? ""
  608. let result = KMMemberCenterResult(code: code, msg: message, result: result_bool)
  609. if code == 200 {
  610. complete(true, result)
  611. } else {
  612. complete(false, result)
  613. }
  614. }
  615. }
  616. /**
  617. @abstract 获取用户当前会员情况
  618. @param complete 回调
  619. */
  620. func userRightList(_ complete: @escaping KMMemberCenterComplete) {
  621. let token: String = KMMemberInfo.shared.access_token
  622. if token == "" {
  623. complete(false, nil)
  624. return
  625. }
  626. let urlString = configuration.activityBaseURL() + "/member-system-sso//user/rightList"
  627. KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: nil) { requestSerializer in
  628. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  629. } completion: { [weak self] (task, responseObject, error) in
  630. var dic: NSDictionary = [:]
  631. if error == nil, let responseObject = responseObject as? NSDictionary {
  632. dic = responseObject
  633. } else {
  634. var info = responseObject
  635. if let error = error {
  636. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  637. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  638. }
  639. }
  640. dic = (info as? NSDictionary) ?? [:]
  641. }
  642. let code: Int = dic["code"] as? Int ?? 0
  643. let result_Array: [NSDictionary] = dic["result"] as? [NSDictionary] ?? [[:]]
  644. let message: String = dic["msg"] as? String ?? ""
  645. var results: [KMMemberUserInfoActiveVIP] = []
  646. for dict1 in result_Array {
  647. var activeVIP_id = ""
  648. var activeVIP_userId = ""
  649. var activeVIP_status = 0
  650. var activeVIP_endDate = ""
  651. var activeVIP_payType = 0
  652. var activeVIP_productName = ""
  653. var activeVIP_levels = ""
  654. var activeVIP_platforms = ""
  655. var activeVIP_point = 0
  656. var activeVIP_maxDeviceNum = 0
  657. var activeVIP_paymentModel = ""
  658. var activeVIP_isAi = ""
  659. if let token = dict1["id"] { activeVIP_id = token as! String }
  660. if let token = dict1["userId"] { activeVIP_userId = token as! String }
  661. if let token = dict1["status"] { activeVIP_status = token as! Int }
  662. if let token = dict1["endDate"] { activeVIP_endDate = token as! String }
  663. if let token = dict1["payType"] { activeVIP_payType = token as! Int }
  664. if let token = dict1["productName"] { activeVIP_productName = token as! String }
  665. if let token = dict1["levels"] { activeVIP_levels = token as! String }
  666. if let token = dict1["platforms"] { activeVIP_platforms = token as! String }
  667. if let token = dict1["point"] { activeVIP_point = token as! Int }
  668. if let token = dict1["maxDeviceNum"] { activeVIP_maxDeviceNum = token as! Int }
  669. if let token = dict1["paymentModel"] { activeVIP_paymentModel = token as! String }
  670. if let token = dict1["isAi"] { activeVIP_isAi = token as! String }
  671. let userInfoActiveVIP = KMMemberUserInfoActiveVIP(id: activeVIP_id, userId: activeVIP_userId, status: activeVIP_status, endDate: activeVIP_endDate, payType: activeVIP_payType, productName: activeVIP_productName, levels: activeVIP_levels, platforms: activeVIP_platforms, point: activeVIP_point, maxDeviceNum: activeVIP_maxDeviceNum, paymentModel: activeVIP_paymentModel, isAi: activeVIP_isAi)
  672. results.append(userInfoActiveVIP)
  673. }
  674. let result = KMMemberCenterResult(code: code, msg: message, activeVIPs: results)
  675. if code == 200 {
  676. complete(true, result)
  677. } else {
  678. complete(false, result)
  679. }
  680. }
  681. }
  682. /**
  683. @abstract 用户手动注销
  684. @param code 邮箱验证码
  685. @param complete 回调
  686. */
  687. func userLogOffForUser(code: String, _ complete: @escaping KMMemberCenterComplete) {
  688. let token: String = KMMemberInfo.shared.access_token
  689. if token == "" {
  690. complete(false, nil)
  691. return
  692. }
  693. let urlString = String(format: "%@/member-system-sso/user/logOffForUser?code=%@&appId=1", configuration.activityBaseURL(), code)
  694. KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: nil) { requestSerializer in
  695. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  696. } completion: { [weak self] (task, responseObject, error) in
  697. var dic: NSDictionary = [:]
  698. if error == nil, let responseObject = responseObject as? NSDictionary {
  699. dic = responseObject
  700. } else {
  701. var info = responseObject
  702. if let error = error {
  703. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  704. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  705. }
  706. }
  707. dic = (info as? NSDictionary) ?? [:]
  708. }
  709. let code: Int = dic["code"] as? Int ?? 0
  710. let message: String = dic["msg"] as? String ?? ""
  711. let result_dict: NSDictionary = dic["result"] as? NSDictionary ?? [:]
  712. var currentTime = ""
  713. var logOffTime = ""
  714. if let token = result_dict["currentTime"] { currentTime = token as! String }
  715. if let token = result_dict["logOffTime"] { logOffTime = token as! String }
  716. let logOff = KMMemberLogOff(currentTime: currentTime, logOffTime: logOffTime)
  717. let result = KMMemberCenterResult(code: code, msg: message, logOff: logOff)
  718. if code == 200 {
  719. complete(true, result)
  720. } else {
  721. complete(false, result)
  722. }
  723. }
  724. }
  725. /**
  726. @abstract 撤销注销申请
  727. @param complete 回调
  728. */
  729. func userRevokeCancel(_ complete: @escaping KMMemberCenterComplete) {
  730. let token: String = KMMemberInfo.shared.access_token
  731. if token == "" {
  732. complete(false, nil)
  733. return
  734. }
  735. let urlString = configuration.activityBaseURL() + "/member-system-sso/user/revokeCancel"
  736. KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: nil) { requestSerializer in
  737. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  738. } completion: { [weak self] (task, responseObject, error) in
  739. var dic: NSDictionary = [:]
  740. if error == nil, let responseObject = responseObject as? NSDictionary {
  741. dic = responseObject
  742. } else {
  743. var info = responseObject
  744. if let error = error {
  745. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  746. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  747. }
  748. }
  749. dic = (info as? NSDictionary) ?? [:]
  750. }
  751. let code: Int = dic["code"] as? Int ?? 0
  752. let message: String = dic["msg"] as? String ?? ""
  753. let result_Bool: Bool = dic["result"] as? Bool ?? false
  754. let result = KMMemberCenterResult(code: code, msg: message, result: result_Bool)
  755. if code == 200 {
  756. complete(true, result)
  757. } else {
  758. complete(false, result)
  759. }
  760. }
  761. }
  762. // MARK: 商品模块
  763. /**
  764. @abstract 获取上架中的产品
  765. @param isEducation 是否教育优惠
  766. @param complete 回调
  767. */
  768. func getListingProducts(isEducation: Int, _ complete: @escaping KMMemberProductComplete) {
  769. let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/getListingProducts"
  770. var platformId = "2"
  771. #if VERSION_FREE
  772. #if VERSION_DMG
  773. // DMG
  774. platformId = "2"
  775. #else
  776. // AppStore 免费版本
  777. #endif
  778. #else
  779. // AppStore 付费版
  780. platformId = "5"
  781. #endif
  782. let params: [String: Any] = ["isEducation": NSNumber(value: Int32(isEducation)),
  783. "platformId": platformId]
  784. if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
  785. KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
  786. } completion: { [weak self] (task, responseObject, error) in
  787. var dic: NSDictionary = [:]
  788. if error == nil, let responseObject = responseObject as? NSDictionary {
  789. dic = responseObject
  790. } else {
  791. var info = responseObject
  792. if let error = error {
  793. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  794. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  795. }
  796. }
  797. dic = (info as? NSDictionary) ?? [:]
  798. }
  799. let code: Int = dic["code"] as? Int ?? 0
  800. let result_Array: [NSDictionary] = dic["result"] as? [NSDictionary] ?? [[:]]
  801. let message: String = dic["msg"] as? String ?? ""
  802. var results: [KMListingProductsModel] = []
  803. for dict1 in result_Array {
  804. var id = ""
  805. var productName = ""
  806. var price = NSNumber(value: 0.0)
  807. var maxDeviceNum = 0
  808. var levels = ""
  809. var platforms = ""
  810. var productLineId = 0
  811. var paymentModel = 0
  812. var cycle = 0
  813. var code = ""
  814. var cnyPrice = NSNumber(value: 0.0)
  815. if let token = dict1["id"] { id = token as? String ?? id }
  816. if let token = dict1["productName"] { productName = token as? String ?? productName }
  817. if let token = dict1["price"] { price = token as? NSNumber ?? price }
  818. if let token = dict1["maxDeviceNum"] { maxDeviceNum = token as? Int ?? maxDeviceNum }
  819. if let token = dict1["levels"] { levels = token as? String ?? levels }
  820. if let token = dict1["platforms"] { platforms = token as? String ?? platforms }
  821. if let token = dict1["productLineId"] { productLineId = token as? Int ?? productLineId }
  822. if let token = dict1["paymentModel"] { paymentModel = token as? Int ?? paymentModel }
  823. if let token = dict1["cycle"] { cycle = token as? Int ?? cycle }
  824. if let token = dict1["code"] { code = token as? String ?? code }
  825. if let token = dict1["cnyPrice"] { cnyPrice = token as? NSNumber ?? cnyPrice }
  826. let products = KMListingProductsModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, code: code, cnyPrice: cnyPrice)
  827. results.append(products)
  828. }
  829. let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
  830. if code == 200 {
  831. complete(true, result)
  832. } else {
  833. complete(false, result)
  834. }
  835. }
  836. } else {
  837. print("Invalid URL")
  838. complete(false, nil)
  839. }
  840. }
  841. /**
  842. @abstract 获取已登录用户购买商品价格
  843. @param productId 购买的产品id
  844. @param isEducation 是否教育优惠
  845. @param complete 回调
  846. */
  847. func getProductPriceForBuy(productId: String, isEducation: Int, userId: String, _ complete: @escaping KMMemberProductComplete) {
  848. let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/getProductPriceForBuy"
  849. let params: [String: Any] = ["productId": productId,
  850. "isEducation": isEducation,
  851. "userId": userId]
  852. if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
  853. KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
  854. } completion: { [weak self] (task, responseObject, error) in
  855. var dic: NSDictionary = [:]
  856. if error == nil, let responseObject = responseObject as? NSDictionary {
  857. dic = responseObject
  858. } else {
  859. var info = responseObject
  860. if let error = error {
  861. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  862. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  863. }
  864. }
  865. dic = (info as? NSDictionary) ?? [:]
  866. }
  867. let code: Int = dic["code"] as? Int ?? 0
  868. let result_Array: [NSDictionary] = [dic["result"]] as? [NSDictionary] ?? [[:]]
  869. let message: String = dic["msg"] as? String ?? ""
  870. var results: [KMListingProductsModel] = []
  871. for dict1 in result_Array {
  872. var id = ""
  873. var productName = ""
  874. var price = NSNumber(value: 0.0)
  875. var maxDeviceNum = 0
  876. var levels = ""
  877. var platforms = ""
  878. var productLineId = 0
  879. var paymentModel = 0
  880. var cycle = 0
  881. var code = ""
  882. var cnyPrice = NSNumber(value: 0.0)
  883. if let token = dict1["id"] { id = token as! String }
  884. if let token = dict1["productName"] { productName = token as! String }
  885. if let token = dict1["price"] { price = token as! NSNumber }
  886. if let token = dict1["maxDeviceNum"] { maxDeviceNum = token as! Int }
  887. if let token = dict1["levels"] { levels = token as! String }
  888. if let token = dict1["platforms"] { platforms = token as! String }
  889. if let token = dict1["productLineId"] { productLineId = token as! Int }
  890. if let token = dict1["paymentModel"] { paymentModel = token as! Int }
  891. if let token = dict1["cycle"] { cycle = token as! Int }
  892. if let token = dict1["code"] { code = token as! String }
  893. if let token = dict1["cnyPrice"] { cnyPrice = token as! NSNumber }
  894. let products = KMListingProductsModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, code: code, cnyPrice: cnyPrice)
  895. results.append(products)
  896. }
  897. let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
  898. if code == 200 {
  899. complete(true, result)
  900. } else {
  901. complete(false, result)
  902. }
  903. }
  904. } else {
  905. print("Invalid URL")
  906. complete(false, nil)
  907. }
  908. }
  909. /**
  910. @abstract 获取批量阶段购买价格
  911. @param productId 购买的产品id
  912. @param num 批量个数
  913. @param complete 回调
  914. */
  915. func getBatchProductPrice(productId: String, num: Int, _ complete: @escaping KMMemberProductComplete) {
  916. let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/getBatchProductPrice"
  917. let params: [String: Any] = ["productId": productId,
  918. "num": NSNumber(value: Int32(num))]
  919. if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
  920. KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
  921. } completion: { [weak self] (task, responseObject, error) in
  922. var dic: NSDictionary = [:]
  923. if error == nil, let responseObject = responseObject as? NSDictionary {
  924. dic = responseObject
  925. } else {
  926. var info = responseObject
  927. if let error = error {
  928. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  929. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  930. }
  931. }
  932. dic = (info as? NSDictionary) ?? [:]
  933. }
  934. let code: Int = dic["code"] as? Int ?? 0
  935. let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
  936. let message: String = dic["msg"] as? String ?? ""
  937. var productId = ""
  938. var totalPrice = ""
  939. var price = ""
  940. var batchPrice = ""
  941. var cnyPrice = ""
  942. var cnyBatchPrice = ""
  943. var cnyTotalPrice = ""
  944. if let token = result["productId"] { productId = token as! String }
  945. if let token = result["totalPrice"] { totalPrice = token as! String }
  946. if let token = result["price"] { price = token as! String }
  947. if let token = result["batchPrice"] { batchPrice = token as! String }
  948. if let token = result["cnyPrice"] { cnyPrice = token as! String }
  949. if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as! String }
  950. if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as! String }
  951. let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
  952. let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
  953. if code == 200 {
  954. complete(true, result1)
  955. } else {
  956. complete(false, result1)
  957. }
  958. }
  959. } else {
  960. print("Invalid URL")
  961. }
  962. }
  963. /**
  964. @abstract 验证商品优惠券,返回商品优惠后价格
  965. @param productId 购买的产品id
  966. @param userId 用户ID
  967. @param code 优惠券
  968. @param complete 回调
  969. */
  970. func checkCoupon(productId: String, userId: String, code: String, _ complete: @escaping KMMemberProductComplete) {
  971. let token: String = KMMemberInfo.shared.access_token
  972. if token == "" {
  973. complete(false, nil)
  974. return
  975. }
  976. let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/checkCoupon"
  977. let params: [String: Any] = ["productId": productId,
  978. "userId": userId,
  979. "code": code]
  980. if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
  981. KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
  982. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  983. } completion: { [weak self] (task, responseObject, error) in
  984. var dic: NSDictionary = [:]
  985. if error == nil, let responseObject = responseObject as? NSDictionary {
  986. dic = responseObject
  987. } else {
  988. var info = responseObject
  989. if let error = error {
  990. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  991. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  992. }
  993. }
  994. dic = (info as? NSDictionary) ?? [:]
  995. }
  996. let code: Int = dic["code"] as? Int ?? 0
  997. let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
  998. let message: String = dic["msg"] as? String ?? ""
  999. var id = ""
  1000. var productName = ""
  1001. var price = ""
  1002. var maxDeviceNum = 0
  1003. var displayPrice = ""
  1004. var levels = ""
  1005. var platforms = ""
  1006. var productLineId = 0
  1007. var paymentModel = 0
  1008. var cycle = 0
  1009. var cnyPrice = ""
  1010. var displayCnyPrice = ""
  1011. if let token = result["id"] { id = token as! String }
  1012. if let token = result["productName"] { productName = token as! String }
  1013. if let token = result["price"] { price = token as! String }
  1014. if let token = result["maxDeviceNum"] { maxDeviceNum = token as! Int }
  1015. if let token = result["displayPrice"] { displayPrice = token as! String }
  1016. if let token = result["levels"] { levels = token as! String }
  1017. if let token = result["platforms"] { platforms = token as! String }
  1018. if let token = result["productLineId"] { productLineId = token as! Int }
  1019. if let token = result["paymentModel"] { paymentModel = token as! Int }
  1020. if let token = result["cycle"] { cycle = token as! Int }
  1021. if let token = result["cnyPrice"] { cnyPrice = token as! String }
  1022. if let token = result["displayCnyPrice"] { displayCnyPrice = token as! String }
  1023. let products = KMCheckCouponModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, displayPrice: displayPrice, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, cnyPrice: cnyPrice, displayCnyPrice: displayCnyPrice)
  1024. let result1 = KMMemberProductResult(code: code, msg: message, checkCoupon: products)
  1025. if code == 200 {
  1026. complete(true, result1)
  1027. } else {
  1028. complete(false, result1)
  1029. }
  1030. }
  1031. } else {
  1032. print("Invalid URL")
  1033. complete(false, nil)
  1034. }
  1035. }
  1036. /**
  1037. @abstract 检查邮箱教育优惠资格
  1038. @param email 邮箱
  1039. @param complete 回调
  1040. */
  1041. func checkEducation(email: String, _ complete: @escaping KMMemberProductComplete) {
  1042. let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/checkEducation"
  1043. let params: [String: Any] = ["email": email]
  1044. if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
  1045. KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
  1046. } completion: { [weak self] (task, responseObject, error) in
  1047. var dic: NSDictionary = [:]
  1048. if error == nil, let responseObject = responseObject as? NSDictionary {
  1049. dic = responseObject
  1050. } else {
  1051. var info = responseObject
  1052. if let error = error {
  1053. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  1054. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  1055. }
  1056. }
  1057. dic = (info as? NSDictionary) ?? [:]
  1058. }
  1059. let code: Int = dic["code"] as? Int ?? 0
  1060. let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
  1061. let message: String = dic["msg"] as? String ?? ""
  1062. var productId = ""
  1063. var totalPrice = ""
  1064. var price = ""
  1065. var batchPrice = ""
  1066. var cnyPrice = ""
  1067. var cnyBatchPrice = ""
  1068. var cnyTotalPrice = ""
  1069. if let token = result["productId"] { productId = token as! String }
  1070. if let token = result["totalPrice"] { totalPrice = token as! String }
  1071. if let token = result["price"] { price = token as! String }
  1072. if let token = result["batchPrice"] { batchPrice = token as! String }
  1073. if let token = result["cnyPrice"] { cnyPrice = token as! String }
  1074. if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as! String }
  1075. if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as! String }
  1076. let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
  1077. let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
  1078. if code == 200 {
  1079. complete(true, result1)
  1080. } else {
  1081. complete(false, result1)
  1082. }
  1083. }
  1084. } else {
  1085. print("Invalid URL")
  1086. complete(false, nil)
  1087. }
  1088. }
  1089. // MARK: 个人中心模块
  1090. // MARK: 订单模块
  1091. /**
  1092. @abstract 支付后查询订单状态
  1093. @param orderId 订单id
  1094. @param complete 回调
  1095. */
  1096. func getStateByOrderId(orderId: String, _ complete: @escaping KMMemberRequestInfoComplete) {
  1097. let token: String = KMMemberInfo.shared.access_token
  1098. if token == "" {
  1099. complete(false, nil)
  1100. return
  1101. }
  1102. let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/getStateByOrderId"
  1103. let params: [String: Any] = ["orderId": orderId]
  1104. if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
  1105. KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
  1106. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  1107. } completion: { [weak self] (task, responseObject, error) in
  1108. var dic: NSDictionary = [:]
  1109. if error == nil, let responseObject = responseObject as? NSDictionary {
  1110. dic = responseObject
  1111. } else {
  1112. var info = responseObject
  1113. if let error = error {
  1114. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  1115. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  1116. }
  1117. }
  1118. dic = (info as? NSDictionary) ?? [:]
  1119. }
  1120. let code: Int = dic["code"] as? Int ?? 0
  1121. if code == 200 {
  1122. complete(true, dic)
  1123. } else {
  1124. complete(false, dic)
  1125. }
  1126. }
  1127. } else {
  1128. print("Invalid URL")
  1129. complete(false, nil)
  1130. }
  1131. }
  1132. /**
  1133. @abstract 创建订单(买断)
  1134. @param productId 产品id
  1135. @param paymentMethod 支付方式 PAYPAL(0),ALIPAY(1),WXPAY(2),PADDLE(3)
  1136. @param price 价格
  1137. @param discountFlag 0原价,1优惠券,2升级,3教育优惠,4批量购买,5黑五折扣
  1138. @param couponCode 优惠卷
  1139. @param num 批量购买数量
  1140. @param complete 回调
  1141. */
  1142. func createOrder(productId: String, paymentMethod: Int, price: NSNumber, discountFlag: Int, couponCode: String, num: Int, _ complete: @escaping KMMemberProductComplete) {
  1143. let token: String = KMMemberInfo.shared.access_token
  1144. if token == "" {
  1145. complete(false, nil)
  1146. return
  1147. }
  1148. let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/createOrder"
  1149. let params: [String: Any] = ["productId": productId,
  1150. "paymentMethod": paymentMethod,
  1151. "price": price,
  1152. "discountFlag": discountFlag,
  1153. "couponCode": couponCode,
  1154. "num": num]
  1155. KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: params) { requestSerializer in
  1156. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  1157. } completion: { [weak self] (task, responseObject, error) in
  1158. var dic: NSDictionary = [:]
  1159. if error == nil, let responseObject = responseObject as? NSDictionary {
  1160. dic = responseObject
  1161. } else {
  1162. var info = responseObject
  1163. if let error = error {
  1164. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  1165. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  1166. }
  1167. }
  1168. dic = (info as? NSDictionary) ?? [:]
  1169. }
  1170. let code: Int = dic["code"] as? Int ?? 0
  1171. let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
  1172. let message: String = dic["msg"] as? String ?? ""
  1173. var thirdOrderNo = ""
  1174. var orderId = ""
  1175. var payHref = ""
  1176. if code == 200 {
  1177. if let token = result["thirdOrderNo"] { thirdOrderNo = token as! String }
  1178. if let token = result["orderId"] { orderId = token as! String }
  1179. if let token = result["payHref"] { payHref = token as! String }
  1180. let products = KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref)
  1181. let result1 = KMMemberProductResult(code: code, msg: message, createOrder: products)
  1182. complete(true, result1)
  1183. } else {
  1184. let result1 = KMMemberProductResult(code: code, msg: message, createOrder: KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref))
  1185. complete(false, result1)
  1186. }
  1187. }
  1188. }
  1189. /**
  1190. @abstract 创建订单(订阅)
  1191. @param productId 产品id
  1192. @param paymentMethod 支付方式 PAYPAL(0),ALIPAY(1),WXPAY(2),PADDLE(3)
  1193. @param price 价格
  1194. @param discountFlag 0原价,1优惠券,2升级,3教育优惠,4批量购买,5黑五折扣
  1195. @param couponCode 优惠卷
  1196. @param num 批量购买数量
  1197. @param complete 回调
  1198. */
  1199. func createSubscriber(productId: String, paymentMethod: Int, price: NSNumber, discountFlag: Int, couponCode: String, num: Int, _ complete: @escaping KMMemberProductComplete) {
  1200. let token: String = KMMemberInfo.shared.access_token
  1201. if token == "" {
  1202. complete(false, nil)
  1203. return
  1204. }
  1205. let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/createSubscription"
  1206. let params: [String: Any] = ["productId": productId,
  1207. "paymentMethod": paymentMethod,
  1208. "price": price,
  1209. "discountFlag": discountFlag,
  1210. "couponCode": couponCode,
  1211. "num": num]
  1212. KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: params) { requestSerializer in
  1213. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  1214. } completion: { [weak self] (task, responseObject, error) in
  1215. var dic: NSDictionary = [:]
  1216. if error == nil, let responseObject = responseObject as? NSDictionary {
  1217. dic = responseObject
  1218. } else {
  1219. var info = responseObject
  1220. if let error = error {
  1221. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  1222. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  1223. }
  1224. }
  1225. dic = (info as? NSDictionary) ?? [:]
  1226. }
  1227. let code: Int = dic["code"] as? Int ?? 0
  1228. let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
  1229. let message: String = dic["msg"] as? String ?? ""
  1230. var thirdOrderNo = ""
  1231. var orderId = ""
  1232. var payHref = ""
  1233. if code == 200 {
  1234. if let token = result["thirdOrderNo"] { thirdOrderNo = token as! String }
  1235. if let token = result["orderId"] { orderId = token as! String }
  1236. if let token = result["payHref"] { payHref = token as! String }
  1237. let products = KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref)
  1238. let result1 = KMMemberProductResult(code: code, msg: message, createOrder: products)
  1239. complete(true, result1)
  1240. } else {
  1241. let result1 = KMMemberProductResult(code: code, msg: message, createOrder: KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref))
  1242. complete(false, result1)
  1243. }
  1244. }
  1245. }
  1246. /**
  1247. @abstract 获取订单列表
  1248. @param orderStatus 0全部1待支付
  1249. @param complete 回调
  1250. */
  1251. func getOrderListByStatus(orderStatus: Int, _ complete: @escaping KMMemberProductComplete) {
  1252. let token: String = KMMemberInfo.shared.access_token
  1253. if token == "" {
  1254. complete(false, nil)
  1255. return
  1256. }
  1257. let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/getOrderListByStatus"
  1258. let params: [String: Any] = ["orderStatus": orderStatus]
  1259. KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
  1260. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  1261. } completion: { [weak self] (task, responseObject, error) in
  1262. var dic: NSDictionary = [:]
  1263. if error == nil, let responseObject = responseObject as? NSDictionary {
  1264. dic = responseObject
  1265. } else {
  1266. var info = responseObject
  1267. if let error = error {
  1268. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  1269. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  1270. }
  1271. }
  1272. dic = (info as? NSDictionary) ?? [:]
  1273. }
  1274. let code: Int = dic["code"] as? Int ?? 0
  1275. let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
  1276. let message: String = dic["msg"] as? String ?? ""
  1277. // var thirdOrderNo = ""
  1278. // var orderId = ""
  1279. // var payHref = ""
  1280. // if code == 200 {
  1281. // if let token = result["thirdOrderNo"] { thirdOrderNo = token as! String }
  1282. // if let token = result["orderId"] { orderId = token as! String }
  1283. // if let token = result["payHref"] { payHref = token as! String }
  1284. // let products = KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref)
  1285. // let result1 = KMMemberProductResult(code: code, msg: message, createOrder: products)
  1286. // complete(true, result1)
  1287. // } else {
  1288. // let result1 = KMMemberProductResult(code: code, msg: message, createOrder: KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref))
  1289. // complete(false, result1)
  1290. // }
  1291. }
  1292. }
  1293. /**
  1294. @abstract 关闭订单
  1295. @param orderId 订单id
  1296. @param complete 回调
  1297. */
  1298. func closeByOrderId(orderId: String, _ complete: @escaping KMMemberRequestInfoComplete) {
  1299. let token: String = KMMemberInfo.shared.access_token
  1300. if token == "" {
  1301. complete(false, nil)
  1302. return
  1303. }
  1304. let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/closeOrder"
  1305. KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: nil) { requestSerializer in
  1306. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  1307. } completion: { [weak self] (task, responseObject, error) in
  1308. var dic: NSDictionary = [:]
  1309. if error == nil, let responseObject = responseObject as? NSDictionary {
  1310. dic = responseObject
  1311. } else {
  1312. var info = responseObject
  1313. if let error = error {
  1314. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  1315. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  1316. }
  1317. }
  1318. dic = (info as? NSDictionary) ?? [:]
  1319. }
  1320. let code: Int = dic["code"] as? Int ?? 0
  1321. if code == 200 {
  1322. complete(true, dic)
  1323. } else {
  1324. complete(false, dic)
  1325. }
  1326. }
  1327. }
  1328. // MARK: 苹果支付
  1329. /**
  1330. @abstract APPstore 权益校验
  1331. @param orderStatus 0全部1待支付
  1332. @param complete 回调
  1333. */
  1334. func appStoreEquityVerification(orderStatus: Int, _ complete: @escaping KMMemberProductComplete) {
  1335. let token: String = KMMemberInfo.shared.access_token
  1336. if token == "" {
  1337. complete(false, nil)
  1338. return
  1339. }
  1340. let urlString = configuration.activityBaseURL() + "/member-system-website/applePay/appStoreEquityVerification"
  1341. let params: [String: Any] = ["userId": "",
  1342. "applePayProductId": "",
  1343. "transactionId": "",
  1344. "productCode": ""]
  1345. KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
  1346. requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
  1347. } completion: { [weak self] (task, responseObject, error) in
  1348. var dic: NSDictionary = [:]
  1349. if error == nil, let responseObject = responseObject as? NSDictionary {
  1350. dic = responseObject
  1351. } else {
  1352. var info = responseObject
  1353. if let error = error {
  1354. if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
  1355. info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
  1356. }
  1357. }
  1358. dic = (info as? NSDictionary) ?? [:]
  1359. }
  1360. let code: Int = dic["code"] as? Int ?? 0
  1361. let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
  1362. let message: String = dic["msg"] as? String ?? ""
  1363. let result1 = KMMemberProductResult(code: code, msg: message, result: "")
  1364. if code == 200 {
  1365. complete(true, result1)
  1366. } else {
  1367. complete(false, result1)
  1368. }
  1369. }
  1370. }
  1371. // MARK: 评估模块
  1372. // MARK: 活动模块
  1373. // MARK: 翻译模块
  1374. // MARK: AI模块
  1375. // MARK: 会员赠送模块
  1376. // MARK: Error Code
  1377. static func typeOfMessage(type: KMMemberCenterErrorCodeType?) -> String {
  1378. var result: String = ""
  1379. switch type {
  1380. case .EXCEPTION_MSG_TOKEN_IS_INVALID:
  1381. result = "无效的token或者token已过期"
  1382. break;
  1383. case .EXCEPTION_MSG_DEVICE_NUM_MAX:
  1384. result = "您的登录设备已达上限,请退出其他设备重新登录"
  1385. break;
  1386. case .EXCEPTION_MSG_USER_NOT_LOGIN:
  1387. result = "用户没有登录,请登录后再访问"
  1388. break;
  1389. case .EMAIL_VERIFY_CODE_KEY_ERROR:
  1390. result = "email code error!"
  1391. break;
  1392. case .EMAIL_REGISTER_ERROR:
  1393. result = "Register error!"
  1394. break;
  1395. case .EXCEPTION_MSG_PASSWORD_ERROR:
  1396. result = NSLocalizedString("Password error.", tableName: "MemberCenterLocalizable", comment: "")
  1397. break;
  1398. case .EXCEPTION_MSG_CODE_ACTION_ERROR:
  1399. result = "code action error"
  1400. break;
  1401. case .EXCEPTION_MSG_CODE_SEND_ERROR:
  1402. result = "code send error"
  1403. break;
  1404. case .EXCEPTION_MAIL_CODE_SEND_ERROR:
  1405. result = "mail send error"
  1406. break;
  1407. case .VERIFY_CODE_SEND_TOO_QUICKLY:
  1408. result = "code send too quickly"
  1409. break;
  1410. case .EXCEPTION_MSG_EMAIL_EXIST:
  1411. result = "该邮箱已有账号,请前往登录"
  1412. break;
  1413. case .EXCEPTION_MSG_EMAIL_NOT_REGISTER:
  1414. result = NSLocalizedString("This email has not been registered, please log in through the account verification code, we will automatically register an account for you.", tableName: "MemberCenterLocalizable", comment: "")
  1415. break;
  1416. case .EXCEPTION_MSG_EMAIL_LOGOUT_ING:
  1417. result = "注销中,无法登录,若有问题可联系客服"
  1418. break;
  1419. case .EXCEPTION_MSG_EMAIL_INVALID:
  1420. result = NSLocalizedString("Email format error. Please enter the correct email.", tableName: "MemberCenterLocalizable", comment: "")
  1421. break;
  1422. case .EXCEPTION_MSG_PASSWORD_NOT_INCONSISTENT:
  1423. result = "密码不一致,请重新输入"
  1424. break;
  1425. case .EXCEPTION_MSG_PASSWORD_SIZE_MIN:
  1426. result = "密码请包含6~24个字符"
  1427. break;
  1428. case .EXCEPTION_MSG_PASSWORD_SIZE_MAX:
  1429. result = "密码请包含6~24个字符"
  1430. break;
  1431. case .EXCEPTION_MSG_PLEASE_ADD_AUTH_CONFIG:
  1432. result = "please add auth config"
  1433. break;
  1434. case .EXCEPTION_MSG_USER_SUBSCRIPTION_IN_PROGRESS:
  1435. result = "您目前还在订阅期内,暂时无法注销,请订阅期结束后再点击注销账号"
  1436. break;
  1437. case .EXCEPTION_TIME_TRANSFER_ERROR:
  1438. result = "时间转换失败"
  1439. break;
  1440. case .EXCEPTION_MSG_PASSWORD_CONTAIN_EMPTY:
  1441. result = "密码不能包含空格"
  1442. break;
  1443. case .UNKNOWN:
  1444. result = "UNKNOWN"
  1445. break;
  1446. case .SUCCESS:
  1447. result = "SUCCESS"
  1448. break;
  1449. default:
  1450. result = "Network error"
  1451. }
  1452. return result
  1453. }
  1454. }