Commit fbc1b8de authored by Mazy's avatar Mazy

optimize mine logic

parent e97306ac
...@@ -158,34 +158,33 @@ class ZTPurchaseManager: NSObject { ...@@ -158,34 +158,33 @@ class ZTPurchaseManager: NSObject {
print("Restore Success: \(results.restoredPurchases)") print("Restore Success: \(results.restoredPurchases)")
if let product = results.restoredPurchases.last { if let product = results.restoredPurchases.last {
let receiptData = SwiftyStoreKit.localReceiptData if product.needsFinishTransaction {
let receiptString = receiptData?.base64EncodedString(options: []) ?? "" let receiptData = SwiftyStoreKit.localReceiptData
print("receiptString: \(receiptString)") let receiptString = receiptData?.base64EncodedString(options: []) ?? ""
let dict = ["productId": product.productId, "transactionId" : (product.transaction.transactionIdentifier ?? ""), "receiptData" : receiptString] print("receiptString: \(receiptString)")
print("productId transactionId receiptData: \(dict)") let dict = ["productId": product.productId, "transactionId" : (product.transaction.transactionIdentifier ?? ""), "receiptData" : receiptString]
// TODO: 服务器验证 print("productId transactionId receiptData: \(dict)")
let innerHud = MBProgressHUD.showAdded(to:view, animated: true) // TODO: 服务器验证
TQNetworkTools.shared().post(withBodyAction: iosIPAVerifyReceipt, parameters: [:], body: dict, success: { (data) in let innerHud = MBProgressHUD.showAdded(to:view, animated: true)
innerHud.hide(animated: true) TQNetworkTools.shared().post(withBodyAction: iosIPAVerifyReceipt, parameters: [:], body: dict, success: { (data) in
print("success----iosIPAVerifyReceipt-----------------\(data)------") innerHud.hide(animated: true)
guard let dict = data as? [String:Any], let result = dict["result"] as? [String:Any], let data = result["data"] as? [String:Any] else { print("success----iosIPAVerifyReceipt-----------------\(data)------")
return guard let dict = data as? [String:Any], let result = dict["result"] as? [String:Any], let data = result["data"] as? [String:Any] else {
} return
}
guard let status = data["status"] as? Bool, status == true else {
return guard let status = data["status"] as? Bool, status == true else {
} return
if product.needsFinishTransaction { }
print("Purchase Success: \(product.productId)")
SwiftyStoreKit.finishTransaction(product.transaction) SwiftyStoreKit.finishTransaction(product.transaction)
success()
}) { (error) in
innerHud.hide(animated: true)
} }
print("Purchase Success: \(product.productId)")
success()
}) { (error) in
innerHud.hide(animated: true)
} }
} }
} else { } else {
MBProgressHUD.showError("没有商品可恢复") MBProgressHUD.showError("没有商品可恢复")
print("Nothing to Restore") print("Nothing to Restore")
......
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
if (Member) { if (Member) {
_gongNengLabel.text = kLocalizedString(@"mine_unlocked"); _gongNengLabel.text = kLocalizedString(@"mine_unlocked");
_timeLabel.text = kLocalizedString(@"mine_free_used"); _timeLabel.text = kLocalizedString(@"mine_free_used");
// _xuFeiButton.hidden = YES; _xuFeiButton.hidden = YES;
}else{ }else{
_gongNengLabel.text = kLocalizedString(@"mine_premium_services_locked"); _gongNengLabel.text = kLocalizedString(@"mine_premium_services_locked");
_timeLabel.text = kLocalizedString(@"mine_unlock_more_services"); _timeLabel.text = kLocalizedString(@"mine_unlock_more_services");
...@@ -197,10 +197,20 @@ ...@@ -197,10 +197,20 @@
_nicknameLabel.text = userInfo.nickname; _nicknameLabel.text = userInfo.nickname;
} }
}else{ }else{
_nicknameLabel.text = kLocalizedString(@"mine_sign"); // [[data Read] objectForKey:@"NickName"]; if (Member) {
_gongNengLabel.text = kLocalizedString(@"mine_premium_services_locked"); _gongNengLabel.text = kLocalizedString(@"mine_unlocked");
_timeLabel.text = kLocalizedString(@"mine_unlock_more_services"); _timeLabel.text = kLocalizedString(@"mine_free_used");
[_xuFeiButton setTitle:kLocalizedString(@"mine_unlock") forState:(UIControlStateNormal)]; _nicknameLabel.text = kLocalizedString(@"mine_sign"); // [[data Read] objectForKey:@"NickName"];
_xuFeiButton.hidden = true;
}else{
_gongNengLabel.text = kLocalizedString(@"mine_premium_services_locked");
_timeLabel.text = kLocalizedString(@"mine_unlock_more_services");
[_xuFeiButton setTitle:kLocalizedString(@"mine_unlock") forState:(UIControlStateNormal)];
_xuFeiButton.hidden = false;
}
// _gongNengLabel.text = kLocalizedString(@"mine_premium_services_locked");
// _timeLabel.text = kLocalizedString(@"mine_unlock_more_services");
// [_xuFeiButton setTitle:kLocalizedString(@"mine_unlock") forState:(UIControlStateNormal)];
} }
if ([userInfo.uid isEqual: @""]) { if ([userInfo.uid isEqual: @""]) {
......
...@@ -156,7 +156,7 @@ appName = "Family Mapp"; ...@@ -156,7 +156,7 @@ appName = "Family Mapp";
"mine_sign"="Sign in"; "mine_sign"="Sign in";
"mine_click_nickname"="Click name to edit"; "mine_click_nickname"="Click name to edit";
"mine_unlock_more_services"="Unlock to access Premium services"; "mine_unlock_more_services"="Unlock to access Premium services";
"mine_unlock"="Unlocked"; "mine_unlock"="Unlock";
"mine_userID"="User ID"; "mine_userID"="User ID";
"mine_track"="My track"; "mine_track"="My track";
"mine_emergenry_contacts"="Emergency contacts"; "mine_emergenry_contacts"="Emergency contacts";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment