From 677497cbfbf159417f2b1bb64aee0196c9fa6382 Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期一, 09 九月 2024 18:37:07 +0800 Subject: [PATCH] fix --- XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.swift | 12 XQMuse/Root/Home/TCell/Home_Style_1_TCell.swift | 14 XQMuse/Root/Home/View/HomeHeaderVC.swift | 1 XQMuse/Root/Home/TCell/Home_Style_3_TCell.swift | 23 + XQMuse/Root/Home/TCell/Home_Style_4_TCell.swift | 14 XQMuse/Root/TreeGroup/TreeTeskVC.swift | 66 +-- XQMuse/Root/Home/CCell/Home_Style_4_Inner_1_CCell.xib | 9 XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift | 2 XQMuse/Root/Home/CCell/HomeRelaxVoiceCCell.swift | 11 XQMuse/Root/Home/VC/HomeTyroGuideVC.swift | 5 XQMuse/Root/Home/CCell/HomeRelaxBanner_2_CCell.xib | 13 XQMuse/Root/Home/CCell/HomeRelaxVoiceCCell.xib | 4 XQMuse.xcodeproj/project.pbxproj | 28 + XQMuse/Root/Home/VC/BackgroundVoiceVC.swift | 109 ++++++ XQMuse/Root/Network/Models.swift | 74 ++++ XQMuse/Root/Home/TCell/Home_Style_5_TCell.xib | 64 +++ XQMuse/Root/Home/CCell/HomeRelaxBanner_2_CCell.swift | 16 XQMuse/Root/Home/TCell/Home_Style_3_TCell.xib | 33 - XQMuse/Root/Home/VC/HomeItemListVC.swift | 21 XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.swift | 16 XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.xib | 23 XQMuse/Root/Home/VC/HomeItemDetailVC.swift | 32 + XQMuse/Root/Network/NetworkRequest.swift | 7 XQMuse/Root/Home/VC/BackgroundVoiceVC.xib | 26 + XQMuse/Root/PayMusicView/PayMusicVC.swift | 39 ++ XQMuse/Root/Home/HomeVC.swift | 158 ++++++-- XQMuse/Root/Network/ViewModels/UserViewModel.swift | 27 + XQMuse/Root/Home/TCell/Home_Style_1_TCell.xib | 6 XQMuse/Config/Enums/Enums.swift | 11 XQMuse/Root/Home/View/HomeTopMenuView.swift | 20 + XQMuse/Root/Home/TCell/Home_Style_5_TCell.swift | 23 + XQMuse/Root/Home/View/HomeTopMenuView.xib | 8 XQMuse/Root/Home/VC/HomeItemDetailVC.xib | 16 XQMuse/Root/Network/Services.swift | 74 ++++ 34 files changed, 833 insertions(+), 172 deletions(-) diff --git a/XQMuse.xcodeproj/project.pbxproj b/XQMuse.xcodeproj/project.pbxproj index a7ea68d..f5aacf9 100644 --- a/XQMuse.xcodeproj/project.pbxproj +++ b/XQMuse.xcodeproj/project.pbxproj @@ -216,6 +216,13 @@ 13C5838A2C86A42B0071BCBE /* apngb-animated-level-3.png in Resources */ = {isa = PBXBuildFile; fileRef = 13C583892C86A42B0071BCBE /* apngb-animated-level-3.png */; }; 13C5838C2C86A4770071BCBE /* apngb-animated-level-4.png in Resources */ = {isa = PBXBuildFile; fileRef = 13C5838B2C86A4770071BCBE /* apngb-animated-level-4.png */; }; 13C5838E2C86A4F90071BCBE /* apngb-animated-level-5.png in Resources */ = {isa = PBXBuildFile; fileRef = 13C5838D2C86A4F90071BCBE /* apngb-animated-level-5.png */; }; + 13C9DDCD2C8EE1F20008946B /* Home_Style_5_TCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13C9DDCC2C8EE1F20008946B /* Home_Style_5_TCell.xib */; }; + 13C9DDCE2C8EE1F20008946B /* Home_Style_5_TCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13C9DDCB2C8EE1F20008946B /* Home_Style_5_TCell.swift */; }; + 13C9DDD42C8EE8EB0008946B /* apngb-animated-level-7.png in Resources */ = {isa = PBXBuildFile; fileRef = 13C9DDCF2C8EE8EB0008946B /* apngb-animated-level-7.png */; }; + 13C9DDD52C8EE8EB0008946B /* apngb-animated-level-6.png in Resources */ = {isa = PBXBuildFile; fileRef = 13C9DDD02C8EE8EB0008946B /* apngb-animated-level-6.png */; }; + 13C9DDD62C8EE8EB0008946B /* apngb-animated-level-8.png in Resources */ = {isa = PBXBuildFile; fileRef = 13C9DDD12C8EE8EB0008946B /* apngb-animated-level-8.png */; }; + 13C9DDD72C8EE8EB0008946B /* apngb-animated-level-9.png in Resources */ = {isa = PBXBuildFile; fileRef = 13C9DDD22C8EE8EB0008946B /* apngb-animated-level-9.png */; }; + 13C9DDD82C8EE8EB0008946B /* apngb-animated-level-10.png in Resources */ = {isa = PBXBuildFile; fileRef = 13C9DDD32C8EE8EB0008946B /* apngb-animated-level-10.png */; }; 13CBC5D92C73532B00BC66C7 /* MeVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13CBC5D82C73532B00BC66C7 /* MeVC.xib */; }; 13CBCCDF2C74793D00C67701 /* NoticeCenterSysDetailVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13CBCCDD2C74793D00C67701 /* NoticeCenterSysDetailVC.swift */; }; 13CBCCE02C74793D00C67701 /* NoticeCenterSysDetailVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13CBCCDE2C74793D00C67701 /* NoticeCenterSysDetailVC.xib */; }; @@ -470,6 +477,13 @@ 13C583892C86A42B0071BCBE /* apngb-animated-level-3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "apngb-animated-level-3.png"; sourceTree = "<group>"; }; 13C5838B2C86A4770071BCBE /* apngb-animated-level-4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "apngb-animated-level-4.png"; sourceTree = "<group>"; }; 13C5838D2C86A4F90071BCBE /* apngb-animated-level-5.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "apngb-animated-level-5.png"; sourceTree = "<group>"; }; + 13C9DDCB2C8EE1F20008946B /* Home_Style_5_TCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Home_Style_5_TCell.swift; sourceTree = "<group>"; }; + 13C9DDCC2C8EE1F20008946B /* Home_Style_5_TCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Home_Style_5_TCell.xib; sourceTree = "<group>"; }; + 13C9DDCF2C8EE8EB0008946B /* apngb-animated-level-7.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "apngb-animated-level-7.png"; sourceTree = "<group>"; }; + 13C9DDD02C8EE8EB0008946B /* apngb-animated-level-6.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "apngb-animated-level-6.png"; sourceTree = "<group>"; }; + 13C9DDD12C8EE8EB0008946B /* apngb-animated-level-8.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "apngb-animated-level-8.png"; sourceTree = "<group>"; }; + 13C9DDD22C8EE8EB0008946B /* apngb-animated-level-9.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "apngb-animated-level-9.png"; sourceTree = "<group>"; }; + 13C9DDD32C8EE8EB0008946B /* apngb-animated-level-10.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "apngb-animated-level-10.png"; sourceTree = "<group>"; }; 13CBC5D82C73532B00BC66C7 /* MeVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MeVC.xib; sourceTree = "<group>"; }; 13CBCCDD2C74793D00C67701 /* NoticeCenterSysDetailVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoticeCenterSysDetailVC.swift; sourceTree = "<group>"; }; 13CBCCDE2C74793D00C67701 /* NoticeCenterSysDetailVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NoticeCenterSysDetailVC.xib; sourceTree = "<group>"; }; @@ -782,6 +796,11 @@ 137ECADB2C78578A00C338BE /* Pngs */ = { isa = PBXGroup; children = ( + 13C9DDD02C8EE8EB0008946B /* apngb-animated-level-6.png */, + 13C9DDCF2C8EE8EB0008946B /* apngb-animated-level-7.png */, + 13C9DDD12C8EE8EB0008946B /* apngb-animated-level-8.png */, + 13C9DDD22C8EE8EB0008946B /* apngb-animated-level-9.png */, + 13C9DDD32C8EE8EB0008946B /* apngb-animated-level-10.png */, 13BF65EA2C804BE100E20F0E /* apngb-animated-flow.png */, 135C2A4F2C7EC48D00CC2A67 /* apngb-animated_sun.png */, 13B06A072C78A0D300477FA9 /* apngb-animated-level-1.png */, @@ -997,6 +1016,8 @@ 1377B40B2C6D936A00CF7CA5 /* CommentUserInputContentTCell.xib */, 1308C9AF2C7DCDC80017A9FC /* SearchHotTCell.swift */, 1308C9B02C7DCDC80017A9FC /* SearchHotTCell.xib */, + 13C9DDCB2C8EE1F20008946B /* Home_Style_5_TCell.swift */, + 13C9DDCC2C8EE1F20008946B /* Home_Style_5_TCell.xib */, ); path = TCell; sourceTree = "<group>"; @@ -1194,11 +1215,13 @@ 13A6594E2C6F641100F731FA /* CourseDetail_2_Inner_TCell.xib in Resources */, 13FF0B462C75C820008E26CF /* WalletVC.xib in Resources */, 130B765E2C6C4C33006371AF /* HomeItemListVC.xib in Resources */, + 13C9DDD72C8EE8EB0008946B /* apngb-animated-level-9.png in Resources */, 13F24E3D2C75866100D2BA90 /* BindPhone_3_VC.xib in Resources */, 13CBC5D92C73532B00BC66C7 /* MeVC.xib in Resources */, 1385E0072C6C558200AADB1F /* HomeRelaxBanner_2_CCell.xib in Resources */, 131111822C749085002877FC /* StudyListVC.xib in Resources */, 132EB01D2C6B32B200990429 /* RegisterVC.xib in Resources */, + 13C9DDD42C8EE8EB0008946B /* apngb-animated-level-7.png in Resources */, 137ECAD32C783C2000C338BE /* bg.mov in Resources */, 1336EFA92C6DEC6B0075E070 /* PaymentOrderResultTopView.xib in Resources */, 1331391A2C742A0C009E179E /* UserProfileVC.xib in Resources */, @@ -1206,6 +1229,7 @@ 13334FDC2C7321BE00914086 /* PavilionItemCell.xib in Resources */, 1333DC7E2C72E7A500D8ACAE /* CourseSendGiftView.xib in Resources */, 132C40292C816003002E3270 /* SourceHanSerifCN-Medium.otf in Resources */, + 13C9DDD52C8EE8EB0008946B /* apngb-animated-level-6.png in Resources */, 137ABE352C6B3F64003A91C5 /* ForgotPasswordVC.xib in Resources */, 13C5838A2C86A42B0071BCBE /* apngb-animated-level-3.png in Resources */, 13A0A8A52C746B5600DF08B6 /* CommonDatePickerView.xib in Resources */, @@ -1228,6 +1252,7 @@ 13391E022C73334000B9513F /* PavilionDetailVC.xib in Resources */, 13EC08902C74990B00E00128 /* EmptyCCell.xib in Resources */, 1377B4172C6DCC4300CF7CA5 /* Home_Style_4_Inner_1_CCell.xib in Resources */, + 13C9DDD62C8EE8EB0008946B /* apngb-animated-level-8.png in Resources */, 13FB6D8C2C6EFB5400A0685D /* CourseDetailHeaderView.xib in Resources */, 1324A64D2C80706700AA5098 /* PlanGuide_1_VC.xib in Resources */, 13985D9F2C69B2440046B6DC /* Assets.xcassets in Resources */, @@ -1258,6 +1283,7 @@ 139466482C6B8E0200F6FB15 /* UpdatePhoneVC.xib in Resources */, 134A453A2C6E167D00538D78 /* CourseOfficalCommendTopCCell.xib in Resources */, 13BA27132C81B6DD006D4CD1 /* SourceHanSerifCN-Light.otf in Resources */, + 13C9DDD82C8EE8EB0008946B /* apngb-animated-level-10.png in Resources */, 13271D852C75EF8200DE1328 /* AddBankInfoVC.xib in Resources */, 1377B40D2C6D936A00CF7CA5 /* CommentUserInputContentTCell.xib in Resources */, 137175CC2C6C412A00B38EF1 /* BackgroundVoiceVC.xib in Resources */, @@ -1270,6 +1296,7 @@ 13B021DB2C75DD0600414769 /* BankWithdrawVC.xib in Resources */, 1338A6DE2C76DD5E006CDD15 /* SpendingDetailInfoVC.xib in Resources */, 137ECAD72C783C7700C338BE /* TreeTeskVC.xib in Resources */, + 13C9DDCD2C8EE1F20008946B /* Home_Style_5_TCell.xib in Resources */, 1308C9B12C7DCDC80017A9FC /* SearchHotTCell.xib in Resources */, 137ABE3C2C6B6BDD003A91C5 /* ForgotPasswordInputCodeVC.xib in Resources */, 13EA70052C75FA16005DF280 /* WalletRechargeVC.xib in Resources */, @@ -1415,6 +1442,7 @@ 1324A64C2C80706700AA5098 /* PlanGuide_1_VC.swift in Sources */, 13CBCCE32C747C3D00C67701 /* NoticeCenterUserRepeaceDetailVC.swift in Sources */, 135C2A672C7F033300CC2A67 /* CLFullScreenLeftController.swift in Sources */, + 13C9DDCE2C8EE1F20008946B /* Home_Style_5_TCell.swift in Sources */, 138FE0DE2C757B2A00A964E8 /* BindPhone_1_VC.swift in Sources */, 13A0A8A62C746B5600DF08B6 /* CommonDatePickerView.swift in Sources */, 130C07052C76D1A000ADB098 /* SpendingDetailHeaderVC.swift in Sources */, diff --git a/XQMuse/Config/Enums/Enums.swift b/XQMuse/Config/Enums/Enums.swift index 38d6c27..a1f632e 100644 --- a/XQMuse/Config/Enums/Enums.swift +++ b/XQMuse/Config/Enums/Enums.swift @@ -13,3 +13,14 @@ case man = 1 case woman = 2 } + +enum DisplayType:Int,HandyJSONEnum{ + case horizontal = 1 //横 + case vertical = 2 //竖 +} + +enum ChargeType:Int,HandyJSONEnum{ + case free = 1 //免费 + case vipFree = 2 //会员免费 + case payment = 3 // 需支付 +} diff --git a/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.swift b/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.swift index 6856569..33dc2e5 100644 --- a/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.swift +++ b/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.swift @@ -10,10 +10,24 @@ class HomeRelaxBannerCCell: UICollectionViewCell { - override func awakeFromNib() { + @IBOutlet weak var img_vip: UIImageView! + @IBOutlet weak var img_cover: UIImageView! + @IBOutlet weak var label_title: UILabel! + @IBOutlet weak var label_subTitle: UILabel! + @IBOutlet weak var label_num: UILabel! + + override func awakeFromNib() { super.awakeFromNib() // Initialization code jq_cornerRadius = 25 } + func setMeditationModel(_ model:MeditationModel){ + img_cover.sd_setImage(with: URL(string: model.coverUrl)) + label_title.text = model.meditationTitle + label_subTitle.text = model.coverDescription + label_num.text = "\(model.realLearnedNum)" + img_vip.isHidden = model.chargeType != .vipFree + } + } diff --git a/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.xib b/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.xib index 6800b00..3117a74 100644 --- a/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.xib +++ b/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.xib @@ -38,24 +38,21 @@ <color key="textColor" red="0.94901960784313721" green="0.92549019607843142" blue="0.97254901960784312" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="--" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AYK-rI-cj9"> - <rect key="frame" x="20" y="32" width="10" height="10.666666666666664"/> - <constraints> - <constraint firstAttribute="height" constant="10.57" id="NiE-Uq-pWy"/> - </constraints> - <fontDescription key="fontDescription" type="system" pointSize="10"/> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="1000" verticalHuggingPriority="251" text="--" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AYK-rI-cj9"> + <rect key="frame" x="20" y="31.999999999999996" width="6.3333333333333321" height="7.3333333333333321"/> + <fontDescription key="fontDescription" type="system" pointSize="6"/> <color key="textColor" red="0.94901960780000005" green="0.92549019610000005" blue="0.97254901959999995" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <nil key="highlightedColor"/> </label> <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_use_small" translatesAutoresizingMaskIntoConstraints="NO" id="3TE-Zp-CLh"> - <rect key="frame" x="37.666666666666664" y="34.333333333333343" width="6" height="6"/> + <rect key="frame" x="34" y="32.666666666666686" width="6" height="6"/> <constraints> <constraint firstAttribute="height" constant="6" id="BJm-m4-3Q1"/> <constraint firstAttribute="width" constant="6" id="zT4-1f-9rs"/> </constraints> </imageView> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZK6-Lk-6Cs"> - <rect key="frame" x="45.666666666666664" y="33.666666666666686" width="4.6666666666666643" height="7.3333333333333357"/> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="0" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZK6-Lk-6Cs"> + <rect key="frame" x="42" y="31.999999999999996" width="67" height="7.3333333333333321"/> <fontDescription key="fontDescription" type="system" pointSize="6"/> <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> <nil key="highlightedColor"/> @@ -71,6 +68,7 @@ <constraint firstItem="AYK-rI-cj9" firstAttribute="leading" secondItem="fsN-0y-q8f" secondAttribute="leading" id="M3h-qb-5fd"/> <constraint firstItem="fsN-0y-q8f" firstAttribute="top" secondItem="Emq-gn-QOX" secondAttribute="top" constant="16" id="PfC-RB-Ljg"/> <constraint firstItem="KBd-aZ-LFh" firstAttribute="centerY" secondItem="Emq-gn-QOX" secondAttribute="centerY" id="Vtg-Dw-LYO"/> + <constraint firstItem="KBd-aZ-LFh" firstAttribute="leading" secondItem="ZK6-Lk-6Cs" secondAttribute="trailing" constant="10" id="YoN-ge-YLi"/> <constraint firstItem="3TE-Zp-CLh" firstAttribute="centerY" secondItem="AYK-rI-cj9" secondAttribute="centerY" id="Zcl-sX-hPV"/> <constraint firstItem="fsN-0y-q8f" firstAttribute="leading" secondItem="Emq-gn-QOX" secondAttribute="leading" constant="20" id="aKT-wu-4QP"/> <constraint firstAttribute="trailing" secondItem="KBd-aZ-LFh" secondAttribute="trailing" constant="17" id="sog-4H-upG"/> @@ -98,6 +96,13 @@ <constraint firstAttribute="bottom" secondItem="u6A-Y4-rQ5" secondAttribute="bottom" id="urP-g7-eE1"/> </constraints> <size key="customSize" width="165" height="218"/> + <connections> + <outlet property="img_cover" destination="u6A-Y4-rQ5" id="jgL-1i-bbr"/> + <outlet property="img_vip" destination="qF4-sn-dec" id="Srv-K5-XZ8"/> + <outlet property="label_num" destination="ZK6-Lk-6Cs" id="YnU-l2-kpJ"/> + <outlet property="label_subTitle" destination="AYK-rI-cj9" id="fbU-5M-2Gw"/> + <outlet property="label_title" destination="fsN-0y-q8f" id="MyU-K8-8hi"/> + </connections> <point key="canvasLocation" x="168.70229007633588" y="79.577464788732399"/> </collectionViewCell> </objects> diff --git a/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_CCell.swift b/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_CCell.swift index 7b4b0c7..3ed6025 100644 --- a/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_CCell.swift +++ b/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_CCell.swift @@ -11,10 +11,17 @@ class HomeRelaxBanner_2_CCell: UICollectionViewCell { @IBOutlet weak var view_text_bg: UIView! + + @IBOutlet weak var img_vip: UIImageView! + @IBOutlet weak var img_cover: UIImageView! + @IBOutlet weak var label_title: UILabel! + @IBOutlet weak var label_subTitle: UILabel! + @IBOutlet weak var label_num: UILabel! + + private var meditationModel:MeditationModel? override func awakeFromNib() { super.awakeFromNib() // Initialization code - jq_cornerRadius = 10 @@ -29,4 +36,11 @@ visualEffectView.layer.masksToBounds = true } + func setMeditationModel(_ model:MeditationModel){ + img_cover.sd_setImage(with: URL(string: model.coverUrl)) + label_title.text = model.meditationTitle + label_subTitle.text = model.coverDescription + label_num.text = "\(model.realLearnedNum)" + img_vip.isHidden = model.chargeType != .vipFree + } } diff --git a/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_CCell.xib b/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_CCell.xib index 93f37e0..7d7199b 100644 --- a/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_CCell.xib +++ b/XQMuse/Root/Home/CCell/HomeRelaxBanner_2_CCell.xib @@ -31,9 +31,10 @@ <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <nil key="highlightedColor"/> </label> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="--" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="z5u-My-91l"> - <rect key="frame" x="20" y="33" width="106" height="10.666666666666664"/> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="--" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="z5u-My-91l"> + <rect key="frame" x="20" y="33" width="10.666666666666664" height="10.666666666666664"/> <constraints> + <constraint firstAttribute="width" relation="lessThanOrEqual" constant="100" id="Fam-ne-FM1"/> <constraint firstAttribute="height" constant="10.57" id="epJ-Xi-ukn"/> </constraints> <fontDescription key="fontDescription" type="system" pointSize="11"/> @@ -47,7 +48,7 @@ <constraint firstAttribute="width" constant="10" id="AvO-zD-TXx"/> </constraints> </imageView> - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="1000" verticalHuggingPriority="251" text="0" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JaY-19-IAL"> + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" horizontalCompressionResistancePriority="1000" text="0" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JaY-19-IAL"> <rect key="frame" x="148" y="31.666666666666682" width="7" height="13.333333333333332"/> <fontDescription key="fontDescription" type="system" pointSize="11"/> <color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> @@ -55,7 +56,6 @@ </label> </subviews> <constraints> - <constraint firstItem="hE1-AV-t8f" firstAttribute="leading" secondItem="z5u-My-91l" secondAttribute="trailing" constant="10" id="5Tc-Ch-Q0R"/> <constraint firstItem="JaY-19-IAL" firstAttribute="centerY" secondItem="z5u-My-91l" secondAttribute="centerY" id="GM9-nN-Cds"/> <constraint firstItem="byc-Ar-sJL" firstAttribute="top" secondItem="Fb9-IV-vVk" secondAttribute="top" constant="17" id="LaZ-g6-4n6"/> <constraint firstAttribute="trailing" secondItem="JaY-19-IAL" secondAttribute="trailing" constant="23" id="NHd-om-jRN"/> @@ -85,6 +85,11 @@ </constraints> <size key="customSize" width="178" height="301"/> <connections> + <outlet property="img_cover" destination="cCC-0f-GSV" id="85x-ue-edy"/> + <outlet property="img_vip" destination="yBF-fO-fwz" id="icq-m9-dx3"/> + <outlet property="label_num" destination="JaY-19-IAL" id="2RU-X7-0wb"/> + <outlet property="label_subTitle" destination="z5u-My-91l" id="j4L-bl-DhS"/> + <outlet property="label_title" destination="byc-Ar-sJL" id="CAQ-8Z-yC9"/> <outlet property="view_text_bg" destination="Fb9-IV-vVk" id="Ol7-cR-BWU"/> </connections> <point key="canvasLocation" x="236.64122137404578" y="108.80281690140846"/> diff --git a/XQMuse/Root/Home/CCell/HomeRelaxVoiceCCell.swift b/XQMuse/Root/Home/CCell/HomeRelaxVoiceCCell.swift index ff7daf8..3ce5a27 100644 --- a/XQMuse/Root/Home/CCell/HomeRelaxVoiceCCell.swift +++ b/XQMuse/Root/Home/CCell/HomeRelaxVoiceCCell.swift @@ -9,9 +9,16 @@ class HomeRelaxVoiceCCell: UICollectionViewCell { - override func awakeFromNib() { + @IBOutlet weak var imgView: UIImageView! + @IBOutlet weak var img_play: UIImageView! + + override func awakeFromNib() { super.awakeFromNib() - // Initialization code + } + func setModel(_ model:BGMModel){ + imgView.sd_setImage(with: URL(string: model.imageUrl)) + } + } diff --git a/XQMuse/Root/Home/CCell/HomeRelaxVoiceCCell.xib b/XQMuse/Root/Home/CCell/HomeRelaxVoiceCCell.xib index 18b553c..aec5e76 100644 --- a/XQMuse/Root/Home/CCell/HomeRelaxVoiceCCell.xib +++ b/XQMuse/Root/Home/CCell/HomeRelaxVoiceCCell.xib @@ -43,6 +43,10 @@ <real key="value" value="25"/> </userDefinedRuntimeAttribute> </userDefinedRuntimeAttributes> + <connections> + <outlet property="imgView" destination="4jb-6c-6TI" id="CpA-SF-ajE"/> + <outlet property="img_play" destination="MaL-3z-5UT" id="e0T-d5-lGq"/> + </connections> <point key="canvasLocation" x="173.2824427480916" y="85.563380281690144"/> </collectionViewCell> </objects> 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 9792db2..b6af8e0 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 @@ -10,11 +10,23 @@ class Home_Style_4_Inner_1_CCell: UICollectionViewCell { + @IBOutlet weak var cover_bgImage: UIImageView! @IBOutlet weak var view_shadow: UIView! + @IBOutlet weak var label_title: UILabel! + @IBOutlet weak var label_subTitle: UILabel! + + var meditationModel:MeditationModel? override func awakeFromNib() { super.awakeFromNib() view_shadow.jq_gradientColor(colorArr: [UIColor.black.withAlphaComponent(0.2).cgColor,UIColor.clear.cgColor], cornerRadius: 0, startPoint: CGPoint(x: 1, y: 1), endPoint: CGPoint(x: 1, y: 0), bounds: nil, locations: nil) } + + func setMeditationModel(_ model:MeditationModel){ + label_title.text = model.meditationTitle + label_subTitle.text = model.coverDescription + cover_bgImage.sd_setImage(with: URL(string: model.coverUrl)) + } + } 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 47d5085..c6b20e9 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 @@ -38,13 +38,13 @@ </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"> - <rect key="frame" x="43" y="53.333333333333343" width="42" height="20.333333333333329"/> + <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"> - <rect key="frame" x="43" y="77.666666666666686" width="94" height="12"/> + <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"/> <nil key="highlightedColor"/> @@ -52,6 +52,7 @@ </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> + <constraint firstAttribute="trailing" secondItem="NTV-9E-3YX" secondAttribute="trailing" constant="10" id="1d8-hO-XQO"/> <constraint firstItem="NTV-9E-3YX" firstAttribute="leading" secondItem="tDO-qY-aGP" secondAttribute="leading" id="51K-EF-Rvn"/> <constraint firstItem="blS-wb-4tS" firstAttribute="leading" secondItem="all-AA-1bU" secondAttribute="leading" constant="24" id="Lqw-Rn-RNa"/> <constraint firstItem="NTV-9E-3YX" firstAttribute="top" secondItem="tDO-qY-aGP" secondAttribute="bottom" constant="4" id="ZMe-Wi-gxX"/> @@ -59,6 +60,7 @@ <constraint firstAttribute="height" constant="100" id="j9f-27-wVi"/> <constraint firstItem="tDO-qY-aGP" firstAttribute="leading" secondItem="blS-wb-4tS" secondAttribute="trailing" constant="4.5" id="mdv-eZ-D7N"/> <constraint firstAttribute="bottom" secondItem="blS-wb-4tS" secondAttribute="bottom" constant="23.5" id="o7z-53-St0"/> + <constraint firstAttribute="trailing" secondItem="tDO-qY-aGP" secondAttribute="trailing" constant="10" id="zHF-Km-O8b"/> </constraints> </view> </subviews> @@ -77,6 +79,9 @@ </constraints> <size key="customSize" width="413" height="265"/> <connections> + <outlet property="cover_bgImage" destination="ajx-e3-nPT" id="l9S-XD-2EW"/> + <outlet property="label_subTitle" destination="NTV-9E-3YX" id="DjB-ZR-jnv"/> + <outlet property="label_title" destination="tDO-qY-aGP" id="778-Vx-HnN"/> <outlet property="view_shadow" destination="all-AA-1bU" id="JuG-YX-jmu"/> </connections> <point key="canvasLocation" x="416.03053435114504" y="96.126760563380287"/> diff --git a/XQMuse/Root/Home/HomeVC.swift b/XQMuse/Root/Home/HomeVC.swift index 0810994..4cb581f 100644 --- a/XQMuse/Root/Home/HomeVC.swift +++ b/XQMuse/Root/Home/HomeVC.swift @@ -7,7 +7,10 @@ import UIKit import JQTools +import RxSwift import MediaPlayer + +let SetBGMSuccess_Noti = Notification.Name.init("SetBGMSuccess_Noti") struct TitleItem{ var title = "" @@ -16,20 +19,35 @@ var coverImage:String? } +class HomeViewModel{ + var homeTopMenuItems = [HomeTopMenuItem]() + var todyModel:MeditationModel? + var privateTodyModels = [MeditationModel]() + var meditationList = [MeditationListModel]() +} + class HomeVC: BaseVC { private var tableView:UITableView! private let topMenuView = HomeTopMenuView.jq_loadNibView() private var titleItems = [TitleItem]() + private var viewModel = HomeViewModel() override func viewDidLoad() { super.viewDidLoad() + titleItems.removeAll() + titleItems.append(TitleItem(title: "每日疗愈", subTitle: "Daily Meditation")) titleItems.append(TitleItem(title: "私人订制", subTitle: "Private Meditation",hasMore: true)) titleItems.append(TitleItem(title: "新手冥想指南", subTitle: "Meditation guide")) - titleItems.append(TitleItem(title: "放松助眠", subTitle: "与内心的宁静与喜悦入睡",hasMore:true)) - titleItems.append(TitleItem(title: "放松助眠", subTitle: "与内心的宁静与喜悦入睡",hasMore:true)) - titleItems.append(TitleItem(title: "放松助眠", subTitle: "与内心的宁静与喜悦入睡",hasMore:true)) + + if let setting = UserDefaultSettingViewModel.getSetting(){ + if let audioFile = setting.bgm?.audioFile{ + AudioPlayer.getSharedInstance().playBGMAt(audioFile) + } + } + + getData() } override func setUI() { @@ -75,8 +93,8 @@ tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 40, right: 0) tableView.showsVerticalScrollIndicator = false DispatchQueue.main.async { - let height = self.topMenuView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).height - self.topMenuView.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: height - 70) + let h = 119 + 20.5 + JQ_ScreenW * 0.913 + self.topMenuView.frame = CGRect(x: 0, y: 0, width: JQ_ScreenW, height: h) self.tableView.tableHeaderView = self.topMenuView } @@ -86,6 +104,8 @@ tableView.register(UINib(nibName: "Home_Style_2_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_2_TCell") tableView.register(UINib(nibName: "Home_Style_3_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_3_TCell") tableView.register(UINib(nibName: "Home_Style_4_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_4_TCell") + + tableView.register(UINib(nibName: "Home_Style_5_TCell", bundle: nil), forCellReuseIdentifier: "_Home_Style_5_TCell") tableView.separatorStyle = .none tableView.delegate = self @@ -107,6 +127,51 @@ let vc = HomeItemListVC(topTitle: item.title, id: item.id) self.push(vc: vc) } + + NotificationCenter.default.rx.notification(SetBGMSuccess_Noti).take(until: self.rx.deallocated).subscribe(onNext: {data in + self.topMenuView.resetTopImage() + }).disposed(by: disposeBag) + } + + private func getData(){ + + Services.getCategoryListByType(type: 1).subscribe(onNext: { data in + var items = [HomeTopMenuItem]() + for v in data.data ?? []{ + let model = HomeTopMenuItem(id: v.id, title: v.categoryName, image: v.firstIconUrl, imageFrom: .url) + items.append(model) + } + + self.viewModel.homeTopMenuItems = items + let h = ceil(Double(items.count) / 4.0) * 119 + 20.5 + JQ_ScreenW * 0.913 + self.topMenuView.menu_height.constant = ceil(Double(items.count) / 4.0) * 119 + self.tableView.tableHeaderView?.frame = CGRect(origin: .zero, size: CGSizeMake(JQ_ScreenW, h)) + self.topMenuView.resetItems(items) + self.topMenuView.menu_collectionView.reloadData() + }).disposed(by: disposeBag) + + Services.getTopdayMedita().subscribe(onNext: { data in + self.viewModel.todyModel = data.data?.clientMeditationVO + self.tableView.reloadRows(at: [IndexPath(row: 0, section: 0)], with: .none) + }).disposed(by: disposeBag) + + Services.getPersonalityPlan().subscribe(onNext: { data in + if let m = data.data{ + self.viewModel.privateTodyModels = m + self.tableView.reloadRows(at: [IndexPath(row: 1, section: 0)], with: .none) + } + }).disposed(by: disposeBag) + + Services.getMeditationAndCateList().subscribe(onNext: { data in + if let m = data.data{ + self.viewModel.meditationList.removeAll() + self.viewModel.meditationList = m + for v in self.viewModel.meditationList{ + self.titleItems.append(TitleItem(title: v.clientMeditationCategoryVO?.categoryName ?? "", subTitle: v.clientMeditationCategoryVO?.description ?? "",hasMore:true)) + } + self.tableView.reloadData() + } + }).disposed(by: disposeBag) } @objc func searchAction(){ @@ -133,18 +198,21 @@ break default: let topTitle = titleItems[sender.tag - 200].title - let vc = HomeItemListVC(topTitle: topTitle, id: 0) - push(vc: vc) + let m = viewModel.meditationList[sender.tag - 200 - 3] + if let id = m.clientMeditationCategoryVO?.id{ + let vc = HomeItemListVC(topTitle: topTitle, id: id) + push(vc: vc) + } } } - } extension HomeVC:UITableViewDelegate & UITableViewDataSource{ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if indexPath.section == 2{ - let vc = HomeTyroGuideVC() + let vc = WebVC(type: .guide) + vc.title = "心泉·疗愈" push(vc: vc) } } @@ -152,56 +220,65 @@ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { if indexPath.section == 0{ let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_1_TCell") as! Home_Style_1_TCell + cell.model = viewModel.todyModel return cell - } - - if indexPath.section == 1{ + }else if indexPath.section == 1{ let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_4_TCell") as! Home_Style_4_TCell cell.style = .style1 + cell.setModels(viewModel.privateTodyModels) return cell - } - - if indexPath.section == 2{ + }else if indexPath.section == 2{ let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_2_TCell") as! Home_Style_2_TCell cell.view_shadow.isHidden = true return cell - } + }else { - if indexPath.section == 3{ - let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_3_TCell") as! Home_Style_3_TCell - return cell + let index = indexPath.section - 3 + if index == 0 && indexPath.row != 0{ + let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_5_TCell") as! Home_Style_5_TCell + return cell + }else{ + let m = viewModel.meditationList[index] + if m.clientMeditationCategoryVO!.showType == .horizontal{ + let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_4_TCell") as! Home_Style_4_TCell + cell.style = .style1 + cell.setModels(m.clientMeditationVOList) + return cell + }else if m.clientMeditationCategoryVO!.showType == .vertical{ + let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_3_TCell") as! Home_Style_3_TCell + cell.setModels(m.clientMeditationVOList) + return cell + } + } + return UITableViewCell() } - - if indexPath.section == 4{ - let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_4_TCell") as! Home_Style_4_TCell - cell.style = .style2 - return cell - } - - if indexPath.section == 5{ - let cell = tableView.dequeueReusableCell(withIdentifier: "_Home_Style_4_TCell") as! Home_Style_4_TCell - cell.style = .style2 - return cell - } - - return UITableViewCell() } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + + if section - 3 == 0{ + return 2 + } return 1 } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if indexPath.section == 0 || indexPath.section == 1 || indexPath.section == 2{ return JQ_ScreenW * 0.551 + }else{ + let index = indexPath.section - 3 + let m = viewModel.meditationList[index] + + if index == 0 && indexPath.row != 0 { + return 236 + } + + if m.clientMeditationCategoryVO?.showType == .horizontal{ + return 328 + }else{ + return 213 + } } - if indexPath.section == 3{ - return 397.3 - } - if indexPath.section == 4 || indexPath.section == 5{ - return 328 - } - return 0 } func numberOfSections(in tableView: UITableView) -> Int { @@ -224,7 +301,6 @@ }else{ headerView.btn_more.setImage(UIImage(named: "icon_exchange"), for: .normal) } - return headerView } diff --git a/XQMuse/Root/Home/TCell/Home_Style_1_TCell.swift b/XQMuse/Root/Home/TCell/Home_Style_1_TCell.swift index c9fe163..155c447 100644 --- a/XQMuse/Root/Home/TCell/Home_Style_1_TCell.swift +++ b/XQMuse/Root/Home/TCell/Home_Style_1_TCell.swift @@ -9,6 +9,20 @@ class Home_Style_1_TCell: UITableViewCell { + var model:MeditationModel?{ + didSet{ + if let m = model{ + img_cover.sd_setImage(with: URL(string: m.backgroundUrl)) + label_title.text = "\(m.meditationTitle) | 00:00" + label_joinNum.text = "\(m.realLearnedNum)人已参加学习" + } + } + } + @IBOutlet weak var img_cover: UIImageView! + @IBOutlet weak var label_title: UILabel! + @IBOutlet weak var label_joinNum: UILabel! + @IBOutlet weak var img_play: UIImageView! + override func awakeFromNib() { super.awakeFromNib() selectionStyle = .none diff --git a/XQMuse/Root/Home/TCell/Home_Style_1_TCell.xib b/XQMuse/Root/Home/TCell/Home_Style_1_TCell.xib index 71edfb2..8a2c700 100644 --- a/XQMuse/Root/Home/TCell/Home_Style_1_TCell.xib +++ b/XQMuse/Root/Home/TCell/Home_Style_1_TCell.xib @@ -71,6 +71,12 @@ <constraint firstAttribute="trailing" secondItem="xQx-q9-7lM" secondAttribute="trailing" id="z0K-q8-ey1"/> </constraints> </tableViewCellContentView> + <connections> + <outlet property="img_cover" destination="MKZ-ZX-Qgl" id="MVe-HP-Kia"/> + <outlet property="img_play" destination="g9v-rM-WZr" id="eqA-n5-5Qy"/> + <outlet property="label_joinNum" destination="KpH-Aq-7Pf" id="51p-uN-6M7"/> + <outlet property="label_title" destination="bu5-9N-LaQ" id="TM0-io-hMz"/> + </connections> <point key="canvasLocation" x="140.45801526717557" y="104.92957746478874"/> </tableViewCell> </objects> diff --git a/XQMuse/Root/Home/TCell/Home_Style_3_TCell.swift b/XQMuse/Root/Home/TCell/Home_Style_3_TCell.swift index 5ed61e1..5c327ff 100644 --- a/XQMuse/Root/Home/TCell/Home_Style_3_TCell.swift +++ b/XQMuse/Root/Home/TCell/Home_Style_3_TCell.swift @@ -11,7 +11,8 @@ class Home_Style_3_TCell: UITableViewCell { @IBOutlet weak var collectionView: UICollectionView! - + var meditationModels = [MeditationModel]() + override func awakeFromNib() { super.awakeFromNib() selectionStyle = .none @@ -23,33 +24,45 @@ collectionView.bounces = false collectionView.showsHorizontalScrollIndicator = false collectionView.register(UINib(nibName: "HomeRelaxBannerCCell", bundle: nil), forCellWithReuseIdentifier: "_HomeRelaxBannerCCell") - collectionView.scrollToItem(at: IndexPath(row: 2, section: 0), at: .centeredHorizontally, animated: true) +// collectionView.scrollToItem(at: IndexPath(row: 2, section: 0), at: .centeredHorizontally, animated: true) collectionView.contentInset = UIEdgeInsets(top: 0, left: 100 , bottom: 0, right: 100) } + + func setModels(_ items:[MeditationModel]){ + self.meditationModels = items + collectionView.reloadData() + } } extension Home_Style_3_TCell:UICollectionViewDelegate & UICollectionViewDataSource{ func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 5 + return meditationModels.count } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBannerCCell", for: indexPath) as! HomeRelaxBannerCCell cell.contentView.backgroundColor = .jq_randomColor + cell.setMeditationModel(meditationModels[indexPath.row]) return cell } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - if indexPath.row == 0{ + let m = meditationModels[indexPath.row] + if m.chargeType == .payment{ let vc = PaymentOrderVC() JQ_currentViewController().jq_push(vc: vc) + return } - if indexPath.row == 1{ + if m.chargeType == .vipFree{ let vc = VIPCenterVC() JQ_currentViewController().jq_push(vc: vc) + return } + + let vc = HomeItemDetailVC(id: m.id) + JQ_currentViewController().jq_push(vc: vc) } } diff --git a/XQMuse/Root/Home/TCell/Home_Style_3_TCell.xib b/XQMuse/Root/Home/TCell/Home_Style_3_TCell.xib index bd1a211..e24a6d7 100644 --- a/XQMuse/Root/Home/TCell/Home_Style_3_TCell.xib +++ b/XQMuse/Root/Home/TCell/Home_Style_3_TCell.xib @@ -10,11 +10,11 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> - <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="_Home_Style_3_TCell" rowHeight="551" id="KGk-i7-Jjw" customClass="Home_Style_3_TCell" customModule="XQMuse" customModuleProvider="target"> - <rect key="frame" x="0.0" y="0.0" width="659" height="551"/> + <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="_Home_Style_3_TCell" rowHeight="223" id="KGk-i7-Jjw" customClass="Home_Style_3_TCell" customModule="XQMuse" customModuleProvider="target"> + <rect key="frame" x="0.0" y="0.0" width="659" height="223"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> - <rect key="frame" x="0.0" y="0.0" width="659" height="551"/> + <rect key="frame" x="0.0" y="0.0" width="659" height="223"/> <autoresizingMask key="autoresizingMask"/> <subviews> <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="uxp-FZ-nad"> @@ -31,45 +31,20 @@ <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/> </collectionViewFlowLayout> </collectionView> - <stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="9.5" translatesAutoresizingMaskIntoConstraints="NO" id="meU-cT-u69"> - <rect key="frame" x="152.33333333333334" y="270.33333333333331" width="354.33333333333326" height="126.66666666666669"/> - <subviews> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="MRf-5Q-3iT"> - <rect key="frame" x="0.0" y="0.0" width="111.66666666666667" height="126.66666666666667"/> - <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> - <state key="normal" image="bg_home_3"/> - </button> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="baI-cf-dmt"> - <rect key="frame" x="121.33333333333334" y="0.0" width="111.66666666666666" height="126.66666666666667"/> - <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> - <state key="normal" image="bg_home_1"/> - </button> - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Jy6-tY-w5F"> - <rect key="frame" x="242.66666666666666" y="0.0" width="111.66666666666666" height="126.66666666666667"/> - <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> - <state key="normal" image="bg_home_2"/> - </button> - </subviews> - </stackView> </subviews> <constraints> - <constraint firstItem="meU-cT-u69" firstAttribute="top" secondItem="uxp-FZ-nad" secondAttribute="bottom" constant="57" id="8Sh-vV-ZJA"/> <constraint firstItem="uxp-FZ-nad" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="FUv-Km-zco"/> <constraint firstAttribute="trailing" secondItem="uxp-FZ-nad" secondAttribute="trailing" id="PxF-ZL-MPJ"/> - <constraint firstItem="meU-cT-u69" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" id="iNc-ef-Yhd"/> <constraint firstItem="uxp-FZ-nad" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="onW-fv-uZ8"/> </constraints> </tableViewCellContentView> <connections> <outlet property="collectionView" destination="uxp-FZ-nad" id="Idx-Ei-fon"/> </connections> - <point key="canvasLocation" x="339.69465648854958" y="198.23943661971833"/> + <point key="canvasLocation" x="339.69465648854958" y="82.74647887323944"/> </tableViewCell> </objects> <resources> - <image name="bg_home_1" width="111.66666412353516" height="126.66666412353516"/> - <image name="bg_home_2" width="111.66666412353516" height="126.66666412353516"/> - <image name="bg_home_3" width="111.66666412353516" height="126.66666412353516"/> <systemColor name="systemBackgroundColor"> <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> </systemColor> diff --git a/XQMuse/Root/Home/TCell/Home_Style_4_TCell.swift b/XQMuse/Root/Home/TCell/Home_Style_4_TCell.swift index de52d04..5dc3c75 100644 --- a/XQMuse/Root/Home/TCell/Home_Style_4_TCell.swift +++ b/XQMuse/Root/Home/TCell/Home_Style_4_TCell.swift @@ -16,7 +16,8 @@ class Home_Style_4_TCell: UITableViewCell { var style:Home_Style_4_Style! - + var meditationModels = [MeditationModel]() + @IBOutlet weak var collectionView: UICollectionView! override func awakeFromNib() { @@ -28,22 +29,29 @@ collectionView.register(UINib(nibName: "Home_Style_4_Inner_CCell", bundle: nil), forCellWithReuseIdentifier: "_Home_Style_4_Inner_CCell") collectionView.showsHorizontalScrollIndicator = false } + + func setModels(_ items:[MeditationModel]){ + self.meditationModels = items + collectionView.reloadData() + } } extension Home_Style_4_TCell:UICollectionViewDelegate & UICollectionViewDataSource{ func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let detailVC = HomeItemDetailVC() + + let detailVC = HomeItemDetailVC(id: meditationModels[indexPath.row].id) JQ_currentViewController().jq_push(vc: detailVC) } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 3 + return meditationModels.count } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { if style == .style1{ let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_Home_Style_4_Inner_1_CCell", for: indexPath) as! Home_Style_4_Inner_1_CCell + cell.setMeditationModel(meditationModels[indexPath.row]) return cell } diff --git a/XQMuse/Root/Home/TCell/Home_Style_5_TCell.swift b/XQMuse/Root/Home/TCell/Home_Style_5_TCell.swift new file mode 100644 index 0000000..18f0ef5 --- /dev/null +++ b/XQMuse/Root/Home/TCell/Home_Style_5_TCell.swift @@ -0,0 +1,23 @@ +// +// Home_Style_5_TCell.swift +// XQMuse +// +// Created by 无故事王国 on 2024/9/9. +// + +import UIKit + +class Home_Style_5_TCell: UITableViewCell { + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + + // Configure the view for the selected state + } + +} diff --git a/XQMuse/Root/Home/TCell/Home_Style_5_TCell.xib b/XQMuse/Root/Home/TCell/Home_Style_5_TCell.xib new file mode 100644 index 0000000..cbb6076 --- /dev/null +++ b/XQMuse/Root/Home/TCell/Home_Style_5_TCell.xib @@ -0,0 +1,64 @@ +<?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"> + <device id="retina6_12" orientation="portrait" appearance="light"/> + <dependencies> + <deployment identifier="iOS"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/> + <capability name="Safe area layout guides" minToolsVersion="9.0"/> + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> + </dependencies> + <objects> + <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> + <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> + <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="_Home_Style_5_TCell" rowHeight="181" id="KGk-i7-Jjw" customClass="Home_Style_5_TCell" customModule="XQMuse" customModuleProvider="target"> + <rect key="frame" x="0.0" y="0.0" width="462" height="181"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> + <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> + <rect key="frame" x="0.0" y="0.0" width="462" height="181"/> + <autoresizingMask key="autoresizingMask"/> + <subviews> + <stackView opaque="NO" contentMode="scaleToFill" spacing="9.5" translatesAutoresizingMaskIntoConstraints="NO" id="iSv-Jr-Qcx"> + <rect key="frame" x="53.666666666666657" y="27.333333333333336" width="354.66666666666674" height="126.66666666666666"/> + <subviews> + <button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="30T-1D-WNl"> + <rect key="frame" x="0.0" y="0.0" width="111.66666666666667" height="126.66666666666667"/> + <constraints> + <constraint firstAttribute="width" secondItem="30T-1D-WNl" secondAttribute="height" multiplier="1:1.134" id="rI9-Qc-ZN4"/> + </constraints> + <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> + <state key="normal" image="bg_home_3"/> + </button> + <button opaque="NO" contentMode="scaleAspectFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="vXA-OX-SB1"> + <rect key="frame" x="121.33333333333334" y="0.0" width="112" height="126.66666666666667"/> + <constraints> + <constraint firstAttribute="width" secondItem="vXA-OX-SB1" secondAttribute="height" multiplier="1:1.134" id="AHL-qK-kMk"/> + </constraints> + <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> + <state key="normal" image="bg_home_1"/> + </button> + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xmc-SJ-H1U"> + <rect key="frame" x="243.00000000000003" y="0.0" width="111.66666666666666" height="126.66666666666667"/> + <constraints> + <constraint firstAttribute="width" secondItem="xmc-SJ-H1U" secondAttribute="height" multiplier="1:1.134" id="nka-Yt-rjX"/> + </constraints> + <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> + <state key="normal" image="bg_home_2"/> + </button> + </subviews> + </stackView> + </subviews> + <constraints> + <constraint firstItem="iSv-Jr-Qcx" firstAttribute="centerX" secondItem="H2p-sc-9uM" secondAttribute="centerX" id="XSN-Du-6vJ"/> + <constraint firstItem="iSv-Jr-Qcx" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="dNR-kv-uAL"/> + </constraints> + </tableViewCellContentView> + <viewLayoutGuide key="safeArea" id="njF-e1-oar"/> + <point key="canvasLocation" x="174.04580152671755" y="68.661971830985919"/> + </tableViewCell> + </objects> + <resources> + <image name="bg_home_1" width="111.66666412353516" height="126.66666412353516"/> + <image name="bg_home_2" width="111.66666412353516" height="126.66666412353516"/> + <image name="bg_home_3" width="111.66666412353516" height="126.66666412353516"/> + </resources> +</document> diff --git a/XQMuse/Root/Home/VC/BackgroundVoiceVC.swift b/XQMuse/Root/Home/VC/BackgroundVoiceVC.swift index f1ee5b9..44adf7a 100644 --- a/XQMuse/Root/Home/VC/BackgroundVoiceVC.swift +++ b/XQMuse/Root/Home/VC/BackgroundVoiceVC.swift @@ -13,11 +13,52 @@ @IBOutlet weak var slider_voice: UISlider! @IBOutlet weak var collectionView: UICollectionView! - + + private var items = [BGMModel]() + private var settingModel = UserDefaultSettingViewModel.getSetting() + private var audioPlayer = AudioPlayer.getSharedInstance() + private var playAtIndex:IndexPath? + private var tempPlayer:AVPlayer? + private var isPlaying:Bool = false + + override func viewDidDisappear(_ animated: Bool) { + super.viewDidDisappear(animated) + audioPlayer.playBGM() + } + + override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + audioPlayer.pauseBGM() + } + override func viewDidLoad() { super.viewDidLoad() title = "心泉·疗愈" - + + slider_voice.isEnabled = false + slider_voice.value = Float(settingModel?.volume ?? 0.5) + slider_voice.addTarget(self, action: #selector(volumeChange(_:)), for: .valueChanged) + Services.getBGM().subscribe(onNext: {[unowned self]data in + if let m = data.data{ + self.items = m + self.slider_voice.isEnabled = true + self.collectionView.reloadData() + + DispatchQueue.main.asyncAfter(delay: 0.8) { + for (index,v) in m.enumerated(){ + if v.id == self.settingModel?.bgm?.id{ + self.playAtIndex = IndexPath(row: index, section: 0) + self.collectionView.scrollToItem(at: IndexPath(row: index, section: 0), at: .centeredHorizontally, animated: true) + break + } + } + self.collectionView.reloadData() + } + } + }).disposed(by: disposeBag) + + //播放完成 + NotificationCenter.default.addObserver(self, selector: #selector(playBGMbackEnd), name:NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: nil) } override func setUI() { @@ -39,19 +80,79 @@ collectionView.bounces = false collectionView.showsHorizontalScrollIndicator = false collectionView.register(UINib(nibName: "HomeRelaxVoiceCCell", bundle: nil), forCellWithReuseIdentifier: "_HomeRelaxVoiceCCell") - collectionView.scrollToItem(at: IndexPath(row: 2, section: 0), at: .centeredHorizontally, animated: true) collectionView.contentInset = UIEdgeInsets(top: 0, left: 100 , bottom: 0, right: 100) + } + + @objc func playBGMbackEnd(){ + isPlaying = false + collectionView.reloadData() + } + + @IBAction func setttingAction(_ sender: UIButton) { + if settingModel != nil{ + guard let index = playAtIndex else {return} + settingModel?.bgm = items[index.row] + settingModel?.volume = Double(slider_voice.value) + UserDefaultSettingViewModel.saveSetting(settingModel!) + audioPlayer.playBGMAt(items[index.row].audioFile) + alertSuccess(msg: "设置成功") + NotificationCenter.default.post(name: SetBGMSuccess_Noti, object: items[index.row]) + } + } + + @objc func volumeChange(_ slider:UISlider){ + tempPlayer?.volume = slider.value + } + + deinit{ + NotificationCenter.default.removeObserver(self, name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: nil) + } +} + +extension BackgroundVoiceVC:UIScrollViewDelegate{ + + func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { + let p = CGPoint(x: collectionView.contentOffset.x + collectionView.frame.size.width / 2, y:0) + if let v = collectionView.indexPathForItem(at: p){ + playAtIndex = v + } } } extension BackgroundVoiceVC:UICollectionViewDelegate & UICollectionViewDataSource{ + + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + playAtIndex = indexPath + let model = items[indexPath.row] + collectionView.scrollToItem(at: indexPath, at: .centeredHorizontally, animated: true) + + guard let URL = URL(string: model.audioFile) else { return } + + tempPlayer = AVPlayer(url: URL) + tempPlayer?.volume = slider_voice.value + tempPlayer!.play() + isPlaying = true + collectionView.reloadData() + } + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 5 + return items.count + } + + func numberOfSections(in collectionView: UICollectionView) -> Int { + return 1 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxVoiceCCell", for: indexPath) as! HomeRelaxVoiceCCell cell.contentView.backgroundColor = .jq_randomColor + cell.setModel(items[indexPath.row]) + + if isPlaying && indexPath == playAtIndex{ + cell.img_play.image = UIImage(named: "icon_play_purse") + }else{ + cell.img_play.image = UIImage(named: "icon_play") + } return cell } } diff --git a/XQMuse/Root/Home/VC/BackgroundVoiceVC.xib b/XQMuse/Root/Home/VC/BackgroundVoiceVC.xib index c983955..68b560a 100644 --- a/XQMuse/Root/Home/VC/BackgroundVoiceVC.xib +++ b/XQMuse/Root/Home/VC/BackgroundVoiceVC.xib @@ -11,7 +11,7 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="BackgroundVoiceVC" customModule="XQMuse" customModuleProvider="target"> <connections> - <outlet property="collectionView" destination="IMe-2Z-Saj" id="x0H-ex-6T5"/> + <outlet property="collectionView" destination="IMe-2Z-Saj" id="GI4-46-ag9"/> <outlet property="slider_voice" destination="XVQ-J7-Tg5" id="W8U-bw-7Jr"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> </connections> @@ -37,7 +37,7 @@ <nil key="textColor"/> <nil key="highlightedColor"/> </label> - <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.0" maxValue="100" minimumValueImage="icon_voice_close" maximumValueImage="icon_voice_open" translatesAutoresizingMaskIntoConstraints="NO" id="XVQ-J7-Tg5"> + <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" minimumValueImage="icon_voice_close" maximumValueImage="icon_voice_open" translatesAutoresizingMaskIntoConstraints="NO" id="XVQ-J7-Tg5"> <rect key="frame" x="19" y="124" width="355" height="31"/> <color key="minimumTrackTintColor" red="0.71372549019607845" green="0.86274509803921573" blue="0.56470588235294117" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="maximumTrackTintColor" red="0.90588235294117647" green="0.90588235294117647" blue="0.90588235294117647" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> @@ -69,6 +69,25 @@ <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/> </collectionViewFlowLayout> </collectionView> + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Fex-hD-lXe"> + <rect key="frame" x="45" y="744" width="303" height="40"/> + <color key="backgroundColor" red="0.55686274509803924" green="0.64313725490196072" blue="0.47843137254901957" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + <constraints> + <constraint firstAttribute="height" constant="40" id="9JM-hR-8TO"/> + </constraints> + <fontDescription key="fontDescription" type="system" weight="medium" pointSize="15"/> + <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> + <state key="normal" title="保存设置"/> + <userDefinedRuntimeAttributes> + <userDefinedRuntimeAttribute type="boolean" keyPath="ld_maskToBoundsXIB" value="YES"/> + <userDefinedRuntimeAttribute type="number" keyPath="ld_cornerRadiusXIB"> + <real key="value" value="20"/> + </userDefinedRuntimeAttribute> + </userDefinedRuntimeAttributes> + <connections> + <action selector="setttingAction:" destination="-1" eventType="touchUpInside" id="bI1-rh-Ktb"/> + </connections> + </button> </subviews> <viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/> @@ -82,6 +101,7 @@ <constraint firstItem="IMe-2Z-Saj" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" id="OCp-XE-yX3"/> <constraint firstItem="IMe-2Z-Saj" firstAttribute="top" secondItem="ZGI-tV-gLQ" secondAttribute="bottom" constant="34" id="Rdt-Kx-OGp"/> <constraint firstItem="ZGI-tV-gLQ" firstAttribute="top" secondItem="XVQ-J7-Tg5" secondAttribute="bottom" constant="55" id="Sx4-E7-NCS"/> + <constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="Fex-hD-lXe" secondAttribute="trailing" constant="45" id="a6x-Od-xK0"/> <constraint firstItem="ZnS-y1-db2" firstAttribute="leading" secondItem="ZGI-tV-gLQ" secondAttribute="trailing" constant="9" id="b96-6e-A8B"/> <constraint firstItem="7p2-Gb-yaE" firstAttribute="centerY" secondItem="Pah-Qd-T99" secondAttribute="centerY" id="c3z-R4-piy"/> <constraint firstItem="fnl-2z-Ty3" firstAttribute="trailing" secondItem="XVQ-J7-Tg5" secondAttribute="trailing" constant="21" id="cCS-Wo-sPO"/> @@ -90,6 +110,8 @@ <constraint firstItem="ZnS-y1-db2" firstAttribute="centerY" secondItem="ZGI-tV-gLQ" secondAttribute="centerY" id="jfb-sk-rwP"/> <constraint firstItem="Pah-Qd-T99" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="14" id="lY0-v3-RAo"/> <constraint firstItem="XVQ-J7-Tg5" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="21" id="mOo-uy-aLe"/> + <constraint firstItem="Fex-hD-lXe" firstAttribute="leading" secondItem="fnl-2z-Ty3" secondAttribute="leading" constant="45" id="pUr-9f-1wN"/> + <constraint firstItem="fnl-2z-Ty3" firstAttribute="bottom" secondItem="Fex-hD-lXe" secondAttribute="bottom" constant="34" id="tCV-91-mmJ"/> </constraints> <point key="canvasLocation" x="139.69465648854961" y="20.422535211267608"/> </view> diff --git a/XQMuse/Root/Home/VC/HomeItemDetailVC.swift b/XQMuse/Root/Home/VC/HomeItemDetailVC.swift index a0ff079..0badbb4 100644 --- a/XQMuse/Root/Home/VC/HomeItemDetailVC.swift +++ b/XQMuse/Root/Home/VC/HomeItemDetailVC.swift @@ -15,12 +15,34 @@ @IBOutlet weak var btn_play: UIButton! @IBOutlet weak var label_title: UILabel! @IBOutlet weak var label_subtitle: UILabel! - @IBOutlet weak var btn_like: UIButton! @IBOutlet weak var label_commentNum: UILabel! @IBOutlet weak var view_coutdown: UIView! @IBOutlet weak var img_countdonw: UIImageView! @IBOutlet weak var label_countdown: UILabel! + @IBOutlet weak var view_playState: UIView! + @IBOutlet weak var label_playState: UILabel! + + private var collect_bitem:UIBarButtonItem! + private var id:Int! + private var model:MeditationModel?{ + didSet{ + if let m = model{ + label_title.text = m.meditationTitle + label_subtitle.text = m.detailDescription + } + } + } + + init(id:Int) { + super.init(nibName: nil, bundle: nil) + self.id = id + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + override func viewDidLoad() { super.viewDidLoad() title = "心泉·疗愈" @@ -30,6 +52,11 @@ }else{ endMiniRunloop() } + + Services.getMeditationDetail(id: id).subscribe(onNext: {data in + self.model = data.data + self.collect_bitem.image = data.data?.favorite == 1 ? UIImage(named: "btn_collect"):UIImage(named: "btn_collect_1_s") + }).disposed(by: disposeBag) } override func viewDidAppear(_ animated: Bool) { @@ -46,7 +73,8 @@ override func setUI() { - let collect_bitem = UIBarButtonItem(image: UIImage(named: "btn_collect"), style: .plain, target: self, action: #selector(collectionAction)) + view_playState.isHidden = true + collect_bitem = UIBarButtonItem(image: UIImage(named: "btn_collect"), style: .plain, target: self, action: #selector(collectionAction)) collect_bitem.tintColor = .white let share_bitem = UIBarButtonItem(image: UIImage(named: "btn_share"), style: .plain, target: self, action: #selector(shareAction)) share_bitem.tintColor = .white diff --git a/XQMuse/Root/Home/VC/HomeItemDetailVC.xib b/XQMuse/Root/Home/VC/HomeItemDetailVC.xib index 1a76bda..5f4b7d0 100644 --- a/XQMuse/Root/Home/VC/HomeItemDetailVC.xib +++ b/XQMuse/Root/Home/VC/HomeItemDetailVC.xib @@ -10,17 +10,18 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HomeItemDetailVC" customModule="XQMuse" customModuleProvider="target"> <connections> - <outlet property="btn_like" destination="OBt-Rv-6FE" id="Arb-Gb-v5a"/> <outlet property="btn_play" destination="Qgc-UW-rO1" id="MUw-JK-1pS"/> <outlet property="img_countdonw" destination="gxd-0O-eUD" id="rzB-8i-qOk"/> <outlet property="label_commentNum" destination="IkS-qR-riK" id="9zO-Xt-6XC"/> <outlet property="label_countdown" destination="akf-L4-aPE" id="goO-Gd-TLu"/> + <outlet property="label_playState" destination="4zW-Bq-V7P" id="vSm-Rr-gtL"/> <outlet property="label_subtitle" destination="xYv-9B-0fk" id="6WT-eV-ZES"/> <outlet property="label_title" destination="0CQ-Qn-OOa" id="3vY-s9-wNj"/> <outlet property="slider_voice" destination="P8W-2A-zOo" id="hiF-Hr-YQ0"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> <outlet property="view_coutdown" destination="V28-7K-Bfm" id="pqU-2r-w5U"/> <outlet property="view_function" destination="vIs-Dn-PVO" id="bNm-Q1-CdV"/> + <outlet property="view_playState" destination="3rZ-t0-pdK" id="ftL-wH-p2W"/> </connections> </placeholder> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> @@ -116,15 +117,6 @@ <action selector="commentAction:" destination="-1" eventType="touchUpInside" id="den-g3-cBv"/> </connections> </view> - <button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OBt-Rv-6FE"> - <rect key="frame" x="349.33333333333331" y="55" width="23.666666666666686" height="22"/> - <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/> - <state key="normal" image="btn_like_u"/> - <state key="selected" image="btn_like"/> - <connections> - <action selector="beLikeAction:" destination="-1" eventType="touchUpInside" id="yQs-VU-v7b"/> - </connections> - </button> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="--" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="xYv-9B-0fk"> <rect key="frame" x="22.666666666666657" y="73" width="257.33333333333337" height="17"/> <fontDescription key="fontDescription" type="system" pointSize="14"/> @@ -148,14 +140,12 @@ <constraint firstItem="xYv-9B-0fk" firstAttribute="trailing" secondItem="0CQ-Qn-OOa" secondAttribute="trailing" id="J00-LT-ihn"/> <constraint firstItem="Soz-NO-Sl6" firstAttribute="centerX" secondItem="oe5-fX-A8S" secondAttribute="centerX" id="JQk-V6-Wr2"/> <constraint firstItem="rML-fW-BqA" firstAttribute="leading" secondItem="P8W-2A-zOo" secondAttribute="trailing" id="LQh-3z-ZWN"/> - <constraint firstItem="oe5-fX-A8S" firstAttribute="centerX" secondItem="OBt-Rv-6FE" secondAttribute="centerX" id="MyD-er-pSD"/> <constraint firstAttribute="height" constant="260" id="Nfj-Hc-QTz"/> <constraint firstItem="9ky-8U-0Iq" firstAttribute="top" secondItem="xYv-9B-0fk" secondAttribute="bottom" constant="22" id="NrV-Mq-ATf"/> <constraint firstItem="Soz-NO-Sl6" firstAttribute="top" secondItem="oe5-fX-A8S" secondAttribute="bottom" constant="26" id="QAM-jd-nhq"/> <constraint firstItem="9t3-fS-clT" firstAttribute="centerY" secondItem="9ky-8U-0Iq" secondAttribute="centerY" id="RCH-if-FSR"/> <constraint firstItem="P8W-2A-zOo" firstAttribute="leading" secondItem="zwK-yd-ILF" secondAttribute="trailing" constant="12.5" id="Re5-xC-yA4"/> <constraint firstItem="9ky-8U-0Iq" firstAttribute="leading" secondItem="vIs-Dn-PVO" secondAttribute="leading" constant="23.5" id="Tcc-7u-zff"/> - <constraint firstItem="oe5-fX-A8S" firstAttribute="top" secondItem="OBt-Rv-6FE" secondAttribute="bottom" constant="36.5" id="UnE-r4-Y3J"/> <constraint firstAttribute="trailing" secondItem="xYv-9B-0fk" secondAttribute="trailing" constant="113" id="WeW-cL-yXy"/> <constraint firstItem="xYv-9B-0fk" firstAttribute="leading" secondItem="vIs-Dn-PVO" secondAttribute="leading" constant="22.5" id="a5m-GS-Y4H"/> <constraint firstItem="0CQ-Qn-OOa" firstAttribute="top" secondItem="vIs-Dn-PVO" secondAttribute="top" constant="20" id="az1-qw-mly"/> @@ -256,8 +246,6 @@ </objects> <resources> <image name="btn_comment" width="18.666666030883789" height="19"/> - <image name="btn_like" width="21.666666030883789" height="17"/> - <image name="btn_like_u" width="23.666666030883789" height="19.666666030883789"/> <image name="btn_list" width="17" height="13.666666984558105"/> <image name="btn_roll" width="22.666666030883789" height="19.666666030883789"/> <image name="btn_time" width="20.666666030883789" height="20.666666030883789"/> diff --git a/XQMuse/Root/Home/VC/HomeItemListVC.swift b/XQMuse/Root/Home/VC/HomeItemListVC.swift index df96fbf..1d2c234 100644 --- a/XQMuse/Root/Home/VC/HomeItemListVC.swift +++ b/XQMuse/Root/Home/VC/HomeItemListVC.swift @@ -7,9 +7,14 @@ import UIKit import JQTools +import RxSwift +import RxRelay -class HomeItemViewModel:RefreshModel<SimpleModel>{ - +class HomeItemViewModel:RefreshInnerModel<MeditationModel>{ + var id = BehaviorRelay<Int>(value: 0) + override func api() -> (Observable<BaseResponse<BaseResponseList<MeditationModel>>>)? { + return Services.getMeditationPage(id.value, page: page) + } } @@ -17,14 +22,12 @@ private var collectionView:UICollectionView! private var topTitle:String! - private var id:Int! - private var viewModel = HomeItemViewModel() init(topTitle:String,id:Int) { super.init(nibName: nil, bundle: nil) self.topTitle = topTitle - self.id = id + self.viewModel.id.accept(id) } override func viewDidLoad() { @@ -32,6 +35,7 @@ title = self.topTitle viewModel.configure(collectionView) + viewModel.beginRefresh() } override func setUI() { @@ -64,16 +68,19 @@ extension HomeItemListVC:UICollectionViewDelegate & UICollectionViewDataSource{ func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_CCell", for: indexPath) as! HomeRelaxBanner_2_CCell + let model = viewModel.dataSource.value!.list[indexPath.row] cell.backgroundColor = .jq_randomColor + cell.setMeditationModel(model) return cell } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 50 + return viewModel.dataSource.value?.list.count ?? 0 } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let vc = HomeItemDetailVC() + let id = viewModel.dataSource.value!.list[indexPath.row].id + let vc = HomeItemDetailVC(id: id) push(vc: vc) } } diff --git a/XQMuse/Root/Home/VC/HomeTyroGuideVC.swift b/XQMuse/Root/Home/VC/HomeTyroGuideVC.swift index dbaed65..6d3706a 100644 --- a/XQMuse/Root/Home/VC/HomeTyroGuideVC.swift +++ b/XQMuse/Root/Home/VC/HomeTyroGuideVC.swift @@ -6,7 +6,7 @@ // import UIKit - +@available(*,deprecated,message: "废弃") class HomeTyroGuideVC: BaseVC { var scrollView:UIScrollView! @@ -15,6 +15,9 @@ override func viewDidLoad() { super.viewDidLoad() title = "心泉·疗愈" + Services.agreementBy(.guide).subscribe(onNext: {data in + + }).disposed(by: disposeBag) } override func setUI() { diff --git a/XQMuse/Root/Home/View/HomeHeaderVC.swift b/XQMuse/Root/Home/View/HomeHeaderVC.swift index ca62bbe..7e5fd0c 100644 --- a/XQMuse/Root/Home/View/HomeHeaderVC.swift +++ b/XQMuse/Root/Home/View/HomeHeaderVC.swift @@ -39,7 +39,6 @@ label_subTitle.snp.makeConstraints { make in make.left.equalTo(19) make.top.equalTo(label_title.snp.bottom).offset(9) - make.height.equalTo(5.5) } btn_more = UIButton(type: .custom) diff --git a/XQMuse/Root/Home/View/HomeTopMenuView.swift b/XQMuse/Root/Home/View/HomeTopMenuView.swift index 02a78a4..51f2295 100644 --- a/XQMuse/Root/Home/View/HomeTopMenuView.swift +++ b/XQMuse/Root/Home/View/HomeTopMenuView.swift @@ -7,6 +7,7 @@ import UIKit import JQTools +import RxSwift enum ImageFromType { case local @@ -22,16 +23,21 @@ class HomeTopMenuView: UIView,JQNibView{ + @IBOutlet weak var image_top: UIImageView! @IBOutlet weak var menu_collectionView: UICollectionView! - + @IBOutlet weak var menu_height: NSLayoutConstraint! + + private var disposeBag = DisposeBag() private var defaultItems = [HomeTopMenuItem]() private var clouse:((HomeTopMenuItem)->Void)? override func awakeFromNib() { super.awakeFromNib() + menu_height.constant = 119 menu_collectionView.delegate = self menu_collectionView.dataSource = self + menu_collectionView.isScrollEnabled = false menu_collectionView.register(UINib(nibName: "HomeTopMenuCCell", bundle: nil), forCellWithReuseIdentifier: "_HomeTopMenuCCell") defaultItems.append(HomeTopMenuItem(title: "睡眠疗愈", image: "icon_sleep", imageFrom: .local)) @@ -41,6 +47,18 @@ menu_collectionView.reloadData() } + func resetTopImage(){ + if let imgUrl = UserDefaultSettingViewModel.getSetting()?.bgm?.imageUrl{ + image_top.sd_setImage(with: URL(string: imgUrl)) + } + } + + func resetItems(_ items:[HomeTopMenuItem]){ + defaultItems.removeAll() + defaultItems = items + menu_collectionView.reloadData() + } + func insertOthers(_ others:[HomeTopMenuItem]){ defaultItems.append(contentsOf: others) menu_collectionView.reloadData() diff --git a/XQMuse/Root/Home/View/HomeTopMenuView.xib b/XQMuse/Root/Home/View/HomeTopMenuView.xib index 77ce5fe..bf18d30 100644 --- a/XQMuse/Root/Home/View/HomeTopMenuView.xib +++ b/XQMuse/Root/Home/View/HomeTopMenuView.xib @@ -31,10 +31,10 @@ </constraints> </view> <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="qBC-HM-Cn0"> - <rect key="frame" x="0.0" y="305.66666666666669" width="332" height="119"/> + <rect key="frame" x="0.0" y="305.66666666666669" width="332" height="157.33333333333331"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> - <constraint firstAttribute="height" constant="119" id="A1l-yg-7AW"/> + <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="119" id="A1l-yg-7AW"/> </constraints> <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="1n0-2c-Gsq"> <size key="itemSize" width="128" height="128"/> @@ -44,7 +44,7 @@ </collectionViewFlowLayout> </collectionView> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hye-ra-wFd"> - <rect key="frame" x="0.0" y="433.66666666666669" width="332" height="9"/> + <rect key="frame" x="0.0" y="472" width="332" height="9"/> <color key="backgroundColor" red="0.94117647058823528" green="0.94117647058823528" blue="0.94117647058823528" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <constraints> <constraint firstAttribute="height" constant="9" id="LoO-4l-CvD"/> @@ -66,7 +66,9 @@ </constraints> <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/> <connections> + <outlet property="image_top" destination="6fX-5q-86Z" id="YZ8-fz-Vpa"/> <outlet property="menu_collectionView" destination="qBC-HM-Cn0" id="uq1-Wy-qlH"/> + <outlet property="menu_height" destination="A1l-yg-7AW" id="AQM-ma-8Fv"/> </connections> <point key="canvasLocation" x="90.07633587786259" y="-110.21126760563381"/> </view> diff --git a/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift b/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift index f2320ff..d22fbf6 100644 --- a/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift +++ b/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift @@ -52,7 +52,7 @@ } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let vc = HomeItemDetailVC() + let vc = HomeItemDetailVC(id: 0) JQ_currentViewController().jq_push(vc: vc) } } diff --git a/XQMuse/Root/Network/Models.swift b/XQMuse/Root/Network/Models.swift index 6990177..14b0a38 100644 --- a/XQMuse/Root/Network/Models.swift +++ b/XQMuse/Root/Network/Models.swift @@ -8,6 +8,14 @@ import HandyJSON import UserDefaultsStore +struct UserDefaultSettingModel:HandyJSON,Identifiable,Codable { + static let idKey = \UserDefaultSettingModel.id + var id = 0 + var volume:Double = 0.5 + var bgm:BGMModel? +} + + struct LoginUserInfoModel:HandyJSON,Identifiable,Codable{ static let idKey = \LoginUserInfoModel.userid @@ -37,3 +45,69 @@ var secret:String = "" var successFlag:Bool = false } + +struct BGMModel:HandyJSON,Identifiable,Codable{ + static let idKey = \BGMModel.id + + var audioFile: String = "" + var audioFileName: String = "" + var id: Int = 0 + var imageUrl: String = "" +} + +struct ItemTypeModel:HandyJSON{ + var categoryName = "" + var description = "" + var id = 0 + var firstIconUrl = "" //icon图片 用于顶部四个分类展示 + var secondIconUrl = "" //icon图片 用于下面的三个分类展示 + var showType = 0 //展示方式 1=横版 2=竖版 +} + +struct ToDayMeditationModel:HandyJSON{ + var clientMeditationVO: MeditationModel? + var endPlayTime: String = "" + var id: Int = 0 + var imageUrl: String = "" + var meditationId: Int = 0 + var startPlayTime: String = "" +} + +struct MeditationListModel:HandyJSON{ + var clientMeditationCategoryVO:MeditationTitleModel? + var clientMeditationVOList = [MeditationModel]() +} + +struct MeditationTitleModel:HandyJSON{ + var categoryName: String = "" + var description: String = "" + var firstIconUrl: String = "" + var id: Int = 0 + var secondIconUrl: String = "" + var showType: DisplayType = .horizontal +} + +struct MeditationModel:HandyJSON{ + var backgroundUrl: String = "" + var cateId: Int = 0 + var chargeType:ChargeType = .free + var coverDescription: String = "" + var coverUrl: String = "" + var detailDescription: String = "" + var favoriteCount: Int = 0 + var generalPrice: Int = 0 + var iconUrl: String = "" + var id: Int = 0 + var iosPrice: Int = 0 + var listingStatus: Int = 0 + var meditationTitle: String = "" + var realLearnedNum: Int = 0 + var sanskrit: Int = 0 + var sortNum: Int = 0 + var tutorAudioUrl: String = "" + var virtualLearnedNum: Int = 0 + var favorite:Int = 0 // 是否收藏:1:是 2:否 +} + + + diff --git a/XQMuse/Root/Network/NetworkRequest.swift b/XQMuse/Root/Network/NetworkRequest.swift index cd3464f..5ee4147 100644 --- a/XQMuse/Root/Network/NetworkRequest.swift +++ b/XQMuse/Root/Network/NetworkRequest.swift @@ -23,7 +23,8 @@ struct BaseResponseList<T :HandyJSON>: HandyJSON { var list: [T] = [] - var totalSession:Int = 0 + var pages:Int = 0 + var total:Int = 0 } struct BaseData<T: HandyJSON>: HandyJSON { @@ -199,7 +200,11 @@ if encoding != nil { newEncoding = encoding! } else { + #if DEBUG + newEncoding = URLEncoding.queryString + #else newEncoding = method == .post ? URLEncoding.httpBody : URLEncoding.queryString + #endif } sharedSessionManager.request(params.url.absoluteString, method: method, parameters:params.done(), encoding: newEncoding, headers:headers).validate().responseData{response in diff --git a/XQMuse/Root/Network/Services.swift b/XQMuse/Root/Network/Services.swift index 22ac7f5..60ec184 100644 --- a/XQMuse/Root/Network/Services.swift +++ b/XQMuse/Root/Network/Services.swift @@ -12,7 +12,7 @@ import JQTools #if DEBUG -let All_Url = "https://console-mock.apipost.cn/mock/edb6887b-40b2-4245-aab0-50d773033f15" +let All_Url = "https://mock.apipost.net/mock/31b303c60464000" #else let All_Url = "http://" //正式地址 #endif @@ -33,10 +33,12 @@ params.interface(url: "/auth/app/login") .append(key: "cellPhone", value: phone) .append(key: "password", value: content.jq_md5String().uppercased()) + .append(key: "apipost_id", value: "246d780670e267") case .code: params.interface(url: "/auth/app/captchaLogin") .append(key: "cellPhone", value: phone) .append(key: "captcha",value:content) + .append(key: "apipost_id", value: "246d780670e265") } return NetworkRequest.request(params: params, method: .post, progress: true) } @@ -46,6 +48,7 @@ let params = ParamsAppender.build(url: All_Url) params.interface(url: "/auth/app/sendCaptchaCode") .append(key: "type", value: type.rawValue) + .append(key: "apipost_id", value: "246d7806b0e269") return NetworkRequest.request(params: params, method: .get, progress: true) } @@ -57,6 +60,7 @@ .append(key: "captcha", value: captcha) .append(key: "inviteUserId", value: inviteUserId) .append(key: "password", value: password.jq_md5String().uppercased()) + .append(key: "apipost_id", value: "246d7806b0e268") return NetworkRequest.request(params: params, method: .post, progress: true) } @@ -66,6 +70,7 @@ params.interface(url: "/auth/app/verifyPhone") .append(key: "cellPhone", value: cellPhone) .append(key: "captcha", value: captcha) + .append(key: "apipost_id", value: "246d7806b0e26b") return NetworkRequest.request(params: params, method: .post, progress: true) } @@ -75,7 +80,73 @@ .append(key: "cellPhone", value: cellPhone) .append(key: "password", value: password.jq_md5String().uppercased()) .append(key: "secret", value: secretCode) + .append(key: "apipost_id", value: "246d780670e266") return NetworkRequest.request(params: params, method: .post, progress: true) + } +} + +// MARK: -- 主页 +extension Services{ + class func getBGM()->Observable<BaseResponse<[BGMModel]>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/meditation/client/meditation/home/getHomeBackgroundMusicList") + .append(key: "apipost_id", value: "25c3e3d0b0e155") + return NetworkRequest.request(params: params, method: .get, progress: true) + } + + + /// 获取分类数据 + /// - Parameter type: 类型 1=顶部4个 2=下面3个 + class func getCategoryListByType(type:Int)->Observable<BaseResponse<[ItemTypeModel]>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/meditation/client/meditation/home/getCategoryListByType") + .append(key: "apipost_id", value: "25c3e3d070e154") + .append(key: "type", value: type) + return NetworkRequest.request(params: params, method: .post, progress: false) + } + + /// 获取今日冥想 + class func getTopdayMedita()->Observable<BaseResponse<ToDayMeditationModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/meditation/client/meditation/home/getTodayMeditation") + .append(key: "apipost_id", value: "25c3e3d0b0e15d") + return NetworkRequest.request(params: params, method: .get, progress: false) + } + + /// 获取私人定制 + class func getPersonalityPlan()->Observable<BaseResponse<[MeditationModel]>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/meditation/client/meditation/home/getPersonalityPlan") + .append(key: "apipost_id", value: "25c3e3d0b0e15c") + return NetworkRequest.request(params: params, method: .get, progress: false) + } + + /// 获取全部的冥想音频及分类列表 + class func getMeditationAndCateList()->Observable<BaseResponse<[MeditationListModel]>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/meditation/client/meditation/home/getMeditationAndCateList") + .append(key: "apipost_id", value: "25c3e3d0b0e157") + return NetworkRequest.request(params: params, method: .get, progress: false) + } + + + class func getMeditationPage(_ cateId:Int,page:Int,pageSize:Int = 20)->Observable<BaseResponse<BaseResponseList<MeditationModel>>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/meditation/client/meditation/home/getMeditationAndCateList") + .append(key: "cateId", value: cateId) + .append(key: "pageCurr", value: page) + .append(key: "pageSize", value: pageSize) + .append(key: "apipost_id", value: "25c3e3d0b0e15a") + return NetworkRequest.request(params: params, method: .post, progress: false) + } + + /// 获取冥想音频详情 + class func getMeditationDetail(id:Int)->Observable<BaseResponse<MeditationModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/meditation/client/meditation/home/getMeditationDetails") + .append(key: "id", value: id) + .append(key: "apipost_id", value: "25c3e3d0b0e158") + return NetworkRequest.request(params: params, method: .get, progress: true) } } @@ -85,6 +156,7 @@ let params = ParamsAppender.build(url: All_Url) .interface(url: "/system/public/getContent") .append(key: "key", value: type.rawValue) + .append(key: "apipost_id", value: "2478a330b0e0e3") return NetworkRequest.request(params: params, method: .get, progress: false) } diff --git a/XQMuse/Root/Network/ViewModels/UserViewModel.swift b/XQMuse/Root/Network/ViewModels/UserViewModel.swift index 093001c..5c962f6 100644 --- a/XQMuse/Root/Network/ViewModels/UserViewModel.swift +++ b/XQMuse/Root/Network/ViewModels/UserViewModel.swift @@ -8,6 +8,33 @@ import Foundation import UserDefaultsStore +class UserDefaultSettingViewModel{ + private static let settingInfo = UserDefaultsStore<UserDefaultSettingModel>(uniqueIdentifier: "settingModel")! + + static func saveSetting(_ model:UserDefaultSettingModel){ + do{ + try settingInfo.save(model) + }catch{ + + } + } + + static func getSetting()->UserDefaultSettingModel?{ + var model:UserDefaultSettingModel? + if settingInfo.allObjects().first == nil{ + model = UserDefaultSettingModel() + saveSetting(model!) + }else{ + model = settingInfo.allObjects().first + } + return model + } + + static func clearSetting(){ + settingInfo.deleteAll() + } +} + class UserViewModel{ private static let userInfo = UserDefaultsStore<LoginUserInfoModel>(uniqueIdentifier: "UserInfoModel")! diff --git a/XQMuse/Root/PayMusicView/PayMusicVC.swift b/XQMuse/Root/PayMusicView/PayMusicVC.swift index b57156c..7423f16 100644 --- a/XQMuse/Root/PayMusicView/PayMusicVC.swift +++ b/XQMuse/Root/PayMusicView/PayMusicVC.swift @@ -108,6 +108,7 @@ class AudioPlayer { private var player:AVPlayer? + private var BGMplayer:AVPlayer? private var playIndex:Int = 0 //播放的角标 private var cacheDirectory:URL! private let session = URLSession.shared @@ -187,6 +188,38 @@ } } + func playBGMAt(_ url:String){ + guard let URL = URL(string: url) else { return } + BGMplayer?.pause() + + if BGMplayer == nil{ + BGMplayer = AVPlayer(url: URL) + }else{ + BGMplayer?.replaceCurrentItem(with: AVPlayerItem(url: URL)) + } + DispatchQueue.main.asyncAfter(delay: 3.0) { + self.BGMplayer?.play() + self.BGMplayer?.volume = Float(UserDefaultSettingViewModel.getSetting()?.volume ?? 0.5) + } + + + //播放完成 + NotificationCenter.default.addObserver(self, selector: #selector(playBGMbackEnd), name:NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: nil) + } + + func dellocBGM(){ + BGMplayer?.pause() + BGMplayer = nil + } + + func pauseBGM(){ + BGMplayer?.pause() + } + + func playBGM(){ + BGMplayer?.play() + } + func next(){ playIndex += 1 let index = min((urls.count - 1), playIndex) @@ -198,6 +231,12 @@ } + + @objc private func playBGMbackEnd(){ + self.BGMplayer?.seek(to: CMTimeMake(value: 0, timescale: 1)) + self.BGMplayer?.play() + } + func previous(){ playIndex -= 1 let index = max(0, playIndex) diff --git a/XQMuse/Root/TreeGroup/TreeTeskVC.swift b/XQMuse/Root/TreeGroup/TreeTeskVC.swift index dcac203..4f0e327 100644 --- a/XQMuse/Root/TreeGroup/TreeTeskVC.swift +++ b/XQMuse/Root/TreeGroup/TreeTeskVC.swift @@ -16,11 +16,11 @@ case level_3 = 3 case level_4 = 4 case level_5 = 5 -// case level_6 = 6 -// case level_7 = 7 -// case level_8 = 8 -// case level_9 = 9 -// case level_10 = 10 + case level_6 = 6 + case level_7 = 7 + case level_8 = 8 + case level_9 = 9 + case level_10 = 10 var aniResource:String{ switch self { @@ -29,11 +29,11 @@ case .level_3:return "apngb-animated-level-3" case .level_4:return "apngb-animated-level-4" case .level_5:return "apngb-animated-level-5" -// case .level_6:return "apngb-animated-level-6" -// case .level_7:return "apngb-animated-level-7" -// case .level_8:return "apngb-animated-level-8" -// case .level_9:return "apngb-animated-level-9" -// case .level_10:return "apngb-animated-level-10" + case .level_6:return "apngb-animated-level-6" + case .level_7:return "apngb-animated-level-7" + case .level_8:return "apngb-animated-level-8" + case .level_9:return "apngb-animated-level-9" + case .level_10:return "apngb-animated-level-10" } } } @@ -58,7 +58,7 @@ private var aPNGSunImageView:APNGImageView? private var aPNGActionImageView:APNGImageView? - private var treeLevel:TreeLevel = .level_5{ + private var treeLevel:TreeLevel = .level_1{ didSet{ updateAni() } @@ -178,43 +178,35 @@ aPNGTreeImageView!.contentMode = .redraw let tap = UITapGestureRecognizer(target: self, action: #selector(jumpAction)) aPNGTreeImageView!.addGestureRecognizer(tap) - }else{ - aPNGTreeImageView?.image = treeApngImage } if view.viewWithTag(10101) == nil{ view.addSubview(aPNGTreeImageView!) } - aPNGTreeImageView!.backgroundColor = .red.withAlphaComponent(0.3) - let scale:Double = 0.7 +// aPNGTreeImageView!.backgroundColor = .red.withAlphaComponent(0.1) + let scale:Double = 0.55 aPNGTreeImageView!.snp.remakeConstraints { make in - make.centerX.equalToSuperview() + make.centerX.equalToSuperview().offset(-10) make.bottom.equalToSuperview().offset(-220) - - switch treeLevel { - case .level_1: - make.width.equalTo(184 * scale) - make.height.equalTo(124 * scale) - - case .level_2: - make.width.equalTo(255 * scale) - make.height.equalTo(193 * scale) - - case .level_3: - make.width.equalTo(243 * scale) - make.height.equalTo(237 * scale) - case .level_4: - make.width.equalTo(245 * scale) - make.height.equalTo(280 * scale) - case .level_5: - make.width.equalTo(479 * scale) - make.height.equalTo(389 * scale) - } + make.width.equalTo(642 * scale) + make.height.equalTo(731 * scale) } - aPNGTreeImageView!.startAnimating() + UIView.animate(withDuration: 1.5) { + self.aPNGTreeImageView?.alpha = 0 + + }completion: { state in + if state{ + self.aPNGTreeImageView!.image = treeApngImage + UIView.animate(withDuration: 1.5, delay: 0.2) { + self.aPNGTreeImageView?.alpha = 1 + }completion: { _ in + self.aPNGTreeImageView!.startAnimating() + } + } + } } } } -- Gitblit v1.7.1