| | |
| | | @IBOutlet weak var label_expirtTime: UILabel! |
| | | @IBOutlet weak var webView: WKWebView! |
| | | @IBOutlet weak var webViewHeiCons: NSLayoutConstraint! |
| | | @IBOutlet weak var btn_open: UIButton! |
| | | private var selectIndex = 0 |
| | | |
| | | private var productList = Set<String>() |
| | |
| | | private var isShowMore:Bool = false |
| | | private var orderId:String? //下单后的ID |
| | | |
| | | //测试内购账号:sandbox_muse@163.com / AB328820b1. |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "会员中心" |
| | | btn_open.isEnabled = false |
| | | btn_open.backgroundColor = UIColor.gray |
| | | |
| | | productList.insert("com.XQmuse.Non.renewing.year.1") |
| | | productList.insert("com.XQmuse.Non.renewing.half.year.1") |
| | | productList.insert("com.XQmuse.Non.renewing.month.1") |
| | | productList.insert("com.XQmuse.non.renewable.sub.year.1") |
| | | productList.insert("com.XQmuse.non.renewable.sub.quarter.1") |
| | | productList.insert("com.XQmuse.non.renewable.sub.month.1") |
| | | |
| | | Services.getTurn(progress: false).subscribe(onNext: {[weak self]data in |
| | | guard let weakSelf = self else { return } |
| | | if let m = data.data,m == true{ |
| | | weakSelf.isShowMore = m |
| | | Services.getVipPrice().subscribe(onNext: { data in |
| | | if let m = data.data{ |
| | | weakSelf.vipContentModel = m |
| | | weakSelf.collectionView.reloadData() |
| | | } |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | // Services.getTurn(progress: false).subscribe(onNext: {[weak self]data in |
| | | // guard let weakSelf = self else { return } |
| | | // if let m = data.data,m == true{ |
| | | // weakSelf.isShowMore = m |
| | | // Services.getVipPrice().subscribe(onNext: { data in |
| | | // if let m = data.data{ |
| | | // weakSelf.vipContentModel = m |
| | | // weakSelf.collectionView.reloadData() |
| | | // } |
| | | // }).disposed(by: weakSelf.disposeBag) |
| | | // } |
| | | // }).disposed(by: disposeBag) |
| | | |
| | | |
| | | collectionView.delegate = self |
| | |
| | | collectionView.contentInset = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15) |
| | | collectionView.register(VipCenterCCell.self, forCellWithReuseIdentifier: "cell") |
| | | |
| | | showHUD() |
| | | InPurchaseManager.instance().setProductList(productList) { products in |
| | | self.products = Array(products) |
| | | self.products.sort { p1, p2 in |
| | | return p1.price.doubleValue < p2.price.doubleValue |
| | | } |
| | | self.btn_open.isEnabled = true |
| | | self.btn_open.backgroundColor = UIColor(hexString: "#8AAE65") |
| | | self.collectionView.reloadData() |
| | | hiddenHUD() |
| | | } |
| | | |
| | | |
| | |
| | | guard let weakSelf = self else { return } |
| | | if result.status == 0{ |
| | | hiddenHUD() |
| | | let transactionId = result.receipt?.in_app.first?.original_transaction_id ?? "" |
| | | var purchaseResult:PurchaseInAPP? |
| | | if (result.receipt?.in_app.count ?? 0) >= 2{ |
| | | purchaseResult = result.receipt?.in_app.sorted(by: {$0.original_purchase_date_ms!.int! > $1.original_purchase_date_ms!.int!}).first |
| | | }else{ |
| | | purchaseResult = result.receipt?.in_app.first |
| | | } |
| | | |
| | | let transactionId = purchaseResult?.transaction_id ?? "" |
| | | |
| | | showHUD("正在查询购买结果") |
| | | Services.placeOrderApple(amount: product.price.doubleValue, balanceFlag: .no, orderFrom: 3, transactionIdentifier: transactionId, vipType: weakSelf.selectIndex + 1).subscribe(onNext: { data in |
| | |
| | | let observable = Observable<Int>.interval(RxTimeInterval.seconds(5), scheduler: MainScheduler.instance) |
| | | observable.subscribe { event in |
| | | if event.element == 10{ |
| | | alertError(msg: "订单异常") |
| | | alertError(msg: "订单异常,请联系客服") |
| | | weakSelf.timeLoopDisposeBag = DisposeBag() |
| | | return |
| | | } |
| | |
| | | |
| | | var priorDayPrice:Double = 0 |
| | | switch product.productIdentifier { |
| | | case "com.XQmuse.Non.renewing.year.1": |
| | | // case "com.XQmuse.Non.renewing.year.1": |
| | | case "com.XQmuse.non.renewable.sub.year.1": |
| | | priorDayPrice = product.price.doubleValue / 365.0 |
| | | case "com.XQmuse.Non.renewing.half.year.1": |
| | | // case "com.XQmuse.Non.renewing.half.year.1": |
| | | case "com.XQmuse.non.renewable.sub.quarter.1": |
| | | priorDayPrice = product.price.doubleValue / 180.0 |
| | | case "com.XQmuse.Non.renewing.month.1": |
| | | // case "com.XQmuse.Non.renewing.month.1": |
| | | case "com.XQmuse.non.renewable.sub.month.1": |
| | | priorDayPrice = product.price.doubleValue / 30.0 |
| | | default: |
| | | priorDayPrice = product.price.doubleValue |
| | | } |
| | | //购买后即可享受一年的会员疗愈,畅听疗愈音频 |
| | | //我的->点击"泉疗愈会员" |
| | | |
| | | |
| | | |