|
@@ -69,6 +69,22 @@ class KMMemberCenterManager: NSObject {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // MARK: 拼接URL(为Get类型)
|
|
|
|
+ func constructURLString(baseURLString: String, parameters: [String: Any]) -> String? {
|
|
|
|
+ // Ensure the base URL is valid
|
|
|
|
+ guard var components = URLComponents(string: baseURLString) else {
|
|
|
|
+ return nil
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Convert parameters to query items
|
|
|
|
+ components.queryItems = parameters.map { key, value in
|
|
|
|
+ URLQueryItem(name: key, value: "\(value)")
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Return the complete URL as a string
|
|
|
|
+ return components.url?.absoluteString
|
|
|
|
+ }
|
|
|
|
+
|
|
// MARK: 登录模块
|
|
// MARK: 登录模块
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -832,7 +848,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
|
|
|
#if VERSION_DMG
|
|
#if VERSION_DMG
|
|
// DMG
|
|
// DMG
|
|
- platformId = "1"
|
|
|
|
|
|
+ platformId = "2"
|
|
#else
|
|
#else
|
|
// AppStore 免费版本
|
|
// AppStore 免费版本
|
|
#endif
|
|
#endif
|
|
@@ -840,63 +856,68 @@ class KMMemberCenterManager: NSObject {
|
|
// AppStore 付费版
|
|
// AppStore 付费版
|
|
platformId = "5"
|
|
platformId = "5"
|
|
#endif
|
|
#endif
|
|
- let params: [String: Any] = ["isEducation": isEducation,
|
|
|
|
|
|
+ let params: [String: Any] = ["isEducation": NSNumber(value: Int32(isEducation)),
|
|
"platformId": platformId]
|
|
"platformId": platformId]
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
|
|
|
|
-
|
|
|
|
- } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
- var dic: NSDictionary = [:]
|
|
|
|
- if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
- dic = responseObject
|
|
|
|
- } else {
|
|
|
|
- var info = responseObject
|
|
|
|
- if let error = error {
|
|
|
|
- if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
- info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
|
|
+ if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
|
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
|
|
|
|
+
|
|
|
|
+ } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
+ var dic: NSDictionary = [:]
|
|
|
|
+ if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
+ dic = responseObject
|
|
|
|
+ } else {
|
|
|
|
+ var info = responseObject
|
|
|
|
+ if let error = error {
|
|
|
|
+ if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
+ info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ dic = (info as? NSDictionary) ?? [:]
|
|
}
|
|
}
|
|
- dic = (info as? NSDictionary) ?? [:]
|
|
|
|
- }
|
|
|
|
- let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
- let result_Array: [NSDictionary] = dic["result"] as? [NSDictionary] ?? [[:]]
|
|
|
|
- let message: String = dic["msg"] as? String ?? ""
|
|
|
|
-
|
|
|
|
- var results: [KMListingProductsModel] = []
|
|
|
|
- for dict1 in result_Array {
|
|
|
|
- var id = ""
|
|
|
|
- var productName = ""
|
|
|
|
- var price = NSNumber(value: 0.0)
|
|
|
|
- var maxDeviceNum = 0
|
|
|
|
- var levels = ""
|
|
|
|
- var platforms = ""
|
|
|
|
- var productLineId = 0
|
|
|
|
- var paymentModel = 0
|
|
|
|
- var cycle = 0
|
|
|
|
- var code = ""
|
|
|
|
- var cnyPrice = NSNumber(value: 0.0)
|
|
|
|
|
|
+ let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
+ let result_Array: [NSDictionary] = dic["result"] as? [NSDictionary] ?? [[:]]
|
|
|
|
+ let message: String = dic["msg"] as? String ?? ""
|
|
|
|
|
|
- if let token = dict1["id"] { id = token as? String ?? id }
|
|
|
|
- if let token = dict1["productName"] { productName = token as? String ?? productName }
|
|
|
|
- if let token = dict1["price"] { price = token as? NSNumber ?? price }
|
|
|
|
- if let token = dict1["maxDeviceNum"] { maxDeviceNum = token as? Int ?? maxDeviceNum }
|
|
|
|
- if let token = dict1["levels"] { levels = token as? String ?? levels }
|
|
|
|
- if let token = dict1["platforms"] { platforms = token as? String ?? platforms }
|
|
|
|
- if let token = dict1["productLineId"] { productLineId = token as? Int ?? productLineId }
|
|
|
|
- if let token = dict1["paymentModel"] { paymentModel = token as? Int ?? paymentModel }
|
|
|
|
- if let token = dict1["cycle"] { cycle = token as? Int ?? cycle }
|
|
|
|
- if let token = dict1["code"] { code = token as? String ?? code }
|
|
|
|
- if let token = dict1["cnyPrice"] { cnyPrice = token as? NSNumber ?? cnyPrice }
|
|
|
|
|
|
+ var results: [KMListingProductsModel] = []
|
|
|
|
+ for dict1 in result_Array {
|
|
|
|
+ var id = ""
|
|
|
|
+ var productName = ""
|
|
|
|
+ var price = NSNumber(value: 0.0)
|
|
|
|
+ var maxDeviceNum = 0
|
|
|
|
+ var levels = ""
|
|
|
|
+ var platforms = ""
|
|
|
|
+ var productLineId = 0
|
|
|
|
+ var paymentModel = 0
|
|
|
|
+ var cycle = 0
|
|
|
|
+ var code = ""
|
|
|
|
+ var cnyPrice = NSNumber(value: 0.0)
|
|
|
|
+
|
|
|
|
+ if let token = dict1["id"] { id = token as? String ?? id }
|
|
|
|
+ if let token = dict1["productName"] { productName = token as? String ?? productName }
|
|
|
|
+ if let token = dict1["price"] { price = token as? NSNumber ?? price }
|
|
|
|
+ if let token = dict1["maxDeviceNum"] { maxDeviceNum = token as? Int ?? maxDeviceNum }
|
|
|
|
+ if let token = dict1["levels"] { levels = token as? String ?? levels }
|
|
|
|
+ if let token = dict1["platforms"] { platforms = token as? String ?? platforms }
|
|
|
|
+ if let token = dict1["productLineId"] { productLineId = token as? Int ?? productLineId }
|
|
|
|
+ if let token = dict1["paymentModel"] { paymentModel = token as? Int ?? paymentModel }
|
|
|
|
+ if let token = dict1["cycle"] { cycle = token as? Int ?? cycle }
|
|
|
|
+ if let token = dict1["code"] { code = token as? String ?? code }
|
|
|
|
+ if let token = dict1["cnyPrice"] { cnyPrice = token as? NSNumber ?? cnyPrice }
|
|
|
|
|
|
- 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)
|
|
|
|
- results.append(products)
|
|
|
|
- }
|
|
|
|
|
|
+ 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)
|
|
|
|
+ results.append(products)
|
|
|
|
+ }
|
|
|
|
|
|
- let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
|
|
|
|
- if code == 200 {
|
|
|
|
- complete(true, result)
|
|
|
|
- } else {
|
|
|
|
- complete(false, result)
|
|
|
|
|
|
+ let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
|
|
|
|
+ if code == 200 {
|
|
|
|
+ complete(true, result)
|
|
|
|
+ } else {
|
|
|
|
+ complete(false, result)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ print("Invalid URL")
|
|
|
|
+ complete(false, nil)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -912,60 +933,66 @@ class KMMemberCenterManager: NSObject {
|
|
let params: [String: Any] = ["productId": productId,
|
|
let params: [String: Any] = ["productId": productId,
|
|
"isEducation": isEducation,
|
|
"isEducation": isEducation,
|
|
"userId": userId]
|
|
"userId": userId]
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
|
|
|
|
-
|
|
|
|
- } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
- var dic: NSDictionary = [:]
|
|
|
|
- if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
- dic = responseObject
|
|
|
|
- } else {
|
|
|
|
- var info = responseObject
|
|
|
|
- if let error = error {
|
|
|
|
- if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
- info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
|
|
+ if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
|
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
|
|
|
|
+
|
|
|
|
+ } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
+ var dic: NSDictionary = [:]
|
|
|
|
+ if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
+ dic = responseObject
|
|
|
|
+ } else {
|
|
|
|
+ var info = responseObject
|
|
|
|
+ if let error = error {
|
|
|
|
+ if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
+ info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ dic = (info as? NSDictionary) ?? [:]
|
|
|
|
+ }
|
|
|
|
+ let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
+ let result_Array: [NSDictionary] = [dic["result"]] as? [NSDictionary] ?? [[:]]
|
|
|
|
+ let message: String = dic["msg"] as? String ?? ""
|
|
|
|
+
|
|
|
|
+ var results: [KMListingProductsModel] = []
|
|
|
|
+ for dict1 in result_Array {
|
|
|
|
+ var id = ""
|
|
|
|
+ var productName = ""
|
|
|
|
+ var price = NSNumber(value: 0.0)
|
|
|
|
+ var maxDeviceNum = 0
|
|
|
|
+ var levels = ""
|
|
|
|
+ var platforms = ""
|
|
|
|
+ var productLineId = 0
|
|
|
|
+ var paymentModel = 0
|
|
|
|
+ var cycle = 0
|
|
|
|
+ var code = ""
|
|
|
|
+ var cnyPrice = NSNumber(value: 0.0)
|
|
|
|
+ if let token = dict1["id"] { id = token as! String }
|
|
|
|
+ if let token = dict1["productName"] { productName = token as! String }
|
|
|
|
+ if let token = dict1["price"] { price = token as! NSNumber }
|
|
|
|
+ if let token = dict1["maxDeviceNum"] { maxDeviceNum = token as! Int }
|
|
|
|
+ if let token = dict1["levels"] { levels = token as! String }
|
|
|
|
+ if let token = dict1["platforms"] { platforms = token as! String }
|
|
|
|
+ if let token = dict1["productLineId"] { productLineId = token as! Int }
|
|
|
|
+ if let token = dict1["paymentModel"] { paymentModel = token as! Int }
|
|
|
|
+ if let token = dict1["cycle"] { cycle = token as! Int }
|
|
|
|
+ if let token = dict1["code"] { code = token as! String }
|
|
|
|
+ if let token = dict1["cnyPrice"] { cnyPrice = token as! NSNumber }
|
|
|
|
+ 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)
|
|
|
|
+ results.append(products)
|
|
}
|
|
}
|
|
- dic = (info as? NSDictionary) ?? [:]
|
|
|
|
- }
|
|
|
|
- let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
- let result_Array: [NSDictionary] = [dic["result"]] as? [NSDictionary] ?? [[:]]
|
|
|
|
- let message: String = dic["msg"] as? String ?? ""
|
|
|
|
-
|
|
|
|
- var results: [KMListingProductsModel] = []
|
|
|
|
- for dict1 in result_Array {
|
|
|
|
- var id = ""
|
|
|
|
- var productName = ""
|
|
|
|
- var price = NSNumber(value: 0.0)
|
|
|
|
- var maxDeviceNum = 0
|
|
|
|
- var levels = ""
|
|
|
|
- var platforms = ""
|
|
|
|
- var productLineId = 0
|
|
|
|
- var paymentModel = 0
|
|
|
|
- var cycle = 0
|
|
|
|
- var code = ""
|
|
|
|
- var cnyPrice = NSNumber(value: 0.0)
|
|
|
|
- if let token = dict1["id"] { id = token as! String }
|
|
|
|
- if let token = dict1["productName"] { productName = token as! String }
|
|
|
|
- if let token = dict1["price"] { price = token as! NSNumber }
|
|
|
|
- if let token = dict1["maxDeviceNum"] { maxDeviceNum = token as! Int }
|
|
|
|
- if let token = dict1["levels"] { levels = token as! String }
|
|
|
|
- if let token = dict1["platforms"] { platforms = token as! String }
|
|
|
|
- if let token = dict1["productLineId"] { productLineId = token as! Int }
|
|
|
|
- if let token = dict1["paymentModel"] { paymentModel = token as! Int }
|
|
|
|
- if let token = dict1["cycle"] { cycle = token as! Int }
|
|
|
|
- if let token = dict1["code"] { code = token as! String }
|
|
|
|
- if let token = dict1["cnyPrice"] { cnyPrice = token as! NSNumber }
|
|
|
|
- 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)
|
|
|
|
- results.append(products)
|
|
|
|
- }
|
|
|
|
|
|
|
|
- let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
|
|
|
|
- if code == 200 {
|
|
|
|
- complete(true, result)
|
|
|
|
- } else {
|
|
|
|
- complete(false, result)
|
|
|
|
|
|
+ let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
|
|
|
|
+ if code == 200 {
|
|
|
|
+ complete(true, result)
|
|
|
|
+ } else {
|
|
|
|
+ complete(false, result)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ print("Invalid URL")
|
|
|
|
+ complete(false, nil)
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -979,47 +1006,51 @@ class KMMemberCenterManager: NSObject {
|
|
let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/getBatchProductPrice"
|
|
let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/getBatchProductPrice"
|
|
let params: [String: Any] = ["productId": productId,
|
|
let params: [String: Any] = ["productId": productId,
|
|
"num": NSNumber(value: Int32(num))]
|
|
"num": NSNumber(value: Int32(num))]
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
|
|
|
|
-
|
|
|
|
- } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
- var dic: NSDictionary = [:]
|
|
|
|
- if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
- dic = responseObject
|
|
|
|
- } else {
|
|
|
|
- var info = responseObject
|
|
|
|
- if let error = error {
|
|
|
|
- if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
- info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
|
|
+ if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
|
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
|
|
|
|
+
|
|
|
|
+ } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
+ var dic: NSDictionary = [:]
|
|
|
|
+ if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
+ dic = responseObject
|
|
|
|
+ } else {
|
|
|
|
+ var info = responseObject
|
|
|
|
+ if let error = error {
|
|
|
|
+ if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
+ info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ dic = (info as? NSDictionary) ?? [:]
|
|
}
|
|
}
|
|
- dic = (info as? NSDictionary) ?? [:]
|
|
|
|
- }
|
|
|
|
- let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
- let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
|
|
|
|
- let message: String = dic["msg"] as? String ?? ""
|
|
|
|
-
|
|
|
|
- var productId = ""
|
|
|
|
- var totalPrice = ""
|
|
|
|
- var price = ""
|
|
|
|
- var batchPrice = ""
|
|
|
|
- var cnyPrice = ""
|
|
|
|
- var cnyBatchPrice = ""
|
|
|
|
- var cnyTotalPrice = ""
|
|
|
|
- if let token = result["productId"] { productId = token as! String }
|
|
|
|
- if let token = result["totalPrice"] { totalPrice = token as! String }
|
|
|
|
- if let token = result["price"] { price = token as! String }
|
|
|
|
- if let token = result["batchPrice"] { batchPrice = token as! String }
|
|
|
|
- if let token = result["cnyPrice"] { cnyPrice = token as! String }
|
|
|
|
- if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as! String }
|
|
|
|
- if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as! String }
|
|
|
|
- let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
|
|
|
|
|
|
+ let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
+ let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
|
|
|
|
+ let message: String = dic["msg"] as? String ?? ""
|
|
|
|
+
|
|
|
|
+ var productId = ""
|
|
|
|
+ var totalPrice = ""
|
|
|
|
+ var price = ""
|
|
|
|
+ var batchPrice = ""
|
|
|
|
+ var cnyPrice = ""
|
|
|
|
+ var cnyBatchPrice = ""
|
|
|
|
+ var cnyTotalPrice = ""
|
|
|
|
+ if let token = result["productId"] { productId = token as! String }
|
|
|
|
+ if let token = result["totalPrice"] { totalPrice = token as! String }
|
|
|
|
+ if let token = result["price"] { price = token as! String }
|
|
|
|
+ if let token = result["batchPrice"] { batchPrice = token as! String }
|
|
|
|
+ if let token = result["cnyPrice"] { cnyPrice = token as! String }
|
|
|
|
+ if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as! String }
|
|
|
|
+ if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as! String }
|
|
|
|
+ let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
|
|
|
|
|
|
- let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
|
|
|
|
- if code == 200 {
|
|
|
|
- complete(true, result1)
|
|
|
|
- } else {
|
|
|
|
- complete(false, result1)
|
|
|
|
|
|
+ let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
|
|
|
|
+ if code == 200 {
|
|
|
|
+ complete(true, result1)
|
|
|
|
+ } else {
|
|
|
|
+ complete(false, result1)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ print("Invalid URL")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1040,111 +1071,120 @@ class KMMemberCenterManager: NSObject {
|
|
let params: [String: Any] = ["productId": productId,
|
|
let params: [String: Any] = ["productId": productId,
|
|
"userId": userId,
|
|
"userId": userId,
|
|
"code": code]
|
|
"code": code]
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
|
|
|
|
- requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
|
|
|
|
- } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
- var dic: NSDictionary = [:]
|
|
|
|
- if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
- dic = responseObject
|
|
|
|
- } else {
|
|
|
|
- var info = responseObject
|
|
|
|
- if let error = error {
|
|
|
|
- if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
- info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
|
|
+ if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
|
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
|
|
|
|
+ requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
|
|
|
|
+ } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
+ var dic: NSDictionary = [:]
|
|
|
|
+ if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
+ dic = responseObject
|
|
|
|
+ } else {
|
|
|
|
+ var info = responseObject
|
|
|
|
+ if let error = error {
|
|
|
|
+ if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
+ info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ dic = (info as? NSDictionary) ?? [:]
|
|
}
|
|
}
|
|
- dic = (info as? NSDictionary) ?? [:]
|
|
|
|
- }
|
|
|
|
- let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
- let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
|
|
|
|
- let message: String = dic["msg"] as? String ?? ""
|
|
|
|
-
|
|
|
|
- var id = ""
|
|
|
|
- var productName = ""
|
|
|
|
- var price = ""
|
|
|
|
- var maxDeviceNum = 0
|
|
|
|
- var displayPrice = ""
|
|
|
|
- var levels = ""
|
|
|
|
- var platforms = ""
|
|
|
|
- var productLineId = 0
|
|
|
|
- var paymentModel = 0
|
|
|
|
- var cycle = 0
|
|
|
|
- var cnyPrice = ""
|
|
|
|
- var displayCnyPrice = ""
|
|
|
|
- if let token = result["id"] { id = token as! String }
|
|
|
|
- if let token = result["productName"] { productName = token as! String }
|
|
|
|
- if let token = result["price"] { price = token as! String }
|
|
|
|
- if let token = result["maxDeviceNum"] { maxDeviceNum = token as! Int }
|
|
|
|
- if let token = result["displayPrice"] { displayPrice = token as! String }
|
|
|
|
- if let token = result["levels"] { levels = token as! String }
|
|
|
|
- if let token = result["platforms"] { platforms = token as! String }
|
|
|
|
- if let token = result["productLineId"] { productLineId = token as! Int }
|
|
|
|
- if let token = result["paymentModel"] { paymentModel = token as! Int }
|
|
|
|
- if let token = result["cycle"] { cycle = token as! Int }
|
|
|
|
- if let token = result["cnyPrice"] { cnyPrice = token as! String }
|
|
|
|
- if let token = result["displayCnyPrice"] { displayCnyPrice = token as! String }
|
|
|
|
|
|
+ let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
+ let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
|
|
|
|
+ let message: String = dic["msg"] as? String ?? ""
|
|
|
|
+
|
|
|
|
+ var id = ""
|
|
|
|
+ var productName = ""
|
|
|
|
+ var price = ""
|
|
|
|
+ var maxDeviceNum = 0
|
|
|
|
+ var displayPrice = ""
|
|
|
|
+ var levels = ""
|
|
|
|
+ var platforms = ""
|
|
|
|
+ var productLineId = 0
|
|
|
|
+ var paymentModel = 0
|
|
|
|
+ var cycle = 0
|
|
|
|
+ var cnyPrice = ""
|
|
|
|
+ var displayCnyPrice = ""
|
|
|
|
+ if let token = result["id"] { id = token as! String }
|
|
|
|
+ if let token = result["productName"] { productName = token as! String }
|
|
|
|
+ if let token = result["price"] { price = token as! String }
|
|
|
|
+ if let token = result["maxDeviceNum"] { maxDeviceNum = token as! Int }
|
|
|
|
+ if let token = result["displayPrice"] { displayPrice = token as! String }
|
|
|
|
+ if let token = result["levels"] { levels = token as! String }
|
|
|
|
+ if let token = result["platforms"] { platforms = token as! String }
|
|
|
|
+ if let token = result["productLineId"] { productLineId = token as! Int }
|
|
|
|
+ if let token = result["paymentModel"] { paymentModel = token as! Int }
|
|
|
|
+ if let token = result["cycle"] { cycle = token as! Int }
|
|
|
|
+ if let token = result["cnyPrice"] { cnyPrice = token as! String }
|
|
|
|
+ if let token = result["displayCnyPrice"] { displayCnyPrice = token as! String }
|
|
|
|
|
|
- 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)
|
|
|
|
- let result1 = KMMemberProductResult(code: code, msg: message, checkCoupon: products)
|
|
|
|
- if code == 200 {
|
|
|
|
- complete(true, result1)
|
|
|
|
- } else {
|
|
|
|
- complete(false, result1)
|
|
|
|
|
|
+ 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)
|
|
|
|
+ let result1 = KMMemberProductResult(code: code, msg: message, checkCoupon: products)
|
|
|
|
+ if code == 200 {
|
|
|
|
+ complete(true, result1)
|
|
|
|
+ } else {
|
|
|
|
+ complete(false, result1)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ print("Invalid URL")
|
|
|
|
+ complete(false, nil)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- @abstract 获取批量阶段购买价格
|
|
|
|
- @param productId 购买的产品id
|
|
|
|
- @param isEducation 是否教育优惠
|
|
|
|
|
|
+ @abstract 检查邮箱教育优惠资格
|
|
|
|
+ @param email 邮箱
|
|
@param complete 回调
|
|
@param complete 回调
|
|
*/
|
|
*/
|
|
func checkEducation(email: String, _ complete: @escaping KMMemberProductComplete) {
|
|
func checkEducation(email: String, _ complete: @escaping KMMemberProductComplete) {
|
|
|
|
|
|
let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/checkEducation"
|
|
let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/checkEducation"
|
|
let params: [String: Any] = ["email": email]
|
|
let params: [String: Any] = ["email": email]
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
|
|
|
|
-
|
|
|
|
- } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
- var dic: NSDictionary = [:]
|
|
|
|
- if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
- dic = responseObject
|
|
|
|
- } else {
|
|
|
|
- var info = responseObject
|
|
|
|
- if let error = error {
|
|
|
|
- if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
- info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
|
|
+ if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
|
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
|
|
|
|
+
|
|
|
|
+ } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
+ var dic: NSDictionary = [:]
|
|
|
|
+ if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
+ dic = responseObject
|
|
|
|
+ } else {
|
|
|
|
+ var info = responseObject
|
|
|
|
+ if let error = error {
|
|
|
|
+ if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
+ info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ dic = (info as? NSDictionary) ?? [:]
|
|
}
|
|
}
|
|
- dic = (info as? NSDictionary) ?? [:]
|
|
|
|
- }
|
|
|
|
- let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
- let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
|
|
|
|
- let message: String = dic["msg"] as? String ?? ""
|
|
|
|
-
|
|
|
|
- var productId = ""
|
|
|
|
- var totalPrice = ""
|
|
|
|
- var price = ""
|
|
|
|
- var batchPrice = ""
|
|
|
|
- var cnyPrice = ""
|
|
|
|
- var cnyBatchPrice = ""
|
|
|
|
- var cnyTotalPrice = ""
|
|
|
|
- if let token = result["productId"] { productId = token as! String }
|
|
|
|
- if let token = result["totalPrice"] { totalPrice = token as! String }
|
|
|
|
- if let token = result["price"] { price = token as! String }
|
|
|
|
- if let token = result["batchPrice"] { batchPrice = token as! String }
|
|
|
|
- if let token = result["cnyPrice"] { cnyPrice = token as! String }
|
|
|
|
- if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as! String }
|
|
|
|
- if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as! String }
|
|
|
|
- let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
|
|
|
|
|
|
+ let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
+ let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
|
|
|
|
+ let message: String = dic["msg"] as? String ?? ""
|
|
|
|
+
|
|
|
|
+ var productId = ""
|
|
|
|
+ var totalPrice = ""
|
|
|
|
+ var price = ""
|
|
|
|
+ var batchPrice = ""
|
|
|
|
+ var cnyPrice = ""
|
|
|
|
+ var cnyBatchPrice = ""
|
|
|
|
+ var cnyTotalPrice = ""
|
|
|
|
+ if let token = result["productId"] { productId = token as! String }
|
|
|
|
+ if let token = result["totalPrice"] { totalPrice = token as! String }
|
|
|
|
+ if let token = result["price"] { price = token as! String }
|
|
|
|
+ if let token = result["batchPrice"] { batchPrice = token as! String }
|
|
|
|
+ if let token = result["cnyPrice"] { cnyPrice = token as! String }
|
|
|
|
+ if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as! String }
|
|
|
|
+ if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as! String }
|
|
|
|
+ let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
|
|
|
|
|
|
- let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
|
|
|
|
- if code == 200 {
|
|
|
|
- complete(true, result1)
|
|
|
|
- } else {
|
|
|
|
- complete(false, result1)
|
|
|
|
|
|
+ let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
|
|
|
|
+ if code == 200 {
|
|
|
|
+ complete(true, result1)
|
|
|
|
+ } else {
|
|
|
|
+ complete(false, result1)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ print("Invalid URL")
|
|
|
|
+ complete(false, nil)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1164,27 +1204,33 @@ class KMMemberCenterManager: NSObject {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/getStateByOrderId"
|
|
let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/getStateByOrderId"
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: nil) { requestSerializer in
|
|
|
|
- requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
|
|
|
|
- } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
- var dic: NSDictionary = [:]
|
|
|
|
- if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
- dic = responseObject
|
|
|
|
- } else {
|
|
|
|
- var info = responseObject
|
|
|
|
- if let error = error {
|
|
|
|
- if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
- info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
|
|
+ let params: [String: Any] = ["orderId": orderId]
|
|
|
|
+ if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
|
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
|
|
|
|
+ requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
|
|
|
|
+ } completion: { [weak self] (task, responseObject, error) in
|
|
|
|
+ var dic: NSDictionary = [:]
|
|
|
|
+ if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
|
+ dic = responseObject
|
|
|
|
+ } else {
|
|
|
|
+ var info = responseObject
|
|
|
|
+ if let error = error {
|
|
|
|
+ if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
|
+ info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ dic = (info as? NSDictionary) ?? [:]
|
|
|
|
+ }
|
|
|
|
+ let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
+ if code == 200 {
|
|
|
|
+ complete(true, dic)
|
|
|
|
+ } else {
|
|
|
|
+ complete(false, dic)
|
|
}
|
|
}
|
|
- dic = (info as? NSDictionary) ?? [:]
|
|
|
|
- }
|
|
|
|
- let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
- if code == 200 {
|
|
|
|
- complete(true, dic)
|
|
|
|
- } else {
|
|
|
|
- complete(false, dic)
|
|
|
|
}
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+ print("Invalid URL")
|
|
|
|
+ complete(false, nil)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1263,7 +1309,7 @@ class KMMemberCenterManager: NSObject {
|
|
complete(false, nil)
|
|
complete(false, nil)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/createOrder"
|
|
|
|
|
|
+ let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/createSubscription"
|
|
let params: [String: Any] = ["productId": productId,
|
|
let params: [String: Any] = ["productId": productId,
|
|
"paymentMethod": paymentMethod,
|
|
"paymentMethod": paymentMethod,
|
|
"price": price,
|
|
"price": price,
|