XQMuse.xcodeproj/project.pbxproj
@@ -190,6 +190,8 @@ 138F0C322C7594BB0072A16C /* TreatyVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138F0C312C7594BB0072A16C /* TreatyVC.swift */; }; 138F0C352C7597CA0072A16C /* HelpCenterVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138F0C332C7597CA0072A16C /* HelpCenterVC.swift */; }; 138F0C362C7597CA0072A16C /* HelpCenterVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 138F0C342C7597CA0072A16C /* HelpCenterVC.xib */; }; 138F9E0F2CF4229500075C5D /* PurchaseMethodView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138F9E0E2CF4229500075C5D /* PurchaseMethodView.swift */; }; 138F9E112CF422B200075C5D /* PurchaseMethodView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 138F9E102CF422B200075C5D /* PurchaseMethodView.xib */; }; 138FE0DE2C757B2A00A964E8 /* BindPhone_1_VC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138FE0DC2C757B2A00A964E8 /* BindPhone_1_VC.swift */; }; 138FE0DF2C757B2A00A964E8 /* BindPhone_1_VC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 138FE0DD2C757B2A00A964E8 /* BindPhone_1_VC.xib */; }; 138FE0E22C757DE900A964E8 /* BindPhone_2_VC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138FE0E02C757DE900A964E8 /* BindPhone_2_VC.swift */; }; @@ -502,6 +504,8 @@ 138F0C312C7594BB0072A16C /* TreatyVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TreatyVC.swift; sourceTree = "<group>"; }; 138F0C332C7597CA0072A16C /* HelpCenterVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelpCenterVC.swift; sourceTree = "<group>"; }; 138F0C342C7597CA0072A16C /* HelpCenterVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = HelpCenterVC.xib; sourceTree = "<group>"; }; 138F9E0E2CF4229500075C5D /* PurchaseMethodView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PurchaseMethodView.swift; sourceTree = "<group>"; }; 138F9E102CF422B200075C5D /* PurchaseMethodView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PurchaseMethodView.xib; sourceTree = "<group>"; }; 138FE0DC2C757B2A00A964E8 /* BindPhone_1_VC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BindPhone_1_VC.swift; sourceTree = "<group>"; }; 138FE0DD2C757B2A00A964E8 /* BindPhone_1_VC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BindPhone_1_VC.xib; sourceTree = "<group>"; }; 138FE0E02C757DE900A964E8 /* BindPhone_2_VC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BindPhone_2_VC.swift; sourceTree = "<group>"; }; @@ -780,6 +784,8 @@ 13463E9B2CDE2CD500DD0C53 /* View */ = { isa = PBXGroup; children = ( 138F9E0E2CF4229500075C5D /* PurchaseMethodView.swift */, 138F9E102CF422B200075C5D /* PurchaseMethodView.xib */, ); path = View; sourceTree = "<group>"; @@ -1554,6 +1560,7 @@ 13985DBF2C69DDF90046B6DC /* HomeTopMenuView.xib in Resources */, 13C5838E2C86A4F90071BCBE /* apngb-animated-level-5.png in Resources */, 1385E00B2C6C57A900AADB1F /* HomeItemDetailVC.xib in Resources */, 138F9E112CF422B200075C5D /* PurchaseMethodView.xib in Resources */, 138995422C943AA700BC7F78 /* static-level-9.png in Resources */, 13B021DB2C75DD0600414769 /* BankWithdrawVC.xib in Resources */, 1338A6DE2C76DD5E006CDD15 /* SpendingDetailInfoVC.xib in Resources */, @@ -1701,6 +1708,7 @@ 13985DB82C69B80D0046B6DC /* Themes.swift in Sources */, 13985DD02C69F2A80046B6DC /* HomeHeaderVC.swift in Sources */, 135D09212C9167F800658880 /* TreeTeskDetailListTCell.swift in Sources */, 138F9E0F2CF4229500075C5D /* PurchaseMethodView.swift in Sources */, 130AA4A92C72F71700F20944 /* CourseDetialVideoVC.swift in Sources */, 1336EFA52C6DEB550075E070 /* HoverHeaderFlowLayout.swift in Sources */, 13985DB52C69B7DF0046B6DC /* Def.swift in Sources */, XQMuse/Assets.xcassets/Btns/btn_aP.imageset/Contents.json
New file @@ -0,0 +1,22 @@ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "filename" : "btn_aP@2x.png", "idiom" : "universal", "scale" : "2x" }, { "filename" : "btn_aP@3x.png", "idiom" : "universal", "scale" : "3x" } ], "info" : { "author" : "xcode", "version" : 1 } } XQMuse/Assets.xcassets/Btns/btn_aP.imageset/btn_aP@2x.png
XQMuse/Assets.xcassets/Btns/btn_aP.imageset/btn_aP@3x.png
XQMuse/Assets.xcassets/Btns/btn_aP_1.imageset/Contents.json
New file @@ -0,0 +1,22 @@ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "filename" : "btn_aP_1@2x.png", "idiom" : "universal", "scale" : "2x" }, { "filename" : "btn_aP_1@3x.png", "idiom" : "universal", "scale" : "3x" } ], "info" : { "author" : "xcode", "version" : 1 } } XQMuse/Assets.xcassets/Btns/btn_aP_1.imageset/btn_aP_1@2x.png
XQMuse/Assets.xcassets/Btns/btn_aP_1.imageset/btn_aP_1@3x.png
XQMuse/Assets.xcassets/Btns/btn_apple.imageset/Contents.json
New file @@ -0,0 +1,22 @@ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "filename" : "btn_apple@2x.png", "idiom" : "universal", "scale" : "2x" }, { "filename" : "btn_apple@3x.png", "idiom" : "universal", "scale" : "3x" } ], "info" : { "author" : "xcode", "version" : 1 } } XQMuse/Assets.xcassets/Btns/btn_apple.imageset/btn_apple@2x.png
XQMuse/Assets.xcassets/Btns/btn_apple.imageset/btn_apple@3x.png
XQMuse/Assets.xcassets/Btns/btn_wxP.imageset/Contents.json
New file @@ -0,0 +1,22 @@ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "filename" : "btn_wxP@2x.png", "idiom" : "universal", "scale" : "2x" }, { "filename" : "btn_wxP@3x.png", "idiom" : "universal", "scale" : "3x" } ], "info" : { "author" : "xcode", "version" : 1 } } XQMuse/Assets.xcassets/Btns/btn_wxP.imageset/btn_wxP@2x.png
XQMuse/Assets.xcassets/Btns/btn_wxP.imageset/btn_wxP@3x.png
XQMuse/Assets.xcassets/Btns/btn_wxP_1.imageset/Contents.json
New file @@ -0,0 +1,22 @@ { "images" : [ { "idiom" : "universal", "scale" : "1x" }, { "filename" : "btn_wxP_1@2x.png", "idiom" : "universal", "scale" : "2x" }, { "filename" : "btn_wxP_1@3x.png", "idiom" : "universal", "scale" : "3x" } ], "info" : { "author" : "xcode", "version" : 1 } } XQMuse/Assets.xcassets/Btns/btn_wxP_1.imageset/btn_wxP_1@2x.png
XQMuse/Assets.xcassets/Btns/btn_wxP_1.imageset/btn_wxP_1@3x.png
XQMuse/Config/Enums/Enums.swift
@@ -100,6 +100,21 @@ } } var titleContent:String{ switch self { case .level_1:return "亲爱的家人,生命之树的种子已植入这片沃土,请以农夫的心态用心浇灌,为你加油哦。" case .level_2:return "恭喜您,种子发芽了,爱的旅程已经开始,为你加油!" case .level_3:return "幼苗拔地而起,智慧俏然萌发,前方的道路,更加的明亮,继续努力吧!" case .level_4:return "树苗任成长,内心变得更加的柔软包容。未来正在向你招手。" case .level_5:return "小树扎下了深深的根,离爱的梦想越来越近,继续坚持吧。" case .level_6:return "大树已枝繁叶茂,自由的伸展,你的努力成就了这份美好,未来将更加的璀璨。" case .level_7:return "智慧之花即将绽放,满载着希望与能量,前路无限的可能!" case .level_8:return "恭喜你,智慧的花朵已经绽放,让我们走在充满芬芳的道路上吧!" case .level_9:return "智慧之花开满枝头,满满的活力和美好,向你涌来了!" case .level_10:return "真爱的果实已挂满枝头,丰盛而充实,人生如此美好,感谢您的浇灌!" } } var sound:String{ switch self { case .level_1: return oss_domain + "/xinquan/1d3254a9966b476789491032d8bb908a.wav" XQMuse/Root/Home/VC/BackgroundVoiceVC.swift
@@ -144,19 +144,6 @@ }else{ DispatchQueue.main.asyncAfter(delay: 0.6) { self.navigationController?.popViewController() let miniProgram = WXLaunchMiniProgramReq.object() #if DEBUG miniProgram.miniProgramType = .preview #else miniProgram.miniProgramType = .release #endif miniProgram.path = "" WXApi.send(miniProgram){ s in if !s{ alert(msg: "打开失败") } } } } } XQMuse/Root/Home/VC/PaymentOrderResultVC.swift
@@ -185,7 +185,7 @@ } }).disposed(by: disposeBag) case .none:break default:break } } XQMuse/Root/Home/VC/PaymentOrderVC.swift
@@ -11,66 +11,95 @@ let Refreh_PaymentWallet_Noti = Notification.Name.init("Refreh_PaymentWallet_Noti") enum TapType{ case t1 case t2 //z__f__b case t3 //w__x } class PaymentOrderVC: BaseVC { enum PaymentOrderType { case course case muse enum PaymentOrderType:Int{ case muse = 1 case course = 2 case vip = 3 case recharge = 4 } @IBOutlet weak var image_cover: UIImageView! @IBOutlet weak var label_price: UILabel! @IBOutlet weak var label_teacher: UILabel! @IBOutlet weak var label_paymentCount: UILabel! @IBOutlet weak var label_courseName: UILabel! @IBOutlet weak var label_orderPrice: UILabel! @IBOutlet weak var label_currentAccount: UILabel! @IBOutlet weak var label_totalPrice: UILabel! @IBOutlet weak var view_searchUserInput: UIView! @IBOutlet weak var view_searchUserResult: UIView! @IBOutlet weak var image_cover: UIImageView! @IBOutlet weak var label_price: UILabel! @IBOutlet weak var label_teacher: UILabel! @IBOutlet weak var label_paymentCount: UILabel! @IBOutlet weak var label_courseName: UILabel! @IBOutlet weak var label_orderPrice: UILabel! @IBOutlet weak var label_currentAccount: UILabel! @IBOutlet weak var label_totalPrice: UILabel! @IBOutlet weak var view_searchUserInput: UIView! @IBOutlet weak var view_searchUserResult: UIView! @IBOutlet weak var image_avatar: UIImageView! @IBOutlet weak var label_userName: UILabel! @IBOutlet weak var label_userPhone: UILabel! @IBOutlet weak var label_searchInfo: UILabel! @IBOutlet weak var btn_invate: UIButton! @IBOutlet weak var btn_isRead: UIButton! @IBOutlet weak var image_avatar: UIImageView! @IBOutlet weak var label_userName: UILabel! @IBOutlet weak var label_userPhone: UILabel! @IBOutlet weak var label_searchInfo: UILabel! @IBOutlet weak var btn_invate: UIButton! @IBOutlet weak var btn_isRead: UIButton! @IBOutlet weak var tf_phone: QMUITextField! @IBOutlet weak var label_walletBalance: UILabel! @IBOutlet weak var btn_isreadAgreement: UIButton! private var museItemModel:MeditationModel? @IBOutlet weak var tf_phone: QMUITextField! @IBOutlet weak var label_walletBalance: UILabel! @IBOutlet weak var btn_isreadAgreement: UIButton! @IBOutlet weak var label_p_1: UILabel! @IBOutlet weak var label_p_2: UILabel! @IBOutlet weak var btn_tap0: TapBtn! @IBOutlet weak var btn_tap1: TapBtn! @IBOutlet weak var btn_tap2: TapBtn! @IBOutlet weak var img_action_1: UIImageView! @IBOutlet weak var img_action_2: UIImageView! @IBOutlet weak var img_action_3: UIImageView! private var tapType:TapType? private var isShowMore:Bool = false private var discountByCoin:Bool = false private var museItemModel:MeditationModel? private var courseItemModel:CourseModel? private var giftUserId:Int? private var giftToOther:Bool! private var courseModel:CourseModel? private var giftUserId:Int? private var giftToOther:Bool! private var courseModel:CourseModel? private var museModel:MeditationModel? private var balance:Double = 0 private var balance:Double = 0 private var type:PaymentOrderType! private var showType:DisplayType! private var businessId:Int? private var orderId:String? //下单后的ID init(museItemModel:MeditationModel? = nil,courseItemModel:CourseModel? = nil,type:PaymentOrderType,giftToOther:Bool = false,showType:DisplayType!,businessId:Int? = nil) { super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil) self.museItemModel = museItemModel self.courseItemModel = courseItemModel self.giftToOther = giftToOther self.giftToOther = giftToOther self.type = type self.showType = showType self.businessId = businessId } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() title = "确认订单" view_searchUserResult.isHidden = true view_searchUserInput.isHidden = !giftToOther } getBalance() required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func viewDidLoad() { super.viewDidLoad() title = "确认订单" btn_tap0.isUserInteractionEnabled = false view_searchUserResult.isHidden = true view_searchUserInput.isHidden = !giftToOther img_action_1.image = UIImage(named: "icon_choose_small_s") getBalance() let btn = UIButton(type: .custom) btn.setTitle("取消订单", for: .normal) @@ -88,11 +117,19 @@ self.courseModel = m self.image_cover.sd_setImage(with: URL(string: m.coverUrl.components(separatedBy: ",").first?.jq_urlEncoded())) self.label_courseName.text = m.courseTitle self.label_price.text = "愈疗币\(m.iosPrice.jq_formatFloat)" self.label_teacher.text = "导师 \(m.tutor)" self.label_paymentCount.text = "x1" self.label_orderPrice.text = "愈疗币\(m.iosPrice.jq_formatFloat)" self.label_totalPrice.text = "愈疗币\(m.iosPrice.jq_formatFloat)" if self.isShowMore{ self.label_price.text = "¥\(m.iosPrice.jq_formatFloat)" self.label_orderPrice.text = "¥\(m.iosPrice.jq_formatFloat)" self.label_totalPrice.text = "¥\(m.iosPrice.jq_formatFloat)" }else{ self.label_price.text = "愈疗币\(m.iosPrice.jq_formatFloat)" self.label_orderPrice.text = "愈疗币\(m.iosPrice.jq_formatFloat)" self.label_totalPrice.text = "愈疗币\(m.iosPrice.jq_formatFloat)" } } }).disposed(by: disposeBag) } @@ -101,31 +138,104 @@ 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 self.image_cover.sd_setImage(with: URL(string: m.coverUrl.components(separatedBy: ",").first?.jq_urlEncoded())) self.label_courseName.text = m.meditationTitle self.label_price.text = "愈疗币\(m.iosPrice.jq_formatFloat)" self.label_teacher.text = "" self.label_paymentCount.text = "x1" self.label_orderPrice.text = "愈疗币\(m.iosPrice.jq_formatFloat)" self.label_totalPrice.text = "愈疗币\(m.iosPrice.jq_formatFloat)" if self.isShowMore{ self.label_price.text = "¥\(m.iosPrice.jq_formatFloat)" self.label_orderPrice.text = "¥\(m.iosPrice.jq_formatFloat)" self.label_totalPrice.text = "¥\(m.iosPrice.jq_formatFloat)" }else{ self.label_price.text = "愈疗币\(m.iosPrice.jq_formatFloat)" self.label_orderPrice.text = "愈疗币\(m.iosPrice.jq_formatFloat)" self.label_totalPrice.text = "愈疗币\(m.iosPrice.jq_formatFloat)" } } }).disposed(by: disposeBag) } Services.getTurn().subscribe(onNext: {[weak self]data in guard let weakSelf = self else { return } if let m = data.data,m == true{ weakSelf.btn_tap0.isUserInteractionEnabled = true weakSelf.isShowMore = m weakSelf.img_action_1.image = UIImage(named: "icon_choose_small_1") weakSelf.btn_tap1.isHidden = !m weakSelf.btn_tap2.isHidden = !m weakSelf.getBalance() if let m = weakSelf.courseModel{ weakSelf.label_price.text = "¥\(m.iosPrice.jq_formatFloat)" weakSelf.label_orderPrice.text = "¥\(m.iosPrice.jq_formatFloat)" weakSelf.label_totalPrice.text = "¥\(m.iosPrice.jq_formatFloat)" } if let m = weakSelf.museModel{ weakSelf.label_price.text = "¥\(m.iosPrice.jq_formatFloat)" weakSelf.label_orderPrice.text = "¥\(m.iosPrice.jq_formatFloat)" weakSelf.label_totalPrice.text = "¥\(m.iosPrice.jq_formatFloat)" } } }).disposed(by: disposeBag) } override func setUI() { super.setUI() } override func setUI() { super.setUI() override func setRx() { NotificationCenter.default.rx.notification(Refreh_PaymentWallet_Noti).take(until: self.rx.deallocated).subscribe(onNext: {_ in self.getBalance() }).disposed(by: disposeBag) } label_p_1.text = ("支"+"付").appending("宝").appending("支").appending("付") label_p_2.text = ("微"+"信").appending("支").appending("付") } override func setRx() { NotificationCenter.default.rx.notification(Refreh_PaymentWallet_Noti).take(until: self.rx.deallocated).subscribe(onNext: {_ in self.getBalance() }).disposed(by: disposeBag) NotificationCenter.default.rx.notification(UIApplication.didBecomeActiveNotification).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] _ in guard let weakSelf = self else { return } if weakSelf.isShowMore && weakSelf.orderId != nil{ Services.queryPayment(orderId: weakSelf.orderId!).subscribe(onNext: {data in if let str = data.data{ switch str{ case "succeeded": alertSuccess(msg: "购买成功") var id = 0 var money:Double = 0 switch weakSelf.type { case .muse: id = weakSelf.museModel!.id money = weakSelf.museModel!.iosPrice case .course: id = weakSelf.courseModel!.id money = weakSelf.courseModel!.iosPrice default:break } let vc = PaymentOrderResultVC(type: weakSelf.type, id: id, price: money) weakSelf.push(vc: vc) case "failed": alertError(msg: "购买失败") case "closed": alertError(msg: "交易已关闭") case "refunded": alertError(msg: "全额退款") case "pending": alertError(msg: "待支付") default:break } } }).disposed(by: weakSelf.disposeBag) } }).disposed(by: disposeBag) } @objc private func cancelAction(){ if businessId != nil{ @@ -147,45 +257,95 @@ } } private func getBalance(){ Services.getUserBalance().subscribe(onNext: {data in self.balance = data.data ?? 0 self.label_walletBalance.text = String(format: "当前可用 %@疗愈币", data.data?.jq_formatFloat ?? "0") }).disposed(by: disposeBag) } private func getBalance(){ Services.getUserBalance().subscribe(onNext: {data in self.balance = data.data ?? 0 if self.isShowMore{ self.label_walletBalance.text = String(format: "当前可用 ¥%@", data.data?.jq_formatFloat ?? "0") }else{ self.label_walletBalance.text = String(format: "当前可用 %@疗愈币", data.data?.jq_formatFloat ?? "0") } }).disposed(by: disposeBag) } @IBAction func invateRegisterAction(_ sender: UIButton) { @IBAction func discountByCoinAction(_ sender: TapBtn) { discountByCoin.toggle() if discountByCoin{ img_action_1.image = UIImage(named: "icon_choose_small_s") }else{ img_action_1.image = UIImage(named: "icon_choose_small_1") } var price:Double = 0 switch type { case .course: if discountByCoin{ price = max((courseModel?.iosPrice ?? 0) - balance,0) }else{ price = courseModel?.iosPrice ?? 0 } case .muse: if discountByCoin{ price = max((museModel?.iosPrice ?? 0) - balance,0) }else{ price = museModel?.iosPrice ?? 0 } default:break } label_totalPrice.text = "¥" + price.jq_formatFloat } @IBAction func chooseAction(_ sender: TapBtn) { switch sender.tag { case 2001: tapType = .t2 img_action_2.image = UIImage(named: "icon_choose_small_s") img_action_3.image = UIImage(named: "icon_choose_small_1") case 2002: tapType = .t3 img_action_2.image = UIImage(named: "icon_choose_small_1") img_action_3.image = UIImage(named: "icon_choose_small_s") default: break } } @IBAction func invateRegisterAction(_ sender: UIButton) { let string = String(format: "%@%@?userId=%ld",ShareUrl,"/register/register",UserViewModel.getAvatarInfo().id) ShareView.show(URL(string: string)!, title: "分享疗愈时光,让宁静触手可及", desc: "这份疗愈之旅,带来了意想不到的平静和安宁。愿与你一同分享,让我们在繁忙的生活中找到片刻的温柔,静享属于我们的宁静时光。",hasSave: false) { // alertSuccess(msg: "已保存至相册") // alertSuccess(msg: "已保存至相册") } } } @IBAction func searchUserAction(_ sender: UIButton) { @IBAction func searchUserAction(_ sender: UIButton) { tf_phone.resignFirstResponder() guard !tf_phone.text!.isEmpty else { alertError(msg: tf_phone.placeholder ?? "请输入好友手机号");return } guard !tf_phone.text!.isEmpty else { alertError(msg: tf_phone.placeholder ?? "请输入好友手机号");return } guard tf_phone.text!.jq_isPhone else { alertError(msg: "请输入正确的手机号");return } guard tf_phone.text!.jq_isPhone else { alertError(msg: "请输入正确的手机号");return } Services.searchUserByPhone(tf_phone.text!,ignoreAlert: false).subscribe(onNext: { data in self.view_searchUserResult.isHidden = false if let m = data.data,m.id != 0{ 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 self.view_searchUserResult.isHidden = false if let m = data.data,m.id != 0{ 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 self.image_avatar.isHidden = false self.label_userName.isHidden = false self.label_userPhone.isHidden = false self.btn_invate.isHidden = true } } },onError: { _ in self.view_searchUserResult.isHidden = false self.image_avatar.isHidden = true @@ -195,14 +355,14 @@ self.btn_invate.isHidden = false }).disposed(by: disposeBag) } } @IBAction func readAgreementAction(_ sender: UIButton) { sender.isSelected = !sender.isSelected } @IBAction func readAgreementAction(_ sender: UIButton) { sender.isSelected = !sender.isSelected } @IBAction func webAgreementAction(_ sender: UIButton) { @IBAction func webAgreementAction(_ sender: UIButton) { Services.agreementBy(.course).subscribe(onNext: {data in if let model = data.data{ @@ -213,9 +373,9 @@ self.present(vc, animated: true) } }).disposed(by: disposeBag) } } @IBAction func completeAction(_ sender: UIButton) { @IBAction func completeAction(_ sender: UIButton) { var money:Double = 0 @@ -249,18 +409,72 @@ } } guard balance > money else{ CommonAlertView.show(title: "提示", content: "当前余额不足,请先充值", cancelStr: "暂不充值", completeStr: "去充值", isSingle: false) {[weak self] state in if state{ let vc = WalletRechargeVC() self?.push(vc: vc) } } return } if isShowMore{ guard tapType != nil else {alertError(msg: "请选择支付方式");return} if businessId != nil{ Services.gvieCourseAgain(orderForm: type, id: businessId!).subscribe(onNext: {[weak self]data in var price:Double = 0 var targetId:Int = 0 switch type { case .course: price = courseModel!.iosPrice targetId = courseModel!.id case .muse: price = museModel!.iosPrice targetId = museModel!.id default:break } if discountByCoin && balance < price{ alertError(msg: "抵扣余额不足");return } Services.placeOrder(orderForm: type, payType: tapType == .t2 ? 2:1, amount: nil, balanceFlag: discountByCoin ? 1:2, orderId: nil, receiverId: giftUserId, targetId: targetId, vipType: nil).subscribe(onNext: { [self] data in if let m = data.data{ self.orderId = m.orderId if self.tapType == .t2{ UIApplication.shared.open(URL(string: m.qrcodeUrl!)!) } if self.tapType == .t3{ let miniProgram = WXLaunchMiniProgramReq.object() miniProgram.miniProgramType = .release miniProgram.userName = m.orgId! miniProgram.path = m.path! WXApi.send(miniProgram){ s in if !s{ alert(msg: "打开失败") } } } } }).disposed(by: disposeBag) }else{ guard balance > money else{ CommonAlertView.show(title: "提示", content: "当前余额不足,请先充值", cancelStr: "暂不充值", completeStr: "去充值", isSingle: false) {[weak self] state in if state{ let vc = WalletRechargeVC() self?.push(vc: vc) } } 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 self?.courseItemModel?.isBuy = .yes @@ -269,18 +483,6 @@ 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 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) } } } XQMuse/Root/Home/VC/PaymentOrderVC.xib
@@ -14,11 +14,19 @@ <outlet property="btn_invate" destination="3oo-WM-iPM" id="gMF-RC-xpe"/> <outlet property="btn_isRead" destination="9jh-cC-nHB" id="a2J-f4-hup"/> <outlet property="btn_isreadAgreement" destination="9jh-cC-nHB" id="kmT-qh-HGA"/> <outlet property="btn_tap0" destination="dXP-rs-EAP" id="VVG-3s-zFi"/> <outlet property="btn_tap1" destination="TIy-tQ-4jx" id="yel-Bf-h8a"/> <outlet property="btn_tap2" destination="Lax-s0-pLF" id="ybD-wq-wdK"/> <outlet property="image_avatar" destination="TT7-tl-th0" id="5bW-5j-b49"/> <outlet property="image_cover" destination="LBY-Q2-RQA" id="ygZ-SN-xO1"/> <outlet property="img_action_1" destination="XNw-nK-MjP" id="PuF-MB-7qT"/> <outlet property="img_action_2" destination="1jC-lI-k0J" id="xZG-0U-O0Q"/> <outlet property="img_action_3" destination="gVr-M3-Rrs" id="ooh-aj-9Um"/> <outlet property="label_courseName" destination="GMw-pK-u8J" id="bFk-Vl-gDP"/> <outlet property="label_currentAccount" destination="W3z-Hl-09j" id="Lrx-D9-x8Y"/> <outlet property="label_orderPrice" destination="s0D-hY-lov" id="Y0T-c6-a7g"/> <outlet property="label_p_1" destination="ODE-gf-7HU" id="KxB-TH-xan"/> <outlet property="label_p_2" destination="vob-vP-CEg" id="5ic-6b-ggp"/> <outlet property="label_paymentCount" destination="hW7-II-bKY" id="6Oe-Qv-0S4"/> <outlet property="label_price" destination="iyN-A8-Fyo" id="2M1-II-1hx"/> <outlet property="label_searchInfo" destination="jVb-Rt-nvY" id="Vty-h8-0vY"/> @@ -310,7 +318,7 @@ <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="w7E-wj-goh"> <rect key="frame" x="0.0" y="347.33333333333331" width="377" height="57"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dXP-rs-EAP"> <view tag="2000" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dXP-rs-EAP" customClass="TapBtn" customModule="XQMuse" customModuleProvider="target"> <rect key="frame" x="0.0" y="0.0" width="377" height="57"/> <subviews> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_wallet" translatesAutoresizingMaskIntoConstraints="NO" id="3oH-OO-NEc"> @@ -328,7 +336,7 @@ <color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.55686274509803924" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_choose_small_s" translatesAutoresizingMaskIntoConstraints="NO" id="XNw-nK-MjP"> <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="1001" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_choose_small_s" translatesAutoresizingMaskIntoConstraints="NO" id="XNw-nK-MjP"> <rect key="frame" x="347.33333333333331" y="20.333333333333371" width="15.666666666666686" height="16"/> </imageView> </subviews> @@ -344,6 +352,69 @@ <constraint firstAttribute="trailing" secondItem="XNw-nK-MjP" secondAttribute="trailing" constant="14" id="reU-yz-Jef"/> <constraint firstItem="W3z-Hl-09j" firstAttribute="centerY" secondItem="3oH-OO-NEc" secondAttribute="centerY" id="rf6-DL-KBg"/> </constraints> <connections> <action selector="discountByCoinAction:" destination="-1" eventType="touchUpInside" id="BeY-oe-tIv"/> </connections> </view> <view hidden="YES" tag="2001" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TIy-tQ-4jx" customClass="TapBtn" customModule="XQMuse" customModuleProvider="target"> <rect key="frame" x="0.0" y="0.0" width="377" height="57"/> <subviews> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="btn_aP" translatesAutoresizingMaskIntoConstraints="NO" id="s2J-uX-S9K"> <rect key="frame" x="13.000000000000002" y="18" width="20.666666666666671" height="21"/> </imageView> <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="1001" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_choose_small_1" translatesAutoresizingMaskIntoConstraints="NO" id="1jC-lI-k0J"> <rect key="frame" x="347" y="20.333333333333371" width="16" height="16"/> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="余额抵扣" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ODE-gf-7HU"> <rect key="frame" x="41.333333333333343" y="20" width="55.666666666666657" height="17"/> <fontDescription key="fontDescription" type="boldSystem" pointSize="14"/> <color key="textColor" red="0.15686274510000001" green="0.15686274510000001" blue="0.15686274510000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstItem="s2J-uX-S9K" firstAttribute="centerY" secondItem="TIy-tQ-4jx" secondAttribute="centerY" id="SaV-Ww-mse"/> <constraint firstAttribute="trailing" secondItem="1jC-lI-k0J" secondAttribute="trailing" constant="14" id="alr-Te-IIX"/> <constraint firstAttribute="height" constant="57" id="ePw-lf-uo6"/> <constraint firstItem="ODE-gf-7HU" firstAttribute="centerY" secondItem="s2J-uX-S9K" secondAttribute="centerY" id="igo-kE-piM"/> <constraint firstItem="ODE-gf-7HU" firstAttribute="leading" secondItem="s2J-uX-S9K" secondAttribute="trailing" constant="7.5" id="lzs-zH-OmT"/> <constraint firstItem="1jC-lI-k0J" firstAttribute="centerY" secondItem="TIy-tQ-4jx" secondAttribute="centerY" id="n0I-s6-cMi"/> <constraint firstItem="s2J-uX-S9K" firstAttribute="leading" secondItem="TIy-tQ-4jx" secondAttribute="leading" constant="13" id="r6n-tk-Erz"/> </constraints> <connections> <action selector="chooseAction:" destination="-1" eventType="touchUpInside" id="ft5-IK-0Hj"/> </connections> </view> <view hidden="YES" tag="2002" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Lax-s0-pLF" customClass="TapBtn" customModule="XQMuse" customModuleProvider="target"> <rect key="frame" x="0.0" y="0.0" width="377" height="57"/> <subviews> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="btn_wxP" translatesAutoresizingMaskIntoConstraints="NO" id="dNI-Qd-f0r"> <rect key="frame" x="13" y="19.666666666666686" width="20" height="17.666666666666671"/> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="余额抵扣" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vob-vP-CEg"> <rect key="frame" x="40.666666666666671" y="20" width="55.666666666666671" height="17"/> <fontDescription key="fontDescription" type="boldSystem" pointSize="14"/> <color key="textColor" red="0.15686274510000001" green="0.15686274510000001" blue="0.15686274510000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> <imageView clipsSubviews="YES" userInteractionEnabled="NO" tag="1001" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_choose_small_1" translatesAutoresizingMaskIntoConstraints="NO" id="gVr-M3-Rrs"> <rect key="frame" x="347" y="20.333333333333371" width="16" height="16"/> </imageView> </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstAttribute="trailing" secondItem="gVr-M3-Rrs" secondAttribute="trailing" constant="14" id="3k3-oO-FdX"/> <constraint firstItem="vob-vP-CEg" firstAttribute="leading" secondItem="dNI-Qd-f0r" secondAttribute="trailing" constant="7.5" id="8gd-K4-W5I"/> <constraint firstItem="dNI-Qd-f0r" firstAttribute="leading" secondItem="Lax-s0-pLF" secondAttribute="leading" constant="13" id="CbR-5g-VUW"/> <constraint firstItem="dNI-Qd-f0r" firstAttribute="centerY" secondItem="Lax-s0-pLF" secondAttribute="centerY" id="c2U-rK-O2p"/> <constraint firstAttribute="height" constant="57" id="gg9-eo-koC"/> <constraint firstItem="gVr-M3-Rrs" firstAttribute="centerY" secondItem="Lax-s0-pLF" secondAttribute="centerY" id="u9T-Kt-zGf"/> <constraint firstItem="vob-vP-CEg" firstAttribute="centerY" secondItem="dNI-Qd-f0r" secondAttribute="centerY" id="ykf-sm-d2b"/> </constraints> <connections> <action selector="chooseAction:" destination="-1" eventType="touchUpInside" id="5dz-Ha-lYJ"/> </connections> </view> </subviews> <userDefinedRuntimeAttributes> @@ -490,11 +561,14 @@ </view> </objects> <resources> <image name="btn_aP" width="20.666666030883789" height="21"/> <image name="btn_wxP" width="20" height="17.666666030883789"/> <image name="icon_choose_small_1" width="16" height="16"/> <image name="icon_choose_small_2" width="13" height="13"/> <image name="icon_choose_small_s" width="15.666666984558105" height="16"/> <image name="icon_wallet" width="21.666666030883789" height="21.666666030883789"/> <systemColor name="separatorColor"> <color red="0.23529411759999999" green="0.23529411759999999" blue="0.26274509800000001" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/> <color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/> </systemColor> <systemColor name="systemBackgroundColor"> <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> XQMuse/Root/Home/View/PaymentOrderResultTopView.swift
@@ -32,6 +32,7 @@ switch type { case .course:btn_lookCourse.setTitle("查看课程", for: .normal) case .muse:btn_lookCourse.setTitle("查看疗愈", for: .normal) default:break } } XQMuse/Root/Me/VC/VIPCenterVC.swift
@@ -26,6 +26,10 @@ private var productList = Set<String>() private var products = [SKProduct]() private var timeLoopDisposeBag = DisposeBag() private var vipContentModel:VIPContentModel? private var isShowMore:Bool = false private var orderId:String? //下单后的ID override func viewDidLoad() { super.viewDidLoad() @@ -34,6 +38,20 @@ 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") 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.dataSource = self @@ -79,6 +97,34 @@ } }).disposed(by: disposeBag) NotificationCenter.default.rx.notification(UIApplication.didBecomeActiveNotification).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] _ in guard let weakSelf = self else { return } if weakSelf.isShowMore && weakSelf.orderId != nil{ Services.queryPayment(orderId: weakSelf.orderId!).subscribe(onNext: {data in if let str = data.data{ switch str{ case "succeeded": alertSuccess(msg: "购买成功") weakSelf.timeLoopDisposeBag = DisposeBag() NotificationCenter.default.post(name: UpdateUserProfile_Noti, object: nil, userInfo: nil) DispatchQueue.main.asyncAfter(delay: 1.0) { weakSelf.navigationController?.popViewController() } case "failed": alertError(msg: "购买失败") case "closed": alertError(msg: "交易已关闭") case "refunded": alertError(msg: "全额退款") case "pending": alertError(msg: "待支付") default:break } } }).disposed(by: weakSelf.disposeBag) } }).disposed(by: disposeBag) } @IBAction func completeAction(_ sender: UIButton) { @@ -86,50 +132,86 @@ alert(msg: "请先阅读并同意《会员用户协议》");return } showHUD("正在进行内购买") guard products.count != 0 else {return} let oldVipExpireTime = UserViewModel.getAvatarInfo().vipExpireTime if isShowMore{ guard let vipContentModel else { return } let product = products[selectIndex] let userId = UserViewModel.getAvatarInfo().userId.string InPurchaseManager.purchaseProduct(ID: product.productIdentifier, applicationUsername: userId) {[weak self]result in guard let weakSelf = self else { return } if result.status == 0{ hiddenHUD() let transactionId = result.receipt?.in_app.first?.original_transaction_id ?? "" var amount:Double = 0 switch selectIndex{ case 0:amount = Double(vipContentModel.monthlyVipIos) case 1:amount = Double(vipContentModel.quarterlyVipIos) case 2:amount = Double(vipContentModel.annualVipIos) default:break } showHUD("正在查询购买结果") Services.placeOrderApple(amount: product.price.doubleValue, balanceFlag: .no, orderFrom: 3, transactionIdentifier: transactionId, vipType: weakSelf.selectIndex + 1).subscribe(onNext: { data in showHUD("正在查询购买结果") let observable = Observable<Int>.interval(RxTimeInterval.seconds(5), scheduler: MainScheduler.instance) observable.subscribe { event in if event.element == 10{ alertError(msg: "订单异常") weakSelf.timeLoopDisposeBag = DisposeBag() return PurchaseMethodView.show {[weak self] type in guard let weakSelf = self else { return } Services.placeOrder(orderForm: .vip, payType: type == .t2 ? 2:1, amount: amount, balanceFlag: nil, orderId: nil, receiverId: nil, targetId: nil, vipType: weakSelf.selectIndex + 1).subscribe(onNext: { data in if let m = data.data{ weakSelf.orderId = m.orderId if type == .t2{ UIApplication.shared.open(URL(string: m.qrcodeUrl!)!) } Services.getUserDetail(showProgress: false).subscribe(onNext: {data in if data.data?.vipExpireTime != oldVipExpireTime{ hiddenHUD() alertSuccess(msg: "购买成功") weakSelf.timeLoopDisposeBag = DisposeBag() NotificationCenter.default.post(name: UpdateUserProfile_Noti, object: nil, userInfo: nil) DispatchQueue.main.asyncAfter(delay: 1.0) { weakSelf.navigationController?.popViewController() if type == .t3{ let miniProgram = WXLaunchMiniProgramReq.object() miniProgram.miniProgramType = .release miniProgram.userName = m.orgId! miniProgram.path = m.path! WXApi.send(miniProgram){ s in if !s{ alert(msg: "打开失败") } } }).disposed(by: weakSelf.disposeBag) }.disposed(by: weakSelf.timeLoopDisposeBag) } } }).disposed(by: weakSelf.disposeBag) } } errorClouse: { error in alertError(msg: "支付失败") }else{ showHUD("正在进行内购买") guard products.count != 0 else {return} let oldVipExpireTime = UserViewModel.getAvatarInfo().vipExpireTime let product = products[selectIndex] let userId = UserViewModel.getAvatarInfo().userId.string InPurchaseManager.purchaseProduct(ID: product.productIdentifier, applicationUsername: userId) {[weak self]result in guard let weakSelf = self else { return } if result.status == 0{ hiddenHUD() let transactionId = result.receipt?.in_app.first?.original_transaction_id ?? "" showHUD("正在查询购买结果") Services.placeOrderApple(amount: product.price.doubleValue, balanceFlag: .no, orderFrom: 3, transactionIdentifier: transactionId, vipType: weakSelf.selectIndex + 1).subscribe(onNext: { data in showHUD("正在查询购买结果") let observable = Observable<Int>.interval(RxTimeInterval.seconds(5), scheduler: MainScheduler.instance) observable.subscribe { event in if event.element == 10{ alertError(msg: "订单异常") weakSelf.timeLoopDisposeBag = DisposeBag() return } Services.getUserDetail(showProgress: false).subscribe(onNext: {data in if data.data?.vipExpireTime != oldVipExpireTime{ hiddenHUD() alertSuccess(msg: "购买成功") weakSelf.timeLoopDisposeBag = DisposeBag() NotificationCenter.default.post(name: UpdateUserProfile_Noti, object: nil, userInfo: nil) DispatchQueue.main.asyncAfter(delay: 1.0) { weakSelf.navigationController?.popViewController() } } }).disposed(by: weakSelf.disposeBag) }.disposed(by: weakSelf.timeLoopDisposeBag) }).disposed(by: weakSelf.disposeBag) } } errorClouse: { error in alertError(msg: "支付失败") } } } @IBAction func readAction(_ sender: UIButton) { btn_isRead.isSelected = !btn_isRead.isSelected } @IBAction func agreementAction(_ sender: UIButton) { @@ -155,12 +237,21 @@ func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! VipCenterCCell let product = products[indexPath.row] cell.isSelect(indexPath.row == selectIndex,product: product) if vipContentModel != nil{ cell.isSelect(indexPath.row == selectIndex, indexPath: indexPath, vipContentModel: vipContentModel!) }else{ let product = products[indexPath.row] cell.isSelect(indexPath.row == selectIndex,product: product) } return cell } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { if vipContentModel != nil{ return 3 } return products.count } } @@ -260,6 +351,41 @@ } } func isSelect(_ state:Bool,indexPath:IndexPath,vipContentModel:VIPContentModel){ var price:Int = 0 switch indexPath.row{ case 0: price = vipContentModel.monthlyVipIos label_title.text = "月度会员" label_price.text = "¥" + vipContentModel.monthlyVipIos.string lable_priorDay.text = String(format: "¥%.2lf/天", vipContentModel.monthlyVipIos.double / 30.0) case 1: price = vipContentModel.quarterlyVipIos label_title.text = "半年会员" label_price.text = "¥" + vipContentModel.quarterlyVipIos.string lable_priorDay.text = String(format: "¥%.2lf/天", vipContentModel.quarterlyVipIos.double / 30.0) case 2: price = vipContentModel.annualVipIos label_title.text = "年度会员" label_price.text = "¥" + vipContentModel.annualVipIos.string lable_priorDay.text = String(format: "¥%.2lf/天", vipContentModel.annualVipIos.double / 30.0) default:break } if state{ contentView.backgroundColor = UIColor(hexString: "#A6C586") label_title.textColor = .white lable_priorDay.textColor = .white label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: .systemFont(ofSize: 15, weight:.heavy), withColor: .white).add(string: "\(price)", withFont: .systemFont(ofSize: 20, weight:.heavy), withColor: .white).mutableAttributedString }else{ contentView.backgroundColor = UIColor(hexString: "#EFF2F2") label_title.textColor = UIColor(hexString: "#353535") lable_priorDay.textColor = UIColor(hexString: "#B7B7B7") label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: .systemFont(ofSize: 15, weight:.heavy), withColor: UIColor(hexString: "#353535")!).add(string: "\(price)", withFont: .systemFont(ofSize: 20, weight:.heavy), withColor: UIColor(hexString: "#353535")!).mutableAttributedString } } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } XQMuse/Root/Me/VC/WalletRechargeVC.swift
@@ -12,9 +12,12 @@ class WalletRechargeVC: BaseVC { @IBOutlet weak var stackView: UIStackView! @IBOutlet weak var tap_other: TapBtn! @IBOutlet weak var btn_handle: UIButton! @IBOutlet weak var collectionView: UICollectionView! @IBOutlet weak var cons_collectionHei: NSLayoutConstraint! @IBOutlet weak var tap_other_title: UILabel! private var selectIndexPath = IndexPath(row: 0, section: 0) private let cellW = (JQ_ScreenW - (24 * 2) - 3 * 27) / 4 @@ -23,10 +26,24 @@ private var products = [SKProduct]() private var oldPrice:Double = 0 private var timeLoopDisposeBag = DisposeBag() private var isShowMore:Bool = false private var orderId:String? //下单后的ID private var tapType:TapType = .t2 override func viewDidLoad() { super.viewDidLoad() title = "疗愈币充值" 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 weakSelf.tap_other.isHidden = false weakSelf.tap_other_title.text = "支".appending("付").appending("宝") } }).disposed(by: disposeBag) btn_handle.isEnabled = false btn_handle.alpha = 0.6 @@ -64,6 +81,36 @@ override func setUI() { view.backgroundColor = UIColor(hexString: "f6f6f6") stackView.jq_cornerRadius = 10 } override func setRx() { NotificationCenter.default.rx.notification(UIApplication.didBecomeActiveNotification).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] _ in guard let weakSelf = self else { return } if weakSelf.isShowMore && weakSelf.orderId != nil{ Services.queryPayment(orderId: weakSelf.orderId!).subscribe(onNext: {data in if let str = data.data{ switch str{ case "succeeded": alertSuccess(msg: "购买成功") NotificationCenter.default.post(name: WithDrawReply_Noti, object: nil) DispatchQueue.main.asyncAfter(delay: 1.0) { weakSelf.navigationController?.popViewController() } case "failed": alertError(msg: "购买失败") case "closed": alertError(msg: "交易已关闭") case "refunded": alertError(msg: "全额退款") case "pending": alertError(msg: "待支付") default:break } } }).disposed(by: weakSelf.disposeBag) } }).disposed(by: disposeBag) } override func viewDidLayoutSubviews() { @@ -77,34 +124,76 @@ sceneDelegate?.needLogin() return} showHUD("正在进行内购买") let product = products[selectIndexPath.row] InPurchaseManager.purchaseProduct(ID: product.productIdentifier, applicationUsername: userId.string) {[weak self] result in guard let weakSelf = self else { return } if result.status == 0{ let transactionId = result.receipt?.in_app.first?.original_transaction_id ?? "" Services.placeOrderApple(amount: product.price.doubleValue, balanceFlag: .no, orderFrom: 4, transactionIdentifier: transactionId, vipType: nil).subscribe(onNext: { data in showHUD("正在查询购买结果") let observable = Observable<Int>.interval(RxTimeInterval.seconds(5), scheduler: MainScheduler.instance) observable.subscribe { event in Services.myWallet().subscribe(onNext: {data in if let m = data.data{ if m.recharge != weakSelf.oldPrice{ hiddenHUD() alertSuccess(msg: "购买成功") weakSelf.timeLoopDisposeBag = DisposeBag() NotificationCenter.default.post(name: WithDrawReply_Noti, object: nil) DispatchQueue.main.asyncAfter(delay: 1.0) { weakSelf.navigationController?.popViewController() if isShowMore{ let product = products[selectIndexPath.row] Services.placeOrder(orderForm: .recharge, payType: tapType == .t2 ? 2:1, amount: product.price.doubleValue, balanceFlag: nil, orderId: nil, receiverId: nil, targetId: nil, vipType: nil).subscribe(onNext: {[weak self] data in guard let weakSelf = self else { return } if let m = data.data{ weakSelf.orderId = m.orderId if weakSelf.tapType == .t2{ UIApplication.shared.open(URL(string: m.qrcodeUrl!)!) } if weakSelf.tapType == .t3{ let miniProgram = WXLaunchMiniProgramReq.object() miniProgram.miniProgramType = .release miniProgram.userName = m.orgId! miniProgram.path = m.path! WXApi.send(miniProgram){ s in if !s{ alert(msg: "打开失败") } } } } }).disposed(by: disposeBag) }else{ showHUD("正在进行内购买") let product = products[selectIndexPath.row] InPurchaseManager.purchaseProduct(ID: product.productIdentifier, applicationUsername: userId.string) {[weak self] result in guard let weakSelf = self else { return } if result.status == 0{ let transactionId = result.receipt?.in_app.first?.original_transaction_id ?? "" Services.placeOrderApple(amount: product.price.doubleValue, balanceFlag: .no, orderFrom: 4, transactionIdentifier: transactionId, vipType: nil).subscribe(onNext: { data in showHUD("正在查询购买结果") let observable = Observable<Int>.interval(RxTimeInterval.seconds(5), scheduler: MainScheduler.instance) observable.subscribe { event in Services.myWallet().subscribe(onNext: {data in if let m = data.data{ if m.recharge != weakSelf.oldPrice{ hiddenHUD() alertSuccess(msg: "购买成功") weakSelf.timeLoopDisposeBag = DisposeBag() NotificationCenter.default.post(name: WithDrawReply_Noti, object: nil) DispatchQueue.main.asyncAfter(delay: 1.0) { weakSelf.navigationController?.popViewController() } } } } }).disposed(by: weakSelf.disposeBag) }.disposed(by: weakSelf.timeLoopDisposeBag) }).disposed(by: weakSelf.disposeBag) }).disposed(by: weakSelf.disposeBag) }.disposed(by: weakSelf.timeLoopDisposeBag) }).disposed(by: weakSelf.disposeBag) } } errorClouse: { error in alertError(msg: "支付失败") } } errorClouse: { error in alertError(msg: "支付失败") } } @IBAction func tapAction(_ sender: Any) { PurchaseMethodView.show {[weak self] type in guard let weakSelf = self else { return } weakSelf.tapType = type switch type { case .t2: weakSelf.tap_other_title.text = "支".appending("付").appending("宝") case .t3: weakSelf.tap_other_title.text = "微".appending("信") default:break } } } } XQMuse/Root/Me/VC/WalletRechargeVC.xib
@@ -14,6 +14,9 @@ <outlet property="btn_handle" destination="dho-ek-UFQ" id="iQC-VU-0Zr"/> <outlet property="collectionView" destination="dtD-pA-jk2" id="DeN-fT-Su7"/> <outlet property="cons_collectionHei" destination="bd9-0q-BAP" id="w77-cG-RlO"/> <outlet property="stackView" destination="3G8-Xa-pOF" id="Eas-eT-8BO"/> <outlet property="tap_other" destination="r2X-gD-KXz" id="vsV-f4-cnJ"/> <outlet property="tap_other_title" destination="p8P-Ff-jH9" id="Tf8-nL-h8F"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> </connections> </placeholder> @@ -25,45 +28,91 @@ <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="z66-Ao-znz"> <rect key="frame" x="0.0" y="59" width="393" height="759"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ok4-Yz-gOY"> <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="3G8-Xa-pOF"> <rect key="frame" x="14" y="9" width="365" height="141"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="充值金额" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nAx-8V-3yC"> <rect key="frame" x="9.9999999999999964" y="13" width="55.666666666666657" height="17"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="14"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="dtD-pA-jk2"> <rect key="frame" x="0.0" y="58" width="365" height="50"/> <view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="r2X-gD-KXz" customClass="TapBtn" customModule="XQMuse" customModuleProvider="target"> <rect key="frame" x="0.0" y="0.0" width="365" height="48"/> <subviews> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="W1g-Yn-wYR"> <rect key="frame" x="9" y="47" width="347" height="1"/> <color key="backgroundColor" red="0.59215686274509804" green="0.59215686274509804" blue="0.59215686274509804" alpha="0.14999999999999999" colorSpace="custom" customColorSpace="sRGB"/> <constraints> <constraint firstAttribute="height" constant="1" id="r3w-FO-GhA"/> </constraints> </view> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="充值方式" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="haj-xf-DTh"> <rect key="frame" x="9.9999999999999964" y="14.333333333333327" width="63.666666666666657" height="19.333333333333329"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/> <color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="0.80000000000000004" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_more" translatesAutoresizingMaskIntoConstraints="NO" id="blo-b0-r7y"> <rect key="frame" x="349" y="19" width="6" height="10"/> <constraints> <constraint firstAttribute="width" constant="6" id="7xI-SY-eDN"/> <constraint firstAttribute="height" constant="10" id="eOv-Sf-Dhi"/> </constraints> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="--" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p8P-Ff-jH9"> <rect key="frame" x="324.33333333333331" y="14.333333333333327" width="14.666666666666686" height="19.333333333333329"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="16"/> <color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="0.80000000000000004" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstAttribute="height" constant="50" id="bd9-0q-BAP"/> <constraint firstItem="W1g-Yn-wYR" firstAttribute="leading" secondItem="r2X-gD-KXz" secondAttribute="leading" constant="9" id="1qT-Nr-k7u"/> <constraint firstAttribute="bottom" secondItem="W1g-Yn-wYR" secondAttribute="bottom" id="BbZ-zt-WUN"/> <constraint firstAttribute="height" constant="48" id="HYM-rh-bBU"/> <constraint firstItem="p8P-Ff-jH9" firstAttribute="centerY" secondItem="haj-xf-DTh" secondAttribute="centerY" id="Kzm-tP-UeE"/> <constraint firstItem="haj-xf-DTh" firstAttribute="leading" secondItem="r2X-gD-KXz" secondAttribute="leading" constant="10" id="LiE-Uy-aIj"/> <constraint firstItem="haj-xf-DTh" firstAttribute="centerY" secondItem="r2X-gD-KXz" secondAttribute="centerY" id="Uv1-me-lPL"/> <constraint firstAttribute="trailing" secondItem="blo-b0-r7y" secondAttribute="trailing" constant="10" id="gQu-Nf-pbj"/> <constraint firstAttribute="trailing" secondItem="W1g-Yn-wYR" secondAttribute="trailing" constant="9" id="uiK-Oy-pp7"/> <constraint firstItem="blo-b0-r7y" firstAttribute="centerY" secondItem="r2X-gD-KXz" secondAttribute="centerY" id="vm7-eV-oLZ"/> <constraint firstItem="blo-b0-r7y" firstAttribute="leading" secondItem="p8P-Ff-jH9" secondAttribute="trailing" constant="10" id="ygt-rF-Vds"/> </constraints> <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="Cco-HP-q4Y"> <size key="itemSize" width="128" height="128"/> <size key="headerReferenceSize" width="0.0" height="0.0"/> <size key="footerReferenceSize" width="0.0" height="0.0"/> <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/> </collectionViewFlowLayout> </collectionView> <connections> <action selector="tapAction:" destination="-1" eventType="touchUpInside" id="qCX-vo-qsv"/> </connections> </view> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ok4-Yz-gOY"> <rect key="frame" x="0.0" y="0.0" width="365" height="141"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="充值金额" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nAx-8V-3yC"> <rect key="frame" x="9.9999999999999964" y="13" width="55.666666666666657" height="17"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="14"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="dtD-pA-jk2"> <rect key="frame" x="0.0" y="58" width="365" height="50"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstAttribute="height" constant="50" id="bd9-0q-BAP"/> </constraints> <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="Cco-HP-q4Y"> <size key="itemSize" width="128" height="128"/> <size key="headerReferenceSize" width="0.0" height="0.0"/> <size key="footerReferenceSize" width="0.0" height="0.0"/> <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/> </collectionViewFlowLayout> </collectionView> </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstItem="nAx-8V-3yC" firstAttribute="leading" secondItem="Ok4-Yz-gOY" secondAttribute="leading" constant="10" id="1Dh-E8-vyT"/> <constraint firstItem="dtD-pA-jk2" firstAttribute="top" secondItem="nAx-8V-3yC" secondAttribute="bottom" constant="28" id="4E4-or-gJ7"/> <constraint firstAttribute="bottom" secondItem="dtD-pA-jk2" secondAttribute="bottom" constant="33" id="Ndh-eA-Y0R"/> <constraint firstItem="nAx-8V-3yC" firstAttribute="top" secondItem="Ok4-Yz-gOY" secondAttribute="top" constant="13" id="WYJ-dl-1sf"/> <constraint firstAttribute="trailing" secondItem="dtD-pA-jk2" secondAttribute="trailing" id="nvj-jM-GAI"/> <constraint firstItem="dtD-pA-jk2" firstAttribute="leading" secondItem="Ok4-Yz-gOY" secondAttribute="leading" id="tIv-aS-XcX"/> </constraints> </view> </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstItem="nAx-8V-3yC" firstAttribute="leading" secondItem="Ok4-Yz-gOY" secondAttribute="leading" constant="10" id="1Dh-E8-vyT"/> <constraint firstItem="dtD-pA-jk2" firstAttribute="top" secondItem="nAx-8V-3yC" secondAttribute="bottom" constant="28" id="4E4-or-gJ7"/> <constraint firstAttribute="bottom" secondItem="dtD-pA-jk2" secondAttribute="bottom" constant="33" id="Ndh-eA-Y0R"/> <constraint firstItem="nAx-8V-3yC" firstAttribute="top" secondItem="Ok4-Yz-gOY" secondAttribute="top" constant="13" id="WYJ-dl-1sf"/> <constraint firstAttribute="trailing" secondItem="dtD-pA-jk2" secondAttribute="trailing" id="nvj-jM-GAI"/> <constraint firstItem="dtD-pA-jk2" firstAttribute="leading" secondItem="Ok4-Yz-gOY" secondAttribute="leading" id="tIv-aS-XcX"/> </constraints> <userDefinedRuntimeAttributes> <userDefinedRuntimeAttribute type="boolean" keyPath="ld_maskToBoundsXIB" value="YES"/> <userDefinedRuntimeAttribute type="number" keyPath="ld_cornerRadiusXIB"> <real key="value" value="10"/> </userDefinedRuntimeAttribute> </userDefinedRuntimeAttributes> </view> </stackView> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dho-ek-UFQ"> <rect key="frame" x="45" y="210" width="303" height="40"/> <color key="backgroundColor" red="0.54117647059999996" green="0.68235294120000001" blue="0.39607843139999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> @@ -86,11 +135,11 @@ </subviews> <color key="backgroundColor" red="0.96470588235294119" green="0.96470588235294119" blue="0.96470588235294119" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <constraints> <constraint firstItem="Ok4-Yz-gOY" firstAttribute="leading" secondItem="z66-Ao-znz" secondAttribute="leading" constant="14" id="0hn-eY-79h"/> <constraint firstAttribute="trailing" secondItem="3G8-Xa-pOF" secondAttribute="trailing" constant="14" id="6U1-Tc-y3e"/> <constraint firstItem="dho-ek-UFQ" firstAttribute="top" secondItem="3G8-Xa-pOF" secondAttribute="bottom" constant="60" id="ARz-ce-uQN"/> <constraint firstAttribute="trailing" secondItem="dho-ek-UFQ" secondAttribute="trailing" constant="45" id="B15-WD-cjm"/> <constraint firstAttribute="trailing" secondItem="Ok4-Yz-gOY" secondAttribute="trailing" constant="14" id="IJU-kW-9Fa"/> <constraint firstItem="Ok4-Yz-gOY" firstAttribute="top" secondItem="z66-Ao-znz" secondAttribute="top" constant="9" id="Qnn-9a-Nl6"/> <constraint firstItem="dho-ek-UFQ" firstAttribute="top" secondItem="Ok4-Yz-gOY" secondAttribute="bottom" constant="60" id="sXQ-fx-OHD"/> <constraint firstItem="3G8-Xa-pOF" firstAttribute="leading" secondItem="z66-Ao-znz" secondAttribute="leading" constant="14" id="Cf7-xI-XIF"/> <constraint firstItem="3G8-Xa-pOF" firstAttribute="top" secondItem="z66-Ao-znz" secondAttribute="top" constant="9" id="Nfx-bm-CgB"/> <constraint firstItem="dho-ek-UFQ" firstAttribute="leading" secondItem="z66-Ao-znz" secondAttribute="leading" constant="45" id="xtn-l7-j0B"/> </constraints> </view> @@ -107,6 +156,7 @@ </view> </objects> <resources> <image name="icon_more" width="6" height="10.666666984558105"/> <systemColor name="systemBackgroundColor"> <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> </systemColor> XQMuse/Root/Me/View/PurchaseMethodView.swift
New file @@ -0,0 +1,94 @@ // // PurchaseMethodView.swift // XQMuse // // Created by 无故事王国 on 2024/11/25. // import UIKit import JQTools class PurchaseMethodView: UIView,JQNibView{ @IBOutlet weak var view_content: UIView! @IBOutlet weak var img_1: UIImageView! @IBOutlet weak var img_2: UIImageView! @IBOutlet weak var img_select_1: UIImageView! @IBOutlet weak var img_select_2: UIImageView! @IBOutlet weak var label_1: UILabel! @IBOutlet weak var label_2: UILabel! @IBOutlet weak var btn_complete: UIButton! @IBOutlet weak var cons_bottom: NSLayoutConstraint! private var clouse:((TapType)->Void)? var tapType:TapType = .t2 override func awakeFromNib() { super.awakeFromNib() img_1.image = UIImage(named: "btn_aP_1") img_2.image = UIImage(named: "btn_wxP_1") label_1.text = "支".appending("付").appending("宝").appending("支").appending("付") label_2.text = "微".appending("信").appending("支").appending("付") cons_bottom.constant = -JQ_ScreenW / 2 alpha = 0 layoutIfNeeded() } static func show(_ clouse:@escaping (TapType)->Void){ let purchageView = PurchaseMethodView.jq_loadNibView() purchageView.clouse = clouse purchageView.frame = sceneDelegate?.window?.frame ?? .zero sceneDelegate?.window?.addSubview(purchageView) purchageView.cons_bottom.constant = 0 UIView.animate(withDuration: 0.4) { purchageView.alpha = 1.0 purchageView.layoutIfNeeded() } } @IBAction func closeAction(_ sender: Any) { cons_bottom.constant = -JQ_ScreenW / 2 UIView.animate(withDuration: 0.4) { self.alpha = 0 self.layoutIfNeeded() } completion: { _ in self.removeFromSuperview() } } @IBAction func tapAction(_ sender: TapBtn) { if sender.tag == 2100{ tapType = .t2 img_select_1.image = UIImage(named: "icon_choose_small_s") img_select_2.image = UIImage(named: "icon_choose_small_1") }else{ tapType = .t3 img_select_1.image = UIImage(named: "icon_choose_small_1") img_select_2.image = UIImage(named: "icon_choose_small_s") } } @IBAction func completeAction(_ sender: UIButton) { clouse?(tapType) cons_bottom.constant = -JQ_ScreenW / 2 UIView.animate(withDuration: 0.4) { self.alpha = 0 self.layoutIfNeeded() } completion: { _ in self.removeFromSuperview() } } override func layoutSubviews() { super.layoutSubviews() view_content.jq_addCorners(corner: [.topLeft,.topRight], radius: 20,width: JQ_ScreenW,height: 265) btn_complete.localGradientColor(cornerRadius: 20,bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW - 90, height: 40)) } } XQMuse/Root/Me/View/PurchaseMethodView.xib
New file @@ -0,0 +1,160 @@ <?xml version="1.0" encoding="UTF-8"?> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <device id="retina6_12" orientation="portrait" appearance="light"/> <dependencies> <deployment identifier="iOS"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="System colors in document resources" minToolsVersion="11.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="PurchaseMethodView" customModule="XQMuse" customModuleProvider="target"> <rect key="frame" x="0.0" y="0.0" width="393" height="852"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pNc-Y2-GLo"> <rect key="frame" x="0.0" y="59" width="393" height="759"/> <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> <connections> <action selector="closeAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="6WQ-uK-HZO"/> </connections> </button> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HaX-Wh-a97"> <rect key="frame" x="0.0" y="587.66666666666663" width="393" height="264.33333333333337"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="选择支付方式" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GLI-JT-7gT"> <rect key="frame" x="149" y="14.999999999999998" width="95.333333333333314" height="19.333333333333329"/> <fontDescription key="fontDescription" type="system" pointSize="16"/> <nil key="textColor"/> <nil key="highlightedColor"/> </label> <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="6PE-EP-cas"> <rect key="frame" x="0.0" y="49.333333333333371" width="393" height="83"/> <subviews> <view tag="2100" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RIT-LK-itg" customClass="TapBtn" customModule="XQMuse" customModuleProvider="target"> <rect key="frame" x="0.0" y="0.0" width="393" height="39"/> <subviews> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="btn_apple" translatesAutoresizingMaskIntoConstraints="NO" id="tdM-ES-dxN"> <rect key="frame" x="29" y="6.6666666666666288" width="26" height="26"/> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dTN-EJ-wYS"> <rect key="frame" x="67" y="11" width="36" height="17"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="14"/> <nil key="textColor"/> <nil key="highlightedColor"/> </label> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_choose_small_s" translatesAutoresizingMaskIntoConstraints="NO" id="xdN-Qt-RfY"> <rect key="frame" x="348.33333333333331" y="11.666666666666629" width="15.666666666666686" height="16"/> </imageView> </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstItem="dTN-EJ-wYS" firstAttribute="centerY" secondItem="RIT-LK-itg" secondAttribute="centerY" id="FUf-Ya-PDs"/> <constraint firstItem="tdM-ES-dxN" firstAttribute="leading" secondItem="RIT-LK-itg" secondAttribute="leading" constant="29" id="IGH-51-AA7"/> <constraint firstAttribute="trailing" secondItem="xdN-Qt-RfY" secondAttribute="trailing" constant="29" id="PKO-be-asJ"/> <constraint firstItem="xdN-Qt-RfY" firstAttribute="centerY" secondItem="RIT-LK-itg" secondAttribute="centerY" id="QQn-Ig-lny"/> <constraint firstItem="tdM-ES-dxN" firstAttribute="centerY" secondItem="RIT-LK-itg" secondAttribute="centerY" id="RjH-ck-xqU"/> <constraint firstItem="dTN-EJ-wYS" firstAttribute="leading" secondItem="tdM-ES-dxN" secondAttribute="trailing" constant="12" id="XFZ-MN-jIx"/> <constraint firstAttribute="height" constant="39" id="fVd-BB-Y0W"/> </constraints> <connections> <action selector="tapAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="06n-t4-x6f"/> </connections> </view> <view tag="2101" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="8WP-8K-cLJ" customClass="TapBtn" customModule="XQMuse" customModuleProvider="target"> <rect key="frame" x="0.0" y="44" width="393" height="39"/> <subviews> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="btn_apple" translatesAutoresizingMaskIntoConstraints="NO" id="3sm-zl-qdV"> <rect key="frame" x="29" y="6.6666666666666288" width="26" height="26"/> </imageView> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Pnm-GI-HSY"> <rect key="frame" x="67" y="11" width="36" height="17"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="14"/> <nil key="textColor"/> <nil key="highlightedColor"/> </label> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_choose_small_1" translatesAutoresizingMaskIntoConstraints="NO" id="CyO-m6-sGA"> <rect key="frame" x="348" y="11.666666666666629" width="16" height="16"/> </imageView> </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstItem="Pnm-GI-HSY" firstAttribute="centerY" secondItem="8WP-8K-cLJ" secondAttribute="centerY" id="K0v-MQ-jaQ"/> <constraint firstAttribute="trailing" secondItem="CyO-m6-sGA" secondAttribute="trailing" constant="29" id="Km3-5P-isZ"/> <constraint firstItem="Pnm-GI-HSY" firstAttribute="leading" secondItem="3sm-zl-qdV" secondAttribute="trailing" constant="12" id="LBv-fY-uPB"/> <constraint firstAttribute="height" constant="39" id="Okv-ZX-m93"/> <constraint firstItem="CyO-m6-sGA" firstAttribute="centerY" secondItem="8WP-8K-cLJ" secondAttribute="centerY" id="YcR-mG-ZrO"/> <constraint firstItem="3sm-zl-qdV" firstAttribute="centerY" secondItem="8WP-8K-cLJ" secondAttribute="centerY" id="dds-kY-jGp"/> <constraint firstItem="3sm-zl-qdV" firstAttribute="leading" secondItem="8WP-8K-cLJ" secondAttribute="leading" constant="29" id="t8u-fL-uBW"/> </constraints> <connections> <action selector="tapAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="ncB-7a-eia"/> </connections> </view> </subviews> </stackView> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lTN-hx-Y1n"> <rect key="frame" x="45" y="152.33333333333337" width="303" height="40"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <constraints> <constraint firstAttribute="height" constant="40" id="Fhe-x1-V0R"/> </constraints> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="15"/> <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> <state key="normal" title="确认"/> <connections> <action selector="completeAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="5dJ-lw-uRm"/> </connections> </button> </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstAttribute="trailing" secondItem="6PE-EP-cas" secondAttribute="trailing" id="4b3-Ki-8XL"/> <constraint firstItem="6PE-EP-cas" firstAttribute="top" secondItem="GLI-JT-7gT" secondAttribute="bottom" constant="15" id="6md-Yx-d18"/> <constraint firstAttribute="trailing" secondItem="lTN-hx-Y1n" secondAttribute="trailing" constant="45" id="QVv-cO-H3B"/> <constraint firstItem="lTN-hx-Y1n" firstAttribute="top" secondItem="6PE-EP-cas" secondAttribute="bottom" constant="20" id="S1O-lg-Uza"/> <constraint firstItem="GLI-JT-7gT" firstAttribute="centerX" secondItem="HaX-Wh-a97" secondAttribute="centerX" id="Zmh-aA-WiW"/> <constraint firstItem="6PE-EP-cas" firstAttribute="leading" secondItem="HaX-Wh-a97" secondAttribute="leading" id="eYW-4f-Vp7"/> <constraint firstItem="lTN-hx-Y1n" firstAttribute="leading" secondItem="HaX-Wh-a97" secondAttribute="leading" constant="45" id="g3Z-CK-kgy"/> <constraint firstItem="GLI-JT-7gT" firstAttribute="top" secondItem="HaX-Wh-a97" secondAttribute="top" constant="15" id="inj-jo-xUg"/> <constraint firstAttribute="bottomMargin" secondItem="lTN-hx-Y1n" secondAttribute="bottom" constant="30" id="s6C-ai-SqW"/> </constraints> </view> </subviews> <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/> <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.69999999999999996" colorSpace="custom" customColorSpace="sRGB"/> <constraints> <constraint firstItem="HaX-Wh-a97" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="0mR-TH-Wh1"/> <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="pNc-Y2-GLo" secondAttribute="trailing" id="2JS-Wx-GD8"/> <constraint firstAttribute="bottom" secondItem="HaX-Wh-a97" secondAttribute="bottom" id="9TX-Gw-rQo"/> <constraint firstItem="pNc-Y2-GLo" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" id="A69-Qg-wRz"/> <constraint firstItem="pNc-Y2-GLo" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="SH2-83-ai3"/> <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="HaX-Wh-a97" secondAttribute="trailing" id="Uvb-lr-S0N"/> <constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="pNc-Y2-GLo" secondAttribute="bottom" id="Zuf-c1-lz0"/> </constraints> <connections> <outlet property="btn_complete" destination="lTN-hx-Y1n" id="mWD-Qg-GFQ"/> <outlet property="cons_bottom" destination="9TX-Gw-rQo" id="xJK-JS-jF0"/> <outlet property="img_1" destination="tdM-ES-dxN" id="gJ9-Uk-5xT"/> <outlet property="img_2" destination="3sm-zl-qdV" id="GTa-sd-lOW"/> <outlet property="img_select_1" destination="xdN-Qt-RfY" id="QnQ-Dd-d8e"/> <outlet property="img_select_2" destination="CyO-m6-sGA" id="1bd-Gi-AYo"/> <outlet property="label_1" destination="dTN-EJ-wYS" id="rrw-Fs-Nki"/> <outlet property="label_2" destination="Pnm-GI-HSY" id="Mk5-Tr-83O"/> <outlet property="view_content" destination="HaX-Wh-a97" id="UVC-Ih-gmT"/> </connections> <point key="canvasLocation" x="-25.190839694656489" y="20.422535211267608"/> </view> </objects> <resources> <image name="btn_apple" width="26" height="26"/> <image name="icon_choose_small_1" width="16" height="16"/> <image name="icon_choose_small_s" width="15.666666984558105" height="16"/> <systemColor name="systemBackgroundColor"> <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> </systemColor> </resources> </document> XQMuse/Root/Network/Models.swift
@@ -511,6 +511,21 @@ var type = 0 //问题一 问题类型 1:您是否内心纠结敏感多疑?2:您是否辗转反侧彻夜难眠?3:您是否情绪失控暴躁易怒?4:您是否沉迷情感倍受伤害?5:您是否人生迷茫踌躇彷徨?6:其它补充说明 } struct VIPContentModel:HandyJSON{ var annualVipIos:Int = 0 var monthlyVipIos:Int = 0 var quarterlyVipIos:Int = 0 } struct PaymentResultModel:HandyJSON{ var appId: String? var id: Int = 0 var orderId: String? var orderNo: String? var orgId: String? var path: String? var payAmt: String? var payInfo: String? var qrcodeUrl: String? var zeroFlag: Int = 0 } XQMuse/Root/Network/Services.swift
@@ -13,8 +13,8 @@ import CoreLocation #if DEBUG let All_Url = "https://xq.xqzhihui.com/api" //let All_Url = "http://192.168.110.64:9000" //let All_Url = "https://xq.xqzhihui.com/api" let All_Url = "http://192.168.110.64:9000" //let All_Url = "https://mock.apipost.net/mock/31b303c60464000" #else let All_Url = "https://xq.xqzhihui.com/api" @@ -367,6 +367,20 @@ params.interface(url: "/order/mgt/order/order/cancel") .append(key: "uid", value: id) return NetworkRequest.request(params: params, method: .get, progress: true) } class func placeOrder(orderForm:PaymentOrderVC.PaymentOrderType,payType:Int,amount:Double? = nil,balanceFlag:Int? = nil,orderId:Int? = nil,receiverId:Int? = nil,targetId:Int? = nil,vipType:Int? = nil)->Observable<BaseResponse<PaymentResultModel>>{ let params = ParamsAppender.build(url: All_Url) params.interface(url: "/order/client/order/order/placeOrder") .append(key: "orderFrom", value: orderForm.rawValue) .append(key: "payType", value: payType) .append(key: "amount", value: amount) .append(key: "balanceFlag", value: balanceFlag) .append(key: "orderId", value: orderId) .append(key: "receiverId", value: receiverId) .append(key: "targetId", value: targetId) .append(key: "vipType", value: vipType) return NetworkRequest.request(params: params, method: .post, progress: true) } @@ -826,4 +840,23 @@ .append(key: "type", value: type) return NetworkRequest.request(params: params, method: .post, progress: false) } class func getVipPrice()->Observable<BaseResponse<VIPContentModel>>{ let params = ParamsAppender.build(url: All_Url) .interface(url: "/system/system/vip-setting/queryVip") return NetworkRequest.request(params: params, method: .post,encoding: JSONEncoding(), progress: false) } class func queryPayment(orderId:String)->Observable<BaseResponse<String>>{ let params = ParamsAppender.build(url: All_Url) .interface(url: "/order/client/order/order/queryPayment") .append(key: "orderId", value: orderId) return NetworkRequest.request(params: params, method: .post, progress: true) } class func getTurn(progress:Bool = true)->Observable<BaseResponse<Bool>>{ let params = ParamsAppender.build(url: All_Url) .interface(url: "/system/system/home/getTurn") return NetworkRequest.request(params: params, method: .get, progress: progress) } } XQMuse/Root/PayMusicView/PayMusicVC.swift
@@ -310,7 +310,8 @@ NotificationCenter.default.addObserver(forName: ChangeMasterVoice_Noti, object: nil, queue: .main) { noti in if let value = noti.object as? Float{ print("--->进入") self.masterPlayer?.volume = value // self.masterPlayer?.volume = value self.bgmPlayer?.volume = value } } @@ -410,10 +411,10 @@ } self.bgmPlayer = AVPlayer(url: self.urls[firstPlayIndex]) if masterUrl != nil{ self.masterPlayer = AVPlayer(url: masterUrl!) self.masterPlayer?.volume = Float(UserDefaultSettingViewModel.getSetting()?.masterVolume ?? 0.5) } // if masterUrl != nil{ // self.masterPlayer = AVPlayer(url: masterUrl!) // self.masterPlayer?.volume = Float(UserDefaultSettingViewModel.getSetting()?.masterVolume ?? 0.5) // } } self.bgmPlayer?.addPeriodicTimeObserver(forInterval: CMTimeMake(value: 1, timescale: 1), queue: DispatchQueue.main) { [weak self](time) in XQMuse/Root/TreeGroup/TreeTeskVC.swift
@@ -307,7 +307,7 @@ weakSelf.treeInfoModel!.treeLevelType = m.treeLevelType let h = (JQ_ScreenW - 90) * 0.7729 TreeTeskFirstRuleView.show(title: "升级", content:"恭喜!你的树苗已升级为\(weakSelf.treeInfoModel!.treeLevelType.title)阶段!",textAlignment: .center,height: h,textTopOffset: 57) TreeTeskFirstRuleView.show(title: "什么之树", content:weakSelf.treeInfoModel!.treeLevelType.titleContent,textAlignment: .center,height: h,textTopOffset: 57) if let soundURL = URL(string:weakSelf.treeInfoModel?.treeLevelType.sound){ weakSelf.voicePlayer.replaceCurrentItem(with: AVPlayerItem(url: soundURL))