| | |
| | | |
| | | cons_tableHei.constant = CGFloat(studentModels.count * 87) |
| | | tableView.reloadData() |
| | | changePrice(selectClassIndex) |
| | | |
| | | queryCouponInfo {[weak self] () in |
| | | guard let weakSelf = self else { return } |
| | | self?.changePrice(weakSelf.selectClassIndex) |
| | | } |
| | | |
| | | let imgs = m.detailDrawing.components(separatedBy: ",") |
| | | var items = [CommonBannerModel]() |
| | |
| | | } |
| | | } |
| | | |
| | | //计算价格 |
| | | private func changePrice(_ index:Int){ |
| | | if let subM = detailModel?.list[index]{ |
| | | |
| | |
| | | label_originPrice.isHidden = true |
| | | label_vipPrice.isHidden = true |
| | | |
| | | //纯玩湃币没有优惠券项 |
| | | btn_hasCoupon.isHidden = true |
| | | |
| | | //玩湃币 |
| | | label_coin.attributedText = AttributedStringbuilder.build() |
| | | .add(string: "玩湃币:", withFont: UIFont.systemFont(ofSize: 14, weight: .semibold), withColor: UIColor(hexStr: "#3F3F3F")) |
| | |
| | | case .cash: |
| | | label_coin.isHidden = true;fallthrough |
| | | case .cashCoin: |
| | | if subM.originalPrice == 0{label_originPrice.isHidden = true} |
| | | label_originPrice.isHidden = (subM.paymentPrice == subM.originalPrice && subM.paymentPrice != 0 && subM.originalPrice != 0) |
| | | if subM.originalPrice == 0 || subM.originalPrice == subM.paymentPrice{ |
| | | label_originPrice.isHidden = true |
| | | }else{ |
| | | label_originPrice.isHidden = false |
| | | } |
| | | // label_originPrice.isHidden = (subM.paymentPrice == subM.originalPrice && subM.paymentPrice != 0 && subM.originalPrice != 0) |
| | | |
| | | //玩湃币 |
| | | label_coin.attributedText = AttributedStringbuilder.build() |
| | |
| | | label_vipPrice.isHidden = true |
| | | if subM.paymentPrice < subM.vipPrice && subM.paymentPrice != 0{ |
| | | label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else if subM.vipPrice != 0{ |
| | | }else if subM.vipPrice < subM.paymentPrice && subM.vipPrice != 0{ |
| | | label_price.text = (subM.vipPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else if subM.vipPrice != 0 && subM.paymentPrice != 0{ |
| | | let price = min(subM.vipPrice, subM.paymentPrice) |
| | | label_price.text = (price * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else{ |
| | | label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | } |
| | |
| | | label_price.text = (subM.originalPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else if subM.originalPrice == 0 && subM.paymentPrice != 0{ |
| | | label_price.text = (subM.paymentPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | }else{ |
| | | }else if subM.originalPrice != 0 && subM.paymentPrice != 0{ |
| | | var money = min(subM.originalPrice,subM.paymentPrice) |
| | | money = money - (selectCouponModel?.favorable ?? 0) |
| | | label_price.text = (money * studentCount).currency() |
| | | }else{ |
| | | label_price.text = (subM.originalPrice * studentCount - (selectCouponModel?.favorable ?? 0)).currency() |
| | | } |
| | | } |
| | | } |
| | |
| | | label_originPrice.isHidden = true |
| | | label_vipPrice.isHidden = true |
| | | } |
| | | } |
| | | |
| | | queryCouponInfo() |
| | | if label_originPrice.isHidden && label_vipPrice.isHidden && label_coin.isHidden{ |
| | | label_coin.alpha = 0 |
| | | } |
| | | } |
| | | } |
| | | |
| | | private func queryCouponInfo(){ |
| | | //查询优惠券 |
| | | private func queryCouponInfo(complete:(()->Void)? = nil){ |
| | | if let subM = detailModel?.list[selectClassIndex]{ |
| | | |
| | | var price:Double? |
| | |
| | | } |
| | | |
| | | Services.queryAvaiableCopons(id: detailModel!.id, price: price!).subscribe(onNext: { [weak self] data in |
| | | guard let weakSelf = self else { return } |
| | | self?.btn_hasCoupon.isHidden = (data.data?.count ?? 0) == 0 |
| | | self?.couponModels = data.data ?? [] |
| | | |
| | | //重新获取优惠券,在切换套餐时触发 |
| | | if let selectCoupon = self?.selectCouponModel{ |
| | | if !weakSelf.couponModels.contains(where: {$0.id == selectCoupon.id}){ |
| | | weakSelf.selectCouponModel = nil |
| | | weakSelf.btn_couponInfo.setTitle("去选择", for: .normal) |
| | | } |
| | | } |
| | | complete?() |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | } |
| | |
| | | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| | | selectClassIndex = indexPath.row |
| | | collectionView.reloadData() |
| | | changePrice(selectClassIndex) |
| | | queryCouponInfo {[weak self] () in |
| | | self?.changePrice(indexPath.row) |
| | | } |
| | | } |
| | | } |
| | | |