From 9e77b0f9014653255eb51e81b8a8ba719443839d Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期一, 11 十一月 2024 23:52:14 +0800 Subject: [PATCH] fix bug --- XQMuse/Root/Course/VC/CourseDetialVC.swift | 25 XQMuse/Root/Course/VC/CourseDetialOfflineVC.swift | 3 XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.swift | 2 XQMuse/Root/Login/VC/ForgotPasswordInputCodeVC.swift | 2 XQMuse/Root/Plans/PlanGuide_1_VC.swift | 4 XQMuse/Root/TreeGroup/TreeTeskVC.swift | 25 - XQMuse/Config/LaunchImageHelper.swift | 2 XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift | 52 ++ XQMuse/Root/Home/VC/BackgroundVoiceVC.swift | 12 XQMuse/Root/Login/VC/RegisterVC.swift | 20 XQMuse/Root/Me/VC/UserProfileVC.swift | 2 XQMuse/Root/Me/VC/StudyListVC.swift | 10 XQMuse/Root/Me/VC/SpendingDetailInfoVC.xib | 19 XQMuse/Root/Course/TCell/CourseDetail_1_TCell.xib | 8 XQMuse/Root/Home/CCell/HomeRelaxBanner_2_1_CCell.swift | 10 XQMuse/Root/Home/VC/HomeItemDetailVC.swift | 28 + XQMuse/Root/Network/NetworkRequest.swift | 4 XQMuse/Root/Other/WebVC.swift | 21 + XQMuse/Root/Me/VC/WalletRechargeVC.swift | 41 ++ XQMuse/SceneDelegate.swift | 3 XQMuse/Root/Me/VC/AddBankInfoVC.swift | 2 XQMuse/Root/Plans/PlanGuideVC.swift | 4 XQMuse/Root/Home/HomeVC.swift | 112 +++++-- XQMuse/Config/Enums/Enums.swift | 2 XQMuse/Root/Me/VC/InviteVC.xib | 28 + XQMuse/Root/Course/VC/CourseDetialVideoVC.swift | 22 XQMuse/Root/Network/Services.swift | 45 ++ XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.swift | 20 XQMuse/Root/Home/TCell/Home_Style_1_TCell.swift | 14 XQMuse/Root/Home/CCell/HomeRelaxBanner_2_1_CCell.xib | 33 - XQMuse/Root/Me/VC/InviteVC.swift | 16 + XQMuse/Root/Home/TCell/Home_Style_3_TCell.swift | 5 XQMuse/Root/Home/TCell/Home_Style_4_TCell.swift | 22 - XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/bt_private @2x.png | 0 XQMuse/Base.lproj/LaunchScreen.storyboard | 8 XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.xib | 7 XQMuse/Root/Home/VC/PaymentOrderVC.swift | 80 ++++ XQMuse/Root/Me/VC/SpendingDetailInfoVC.swift | 20 + XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.swift | 2 XQMuse/Root/Course/View/CourseDetialCustomerView.swift | 2 XQMuse/Root/Network/Models.swift | 11 XQMuse/Root/Other/View/CountdownChooseListView.swift | 1 XQMuse/Root/Me/VC/AddBankInfoVC.xib | 2 XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/Contents.json | 22 + XQMuse/Root/PayMusicView/PayMusicVC.swift | 34 + XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/bt_private @3x.png | 0 XQMuse/Root/Me/MeVC.swift | 3 XQMuse/Root/Other/View/VideoView.swift | 2 XQMuse/Root/Me/VC/VIPCenterVC.swift | 60 +++ XQMuse/Root/Course/TCell/CourseDetail_2_TCell.swift | 2 XQMuse/Root/Home/VC/HomeItemDetailVC.xib | 2 51 files changed, 614 insertions(+), 262 deletions(-) diff --git a/XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/Contents.json b/XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/Contents.json new file mode 100644 index 0000000..530050c --- /dev/null +++ b/XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "bt_private @2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "bt_private @3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/bt_private @2x.png b/XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/bt_private @2x.png new file mode 100644 index 0000000..e3463e5 --- /dev/null +++ b/XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/bt_private @2x.png Binary files differ diff --git a/XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/bt_private @3x.png b/XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/bt_private @3x.png new file mode 100644 index 0000000..677234e --- /dev/null +++ b/XQMuse/Assets.xcassets/Placeholder/bt_private.imageset/bt_private @3x.png Binary files differ diff --git a/XQMuse/Base.lproj/LaunchScreen.storyboard b/XQMuse/Base.lproj/LaunchScreen.storyboard index 3052f1a..3f66a12 100644 --- a/XQMuse/Base.lproj/LaunchScreen.storyboard +++ b/XQMuse/Base.lproj/LaunchScreen.storyboard @@ -20,20 +20,12 @@ <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="launchScreen" translatesAutoresizingMaskIntoConstraints="NO" id="MTa-Il-dP2"> <rect key="frame" x="0.0" y="0.0" width="393" height="852"/> </imageView> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="备案号:1231231231123" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zWJ-TH-NSU"> - <rect key="frame" x="106.00000000000001" y="793.66666666666663" width="181.33333333333337" height="19.333333333333371"/> - <fontDescription key="fontDescription" type="system" weight="semibold" pointSize="16"/> - <nil key="textColor"/> - <nil key="highlightedColor"/> - </label> </subviews> <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> - <constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="zWJ-TH-NSU" secondAttribute="bottom" constant="5" id="6gC-B5-qpe"/> <constraint firstItem="MTa-Il-dP2" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="6qP-PH-xn1"/> <constraint firstAttribute="bottom" secondItem="MTa-Il-dP2" secondAttribute="bottom" id="8PC-Kf-lOK"/> - <constraint firstItem="zWJ-TH-NSU" firstAttribute="centerX" secondItem="MTa-Il-dP2" secondAttribute="centerX" id="aEe-8n-eho"/> <constraint firstItem="MTa-Il-dP2" firstAttribute="trailing" secondItem="6Tk-OE-BBY" secondAttribute="trailing" id="cbw-XJ-Oln"/> <constraint firstItem="MTa-Il-dP2" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="gMR-H3-3Yf"/> </constraints> diff --git a/XQMuse/Config/Enums/Enums.swift b/XQMuse/Config/Enums/Enums.swift index 50dfd08..8226c54 100644 --- a/XQMuse/Config/Enums/Enums.swift +++ b/XQMuse/Config/Enums/Enums.swift @@ -136,7 +136,7 @@ switch self { case .man:return "男" case .woman:return "女" - case .encrypt:return "" + case .encrypt:return "保密" } } diff --git a/XQMuse/Config/LaunchImageHelper.swift b/XQMuse/Config/LaunchImageHelper.swift index 812f181..c7bb982 100644 --- a/XQMuse/Config/LaunchImageHelper.swift +++ b/XQMuse/Config/LaunchImageHelper.swift @@ -120,7 +120,7 @@ @discardableResult static func replaceLaunchImage(_ replacementImage: UIImage?) -> Bool { guard let image = replacementImage else {return false} - return self.replaceLaunchImage(replacementImage: image, compressionQuality: 0.8, customValidation: nil) + return self.replaceLaunchImage(replacementImage: image, compressionQuality: 1.0, customValidation: nil) } @discardableResult diff --git a/XQMuse/Root/Course/TCell/CourseDetail_1_TCell.xib b/XQMuse/Root/Course/TCell/CourseDetail_1_TCell.xib index 119e604..854378b 100644 --- a/XQMuse/Root/Course/TCell/CourseDetail_1_TCell.xib +++ b/XQMuse/Root/Course/TCell/CourseDetail_1_TCell.xib @@ -17,7 +17,7 @@ <autoresizingMask key="autoresizingMask"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="课程介绍" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lg9-70-w3n"> - <rect key="frame" x="21.666666666666668" y="5" width="59.666666666666657" height="20"/> + <rect key="frame" x="21.666666666666668" y="10" width="59.666666666666657" height="20"/> <constraints> <constraint firstAttribute="height" constant="20" id="8dQ-Gi-hJh"/> </constraints> @@ -26,9 +26,9 @@ <nil key="highlightedColor"/> </label> <wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="WYV-JQ-E3S"> - <rect key="frame" x="21.666666666666657" y="44.666666666666657" width="458" height="280.33333333333337"/> + <rect key="frame" x="21.666666666666657" y="49.666666666666657" width="458" height="275.33333333333337"/> <constraints> - <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="100" id="hfa-qQ-TpS"/> + <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="10" id="hfa-qQ-TpS"/> </constraints> <wkWebViewConfiguration key="configuration"> <audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/> @@ -37,7 +37,7 @@ </wkWebView> </subviews> <constraints> - <constraint firstItem="Lg9-70-w3n" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="5" id="4D5-on-wj2"/> + <constraint firstItem="Lg9-70-w3n" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="10" id="4D5-on-wj2"/> <constraint firstItem="WYV-JQ-E3S" firstAttribute="top" secondItem="Lg9-70-w3n" secondAttribute="bottom" constant="19.5" id="Ar0-7c-kQM"/> <constraint firstItem="Lg9-70-w3n" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="21.5" id="dJv-7a-n9J"/> <constraint firstItem="WYV-JQ-E3S" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="21.5" id="m6n-62-uuK"/> diff --git a/XQMuse/Root/Course/TCell/CourseDetail_2_TCell.swift b/XQMuse/Root/Course/TCell/CourseDetail_2_TCell.swift index c26c650..349b628 100644 --- a/XQMuse/Root/Course/TCell/CourseDetail_2_TCell.swift +++ b/XQMuse/Root/Course/TCell/CourseDetail_2_TCell.swift @@ -51,7 +51,7 @@ JQ_currentViewController().jq_push(vc: vc) }else{ guard sceneDelegate!.checkisLoginState() else{return} - let vc = PaymentOrderVC(courseItemModel: m,type: .course,giftToOther: true,showType: .horizontal) + let vc = PaymentOrderVC(courseItemModel: m,type: .course,giftToOther: false,showType: .horizontal) JQ_currentViewController().jq_push(vc:vc) } } diff --git a/XQMuse/Root/Course/VC/CourseDetialOfflineVC.swift b/XQMuse/Root/Course/VC/CourseDetialOfflineVC.swift index b850200..980d028 100644 --- a/XQMuse/Root/Course/VC/CourseDetialOfflineVC.swift +++ b/XQMuse/Root/Course/VC/CourseDetialOfflineVC.swift @@ -111,8 +111,7 @@ weakSelf.img_cusomter.sd_setImage(with: URL(string: m.wxQrCode.jq_urlEncoded())) if m.detailUrl.jq_isVideo{ - weakSelf.videoView = VideoView(url: m.detailUrl.jq_urlEncoded(),autoPlay: false,needFirstImage: true, delegate: self!) -// weakSelf.videoView!.player.play() + weakSelf.videoView = VideoView(url: m.detailUrl.jq_urlEncoded(),autoPlay: true,needFirstImage: true, delegate: self!) weakSelf.view_video.isHidden = false weakSelf.view_video.addSubview(weakSelf.videoView!) weakSelf.videoView!.snp.makeConstraints { make in diff --git a/XQMuse/Root/Course/VC/CourseDetialVC.swift b/XQMuse/Root/Course/VC/CourseDetialVC.swift index 0e5df32..f63bc05 100644 --- a/XQMuse/Root/Course/VC/CourseDetialVC.swift +++ b/XQMuse/Root/Course/VC/CourseDetialVC.swift @@ -43,7 +43,7 @@ pageMenu.trackerWidth = 27.5 pageMenu.setTrackerHeight(11, cornerRadius:0) pageMenu.trackerFollowingMode = .always - pageMenu.contentInset = UIEdgeInsets(top: 0, left: 19.5, bottom: 15, right: 19.5) + pageMenu.contentInset = UIEdgeInsets(top: 0, left: 10.5, bottom: 15, right: 19.5) pageMenu.setItems(["简介","章节","相关推荐"], selectedItemIndex: 0) pageMenu.backgroundColor = UIColor(hexString: "#F6F6F6") pageMenu.tracker.image = UIImage(named: "icon_unline") @@ -98,7 +98,7 @@ tableView!.delegate = self tableView!.dataSource = self tableView!.showsVerticalScrollIndicator = false - if #available(iOS 15.0, *) { + if #available(iOS 16.0, *) { tableView!.sectionHeaderTopPadding = 0 } tableView!.backgroundColor = UIColor(hexString: "#f6f6f6") @@ -193,7 +193,7 @@ make.height.equalTo(84) } - if courseDetailModel?.chargeType == .payment{ + if courseDetailModel?.chargeType == .payment || courseDetailModel?.chargeType == .free{ let giftBtn = QMUIButton(type: .custom) giftBtn.imagePosition = .left giftBtn.spacingBetweenImageAndTitle = 7.5 @@ -259,17 +259,16 @@ @objc func handleAction(_ btn:QMUIButton){ - if let m = courseDetailModel{ - if m.chargeType == .free || (m.chargeType == .vipFree && UserViewModel.getAvatarInfo().checkVip()) || (m.chargeType == .payment && m.isBuy == .yes){ - guard m.list.count != 0 else { - alertError(msg: "该课程暂未添加章节");return - } - let vc = CourseDetialVideoVC(items: m.list, selectIndex: IndexPath(row: 0, section: 0)) - push(vc: vc);return - } + if let m = courseDetailModel{ + guard m.list.count > 0 else {alert(msg: "当前课程未配置章节");return} - let vc = PaymentOrderVC(courseItemModel: m, type: .course,showType:.horizontal) - push(vc: vc) + if m.chargeType == .free || (m.chargeType == .vipFree && m.isVip == .yes) || (m.chargeType == .payment && m.isBuy == .yes){ + let vc = CourseDetialVideoVC(items: m.list, selectIndex: IndexPath(row: 0, section: 0)) + push(vc: vc) + }else{ + let vc = PaymentOrderVC(courseItemModel: m, type: .course, giftToOther: false, showType: .horizontal) + push(vc: vc) + } } } diff --git a/XQMuse/Root/Course/VC/CourseDetialVideoVC.swift b/XQMuse/Root/Course/VC/CourseDetialVideoVC.swift index ccdb261..3c48b96 100644 --- a/XQMuse/Root/Course/VC/CourseDetialVideoVC.swift +++ b/XQMuse/Root/Course/VC/CourseDetialVideoVC.swift @@ -39,21 +39,23 @@ let item = items[selectIndex.row] guard secondLook > 0 else {return} - Services.watchClouse(chapterId: item.id, isOver: isOver, secondLook: secondLook).subscribe(onNext: { _ in - }).disposed(by: disposeBag) + if !isOver{ + Services.watchClouse(chapterId: item.id, isOver: isOver, secondLook: secondLook).subscribe(onNext: { _ in + + }).disposed(by: disposeBag) + } } override func viewDidLoad() { super.viewDidLoad() title = "课程详情" - videoView = VideoView(url: items[selectIndex.row].videoUrl.jq_urlEncoded(),delegate: self) - videoView?.player.play() - view_bg_video.addSubview(videoView!) - videoView!.snp.makeConstraints { make in - make.edges.equalToSuperview() - } + videoView = VideoView(url: items[selectIndex.row].videoUrl.jq_urlEncoded(),autoPlay: true,delegate: self) + view_bg_video.addSubview(videoView!) + videoView!.snp.makeConstraints { make in + make.edges.equalToSuperview() + } tableView.separatorStyle = .none tableView.delegate = self @@ -127,6 +129,10 @@ func didPlayToEnd(in player: CLPlayer) { isOver = true print("视频播放进度:【完成】") + items[selectIndex.row].isOver = .yes + Services.watchClouse(chapterId: items[selectIndex.row].id, isOver: true, secondLook: items[selectIndex.row].duration).subscribe(onNext: { _ in + + }).disposed(by: disposeBag) } } diff --git a/XQMuse/Root/Course/View/CourseDetialCustomerView.swift b/XQMuse/Root/Course/View/CourseDetialCustomerView.swift index 5b31de8..ca0c9d3 100644 --- a/XQMuse/Root/Course/View/CourseDetialCustomerView.swift +++ b/XQMuse/Root/Course/View/CourseDetialCustomerView.swift @@ -37,7 +37,7 @@ override func layoutSubviews() { super.layoutSubviews() - btn_known.localGradientColor(cornerRadius: 20) + btn_known.localGradientColor(cornerRadius: 20,bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW - 62 * 2, height: 40)) } diff --git a/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_1_CCell.swift b/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_1_CCell.swift index 8115897..0fea82e 100644 --- a/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_1_CCell.swift +++ b/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_1_CCell.swift @@ -60,8 +60,14 @@ image_free.isHidden = true } + + if model.paymentStatus == .yes{ + label_waitPrice.attributedText = AttributedStringbuilder.build().add(string: "待支付|", withFont: .systemFont(ofSize: 10), withColor: .white).add(string: "¥", withFont: UIFont(name: "DIN-Bold", size: 7.11) ?? UIFont.systemFont(ofSize: 7, weight: .bold), withColor: .white).add(string: model.iosPrice.jq_formatFloat, withFont: UIFont(name: "DIN-Bold", size: 11.62) ?? UIFont.systemFont(ofSize: 11.62, weight: .bold), withColor: .white).mutableAttributedString + } + + view_waitPay.isHidden = model.paymentStatus == .no - label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: .systemFont(ofSize: 7.2, weight: .bold), withColor: .white).add(string: model.generalPrice.jq_formatFloat, withFont: .systemFont(ofSize: 11), withColor: .white).mutableAttributedString + label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: .systemFont(ofSize: 7.2, weight: .bold), withColor: .white).add(string: model.iosPrice.jq_formatFloat, withFont: .systemFont(ofSize: 11), withColor: .white).mutableAttributedString } func setMeditationModel(_ model:MeditationModel){ @@ -74,7 +80,7 @@ setChargePrice(model.chargeType, price: model.iosPrice) view_waitPay.isHidden = model.paymentStatus == .no - label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: .systemFont(ofSize: 7.2, weight: .bold), withColor: .white).add(string: model.generalPrice.jq_formatFloat, withFont: .systemFont(ofSize: 11), withColor: .white).mutableAttributedString + label_price.attributedText = AttributedStringbuilder.build().add(string: "¥", withFont: .systemFont(ofSize: 7.2, weight: .bold), withColor: .white).add(string: model.iosPrice.jq_formatFloat, withFont: .systemFont(ofSize: 11), withColor: .white).mutableAttributedString } private func setChargePrice(_ type:ChargeType,price:Double){ diff --git a/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_1_CCell.xib b/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_1_CCell.xib index b6d9715..4c59d29 100644 --- a/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_1_CCell.xib +++ b/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_1_CCell.xib @@ -5,7 +5,6 @@ <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> @@ -28,7 +27,7 @@ <rect key="frame" x="7.0000000000000018" y="5" width="28.666666666666671" height="25"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KaS-j6-dko"> - <rect key="frame" x="0.0" y="0.0" width="28.666666666666664" height="25"/> + <rect key="frame" x="0.0" y="0.0" width="28.666666666666668" height="25"/> <fontDescription key="fontDescription" type="system" pointSize="11"/> <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> @@ -101,26 +100,10 @@ <rect key="frame" x="8" y="7" width="34" height="18"/> </imageView> <view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YMY-eC-fwJ"> - <rect key="frame" x="7" y="6" width="72" height="19.666666666666668"/> + <rect key="frame" x="6.9999999999999982" y="6" width="24.333333333333329" height="19.666666666666668"/> <subviews> - <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kBI-mA-VCH"> - <rect key="frame" x="47" y="1.9999999999999991" width="1" height="14.666666666666664"/> - <color key="backgroundColor" systemColor="systemBackgroundColor"/> - <constraints> - <constraint firstAttribute="width" constant="1" id="u0p-Di-Lfe"/> - </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="y3v-m1-NFl"> - <rect key="frame" x="12" y="3.6666666666666661" width="30" height="12"/> - <constraints> - <constraint firstAttribute="width" constant="30" id="fw1-fA-fkr"/> - </constraints> - <fontDescription key="fontDescription" type="system" pointSize="10"/> - <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> - <nil key="highlightedColor"/> - </label> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PHh-bn-ZWL"> - <rect key="frame" x="54.666666666666664" y="0.0" width="10.333333333333336" height="19.666666666666668"/> + <rect key="frame" x="7" y="0.0" width="10.333333333333336" height="19.666666666666668"/> <fontDescription key="fontDescription" type="system" pointSize="17"/> <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> @@ -129,15 +112,10 @@ <color key="backgroundColor" red="0.8901960784313725" green="0.70196078431372544" blue="0.36862745098039218" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <constraints> <constraint firstAttribute="height" constant="19.5" id="6DB-9g-xbb"/> - <constraint firstItem="y3v-m1-NFl" firstAttribute="leading" secondItem="YMY-eC-fwJ" secondAttribute="leading" constant="12" id="Dtt-NR-dBw"/> <constraint firstAttribute="trailing" secondItem="PHh-bn-ZWL" secondAttribute="trailing" constant="7" id="HAa-Du-CzN"/> <constraint firstItem="PHh-bn-ZWL" firstAttribute="top" secondItem="YMY-eC-fwJ" secondAttribute="top" id="L41-FV-9iR"/> - <constraint firstItem="y3v-m1-NFl" firstAttribute="centerY" secondItem="YMY-eC-fwJ" secondAttribute="centerY" id="LCS-Qy-brQ"/> - <constraint firstItem="PHh-bn-ZWL" firstAttribute="leading" secondItem="kBI-mA-VCH" secondAttribute="trailing" constant="6.5" id="VS2-Fy-SHm"/> - <constraint firstAttribute="bottom" secondItem="kBI-mA-VCH" secondAttribute="bottom" constant="3" id="r3F-1o-hcV"/> - <constraint firstItem="kBI-mA-VCH" firstAttribute="leading" secondItem="y3v-m1-NFl" secondAttribute="trailing" constant="5" id="sPV-Eu-s1T"/> <constraint firstAttribute="bottom" secondItem="PHh-bn-ZWL" secondAttribute="bottom" id="tqb-zF-2Uz"/> - <constraint firstItem="kBI-mA-VCH" firstAttribute="top" secondItem="YMY-eC-fwJ" secondAttribute="top" constant="2" id="xBk-yf-Y9j"/> + <constraint firstItem="PHh-bn-ZWL" firstAttribute="leading" secondItem="YMY-eC-fwJ" secondAttribute="leading" constant="7" id="zMA-HG-aUl"/> </constraints> </view> </subviews> @@ -185,8 +163,5 @@ <image name="icon_offline" width="34" height="18"/> <image name="icon_use_small_s" width="9" height="9"/> <image name="icon_vip" width="25.666666030883789" height="25.666666030883789"/> - <systemColor name="systemBackgroundColor"> - <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> - </systemColor> </resources> </document> diff --git a/XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.swift b/XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.swift index 7834643..42bbf0e 100644 --- a/XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.swift +++ b/XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.swift @@ -27,19 +27,25 @@ func setMeditationModel(_ model:MeditationModel,showType:DisplayType){ self.showType = showType - if model.id == 0{ - cover_bgImage.image = UIImage(named: "bt_private");return - } + view_shadow.isHidden = model.id == 0 label_title.text = model.meditationTitle label_subTitle.text = model.coverDescription - let imgUrls = model.coverUrl.jq_urlEncoded().components(separatedBy: ",") - if showType == .horizontal{ - cover_bgImage.sd_setImage(with: URL(string: imgUrls.first)) + + if model.id == 0{ + cover_bgImage.image = UIImage(named: "bt_private") + cover_bgImage.backgroundColor = .red }else{ - cover_bgImage.sd_setImage(with: URL(string: imgUrls.last)) + let imgUrls = model.coverUrl.jq_urlEncoded().components(separatedBy: ",") + if showType == .horizontal{ + cover_bgImage.sd_setImage(with: URL(string: imgUrls.first)) + }else{ + cover_bgImage.sd_setImage(with: URL(string: imgUrls.last)) + } } + + } } diff --git a/XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.xib b/XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.xib index a92b905..2efc198 100644 --- a/XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.xib +++ b/XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.xib @@ -23,7 +23,7 @@ <constraint firstAttribute="height" constant="9.5" id="wsl-qN-1LP"/> </constraints> </view> - <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ajx-e3-nPT"> + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bt_private" translatesAutoresizingMaskIntoConstraints="NO" id="ajx-e3-nPT"> <rect key="frame" x="0.0" y="0.0" width="413" height="255.66666666666666"/> </imageView> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="all-AA-1bU"> @@ -36,13 +36,13 @@ <constraint firstAttribute="width" constant="14.5" id="cuz-Sz-rLa"/> </constraints> </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="tDO-qY-aGP"> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="--" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tDO-qY-aGP"> <rect key="frame" x="43" y="53.333333333333343" width="360" height="20.333333333333329"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="17"/> <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="can be switched on" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NTV-9E-3YX"> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="--" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NTV-9E-3YX"> <rect key="frame" x="43" y="77.666666666666686" width="360" height="12"/> <fontDescription key="fontDescription" type="system" pointSize="10"/> <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> @@ -86,6 +86,7 @@ </collectionViewCell> </objects> <resources> + <image name="bt_private" width="390" height="205.66667175292969"/> <image name="icon_pay_s" width="14.666666984558105" height="18.666666030883789"/> </resources> </document> diff --git a/XQMuse/Root/Home/HomeVC.swift b/XQMuse/Root/Home/HomeVC.swift index 8234d14..0e2b562 100644 --- a/XQMuse/Root/Home/HomeVC.swift +++ b/XQMuse/Root/Home/HomeVC.swift @@ -14,6 +14,8 @@ import CoreTelephony let SetBGMSuccess_Noti = Notification.Name.init("SetBGMSuccess_Noti") +let ToShowTree_Noti = Notification.Name.init("ToShowTree_Noti") +let ReloadData_Noti = Notification.Name.init("ReloadData_Noti") struct TitleItem{ var id = 0 @@ -26,7 +28,7 @@ class HomeViewModel{ var homeTopMenuItems = [HomeTopMenuItem]() var homeBottomMenuItems = [HomeTopMenuItem]() - var todyModel:MeditationModel? + var todyModel:ToDayMeditationModel? var privateTodyModels = [MeditationModel]() var meditationList = [MeditationListModel]() } @@ -37,6 +39,7 @@ private var titleItems = [TitleItem]() private var viewModel = HomeViewModel() private var timer:Timer? + private var needPopToTree:Bool = false //是否需要跳转到树苗 private var cellularData:CTCellularData! @@ -45,11 +48,28 @@ //获取用户信息 if !(UserViewModel.getLoginInfo()?.accessToken.isEmpty ?? true){ - Services.getUserDetail().subscribe(onNext: {data in + Services.isFirst().subscribe(onNext: {[weak self]data in + if data.data == true{ + self?.navigationController?.tabBarController?.selectedIndex = 2 + var viewModel = UserDefaultSettingViewModel.getSetting() + viewModel?.userFirstOpenTreeTask = true + UserDefaultSettingViewModel.saveSetting(viewModel!) + } + }).disposed(by: disposeBag) + + Services.getUserDetail(showProgress: false).subscribe(onNext: {data in if let m = data.data{UserViewModel.saveAvatarInfo(m)} }).disposed(by: disposeBag) } self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true + + if needPopToTree{ + navigationController?.tabBarController?.selectedIndex = 2 + } + + if AudioPlayer.getSharedInstance().scenePlayer?.timeControlStatus == .paused && UserDefaultSettingViewModel.getSetting()?.bgm != nil{ + AudioPlayer.getSharedInstance().playSceneAt(UserDefaultSettingViewModel.getSetting()!.bgm!.audioFile) + } } override func viewDidLoad() { @@ -94,12 +114,10 @@ if !state{ exit(0) }else{ - if var m = UserDefaultSettingViewModel.getSetting(){ m.userFirstLaunch = false UserDefaultSettingViewModel.saveSetting(m) } - //跳转计划引导 let nav = BaseNav(rootViewController: PlanGuideVC(isFromFist: true)) nav.modalPresentationStyle = .fullScreen @@ -199,16 +217,9 @@ NotificationCenter.default.rx.notification(PlantGuideQuit_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self]data in guard let weakSelf = self else { return } - weakSelf.getData() - Services.isFirst().subscribe(onNext: {data in - if data.data == true{ - weakSelf.navigationController?.tabBarController?.selectedIndex = 2 - let viewModel = UserDefaultSettingViewModel.getSetting() -// viewModel?.userFirstOpenTreeTask = false - UserDefaultSettingViewModel.saveSetting(viewModel!) - } - }).disposed(by: weakSelf.disposeBag) + weakSelf.needPopToTree = data.object as? Bool ?? false + weakSelf.getData() }).disposed(by: disposeBag) @@ -218,6 +229,11 @@ NotificationCenter.default.rx.notification(LoginQuit_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in self.getData() + }).disposed(by: disposeBag) + + + NotificationCenter.default.rx.notification(ReloadData_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in + self.tableView.reloadData() }).disposed(by: disposeBag) } @@ -250,24 +266,25 @@ }).disposed(by: disposeBag) Services.getTopdayMedita().subscribe(onNext: { data in - self.viewModel.todyModel = data.data?.clientMeditationVO + self.viewModel.todyModel = data.data self.tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none) }).disposed(by: disposeBag) + let m = MeditationModel() + m.id = 0 + self.viewModel.privateTodyModels = [m] if !(UserViewModel.getLoginInfo()?.accessToken.isEmpty ?? true){ Services.getPersonalityPlan().subscribe(onNext: { data in if let m = data.data{ if m.count > 0{ self.viewModel.privateTodyModels = m - }else{ - let m = MeditationModel() - m.id = 0 - self.viewModel.privateTodyModels = [m] } self.tableView.reloadRows(at: [IndexPath(row: 1, section: 0)], with: .none) } }).disposed(by: disposeBag) + }else{ + self.tableView.reloadData() } Services.getMeditationAndCateList().subscribe(onNext: { data in @@ -318,7 +335,7 @@ @objc func autoUpdate(){ print("--->") Services.getTopdayMedita().subscribe(onNext: { data in - self.viewModel.todyModel = data.data?.clientMeditationVO + self.viewModel.todyModel = data.data self.tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none) }).disposed(by: disposeBag) } @@ -357,20 +374,39 @@ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if indexPath.section == 0{ - if let m = viewModel.todyModel{ - Services.getMeditationDetail(id: m.id).subscribe(onNext: {[weak self]data in - guard let weakSelf = self else { return } - if let m = data.data{ - - if AudioPlayer.getSharedInstance().meditationModel?.id == m.id && AudioPlayer.getSharedInstance().bgmPlayer?.timeControlStatus == .playing{ - return - } - - AudioPlayer.getSharedInstance().playBGMAt(firstPlayIndex: 0, model: m, delegate: self) - PayMusicVC.show(model: m,isHidden: false) - self?.tableView.reloadData() + if let m = viewModel.todyModel,let detailId = m.clientMeditationVO?.id{ + if AudioPlayer.getSharedInstance().meditationModel?.id == m.meditationId{ + if AudioPlayer.getSharedInstance().bgmPlayer?.timeControlStatus == .paused{ + AudioPlayer.getSharedInstance().bgmPlayer?.play() + AudioPlayer.getSharedInstance().masterPlayer?.play() + PayMusicVC.updateStatus(.playing) + self.viewModel.todyModel?.playAtMe = true + }else{ + AudioPlayer.getSharedInstance().bgmPlayer?.pause() + AudioPlayer.getSharedInstance().masterPlayer?.pause() + PayMusicVC.updateStatus(.pause) + self.viewModel.todyModel?.playAtMe = false } - }).disposed(by: disposeBag) + DispatchQueue.main.asyncAfter(delay: 0.4) { + self.tableView.reloadData() + } + }else{ + //游客模式都能播放 + Services.getMeditationDetail(id: detailId).subscribe(onNext: {[weak self]data in + if let m = data.data{ + + if AudioPlayer.getSharedInstance().meditationModel?.id == m.id && AudioPlayer.getSharedInstance().bgmPlayer?.timeControlStatus == .playing{ + return + } + AudioPlayer.getSharedInstance().playBGMAt(firstPlayIndex: 0, model: m, delegate: self) + PayMusicVC.show(model: m,isHidden: false) + self?.viewModel.todyModel?.playAtMe = true + DispatchQueue.main.asyncAfter(delay: 1.0) { + self?.tableView.reloadData() + } + } + }).disposed(by: disposeBag) + } }else{ alert(msg: "平台暂未设置今日疗愈") } @@ -384,26 +420,28 @@ } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - if indexPath.section == 0{ + if indexPath.section == 0 && indexPath.row == 0{ //每日疗愈 let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_1_TCell") as! Home_Style_1_TCell if viewModel.todyModel?.id != 0{ cell.model = viewModel.todyModel cell.view_data.isHidden = false - cell.img_play.isHidden = AudioPlayer.getSharedInstance().meditationModel?.id == viewModel.todyModel?.id - }else{ cell.img_cover.image = UIImage(named: "bg_today") cell.view_data.isHidden = true } + + print("--->\(cell)") + + cell.setplaying() return cell - }else if indexPath.section == 1{ + }else if indexPath.section == 1 && indexPath.row == 0{ //私人定制 let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_4_TCell") as! Home_Style_4_TCell cell.style = .style1 cell.setModels(viewModel.privateTodyModels,showType: .horizontal) return cell - }else if indexPath.section == 2{ + }else if indexPath.section == 2 && indexPath.row == 0{ // 新手冥想指南 let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_2_TCell") as! Home_Style_2_TCell cell.imgView.image = UIImage(named: "bg_guide_home") diff --git a/XQMuse/Root/Home/TCell/Home_Style_1_TCell.swift b/XQMuse/Root/Home/TCell/Home_Style_1_TCell.swift index 14fc97b..4822a51 100644 --- a/XQMuse/Root/Home/TCell/Home_Style_1_TCell.swift +++ b/XQMuse/Root/Home/TCell/Home_Style_1_TCell.swift @@ -10,7 +10,7 @@ class Home_Style_1_TCell: UITableViewCell { - var model:MeditationModel?{ + var model:ToDayMeditationModel?{ didSet{ if let m = model{ @@ -19,14 +19,14 @@ view_data.isHidden = true }else{ view_data.isHidden = false - img_cover.sd_setImage(with: URL(string: m.coverUrl.jq_urlEncoded())) + img_cover.sd_setImage(with: URL(string: m.imageUrl.jq_urlEncoded())) let turple = Date.jq_formateToTime_tuple(m.time) let minute = (turple.hour * 60 + turple.minute) let second = turple.second - label_title.text = "\(m.meditationTitle) | \(String(format: "%.2ld:%.2ld", minute,second))" - label_joinNum.text = "\(m.realLearnedNum + m.virtualLearnedNum)人已参加学习" + label_title.text = "\(m.clientMeditationVO!.meditationTitle) | \(String(format: "%.2ld:%.2ld", minute,second))" + label_joinNum.text = "\(m.clientMeditationVO!.realLearnedNum + m.clientMeditationVO!.virtualLearnedNum)人已参加学习" } } } @@ -41,5 +41,9 @@ super.awakeFromNib() selectionStyle = .none } - + + func setplaying(){ + img_play.image = AudioPlayer.getSharedInstance().bgmPlayer?.timeControlStatus == .playing ? UIImage(named: "btn_pause"):UIImage(named: "icon_play") + } + } diff --git a/XQMuse/Root/Home/TCell/Home_Style_3_TCell.swift b/XQMuse/Root/Home/TCell/Home_Style_3_TCell.swift index 5c5db54..8549f30 100644 --- a/XQMuse/Root/Home/TCell/Home_Style_3_TCell.swift +++ b/XQMuse/Root/Home/TCell/Home_Style_3_TCell.swift @@ -53,6 +53,11 @@ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let item = meditationModels[indexPath.row] + if (item.chargeType == .payment || item.chargeType == .vipFree || item.id == 0) && (UserViewModel.getLoginInfo()?.token.isEmpty ?? true){ + sceneDelegate?.checkisLoginState() + return + } + Services.getMeditationDetail(id: item.id).subscribe(onNext: {[weak self]data in guard let weakSelf = self else { return } if let m = data.data{ diff --git a/XQMuse/Root/Home/TCell/Home_Style_4_TCell.swift b/XQMuse/Root/Home/TCell/Home_Style_4_TCell.swift index fc45a64..98ea54b 100644 --- a/XQMuse/Root/Home/TCell/Home_Style_4_TCell.swift +++ b/XQMuse/Root/Home/TCell/Home_Style_4_TCell.swift @@ -45,8 +45,9 @@ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let item = meditationModels[indexPath.row] - guard item.id != 0 else{ - alert(msg: "平台暂未设置私人定制");return + if (item.chargeType == .payment || item.chargeType == .vipFree || item.id == 0) && (UserViewModel.getLoginInfo()?.token.isEmpty ?? true){ + sceneDelegate?.checkisLoginState() + return } Services.getMeditationDetail(id: item.id).subscribe(onNext: {[weak self]data in @@ -73,23 +74,6 @@ } } }).disposed(by: disposeBag) - - - -// let isVip = UserViewModel.getAvatarInfo().checkVip() -// if m.chargeType == .free || (m.chargeType == .vipFree && isVip) || (m.chargeType == .payment && m.isBuy == .yes){ -// let detailVC = HomeItemDetailVC(id: meditationModels[indexPath.row].id) -// JQ_currentViewController().jq_push(vc: detailVC) -// }else{ -// if m.chargeType == .vipFree{ -// let vc = VIPCenterVC() -// JQ_currentViewController().jq_push(vc: vc) -// }else{ -// guard sceneDelegate!.checkisLoginState() else{return} -// let vc = PaymentOrderVC(museItemModel: m,type: .muse,showType: .horizontal) -// JQ_currentViewController().jq_push(vc:vc) -// } -// } } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { diff --git a/XQMuse/Root/Home/VC/BackgroundVoiceVC.swift b/XQMuse/Root/Home/VC/BackgroundVoiceVC.swift index 7d0a6de..dd77681 100644 --- a/XQMuse/Root/Home/VC/BackgroundVoiceVC.swift +++ b/XQMuse/Root/Home/VC/BackgroundVoiceVC.swift @@ -58,7 +58,11 @@ yy_popBlock = { [weak self] in if self?.needPopRoot ?? false{ - NotificationCenter.default.post(name: PlantGuideQuit_Noti, object: nil, userInfo: nil) + if JQ_currentNavigationController().viewControllers.first is PlanGuideVC{ + NotificationCenter.default.post(name: PlantGuideQuit_Noti, object: nil, userInfo: nil) + }else{ + self?.navigationController?.popViewController(animated: true) + } }else{ self?.navigationController?.popViewController(animated: true) } @@ -132,9 +136,9 @@ needPopRoot = true NotificationCenter.default.post(name: SetBGMSuccess_Noti, object: items[index.row]) - DispatchQueue.main.asyncAfter(delay: 0.6) { - self.navigationController?.popViewController() - } +// DispatchQueue.main.asyncAfter(delay: 0.6) { +// self.navigationController?.popViewController() +// } } } diff --git a/XQMuse/Root/Home/VC/HomeItemDetailVC.swift b/XQMuse/Root/Home/VC/HomeItemDetailVC.swift index c37eff1..79f4f8c 100644 --- a/XQMuse/Root/Home/VC/HomeItemDetailVC.swift +++ b/XQMuse/Root/Home/VC/HomeItemDetailVC.swift @@ -30,7 +30,6 @@ private var collect_bitem:UIBarButtonItem! private var audioPlayer:AudioPlayer = AudioPlayer.getSharedInstance() - private var id:Int! private var timeLook:Int = 0 //观看时间记录 private var settingViewModel = UserDefaultSettingViewModel.getSetting() @@ -38,11 +37,6 @@ private var totalInterval:TimeInterval = 0 private var model:MeditationModel? - -// init(id:Int) { -// super.init(nibName: nil, bundle: nil) -// self.id = id -// } init(model:MeditationModel) { super.init(nibName: nil, bundle: nil) @@ -85,8 +79,14 @@ self.collect_bitem.image = m.favorite == .yes ? UIImage(named: "btn_collect_1_s"):UIImage(named: "btn_collect_1") self.collect_bitem.tintColor = m.favorite == .yes ? UIColor(hexString: "fe5b60"):.white self.img_background.sd_setImage(with: URL(string: m.backgroundUrl.jq_urlEncoded())) + + if audioPlayer.meditationModel?.id == m.id{ audioPlayer.delegate = self + let value = ((audioPlayer.bgmPlayer?.currentTime().seconds)! / 100.0) * (audioPlayer.bgmPlayer?.currentItem?.duration.seconds)! + if self.audioPlayer.bgmPlayer?.timeControlStatus == .paused{ + self.audioPlayer.setBGMRate(value: value) + } } } @@ -186,21 +186,26 @@ @IBAction func playAction(_ sender: UIButton) { sender.isSelected = !sender.isSelected + showHUD() if let m = model{ if sender.isSelected{ if audioPlayer.meditationModel != nil{ if audioPlayer.meditationModel?.id != m.id{ audioPlayer.playBGMAt(firstPlayIndex: 0, model: m, delegate: self,coverImage: img_background.image) + PayMusicVC.updateStatus(.playing) }else{ audioPlayer.bgmPlayer?.play() audioPlayer.masterPlayer?.play() + PayMusicVC.updateStatus(.playing) } - }else{ audioPlayer.playBGMAt(firstPlayIndex: 0, model: m, delegate: self,coverImage: img_background.image) + PayMusicVC.updateStatus(.playing) } }else{ audioPlayer.bgmPlayer?.pause() + audioPlayer.masterPlayer?.pause() + PayMusicVC.updateStatus(.pause) } } } @@ -271,7 +276,8 @@ } @objc func collectionAction(){ - Services.meditationFavorite(id: id).subscribe(onNext: {data in + guard let id = model?.id else {return} + Services.meditationFavorite(id: id).subscribe(onNext: {data in self.model?.favorite.troggle() if self.model?.favorite == .yes{ alertSuccess(msg: "收藏成功") @@ -303,15 +309,17 @@ func playState(_ state:PlayMusicState){ print("music:当前状态:\(state)") + hiddenHUD() guard audioPlayer.meditationModel?.id == model?.id else {return} + + btn_play.isSelected = self.audioPlayer.bgmPlayer?.timeControlStatus == .playing switch state { case .playing: PayMusicVC.show(model: model!) - if btn_play.isHidden == false {btn_play.isHidden = true} hiddenHUD() - case .paurse:btn_play.isHidden = false + case .paurse:break case .end:break case .next:break } diff --git a/XQMuse/Root/Home/VC/HomeItemDetailVC.xib b/XQMuse/Root/Home/VC/HomeItemDetailVC.xib index 12743c2..1fe3298 100644 --- a/XQMuse/Root/Home/VC/HomeItemDetailVC.xib +++ b/XQMuse/Root/Home/VC/HomeItemDetailVC.xib @@ -170,6 +170,7 @@ </constraints> <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> <state key="normal" image="btn_play"/> + <state key="selected" image="btn_pause"/> <connections> <action selector="playAction:" destination="-1" eventType="touchUpInside" id="DT7-8R-5nM"/> </connections> @@ -252,6 +253,7 @@ <resources> <image name="btn_comment" width="18.666666030883789" height="19"/> <image name="btn_list" width="17" height="13.666666984558105"/> + <image name="btn_pause" width="65.666664123535156" height="65.666664123535156"/> <image name="btn_play" width="65.666664123535156" height="65.666664123535156"/> <image name="btn_roll" width="22.666666030883789" height="19.666666030883789"/> <image name="btn_roll_loop" width="22.666666030883789" height="19.666666030883789"/> diff --git a/XQMuse/Root/Home/VC/PaymentOrderVC.swift b/XQMuse/Root/Home/VC/PaymentOrderVC.swift index 2dd203d..7d109a2 100644 --- a/XQMuse/Root/Home/VC/PaymentOrderVC.swift +++ b/XQMuse/Root/Home/VC/PaymentOrderVC.swift @@ -7,6 +7,7 @@ import UIKit import QMUIKit +import JQTools let Refreh_PaymentWallet_Noti = Notification.Name.init("Refreh_PaymentWallet_Noti") @@ -47,14 +48,16 @@ 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) { @@ -69,7 +72,17 @@ 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 @@ -85,6 +98,10 @@ } 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 @@ -110,6 +127,26 @@ }).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 @@ -119,9 +156,14 @@ @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 } @@ -133,20 +175,25 @@ 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) } @@ -184,7 +231,6 @@ id = m.id } - guard btn_isRead.isSelected else { alertError(msg: "请先阅读并同意《课程/疗愈音频购买协议》");return } @@ -209,6 +255,20 @@ 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 diff --git a/XQMuse/Root/Login/VC/ForgotPasswordInputCodeVC.swift b/XQMuse/Root/Login/VC/ForgotPasswordInputCodeVC.swift index 12215ba..f9040ad 100644 --- a/XQMuse/Root/Login/VC/ForgotPasswordInputCodeVC.swift +++ b/XQMuse/Root/Login/VC/ForgotPasswordInputCodeVC.swift @@ -141,7 +141,7 @@ self.push(vc: vc) } }else{ - Popup_1_View.show(state: .fail, title: "验证失败", subtitle:"手机号验证失败") { + Popup_1_View.show(state: .fail, title: "验证失败", subtitle:"验证码错误") { } } diff --git a/XQMuse/Root/Login/VC/RegisterVC.swift b/XQMuse/Root/Login/VC/RegisterVC.swift index b344c86..9839429 100644 --- a/XQMuse/Root/Login/VC/RegisterVC.swift +++ b/XQMuse/Root/Login/VC/RegisterVC.swift @@ -138,16 +138,24 @@ @IBAction func userResigerAgreementAction(_ sender: Any) { - let vc = WebVC(type: .user) - vc.title = "用户注册协议" - push(vc: vc) + let vc = LoginTreatyVC() + vc.topIndex = 0 + vc.clickHandle {[unowned self] state in + self.btn_isRead.isSelected = state + } + vc.modalPresentationStyle = .custom + present(vc, animated: true) } @IBAction func userPrivateAgreementAction(_ sender: Any) { - let vc = WebVC(type: .privacy) - vc.title = "用户隐私协议" - push(vc: vc) + let vc = LoginTreatyVC() + vc.topIndex = 1 + vc.clickHandle {[unowned self] state in + self.btn_isRead.isSelected = state + } + vc.modalPresentationStyle = .custom + present(vc, animated: true) } diff --git a/XQMuse/Root/Me/MeVC.swift b/XQMuse/Root/Me/MeVC.swift index 78a2f92..fdd1bb5 100644 --- a/XQMuse/Root/Me/MeVC.swift +++ b/XQMuse/Root/Me/MeVC.swift @@ -146,7 +146,7 @@ @objc func rankAction(){ guard sceneDelegate!.checkisLoginState() else {return} - let vc = WebVC(url: ShareUrl + "/ranking/ranking?userId=\(UserViewModel.getAvatarInfo().id)") + let vc = WebVC(url: ShareUrl + "/ranking/ranking?userId=\(UserViewModel.getAvatarInfo().id)",showHelp: true) vc.title = "爱心榜单" push(vc: vc) } @@ -228,6 +228,7 @@ @IBAction func shareAction(_ sender: QMUIButton) { guard sceneDelegate!.checkisLoginState() else {return} let vc = InviteVC() + vc.title = "推广活动" push(vc: vc) } } diff --git a/XQMuse/Root/Me/VC/AddBankInfoVC.swift b/XQMuse/Root/Me/VC/AddBankInfoVC.swift index c8dfb83..b22d47f 100644 --- a/XQMuse/Root/Me/VC/AddBankInfoVC.swift +++ b/XQMuse/Root/Me/VC/AddBankInfoVC.swift @@ -97,7 +97,7 @@ override func setUI() { view.backgroundColor = UIColor(hexString: "f6f6f6") - btn_add.localGradientColor(cornerRadius: 20) + btn_add.localGradientColor(cornerRadius: 20,bounds: CGRect(x: 0, y: 0, width: JQ_ScreenW - 45 * 2, height: 40)) } @IBAction func addhandleAction(_ sender: UIButton) { diff --git a/XQMuse/Root/Me/VC/AddBankInfoVC.xib b/XQMuse/Root/Me/VC/AddBankInfoVC.xib index 0943bcf..0d7df4c 100644 --- a/XQMuse/Root/Me/VC/AddBankInfoVC.xib +++ b/XQMuse/Root/Me/VC/AddBankInfoVC.xib @@ -174,7 +174,7 @@ <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.80000000000000004" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> - <textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="BaQ-Md-hAN" customClass="QMUITextField"> + <textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="银行预留手机号" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="BaQ-Md-hAN" customClass="QMUITextField"> <rect key="frame" x="90" y="14.666666666666686" width="265" height="21"/> <fontDescription key="fontDescription" type="system" pointSize="16"/> <textInputTraits key="textInputTraits" keyboardType="numberPad"/> diff --git a/XQMuse/Root/Me/VC/InviteVC.swift b/XQMuse/Root/Me/VC/InviteVC.swift index 90d1c42..d038ac8 100644 --- a/XQMuse/Root/Me/VC/InviteVC.swift +++ b/XQMuse/Root/Me/VC/InviteVC.swift @@ -17,13 +17,17 @@ @IBOutlet weak var label_role: UILabel! @IBOutlet weak var img_qrCode: UIImageView! @IBOutlet weak var img_poster: UIImageView! + @IBOutlet weak var view_bottomImage: UIView! + @IBOutlet weak var img_footerqrCode: UIImageView! override func viewDidLoad() { super.viewDidLoad() title = "推广活动" + self.view_bottomImage.isHidden = true Services.getCommissionRule().subscribe(onNext: {data in if let m = data.data{ + self.img_footerqrCode.sd_setImage(with: URL(string: m.qrCode)) self.img_qrCode.sd_setImage(with: URL(string: m.qrCode)) self.img_poster.sd_setImage(with: URL(string: m.poster)) self.label_role.attributedText = NSAttributedString.convertHtml(m.rules) @@ -44,7 +48,17 @@ let string = String(format: "%@%@?userId=%ld", ShareUrl,"/poster/poster",UserViewModel.getAvatarInfo().id) ShareView.show(URL(string: string)!, title: "心泉疗愈", desc: "心泉疗愈1",hasSave: true) {[weak self] in - self?.scrollView.jq_captureAsLongImage(saveToAlbum: true) + self?.view_role.isHidden = true + self?.btn_share.isHidden = true + self?.img_qrCode.isHidden = true + self?.view_bottomImage.isHidden = false + self?.view.jq_captureToImage(true) + self?.img_qrCode.isHidden = false + self?.view_role.isHidden = false + self?.btn_share.isHidden = false + self?.view_bottomImage.isHidden = true + +// self?.scrollView.jq_captureAsLongImage(saveToAlbum: true) alertSuccess(msg: "已保存至相册") } } diff --git a/XQMuse/Root/Me/VC/InviteVC.xib b/XQMuse/Root/Me/VC/InviteVC.xib index 7e39a4f..724ddc7 100644 --- a/XQMuse/Root/Me/VC/InviteVC.xib +++ b/XQMuse/Root/Me/VC/InviteVC.xib @@ -12,12 +12,14 @@ <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="InviteVC" customModule="XQMuse" customModuleProvider="target"> <connections> <outlet property="btn_share" destination="XbP-tV-8pd" id="0YX-oc-VDx"/> + <outlet property="img_footerqrCode" destination="TAD-Ax-Dge" id="GzX-8L-xdy"/> <outlet property="img_poster" destination="IZY-Nj-jD0" id="hnL-OL-dhs"/> <outlet property="img_qrCode" destination="bff-wn-eyk" id="FV9-RT-3rK"/> <outlet property="label_role" destination="PXe-Ef-0Zn" id="E0d-R5-kBO"/> <outlet property="label_title" destination="oFE-SE-88r" id="C2L-3T-B60"/> <outlet property="scrollView" destination="Kj8-pf-QQp" id="30y-rn-UUc"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> + <outlet property="view_bottomImage" destination="Boi-rd-9ge" id="bGC-MH-3XL"/> <outlet property="view_role" destination="nfc-1h-yql" id="FWd-fZ-91R"/> </connections> </placeholder> @@ -26,8 +28,8 @@ <rect key="frame" x="0.0" y="0.0" width="393" height="852"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bg_invite" translatesAutoresizingMaskIntoConstraints="NO" id="IZY-Nj-jD0"> - <rect key="frame" x="0.0" y="0.0" width="393" height="483.66666666666669"/> + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="top" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bg_invite" translatesAutoresizingMaskIntoConstraints="NO" id="IZY-Nj-jD0"> + <rect key="frame" x="0.0" y="0.0" width="393" height="852"/> </imageView> <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kj8-pf-QQp"> <rect key="frame" x="0.0" y="59" width="393" height="759"/> @@ -84,7 +86,7 @@ <nil key="highlightedColor"/> </label> </subviews> - <color key="backgroundColor" systemColor="systemBackgroundColor"/> + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <constraints> <constraint firstAttribute="trailing" secondItem="PXe-Ef-0Zn" secondAttribute="trailing" constant="20" id="50t-3i-mW2"/> <constraint firstAttribute="bottom" secondItem="PXe-Ef-0Zn" secondAttribute="bottom" constant="20" id="9Xa-Zo-T2i"/> @@ -120,17 +122,37 @@ <constraint firstItem="fRO-Jr-RG3" firstAttribute="leading" secondItem="Kj8-pf-QQp" secondAttribute="leading" id="g3X-lW-OHt"/> </constraints> </scrollView> + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Boi-rd-9ge"> + <rect key="frame" x="283" y="705" width="96" height="96"/> + <subviews> + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="TAD-Ax-Dge"> + <rect key="frame" x="0.0" y="0.0" width="96" height="96"/> + </imageView> + </subviews> + <color key="backgroundColor" systemColor="systemBackgroundColor"/> + <constraints> + <constraint firstItem="TAD-Ax-Dge" firstAttribute="leading" secondItem="Boi-rd-9ge" secondAttribute="leading" id="0zA-ho-kTu"/> + <constraint firstItem="TAD-Ax-Dge" firstAttribute="top" secondItem="Boi-rd-9ge" secondAttribute="top" id="SG2-Zk-4QW"/> + <constraint firstAttribute="trailing" secondItem="TAD-Ax-Dge" secondAttribute="trailing" id="WzN-RF-ZAJ"/> + <constraint firstAttribute="height" constant="96" id="Y6b-nW-p3s"/> + <constraint firstAttribute="bottom" secondItem="TAD-Ax-Dge" secondAttribute="bottom" id="hFq-3e-T71"/> + <constraint firstAttribute="width" constant="96" id="q69-Wm-x6Z"/> + </constraints> + </view> </subviews> <viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> + <constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="Boi-rd-9ge" secondAttribute="bottom" constant="17" id="9s3-Dw-jox"/> <constraint firstItem="Kj8-pf-QQp" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" id="IMW-r4-OkS"/> <constraint firstItem="IZY-Nj-jD0" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="PQ2-Ha-kPM"/> <constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="Kj8-pf-QQp" secondAttribute="bottom" id="TFq-oj-nHs"/> <constraint firstItem="IZY-Nj-jD0" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="TH6-Zy-Z3J"/> <constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="Kj8-pf-QQp" secondAttribute="trailing" id="YAi-5i-Bes"/> <constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="IZY-Nj-jD0" secondAttribute="trailing" id="cef-7x-EhS"/> + <constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="Boi-rd-9ge" secondAttribute="trailing" constant="14" id="gak-ro-R2Q"/> <constraint firstItem="Kj8-pf-QQp" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="p90-x8-H82"/> + <constraint firstAttribute="bottom" secondItem="IZY-Nj-jD0" secondAttribute="bottom" id="wJW-aB-hUa"/> </constraints> <point key="canvasLocation" x="139.69465648854961" y="20.422535211267608"/> </view> diff --git a/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.swift b/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.swift index 7320046..ad9eb50 100644 --- a/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.swift +++ b/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.swift @@ -29,7 +29,7 @@ title = "系统消息" label_title.text = model.title label_content.text = model.content - label_date.text = model.publishTime + label_date.text = model.time } override func setUI() { diff --git a/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.swift b/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.swift index fe8eb99..df22d50 100644 --- a/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.swift +++ b/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.swift @@ -34,7 +34,7 @@ override func viewDidLoad() { super.viewDidLoad() title = "回复消息" - let avartarImageUrl = model.iconUrl.components(separatedBy: ",").first?.jq_urlEncoded() + let avartarImageUrl = model.iconUrl.components(separatedBy: ",").last?.jq_urlEncoded() image_avartar.sd_setImage(with: URL(string: avartarImageUrl)) label_name.text = model.meditationTitle label_content.text = model.coverDescription diff --git a/XQMuse/Root/Me/VC/SpendingDetailInfoVC.swift b/XQMuse/Root/Me/VC/SpendingDetailInfoVC.swift index 911a521..a336df2 100644 --- a/XQMuse/Root/Me/VC/SpendingDetailInfoVC.swift +++ b/XQMuse/Root/Me/VC/SpendingDetailInfoVC.swift @@ -9,10 +9,15 @@ class SpendingDetailInfoVC: BaseVC { - + @IBOutlet weak var label_price_title: UILabel! + @IBOutlet weak var label_price: UILabel! @IBOutlet weak var label_incomeType: UILabel! + @IBOutlet weak var label_incomeType_title: UILabel! + + @IBOutlet weak var label_datetime: UILabel! + @IBOutlet weak var label_datetime_title: UILabel! @IBOutlet weak var label_orderNum: UILabel! @IBOutlet weak var label_subUserName: UILabel! @IBOutlet weak var image_subUserAvartar: UIImageView! @@ -38,7 +43,7 @@ override func viewDidLoad() { super.viewDidLoad() - title = "收入详情" +// title = "收入详情" navigationController?.navigationBar.scrollEdgeAppearance?.backgroundColor = .white view_incomeType.isHidden = true @@ -50,9 +55,18 @@ Services.balanceDetail(id: id).subscribe(onNext: {data in if let m = data.data{ + if m.changeType == .increase{ + self.title = "收入详情" + }else{ + self.title = "支出详情" + self.label_price_title.text = "交易金额" + self.label_incomeType_title.text = "交易类型" + self.label_datetime_title.text = "交易时间" + } + self.view_incomeType.isHidden = false self.view_datetime.isHidden = false - self.view_orderNum.isHidden = false + self.view_orderNum.isHidden = !m.type.contains("充值") self.view_remark.isHidden = false if m.changeType == .increase{ diff --git a/XQMuse/Root/Me/VC/SpendingDetailInfoVC.xib b/XQMuse/Root/Me/VC/SpendingDetailInfoVC.xib index d1d657c..ccf23a0 100644 --- a/XQMuse/Root/Me/VC/SpendingDetailInfoVC.xib +++ b/XQMuse/Root/Me/VC/SpendingDetailInfoVC.xib @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> +<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="22685"/> + <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"/> @@ -13,9 +13,12 @@ <connections> <outlet property="image_subUserAvartar" destination="Xrs-Ns-uus" id="BWY-Ym-dbP"/> <outlet property="label_datetime" destination="Cv1-Z7-VpI" id="dAs-uh-cnZ"/> + <outlet property="label_datetime_title" destination="2ep-Yl-gTQ" id="uN7-kR-dpm"/> <outlet property="label_incomeType" destination="Vch-45-s0U" id="Fka-TJ-wqx"/> + <outlet property="label_incomeType_title" destination="c50-FX-5d4" id="bPy-Dw-ReC"/> <outlet property="label_orderNum" destination="fQy-0x-TJ9" id="Nea-dJ-cM9"/> <outlet property="label_price" destination="5gW-lj-8Uk" id="U1G-mZ-ph0"/> + <outlet property="label_price_title" destination="Czb-wC-0GY" id="BmH-53-dg5"/> <outlet property="label_remakr" destination="3JX-nJ-8Mi" id="gVL-aU-3ws"/> <outlet property="label_subUserName" destination="lLV-Rs-74K" id="48c-Ll-e0R"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> @@ -35,7 +38,7 @@ <rect key="frame" x="14" y="68" width="365" height="234"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="余额" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Czb-wC-0GY"> - <rect key="frame" x="10" y="17" width="32.666666666666664" height="14"/> + <rect key="frame" x="10" y="17" width="32" height="14"/> <constraints> <constraint firstAttribute="height" constant="14" id="7Tc-45-Re5"/> </constraints> @@ -63,7 +66,7 @@ <rect key="frame" x="0.0" y="0.0" width="345" height="17"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="收入类型" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="c50-FX-5d4"> - <rect key="frame" x="0.0" y="1.3333333333333437" width="49.333333333333336" height="14.333333333333336"/> + <rect key="frame" x="0.0" y="1.3333333333333437" width="48" height="14.333333333333336"/> <fontDescription key="fontDescription" type="system" pointSize="12"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> @@ -88,7 +91,7 @@ <rect key="frame" x="0.0" y="31" width="345" height="17"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="时间" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2ep-Yl-gTQ"> - <rect key="frame" x="0.0" y="1.3333333333333437" width="24.666666666666668" height="14.333333333333336"/> + <rect key="frame" x="0.0" y="1.3333333333333437" width="24" height="14.333333333333336"/> <fontDescription key="fontDescription" type="system" pointSize="12"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> @@ -113,7 +116,7 @@ <rect key="frame" x="0.0" y="62" width="345" height="17"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="流水单号" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4Zm-gu-UT7"> - <rect key="frame" x="0.0" y="1.3333333333333437" width="49.333333333333336" height="14.333333333333336"/> + <rect key="frame" x="0.0" y="1.3333333333333437" width="48" height="14.333333333333336"/> <fontDescription key="fontDescription" type="system" pointSize="12"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> @@ -138,7 +141,7 @@ <rect key="frame" x="0.0" y="93" width="345" height="28"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="下级用户" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BoT-97-SXQ"> - <rect key="frame" x="0.0" y="7.0000000000000009" width="49.333333333333336" height="14.333333333333336"/> + <rect key="frame" x="0.0" y="7.0000000000000009" width="48" height="14.333333333333336"/> <fontDescription key="fontDescription" type="system" pointSize="12"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> @@ -179,7 +182,7 @@ <rect key="frame" x="0.0" y="135" width="345" height="17"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="备注" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="S3M-IX-Tpo"> - <rect key="frame" x="0.0" y="1.3333333333333153" width="24.666666666666668" height="14.333333333333336"/> + <rect key="frame" x="0.0" y="1.3333333333333153" width="24" height="14.333333333333336"/> <fontDescription key="fontDescription" type="system" pointSize="12"/> <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.59999999999999998" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> diff --git a/XQMuse/Root/Me/VC/StudyListVC.swift b/XQMuse/Root/Me/VC/StudyListVC.swift index dbe66af..ad7fa1d 100644 --- a/XQMuse/Root/Me/VC/StudyListVC.swift +++ b/XQMuse/Root/Me/VC/StudyListVC.swift @@ -60,7 +60,7 @@ modelId = datas?.courseList[indexPath.row].id } - if indexPath.section == 0{ + if indexPath.section == 1{ guard datas?.freeCourseList.count != 0 else{return} modelId = datas?.freeCourseList[indexPath.row].id } @@ -96,11 +96,19 @@ }else{ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_1_CCell", for: indexPath) as! HomeRelaxBanner_2_1_CCell cell.setCourseModel(datas!.courseList[indexPath.row]) + cell.view_price.isHidden = true + cell.view_waitPay.isHidden = true + cell.image_free.isHidden = true + cell.img_vip.isHidden = true return cell } }else{ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_1_CCell", for: indexPath) as! HomeRelaxBanner_2_1_CCell cell.setCourseModel(datas!.freeCourseList[indexPath.row]) + cell.view_price.isHidden = true + cell.view_waitPay.isHidden = true + cell.image_free.isHidden = true + cell.img_vip.isHidden = true return cell } } diff --git a/XQMuse/Root/Me/VC/UserProfileVC.swift b/XQMuse/Root/Me/VC/UserProfileVC.swift index 27ed80e..4a0a5b8 100644 --- a/XQMuse/Root/Me/VC/UserProfileVC.swift +++ b/XQMuse/Root/Me/VC/UserProfileVC.swift @@ -67,7 +67,7 @@ tf_nickName.text = UserViewModel.getAvatarInfo().nickname tf_realName.text = UserViewModel.getAvatarInfo().realname tf_sign.text = UserViewModel.getAvatarInfo().signature - tf_gender.text = UserViewModel.getAvatarInfo().gender.rawTitle + tf_gender.text = UserViewModel.getAvatarInfo().gender?.rawTitle ?? "" tf_birthday.text = UserViewModel.getAvatarInfo().birthday tf_degree.text = UserViewModel.getAvatarInfo().education tf_industry.text = UserViewModel.getAvatarInfo().industry diff --git a/XQMuse/Root/Me/VC/VIPCenterVC.swift b/XQMuse/Root/Me/VC/VIPCenterVC.swift index 6dfe76c..240b1b2 100644 --- a/XQMuse/Root/Me/VC/VIPCenterVC.swift +++ b/XQMuse/Root/Me/VC/VIPCenterVC.swift @@ -9,6 +9,8 @@ import JQTools import StoreKit import WebKit +import SwiftyStoreKit +import RxSwift class VIPCenterVC: BaseVC { @@ -23,15 +25,15 @@ private var productList = Set<String>() private var products = [SKProduct]() + private var timeLoopDisposeBag = DisposeBag() override func viewDidLoad() { super.viewDidLoad() title = "会员中心" - productList.insert("com.XQMuse.VIP.month.0") - productList.insert("com.XQMuse.VIP.semester.0") - productList.insert("com.XQMuse.VIP.year.0") - productList.insert("com.XQMuse.VIP.year.renewing.0") + 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") collectionView.delegate = self collectionView.dataSource = self @@ -84,12 +86,42 @@ alert(msg: "请先阅读并同意《会员用户协议》");return } + 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 ?? "" - InPurchaseManager.purchaseProduct(ID: product.productIdentifier, applicationUsername: "") { m in - + 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: error.localizedDescription) } @@ -199,7 +231,21 @@ func isSelect(_ state:Bool,product:SKProduct){ label_title.text = product.localizedTitle - let priorDayPrice = product.price.doubleValue / 365.0 + + var priorDayPrice:Double = 0 + switch product.productIdentifier { + case "com.XQmuse.Non.renewing.year.1": + priorDayPrice = product.price.doubleValue / 365.0 + case "com.XQmuse.Non.renewing.half.year.1": + priorDayPrice = product.price.doubleValue / 180.0 + case "com.XQmuse.Non.renewing.month.1": + priorDayPrice = product.price.doubleValue / 30.0 + default: + priorDayPrice = product.price.doubleValue + } + + + lable_priorDay.text = String(format:"%@%@/天", product.priceLocale.currencySymbol!,priorDayPrice.jq_formatFloat) if state{ contentView.backgroundColor = UIColor(hexString: "#A6C586") diff --git a/XQMuse/Root/Me/VC/WalletRechargeVC.swift b/XQMuse/Root/Me/VC/WalletRechargeVC.swift index 061432d..e434cd5 100644 --- a/XQMuse/Root/Me/VC/WalletRechargeVC.swift +++ b/XQMuse/Root/Me/VC/WalletRechargeVC.swift @@ -8,6 +8,7 @@ import UIKit import JQTools import StoreKit +import RxSwift class WalletRechargeVC: BaseVC { @@ -20,7 +21,9 @@ private let cellH:Double = 35 private var productList = Set<String>() private var products = [SKProduct]() - + private var oldPrice:Double = 0 + private var timeLoopDisposeBag = DisposeBag() + override func viewDidLoad() { super.viewDidLoad() title = "疗愈币充值" @@ -42,6 +45,12 @@ let h = ceil(4.0 / 4.0) * cellH + floor((4.0 - 1) / 4.0) * 27.0 cons_collectionHei.constant = h view.layoutIfNeeded() + + Services.myWallet().subscribe(onNext: {data in + if let m = data.data{ + self.oldPrice = m.recharge + } + }).disposed(by: disposeBag) InPurchaseManager.instance().setProductList(productList) { products in self.products = Array(products) @@ -68,11 +77,31 @@ sceneDelegate?.needLogin() return} + showHUD("正在进行内购买") let product = products[selectIndexPath.row] - InPurchaseManager.purchaseProduct(ID: product.productIdentifier, applicationUsername: userId.string) { model in - if model.status == 0{ - //需要后端监听推送后,才会更新金额,可能延迟 - NotificationCenter.default.post(name: Refreh_PaymentWallet_Noti, object: nil) + 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) } } errorClouse: { error in alertError(msg: error.localizedDescription) @@ -95,7 +124,7 @@ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_WalletCCell", for: indexPath) as! WalletCCell cell.selectAt(indexPath == selectIndexPath) let product = products[indexPath.row] - cell.lable_title.text = product.localizedTitle + cell.lable_title.text = product.price.stringValue btn_handle.isEnabled = true btn_handle.alpha = 1.0 diff --git a/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift b/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift index 28e4798..d9bc092 100644 --- a/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift +++ b/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift @@ -10,6 +10,8 @@ import RxRelay import RxSwift +let WatchHistory_Noti = Notification.Name.init("WatchHistory_Noti") + class WatchHistoryViewModel:RefreshModel<CourseModel>{ let state = BehaviorRelay<Int>(value: 1) @@ -62,6 +64,12 @@ viewModel.configure(collectionView) viewModel.beginRefresh() } + + override func setRx() { + NotificationCenter.default.rx.notification(WatchHistory_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] _ in + self?.viewModel.beginRefresh() + }).disposed(by: disposeBag) + } } extension WatchHistoryDetailVC:UICollectionViewDelegate & UICollectionViewDataSource{ @@ -89,27 +97,43 @@ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let m = viewModel.dataSource.value[indexPath.row] - - if m.paymentStatus == .yes{ - //todo - - return - } - + let item = viewModel.dataSource.value[indexPath.row] if viewModel.state.value == 1{ - Services.getMeditationDetail(id: m.businessId).subscribe(onNext: {data in + //待支付 + if item.paymentStatus == .yes{ + Services.getMeditationDetail(id: item.businessId).subscribe(onNext: {data in + if let m = data.data{ + let vc = PaymentOrderVC(museItemModel: m, type: .muse, giftToOther: false, showType: .horizontal,businessId: item.id) + JQ_currentViewController().jq_push(vc: vc) + } + }).disposed(by: disposeBag) + return + } + + + Services.getMeditationDetail(id: item.businessId).subscribe(onNext: {data in if let m = data.data{ let vc = HomeItemDetailVC(model: m) JQ_currentViewController().jq_push(vc: vc) } }).disposed(by: disposeBag) }else{ - if m.courseType == .online{ -// let vc = CourseDetialVC(courseId: m.businessId) -// JQ_currentViewController().jq_push(vc: vc) - Services.getCourseDetail(courseId: m.businessId).subscribe(onNext: {data in + if item.courseType == .online{ + + //待支付 + if item.paymentStatus == .yes{ + Services.getCourseDetail(courseId: item.businessId).subscribe(onNext: { data in + if let m = data.data{ + let vc = PaymentOrderVC(courseItemModel: m, type: .course, giftToOther: false, showType: .horizontal,businessId: item.id) + JQ_currentViewController().jq_push(vc: vc) + } + }).disposed(by: disposeBag) + return + } + + + Services.getCourseDetail(courseId: item.businessId).subscribe(onNext: {data in if let m = data.data{ if m.isVip == .no && m.chargeType == .vipFree{ let vc = VIPCenterVC() @@ -124,7 +148,7 @@ } }).disposed(by: disposeBag) }else{ - let vc = CourseDetialOfflineVC(courseId: m.businessId) + let vc = CourseDetialOfflineVC(courseId: item.businessId) push(vc: vc) } } diff --git a/XQMuse/Root/Network/Models.swift b/XQMuse/Root/Network/Models.swift index 10fb30a..4d91bf2 100644 --- a/XQMuse/Root/Network/Models.swift +++ b/XQMuse/Root/Network/Models.swift @@ -80,6 +80,9 @@ var imageUrl: String = "" var meditationId: Int = 0 var startPlayTime: String = "" + var time:Int = 0 + + var playAtMe:Bool = false } struct MeditationListModel:HandyJSON{ @@ -124,6 +127,7 @@ var paymentStatus:ConditionType = .no //支付状态 1待支付 2已支付 var isVip:ConditionType = .no var time:Int = 0 + var imageUrl:String = "" required init(){} } @@ -202,13 +206,14 @@ var paymentStatus:ConditionType = .no //支付状态 1待支付 2已支付 var coverDescription:String = "" + var courseId:Int? var list2 = [CourseModel]() var list = [CourseItemModel]() required init(){} } -struct CourseItemModel:HandyJSON{ +class CourseItemModel:HandyJSON{ var chapterTitle:String = "" var courseId: Int = 0 var createBy:String = "" @@ -225,6 +230,8 @@ var updateTime:String = "" var videoUrl:String = "" var virtualLearnedNum: Int = 0 + + required init(){} } @@ -245,7 +252,7 @@ var email: String = "" var freezingOperator: String = "" var freezingReason: String = "" - var gender: GenderType = .encrypt + var gender: GenderType? var hometown: String = "" var id: Int = 0 var income: Int = 0 diff --git a/XQMuse/Root/Network/NetworkRequest.swift b/XQMuse/Root/Network/NetworkRequest.swift index 5cdea49..fa65d20 100644 --- a/XQMuse/Root/Network/NetworkRequest.swift +++ b/XQMuse/Root/Network/NetworkRequest.swift @@ -216,7 +216,9 @@ sharedSessionManager.request(params.url.absoluteString, method: method, parameters:params.done(), encoding: newEncoding, headers:headers).validate().responseData{response in LogInfo("请求地址:\(params.url)") LogInfo("请求参数:\(params.params)") - hiddenHUD(0.5) + if progress{ + hiddenHUD(0.5) + } guard response.error == nil else { LogError("\(response.error!)") diff --git a/XQMuse/Root/Network/Services.swift b/XQMuse/Root/Network/Services.swift index 5046fe1..1b70ac2 100644 --- a/XQMuse/Root/Network/Services.swift +++ b/XQMuse/Root/Network/Services.swift @@ -14,6 +14,7 @@ #if DEBUG 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" @@ -348,6 +349,40 @@ .append(key: "receiverId", value: receiverId) return NetworkRequest.request(params: params, method: .post, progress: true) } + + class func gvieCourseAgain(orderForm:PaymentOrderVC.PaymentOrderType,id:Int)->Observable<BaseResponse<SimpleModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/order/client/order/order/payOrder") + .append(key: "id", value: id) + .append(key: "type", value: 2) + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + class func cancelOrder(id:Int)->Observable<BaseResponse<SimpleModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/order/mgt/order/order/cancel") + .append(key: "uid", value: id) + return NetworkRequest.request(params: params, method: .get, progress: true) + } + + + /// 苹果支付 + /// - Parameters: + /// - amount: 购买会员的金额/充值金额 + /// - balanceFlag: 是否使用余额抵扣 1=是 2=否 + /// - orderFrom: 订单来源 1=冥想音频 2=课程 3=购买会员 4充值 + /// - transactionIdentifier: 苹果订单id + /// - vipType: 订单类型为会员时 必传 会员类型 1月度 2季度 3年度 + class func placeOrderApple(amount:Double,balanceFlag:ConditionType,orderFrom:Int,transactionIdentifier:String,vipType:Int?)->Observable<BaseResponse<SimpleModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/order/client/order/order/placeOrderApple") + .append(key: "amount", value: amount) + .append(key: "balanceFlag", value: balanceFlag.rawValue) + .append(key: "orderFrom", value: orderFrom) + .append(key: "transactionIdentifier", value: transactionIdentifier) + .append(key: "vipType", value: vipType) + return NetworkRequest.request(params: params, method: .post, progress: false) + } } /// 疗愈馆 @@ -382,15 +417,15 @@ params.interface(url: "/user/client/app-user/getUserByPhone") .append(key: "phone", value: phone) .append(key: "apipost_id", value: "2e763463799135") - return NetworkRequest.request(params: params, method: .post, progress: true) + return NetworkRequest.request(params: params, method: .post, progress: true,ignoreAlert: true) } /// 获取用户信息 - class func getUserDetail()->Observable<BaseResponse<UserInfoModel>>{ + class func getUserDetail(showProgress:Bool = true)->Observable<BaseResponse<UserInfoModel>>{ let params = ParamsAppender.build(url: All_Url) params.interface(url: "/user/client/app-user/getUserDetail") .append(key: "apipost_id", value: "2fc350e9799588") - return NetworkRequest.request(params: params, method: .post, progress: false) + return NetworkRequest.request(params: params, method: .post, progress: showProgress,ignoreAlert: true) } /// 获取用户信息 @@ -476,11 +511,11 @@ return NetworkRequest.request(params: params, method: .post, progress: true) } - class func myWallet()->Observable<BaseResponse<WalletModel>>{ + class func myWallet(showprogress: Bool = false)->Observable<BaseResponse<WalletModel>>{ let params = ParamsAppender.build(url: All_Url) params.interface(url: "/user/client/app-user/wallet") .append(key: "apipost_id", value: "3518e3f0b99420") - return NetworkRequest.request(params: params, method: .post, progress: false) + return NetworkRequest.request(params: params, method: .post, progress: showprogress,ignoreAlert: true) } class func getMyBankList()->Observable<BaseResponse<[BankInfoModel]>>{ diff --git a/XQMuse/Root/Other/View/CountdownChooseListView.swift b/XQMuse/Root/Other/View/CountdownChooseListView.swift index 8d7beb8..c01e8f3 100644 --- a/XQMuse/Root/Other/View/CountdownChooseListView.swift +++ b/XQMuse/Root/Other/View/CountdownChooseListView.swift @@ -102,6 +102,7 @@ @IBAction func customReduceAction(_ sender: Any) { userCustomer() var t = tf_input.text?.int ?? 1 + t -= 1 t = max(1,t) status = .choose(t) tf_input.text = t.string diff --git a/XQMuse/Root/Other/View/VideoView.swift b/XQMuse/Root/Other/View/VideoView.swift index 863db7c..e5b9e8b 100644 --- a/XQMuse/Root/Other/View/VideoView.swift +++ b/XQMuse/Root/Other/View/VideoView.swift @@ -49,7 +49,7 @@ player.url = Url if needFirstImage{ - URL.jq_splitVideoFileUrlFps(splitFileUrl: Url, fps: 1) {[weak self] state, images in + URL.jq_splitVideoFileUrlFps(splitFileUrl: Url, fps: 30) {[weak self] state, images in if let first = images.first{ DispatchQueue.main.async { self?.addPlaceHoderView(firstFPSImage: first) diff --git a/XQMuse/Root/Other/WebVC.swift b/XQMuse/Root/Other/WebVC.swift index 7f8bd81..b59d4e1 100644 --- a/XQMuse/Root/Other/WebVC.swift +++ b/XQMuse/Root/Other/WebVC.swift @@ -16,6 +16,7 @@ private(set) var url:String? private(set) var htmlText:String? private(set) var baseUrl:URL? + private var showHelp = false private var progressView = UIProgressView() private let jsCode = """ var meta = document.createElement('meta');" @@ -27,9 +28,10 @@ public var tintColor = UIColor.blue private var subVC:Bool = false - public convenience init(url:String) { + public convenience init(url:String,showHelp:Bool = false) { self.init() self.url = url + self.showHelp = showHelp } public convenience init(type:AgreementType,subVC:Bool = false){ @@ -45,6 +47,17 @@ public override func viewDidLoad() { super.viewDidLoad() + + + if showHelp{ + 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(myHelpAction), for: .touchUpInside) + navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn) + } + let config = WKWebViewConfiguration() let userScript = WKUserScript(source: jsCode, injectionTime: .atDocumentStart, forMainFrameOnly: true) @@ -106,6 +119,12 @@ } } + @objc func myHelpAction(){ + let vc = WebVC(url: ShareUrl + "/ranking/recommend?userId=\(UserViewModel.getAvatarInfo().id)") + vc.title = "我的助力" + push(vc: vc) + } + deinit { webView?.removeObserver(self, forKeyPath: "estimatedProgress") } diff --git a/XQMuse/Root/PayMusicView/PayMusicVC.swift b/XQMuse/Root/PayMusicView/PayMusicVC.swift index 9cf65b6..d703bbb 100644 --- a/XQMuse/Root/PayMusicView/PayMusicVC.swift +++ b/XQMuse/Root/PayMusicView/PayMusicVC.swift @@ -177,6 +177,7 @@ @objc func showDetailAction(){ if let id = meditationModel?.id{ + Services.getMeditationDetail(id: id).subscribe(onNext: {[weak self]data in guard let weakSelf = self else { return } if let m = data.data{ @@ -243,6 +244,9 @@ self.startRunloopAni() PayMusicVC.updateStatus(.playing) } + DispatchQueue.main.asyncAfter(delay: 0.4) { + NotificationCenter.default.post(name: ReloadData_Noti, object: nil, userInfo: nil) + } } @objc func closeAction(_ btn:UIButton){ @@ -262,6 +266,10 @@ if UserDefaultSettingViewModel.getSetting()?.bgm != nil{ AudioPlayer.getSharedInstance().playSceneAt(UserDefaultSettingViewModel.getSetting()!.bgm!.audioFile) } + + DispatchQueue.main.asyncAfter(delay: 0.4) { + NotificationCenter.default.post(name: ReloadData_Noti, object: nil, userInfo: nil) + } } } } @@ -278,7 +286,7 @@ private var timer:Timer? private(set) var times = BehaviorRelay<Int?>(value: nil) //倒计时定时器 private static var _sharedInstance: AudioPlayer? - private(set) var meditationModel:MeditationModel? //疗愈音频 + var meditationModel:MeditationModel? //疗愈音频 var lisenMuseTime:Int = 0 //听疗愈时间记录 weak var delegate:PayMusicDelegate? @@ -396,8 +404,8 @@ autoreleasepool{[unowned self] () in for url in urls { - self.checkCacheAudio(from: url) {[unowned self] _, url in - self.urls.append(url) + self.checkCacheAudio(from: url) {[unowned self] _, url in + self.urls.append(url) } } self.bgmPlayer = AVPlayer(url: self.urls[firstPlayIndex]) @@ -422,7 +430,7 @@ if let m = weakSelf.meditationModel{ var dic = [String:Any]() - dic[MPMediaItemPropertyTitle] = m + dic[MPMediaItemPropertyTitle] = m.meditationTitle dic[MPMediaItemPropertyArtist] = "泉疗愈" dic[MPMediaItemPropertyDiscNumber] = 1 dic[MPNowPlayingInfoPropertyElapsedPlaybackTime] = loadTime @@ -442,8 +450,23 @@ } } - self.bgmPlayer?.currentItem?.rx.observe(AVPlayerItem.Status.self,"status").subscribe(onNext: { _ in + self.bgmPlayer?.rx.observe(AVPlayer.TimeControlStatus.self,"timeControlStatus").subscribe(onNext: { state in + DispatchQueue.main.asyncAfter(delay: 1.0) { + if state == .paused{ + print("----》暂停") + PayMusicVC.updateStatus(.pause) + }else if state == .playing{ + print("----》播放") + PayMusicVC.updateStatus(.playing) + } + } + }).disposed(by: disposeBag) + + + self.bgmPlayer?.currentItem?.rx.observe(AVPlayerItem.Status.self,"status").subscribe(onNext: { _ in + print("---MasterStatus1: \(self.masterPlayer?.status.rawValue ?? 0)") + print("---bgmStatus1: \(self.bgmPlayer?.status.rawValue ?? 0)") if self.bgmPlayer?.status == .readyToPlay && self.masterPlayer?.status == .readyToPlay{ self.bgmPlayer?.play() self.masterPlayer?.play() @@ -453,6 +476,7 @@ self.masterPlayer?.currentItem?.rx.observe(AVPlayerItem.Status.self,"status").subscribe(onNext: { _ in print("---MasterStatus: \(self.masterPlayer?.status.rawValue ?? 0)") + print("---bgmStatus: \(self.bgmPlayer?.status.rawValue ?? 0)") if self.bgmPlayer?.status == .readyToPlay && self.masterPlayer?.status == .readyToPlay{ self.bgmPlayer?.play() self.masterPlayer?.play() diff --git a/XQMuse/Root/Plans/PlanGuideVC.swift b/XQMuse/Root/Plans/PlanGuideVC.swift index 29da77c..b6373e6 100644 --- a/XQMuse/Root/Plans/PlanGuideVC.swift +++ b/XQMuse/Root/Plans/PlanGuideVC.swift @@ -88,7 +88,7 @@ AudioPlayer.getSharedInstance().bgmPlayer?.play() AudioPlayer.getSharedInstance().masterPlayer?.play() PayMusicVC.updateStatus(.playing) - }else if UserDefaultSettingViewModel.getSetting()?.bgm != nil{ + }else if UserDefaultSettingViewModel.getSetting()?.bgm != nil && !(JQ_currentNavigationController().viewControllers.first is PlanGuideVC){ AudioPlayer.getSharedInstance().playSceneAt(UserDefaultSettingViewModel.getSetting()!.bgm!.audioFile) } } @@ -169,11 +169,9 @@ let vc = PlanGuide_1_VC() self?.jq_push(vc: vc) case .toSeting: -// self?.dismiss(animated: true) { let vc = BackgroundVoiceVC(isFromFist: self?.isFromFist ?? false) vc.hidesBottomBarWhenPushed = true JQ_currentNavigationController().pushViewController(vc) -// } } } } diff --git a/XQMuse/Root/Plans/PlanGuide_1_VC.swift b/XQMuse/Root/Plans/PlanGuide_1_VC.swift index 61e21d6..88e467d 100644 --- a/XQMuse/Root/Plans/PlanGuide_1_VC.swift +++ b/XQMuse/Root/Plans/PlanGuide_1_VC.swift @@ -41,10 +41,6 @@ @IBAction func backAction(_ sender: UIButton) { NotificationCenter.default.post(name: PlantGuideQuit_Noti, object: nil) - if var m = UserDefaultSettingViewModel.getSetting(){ - m.userFirstLaunch = false - UserDefaultSettingViewModel.saveSetting(m) - } } @IBAction func answerAction(_ sender: UIButton) { diff --git a/XQMuse/Root/TreeGroup/TreeTeskVC.swift b/XQMuse/Root/TreeGroup/TreeTeskVC.swift index d077716..b9a237d 100644 --- a/XQMuse/Root/TreeGroup/TreeTeskVC.swift +++ b/XQMuse/Root/TreeGroup/TreeTeskVC.swift @@ -161,14 +161,10 @@ Services.treeInfo().subscribe(onNext: {data in if let m = data.data{ self.taskListView.setTreeInfoModel(m) - - //检查hash,进行同步 -// if m.toJSON()?.jq_hash() != self.treeInfoModel?.toJSON()?.jq_hash(){ self.treeInfoModel = m self.updateTreeInfo() self.updateAni(false) try? self.cacheTreeInfoModel.save(m) -// } } }).disposed(by: disposeBag) } @@ -176,9 +172,6 @@ private func updateTreeInfo(){ btn_seedingAgain.isHidden = treeInfoModel!.treeLevelType != .level_10 -// if treeLevel.rawValue != treeInfoModel?.treeLevelType.rawValue{ -// treeLevel = treeInfoModel!.treeLevelType -// } icon_energy.text = String(format: "当前能量值:%ld", treeInfoModel!.energyValue) setProgress(current: treeInfoModel!.growthValue, total: treeInfoModel!.nextLevel) } @@ -311,7 +304,6 @@ if let m = data.data{ sender.isUserInteractionEnabled = true if m.isNext{ - let type = weakSelf.treeInfoModel?.treeLevelType ?? .level_1 weakSelf.treeInfoModel!.treeLevelType = m.treeLevelType let h = (JQ_ScreenW - 90) * 0.7729 @@ -321,10 +313,10 @@ weakSelf.voicePlayer.replaceCurrentItem(with: AVPlayerItem(url: soundURL)) weakSelf.voicePlayer.play() } - weakSelf.updateAni() - weakSelf.getTreeData() - return } + + weakSelf.updateAni() + weakSelf.getTreeData() weakSelf.treeInfoModel?.growthValue = m.growthValue weakSelf.treeInfoModel?.energyValue = 0 @@ -437,15 +429,14 @@ extension TreeTeskVC:CAAnimationDelegate{ func animationDidStart(_ anim: CAAnimation) { - print("开始动画") treeImage.isUserInteractionEnabled = false } func animationDidStop(_ anim: CAAnimation, finished flag: Bool) { - print("结束动画") - if anim.value(forKey: "customType") as! String == "ani_flower"{ - - - } +// print("结束动画") +// if anim.value(forKey: "customType") as! String == "ani_flower"{ +// +// +// } } } diff --git a/XQMuse/SceneDelegate.swift b/XQMuse/SceneDelegate.swift index 71e31cf..768b1e3 100644 --- a/XQMuse/SceneDelegate.swift +++ b/XQMuse/SceneDelegate.swift @@ -76,6 +76,7 @@ } //判断是否需要登录 + @discardableResult func checkisLoginState()->Bool{ if UserViewModel.getLoginInfo()?.accessToken.isEmpty ?? true{ sceneDelegate?.needLogin() @@ -133,8 +134,6 @@ }else{ WXApi.handleOpen(URLContexts.first!.url, delegate: self) } - - } } -- Gitblit v1.7.1