Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
Z
ZhiJi-Overseas
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lmj
ZhiJi-Overseas
Commits
e97306ac
Commit
e97306ac
authored
Jul 08, 2020
by
Mazy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add login if pay success in tourest
parent
1018359e
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
26 deletions
+107
-26
UserInterfaceState.xcuserstate
...cuserdata/mazy.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
ZJMemberPayViewController.m
ZhiJi/Classes/Goods/Controller/ZJMemberPayViewController.m
+26
-11
ZTPurchaseManager.swift
ZhiJi/Classes/Goods/Controller/ZTPurchaseManager.swift
+78
-15
ZJMineViewController.m
ZhiJi/Classes/Mine/Controller/ZJMineViewController.m
+3
-0
No files found.
ZhiJi.xcworkspace/xcuserdata/mazy.xcuserdatad/UserInterfaceState.xcuserstate
View file @
e97306ac
No preview for this file type
ZhiJi/Classes/Goods/Controller/ZJMemberPayViewController.m
View file @
e97306ac
...
@@ -156,13 +156,20 @@
...
@@ -156,13 +156,20 @@
if
(
self
.
payFinish
)
{
if
(
self
.
payFinish
)
{
self
.
payFinish
();
self
.
payFinish
();
}
}
[[
ZJUserInfoManager
shared
]
updataUserInfo
:
^
(
ZJMineUserInfoModel
*
model
)
{
if
(
self
.
presentingViewController
){
if
(
self
.
presentingViewController
){
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
return
;
return
;
}
}
[
self
.
navigationController
popViewControllerAnimated
:
YES
];
[
self
.
navigationController
popViewControllerAnimated
:
YES
];
}
failure
:
^
(
id
error
)
{
if
(
self
.
presentingViewController
){
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
return
;
}
[
self
.
navigationController
popViewControllerAnimated
:
YES
];
}];
}
faliure
:^
{
}
faliure
:^
{
[
MBProgressHUD
hideHUD
];
[
MBProgressHUD
hideHUD
];
...
@@ -179,12 +186,20 @@
...
@@ -179,12 +186,20 @@
-
(
IBAction
)
restoreBtnClick
:
(
id
)
sender
{
-
(
IBAction
)
restoreBtnClick
:
(
id
)
sender
{
[
ZTPurchaseManager
restorePurchasesWithView
:
self
.
view
success
:
^
{
[
ZTPurchaseManager
restorePurchasesWithView
:
self
.
view
success
:
^
{
if
(
self
.
presentingViewController
)
{
[[
ZJUserInfoManager
shared
]
updataUserInfo
:
^
(
ZJMineUserInfoModel
*
model
)
{
if
(
self
.
presentingViewController
){
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
return
;
}
[
self
.
navigationController
popViewControllerAnimated
:
YES
];
}
failure
:
^
(
id
error
)
{
if
(
self
.
presentingViewController
){
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
return
;
return
;
}
}
[
self
.
navigationController
popViewControllerAnimated
:
YES
];
[
self
.
navigationController
popViewControllerAnimated
:
YES
];
}];
}];
}];
}
}
-
(
void
)
getIpaList
{
-
(
void
)
getIpaList
{
...
...
ZhiJi/Classes/Goods/Controller/ZTPurchaseManager.swift
View file @
e97306ac
...
@@ -40,30 +40,45 @@ class ZTPurchaseManager: NSObject {
...
@@ -40,30 +40,45 @@ class ZTPurchaseManager: NSObject {
print
(
"productId transactionId receiptData:
\(
dict
)
"
)
print
(
"productId transactionId receiptData:
\(
dict
)
"
)
// TODO: 服务器验证
// TODO: 服务器验证
let
innerHud
=
MBProgressHUD
.
showAdded
(
to
:
inView
,
animated
:
true
)
let
innerHud
=
MBProgressHUD
.
showAdded
(
to
:
inView
,
animated
:
true
)
TQNetworkTools
.
shared
()
.
post
(
withBodyAction
:
iosIPAVerifyReceipt
,
parameters
:
[:],
body
:
dict
,
success
:
{
(
data
)
in
TQNetworkTools
.
shared
()
.
post
(
withBodyAction
:
iosIPAVerifyReceipt
,
parameters
:
[:],
body
:
dict
,
success
:
{
(
data
)
in
innerHud
.
hide
(
animated
:
true
)
innerHud
.
hide
(
animated
:
true
)
print
(
"success----iosIPAVerifyReceipt-----------------
\(
data
)
------"
)
print
(
"success----iosIPAVerifyReceipt-----------------
\(
data
)
------"
)
if
let
dict
=
data
as?
[
String
:
Any
]
{
if
let
dict
=
data
as?
[
String
:
Any
]
{
if
let
result
=
dict
[
"result"
]
as?
[
String
:
Any
]
{
if
let
result
=
dict
[
"result"
]
as?
[
String
:
Any
]
{
if
let
data
=
result
[
"data"
]
as?
[
String
:
Any
]
{
if
let
data
=
result
[
"data"
]
as?
[
String
:
Any
]
{
print
(
"SwiftyStoreKit---1-
\(
data
)
"
)
if
let
status
=
data
[
"status"
]
as?
Bool
{
if
let
status
=
data
[
"status"
]
as?
Bool
{
print
(
"SwiftyStoreKit--2--
\(
status
)
"
)
if
status
{
if
status
{
print
(
"SwiftyStoreKit--3--
\(
status
)
"
)
if
product
.
needsFinishTransaction
{
if
product
.
needsFinishTransaction
{
SwiftyStoreKit
.
finishTransaction
(
product
.
transaction
)
SwiftyStoreKit
.
finishTransaction
(
product
.
transaction
)
}
}
print
(
"Purchase Success:
\(
product
.
productId
)
"
)
print
(
"Purchase Success:
\(
product
.
productId
)
"
)
success
()
success
()
}
else
{
MBProgressHUD
.
showError
(
"未知错误,请联系客服"
)
}
}
}
else
{
MBProgressHUD
.
showError
(
"未知错误,请联系客服"
)
}
}
}
else
{
MBProgressHUD
.
showError
(
"未知错误,请联系客服"
)
}
}
}
else
{
MBProgressHUD
.
showError
(
"未知错误,请联系客服"
)
}
}
}
else
{
MBProgressHUD
.
showError
(
"未知错误,请联系客服"
)
}
}
})
{
(
error
)
in
})
{
(
error
)
in
innerHud
.
hide
(
animated
:
true
)
innerHud
.
hide
(
animated
:
true
)
//
print("\(error)")
print
(
"
\(
error
)
"
)
faliure
();
faliure
();
}
}
}
else
{
}
else
{
print
(
"Purchase Success: not needsFinishTransaction"
)
success
()
success
()
}
}
case
.
error
(
let
error
):
case
.
error
(
let
error
):
...
@@ -72,15 +87,19 @@ class ZTPurchaseManager: NSObject {
...
@@ -72,15 +87,19 @@ class ZTPurchaseManager: NSObject {
switch
error
.
code
{
switch
error
.
code
{
case
.
unknown
:
case
.
unknown
:
print
(
"Unknown error. Please contact support"
)
print
(
"Unknown error. Please contact support"
)
MBProgressHUD
.
showError
(
NSLocalizedString
(
"alert_unfriend_error"
,
comment
:
""
),
to
:
inView
)
MBProgressHUD
.
showError
(
"无法连接到 iTunes Store, 请稍后再试"
)
case
.
paymentCancelled
:
MBProgressHUD
.
showError
(
"您已取消购买"
)
case
.
paymentInvalid
:
MBProgressHUD
.
showError
(
"无法购买, 请试试其他的"
)
print
(
"The purchase identifier was invalid"
)
case
.
clientInvalid
:
print
(
"Not allowed to make the payment"
)
case
.
clientInvalid
:
print
(
"Not allowed to make the payment"
)
case
.
paymentCancelled
:
break
case
.
paymentInvalid
:
print
(
"The purchase identifier was invalid"
)
MBProgressHUD
.
showError
(
NSLocalizedString
(
"The purchase identifier was invalid"
,
comment
:
""
),
to
:
inView
)
case
.
paymentNotAllowed
:
print
(
"The device is not allowed to make the payment"
)
case
.
paymentNotAllowed
:
print
(
"The device is not allowed to make the payment"
)
case
.
storeProductNotAvailable
:
print
(
"The product is not available in the current storefront"
)
case
.
storeProductNotAvailable
:
print
(
"The product is not available in the current storefront"
)
case
.
cloudServicePermissionDenied
:
print
(
"Access to cloud service information is not allowed"
)
case
.
cloudServicePermissionDenied
:
print
(
"Access to cloud service information is not allowed"
)
case
.
cloudServiceNetworkConnectionFailed
:
print
(
"Could not connect to the network"
)
case
.
cloudServiceNetworkConnectionFailed
:
MBProgressHUD
.
showError
(
"无法连接到网络"
)
print
(
"Could not connect to the network"
)
case
.
cloudServiceRevoked
:
print
(
"User has revoked permission to use this cloud service"
)
case
.
cloudServiceRevoked
:
print
(
"User has revoked permission to use this cloud service"
)
default
:
print
((
error
as
NSError
)
.
localizedDescription
)
default
:
print
((
error
as
NSError
)
.
localizedDescription
)
}
}
...
@@ -130,23 +149,67 @@ class ZTPurchaseManager: NSObject {
...
@@ -130,23 +149,67 @@ class ZTPurchaseManager: NSObject {
// 恢复购买
// 恢复购买
@objc
class
func
restorePurchases
(
view
:
UIView
,
success
:
@escaping(()
->
Void
))
{
@objc
class
func
restorePurchases
(
view
:
UIView
,
success
:
@escaping(()
->
Void
))
{
let
hud
=
MBProgressHUD
.
showAdded
(
to
:
view
,
animated
:
true
)
let
hud
=
MBProgressHUD
.
showAdded
(
to
:
view
,
animated
:
true
)
SwiftyStoreKit
.
restorePurchases
(
atomically
:
true
)
{
results
in
SwiftyStoreKit
.
restorePurchases
(
atomically
:
true
)
{
results
in
hud
.
hide
(
animated
:
true
);
hud
.
hide
(
animated
:
true
);
if
results
.
restoreFailedPurchases
.
count
>
0
{
if
results
.
restoreFailedPurchases
.
count
>
0
{
print
(
"Restore Failed:
\(
results
.
restoreFailedPurchases
)
"
)
print
(
"Restore Failed:
\(
results
.
restoreFailedPurchases
)
"
)
}
}
else
if
results
.
restoredPurchases
.
count
>
0
{
else
if
results
.
restoredPurchases
.
count
>
0
{
print
(
"Restore Success:
\(
results
.
restoredPurchases
)
"
)
print
(
"Restore Success:
\(
results
.
restoredPurchases
)
"
)
if
results
.
restoredPurchases
.
filter
({
$0
.
needsFinishTransaction
})
.
count
<=
0
{
MBProgressHUD
.
showSuccess
(
NSLocalizedString
(
"alert_produce_restore_success"
,
comment
:
""
),
to
:
UIApplication
.
shared
.
windows
.
first
)
if
let
product
=
results
.
restoredPurchases
.
last
{
let
receiptData
=
SwiftyStoreKit
.
localReceiptData
let
receiptString
=
receiptData
?
.
base64EncodedString
(
options
:
[])
??
""
print
(
"receiptString:
\(
receiptString
)
"
)
let
dict
=
[
"productId"
:
product
.
productId
,
"transactionId"
:
(
product
.
transaction
.
transactionIdentifier
??
""
),
"receiptData"
:
receiptString
]
print
(
"productId transactionId receiptData:
\(
dict
)
"
)
// TODO: 服务器验证
let
innerHud
=
MBProgressHUD
.
showAdded
(
to
:
view
,
animated
:
true
)
TQNetworkTools
.
shared
()
.
post
(
withBodyAction
:
iosIPAVerifyReceipt
,
parameters
:
[:],
body
:
dict
,
success
:
{
(
data
)
in
innerHud
.
hide
(
animated
:
true
)
print
(
"success----iosIPAVerifyReceipt-----------------
\(
data
)
------"
)
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
}
if
product
.
needsFinishTransaction
{
SwiftyStoreKit
.
finishTransaction
(
product
.
transaction
)
}
print
(
"Purchase Success:
\(
product
.
productId
)
"
)
success
()
success
()
})
{
(
error
)
in
innerHud
.
hide
(
animated
:
true
)
}
}
}
}
else
{
MBProgressHUD
.
showError
(
NSLocalizedString
(
"alert_no_produce_restore"
,
comment
:
""
))
}
else
{
MBProgressHUD
.
showError
(
"没有商品可恢复"
)
print
(
"Nothing to Restore"
)
print
(
"Nothing to Restore"
)
}
}
}
}
}
}
// @objc class func restorePurchases(view:UIView, success: @escaping(()->Void)) {
// let hud = MBProgressHUD.showAdded(to: view, animated: true)
// SwiftyStoreKit.restorePurchases(atomically: true) { results in
// hud.hide(animated: true);
// if results.restoreFailedPurchases.count > 0 {
// print("Restore Failed: \(results.restoreFailedPurchases)")
// }
// else if results.restoredPurchases.count > 0 {
// print("Restore Success: \(results.restoredPurchases)")
// if results.restoredPurchases.filter({ $0.needsFinishTransaction }).count <= 0 {
// MBProgressHUD.showSuccess(NSLocalizedString("alert_produce_restore_success", comment: ""), to: UIApplication.shared.windows.first)
// success()
// }
// }
// else {
// MBProgressHUD.showError(NSLocalizedString("alert_no_produce_restore", comment: ""))
// print("Nothing to Restore")
// }
// }
// }
}
}
ZhiJi/Classes/Mine/Controller/ZJMineViewController.m
View file @
e97306ac
...
@@ -274,7 +274,10 @@ static NSString *ID = @"mineID";
...
@@ -274,7 +274,10 @@ static NSString *ID = @"mineID";
}];
}];
};
};
}
else
if
([
ZJUserInfoManager
shared
].
isLogin
)
{
[
self
headerSenderClick
];
}
}
}
}
break
;
break
;
default
:
default
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment