Showing
1 changed file
with
38 additions
and
17 deletions
| ... | @@ -7,18 +7,30 @@ | ... | @@ -7,18 +7,30 @@ |
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | import UIKit | 9 | import UIKit |
| 10 | +import SwiftEventBus | ||
| 10 | 11 | ||
| 11 | @objc public class GiftsViewController: UIViewController { | 12 | @objc public class GiftsViewController: UIViewController { |
| 12 | @IBOutlet weak var mainView: UIView! | 13 | @IBOutlet weak var mainView: UIView! |
| 13 | @IBOutlet weak var tableView: UITableView! | 14 | @IBOutlet weak var tableView: UITableView! |
| 14 | 15 | ||
| 15 | public var campaigns:Array<swiftApi.CampaignItemModel> = swiftApi().getCampaignList().filter { $0.offer_category == "gifts_for_you" } | 16 | public var campaigns:Array<swiftApi.CampaignItemModel> = swiftApi().getCampaignList().filter { $0.offer_category == "gifts_for_you" } |
| 17 | + public var seasonalList:Array<swiftApi.LoyaltyGiftsForYouPackage> = swiftApi().getSeasonalList() | ||
| 16 | 18 | ||
| 17 | 19 | ||
| 18 | public override func viewDidLoad() { | 20 | public override func viewDidLoad() { |
| 19 | super.viewDidLoad() | 21 | super.viewDidLoad() |
| 20 | 22 | ||
| 21 | self.hidesBottomBarWhenPushed = true | 23 | self.hidesBottomBarWhenPushed = true |
| 24 | + | ||
| 25 | + if (seasonalList.count > 0) { | ||
| 26 | + for seasonalItem in seasonalList { | ||
| 27 | + let newCampaign = swiftApi.CampaignItemModel() | ||
| 28 | + newCampaign._title = seasonalItem._title | ||
| 29 | + newCampaign._logo_url = seasonalItem._imageUrl | ||
| 30 | + newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId | ||
| 31 | + campaigns.append(newCampaign) | ||
| 32 | + } | ||
| 33 | + } | ||
| 22 | 34 | ||
| 23 | setBackButton() | 35 | setBackButton() |
| 24 | setNavigationTitle("GIFTS for YOU") | 36 | setNavigationTitle("GIFTS for YOU") |
| ... | @@ -66,32 +78,41 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ | ... | @@ -66,32 +78,41 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{ |
| 66 | } | 78 | } |
| 67 | 79 | ||
| 68 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | 80 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| 69 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 81 | + if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "") { |
| 70 | - let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController | 82 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
| 71 | - var url = "" | 83 | + let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController |
| 72 | - let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true") | 84 | + var url = "" |
| 73 | - | 85 | + let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true") |
| 74 | - if (isCcmsOffer) { | 86 | + |
| 75 | - let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() | 87 | + if (isCcmsOffer) { |
| 76 | - let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid } | 88 | + let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns() |
| 89 | + let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid } | ||
| 77 | 90 | ||
| 78 | - if (loyaltyCampaignIdExists == true) { | 91 | + if (loyaltyCampaignIdExists == true) { |
| 79 | - var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel() | 92 | + var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel() |
| 80 | - for item in ccmsCampaigns { | 93 | + for item in ccmsCampaigns { |
| 81 | - if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) { | 94 | + if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) { |
| 82 | - ccmsCampaignFound = item | 95 | + ccmsCampaignFound = item |
| 96 | + } | ||
| 83 | } | 97 | } |
| 98 | + url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound) | ||
| 99 | + } else { | ||
| 100 | + url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) | ||
| 84 | } | 101 | } |
| 85 | - url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound) | 102 | + |
| 86 | } else { | 103 | } else { |
| 87 | url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) | 104 | url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) |
| 88 | } | 105 | } |
| 106 | + vc.campaignUrl = url | ||
| 107 | + self.navigationController?.pushViewController(vc, animated: true) | ||
| 89 | 108 | ||
| 90 | } else { | 109 | } else { |
| 91 | - url = swiftApi().constructCampaignUrl(campaigns[indexPath.row]) | 110 | + let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent() |
| 111 | + seasonalEvent._title = campaigns[indexPath.row]._title ?? "" | ||
| 112 | + seasonalEvent._imageUrl = campaigns[indexPath.row]._logo_url ?? "" | ||
| 113 | + seasonalEvent._loyaltyPackageId = campaigns[indexPath.row]._loyaltyPackageId ?? "" | ||
| 114 | + SwiftEventBus.post("seasonal", sender: seasonalEvent) | ||
| 92 | } | 115 | } |
| 93 | - vc.campaignUrl = url | ||
| 94 | - self.navigationController?.pushViewController(vc, animated: true) | ||
| 95 | } | 116 | } |
| 96 | 117 | ||
| 97 | } | 118 | } | ... | ... |
-
Please register or login to post a comment