| | |
| | | |
| | | import UIKit |
| | | import QMUIKit |
| | | import JQTools |
| | | |
| | | let Refreh_PaymentWallet_Noti = Notification.Name.init("Refreh_PaymentWallet_Noti") |
| | | |
| | |
| | | private var balance:Double = 0 |
| | | private var type:PaymentOrderType! |
| | | private var showType:DisplayType! |
| | | private var businessId:Int? |
| | | |
| | | init(museItemModel:MeditationModel? = nil,courseItemModel:CourseModel? = nil,type:PaymentOrderType,giftToOther:Bool = false,showType:DisplayType!) { |
| | | init(museItemModel:MeditationModel? = nil,courseItemModel:CourseModel? = nil,type:PaymentOrderType,giftToOther:Bool = false,showType:DisplayType!,businessId:Int? = nil) { |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.museItemModel = museItemModel |
| | | self.courseItemModel = courseItemModel |
| | | self.giftToOther = giftToOther |
| | | self.type = type |
| | | self.showType = showType |
| | | self.businessId = businessId |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | |
| | | |
| | | getBalance() |
| | | |
| | | let btn = UIButton(type: .custom) |
| | | btn.setTitle("取消订单", for: .normal) |
| | | btn.setTitleColor(UIColor(hexString: "#353535"), for: .normal) |
| | | btn.titleLabel?.font = .systemFont(ofSize: 15) |
| | | btn.addTarget(self, action: #selector(cancelAction), for: .touchUpInside) |
| | | |
| | | if type == .course{ |
| | | if self.businessId != nil{ |
| | | self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn) |
| | | } |
| | | |
| | | Services.getCourseDetail(courseId: courseItemModel!.id).subscribe(onNext: {data in |
| | | if let m = data.data{ |
| | | self.courseModel = m |
| | |
| | | } |
| | | |
| | | if type == .muse{ |
| | | if self.businessId != nil{ |
| | | self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn) |
| | | } |
| | | |
| | | Services.getMeditationDetail(id: museItemModel!.id).subscribe(onNext: {data in |
| | | if let m = data.data{ |
| | | self.museModel = m |
| | |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | @objc private func cancelAction(){ |
| | | if businessId != nil{ |
| | | CommonAlertView.show(title: "提示", content: "是否取消订单") {[weak self] state in |
| | | guard let weakSelf = self else { return } |
| | | if state{ |
| | | Services.cancelOrder(id: weakSelf.businessId!).subscribe(onNext: {data in |
| | | alertSuccess(msg: "订单已取消") |
| | | for vc in weakSelf.navigationController?.viewControllers ?? []{ |
| | | if vc is WatchHistoryVC{ |
| | | weakSelf.navigationController?.popToViewController(vc, animated: true) |
| | | NotificationCenter.default.post(name: WatchHistory_Noti, object: nil, userInfo: nil) |
| | | break |
| | | } |
| | | } |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private func getBalance(){ |
| | | Services.getUserBalance().subscribe(onNext: {data in |
| | | self.balance = data.data ?? 0 |
| | |
| | | |
| | | @IBAction func invateRegisterAction(_ sender: UIButton) { |
| | | |
| | | let string = String(format: "%@%@?userId=%ld",ShareUrl,"/register/register",UserViewModel.getAvatarInfo().id) |
| | | ShareView.show(URL(string: string)!, title: "心泉疗愈", desc: "心泉疗愈1",hasSave: false) { |
| | | // alertSuccess(msg: "已保存至相册") |
| | | } |
| | | } |
| | | |
| | | @IBAction func searchUserAction(_ sender: UIButton) { |
| | | tf_phone.resignFirstResponder() |
| | | guard !tf_phone.text!.isEmpty else { |
| | | alertError(msg: tf_phone.placeholder ?? "请输入好友手机号");return |
| | | } |
| | |
| | | Services.searchUserByPhone(tf_phone.text!).subscribe(onNext: { data in |
| | | self.view_searchUserResult.isHidden = false |
| | | if let m = data.data,m.id != 0{ |
| | | self.giftUserId = m.userId |
| | | self.giftUserId = m.id |
| | | self.image_avatar.sd_setImage(with: URL(string: m.avatar)) |
| | | self.label_userName.text = m.nickname |
| | | self.label_userPhone.text = m.cellPhone |
| | | self.label_searchInfo.isHidden = true |
| | | self.btn_invate.isHidden = true |
| | | }else{ |
| | | self.image_avatar.isHidden = true |
| | | self.label_userName.isHidden = true |
| | | self.label_userPhone.isHidden = true |
| | | self.label_searchInfo.isHidden = false |
| | | self.btn_invate.isHidden = false |
| | | self.image_avatar.isHidden = false |
| | | self.label_userName.isHidden = false |
| | | self.label_userPhone.isHidden = false |
| | | self.btn_invate.isHidden = true |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | },onError: { _ in |
| | | self.view_searchUserResult.isHidden = false |
| | | self.image_avatar.isHidden = true |
| | | self.label_userName.isHidden = true |
| | | self.label_userPhone.isHidden = true |
| | | self.label_searchInfo.isHidden = false |
| | | self.btn_invate.isHidden = false |
| | | }).disposed(by: disposeBag) |
| | | |
| | | } |
| | | |
| | |
| | | id = m.id |
| | | } |
| | | |
| | | |
| | | guard btn_isRead.isSelected else { |
| | | alertError(msg: "请先阅读并同意《课程/疗愈音频购买协议》");return |
| | | } |
| | |
| | | return |
| | | } |
| | | |
| | | if businessId != nil{ |
| | | Services.gvieCourseAgain(orderForm: type, id: businessId!).subscribe(onNext: {[weak self]data in |
| | | guard let weakSelf = self else { return } |
| | | self?.museItemModel?.isBuy = .yes |
| | | self?.courseItemModel?.isBuy = .yes |
| | | self?.museModel?.isBuy = .yes |
| | | self?.courseModel?.isBuy = .yes |
| | | let vc = PaymentOrderResultVC(type: weakSelf.type, id: id, price: money) |
| | | self?.push(vc: vc) |
| | | }).disposed(by: disposeBag) |
| | | return |
| | | } |
| | | |
| | | |
| | | Services.gvieCourse(orderForm: type, targetId: id,receiverId: giftUserId).subscribe(onNext: {[weak self]data in |
| | | guard let weakSelf = self else { return } |
| | | self?.museItemModel?.isBuy = .yes |