Showing
1 changed file
with
59 additions
and
1 deletions
| ... | @@ -90,11 +90,69 @@ import UIKit | ... | @@ -90,11 +90,69 @@ import UIKit |
| 90 | if (response != nil) { | 90 | if (response != nil) { |
| 91 | DispatchQueue.main.async { | 91 | DispatchQueue.main.async { |
| 92 | if (response?.getStatus == 1) { | 92 | if (response?.getStatus == 1) { |
| 93 | - // Do something | 93 | + self.showSuccessDialog("Το κουπόνι σου ενεργοποιήθηκε","Μπορείς να το βρεις στην αρχική οθόνη της εφαρμογής και στην ενότητα ενεργά δώρα!") |
| 94 | + | ||
| 95 | + swiftApi().getCouponsAsync(getCouponsCallback) | ||
| 96 | + | ||
| 97 | + func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void { | ||
| 98 | + if (couponsData != nil) { | ||
| 99 | + | ||
| 100 | + DispatchQueue.main.async { | ||
| 101 | + print("========= getCouponsRequest SUCCESSSS CouponViewController =========") | ||
| 102 | + } | ||
| 103 | + } else { | ||
| 104 | + print("========= getCouponsRequest ERROR CouponViewController =========") | ||
| 94 | } | 105 | } |
| 95 | } | 106 | } |
| 107 | + } else if (response?.getStatus == 3) { | ||
| 108 | + self.showDialog("Αποτυχία","Το κουπόνι δεν είναι διαθέσιμο για αγορά") | ||
| 109 | + } else if (response?.getStatus == 5) { | ||
| 110 | + self.showDialog("Αποτυχία","Δεν έχεις αρκετούς πόντους") | ||
| 96 | } else { | 111 | } else { |
| 112 | + self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + } else { | ||
| 116 | + self.showDialog("Αποτυχία","Κάτι πήγε στραβά") | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + func showSuccessDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void { | ||
| 121 | + | ||
| 122 | + let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert) | ||
| 123 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
| 124 | + switch action.style{ | ||
| 125 | + case .default: | ||
| 126 | + self.navigationController?.popViewController(animated: true) | ||
| 127 | + | ||
| 128 | + case .cancel: | ||
| 129 | + print("cancel") | ||
| 130 | + | ||
| 131 | + case .destructive: | ||
| 132 | + print("destructive") | ||
| 133 | + | ||
| 134 | + } | ||
| 135 | + })) | ||
| 136 | + self.present(alert, animated: true, completion: nil) | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void { | ||
| 140 | + | ||
| 141 | + let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert) | ||
| 142 | + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | ||
| 143 | + switch action.style{ | ||
| 144 | + case .default: | ||
| 145 | + print("default") | ||
| 146 | + | ||
| 147 | + case .cancel: | ||
| 148 | + print("cancel") | ||
| 149 | + | ||
| 150 | + case .destructive: | ||
| 151 | + print("destructive") | ||
| 152 | + | ||
| 97 | } | 153 | } |
| 154 | + })) | ||
| 155 | + self.present(alert, animated: true, completion: nil) | ||
| 98 | } | 156 | } |
| 99 | 157 | ||
| 100 | // MARK: - Actions | 158 | // MARK: - Actions | ... | ... |
-
Please register or login to post a comment