From 642175113bf6f2c90894e689dacda50278cad570 Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期四, 19 九月 2024 15:50:11 +0800 Subject: [PATCH] complete most UI & Mock API --- XQMuse/Root/Me/VC/BindPhone_2_VC.swift | 40 + XQMuse/Root/Me/VC/NoticeCenterVC.swift | 41 + XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.swift | 32 + XQMuse/Root/Me/VC/SpendingDetailVC.swift | 16 XQMuse/Root/Me/TCell/ContactCustomerTCell.xib | 4 XQMuse/Root/Me/VC/BindAccountVC.swift | 5 XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift | 64 ++ XQMuse/Root/Me/VC/BankWithdrawVC.swift | 89 ++++ XQMuse/Root/Me/VC/ContactCustomerVC.swift | 31 + XQMuse/Root/Me/TCell/BankInfoTCell.swift | 9 XQMuse/Root/Home/TCell/Home_Style_5_TCell.xib | 5 XQMuse/Root/Me/TCell/SpendingDetailContentTCell.swift | 19 XQMuse/Root/Me/VC/StudyListVC.swift | 59 ++ XQMuse/Root/Me/VC/SpendingDetailInfoVC.xib | 12 XQMuse/SceneDelegate.swift | 3 XQMuse/Root/Me/VC/AddBankInfoVC.swift | 101 ++++ XQMuse/Root/Me/VC/ContactCustomerDetailVC.swift | 36 + XQMuse/Root/Login/LoginVC.swift | 1 XQMuse/Root/Me/TCell/SpendingDetailContentTCell.xib | 5 XQMuse/Root/Me/VC/ContactCustomerDetailVC.xib | 3 XQMuse/Root/Home/HomeVC.swift | 12 XQMuse/Root/Me/TCell/MessageTCell.swift | 20 XQMuse/Root/Me/VC/LogoutAccountVC.swift | 8 XQMuse/Root/Me/VC/SpendingDetailHeaderVC.xib | 1 XQMuse/Config/Types.swift | 4 XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.xib | 3 XQMuse/Root/Me/VC/BankWithdrawVC.xib | 8 XQMuse/Root/Me/VC/BindPhone_3_VC.swift | 7 XQMuse/Root/Me/VC/SpendingDetailHeaderVC.swift | 6 XQMuse/Root/Me/VC/TreatyVC.swift | 6 XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.xib | 10 XQMuse/Root/Network/Services.swift | 173 ++++++++ XQMuse/Root/Me/VC/SpendingDetailContentVC.swift | 28 + XQMuse/Root/Me/VC/WalletVC.xib | 3 XQMuse/Root/Me/TCell/MessageTCell.xib | 7 XQMuse/Root/Me/VC/WalletVC.swift | 30 + XQMuse/Root/Me/VC/WatchHistoryVC.swift | 2 XQMuse/Root/Me/VC/SpendingDetailInfoVC.swift | 60 ++ XQMuse/Root/Me/VC/SettingVC.swift | 11 XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.swift | 19 XQMuse/Root/Network/Models.swift | 113 +++++ XQMuse/Root/Me/VC/AddBankInfoVC.xib | 16 XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.swift | 8 XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.xib | 2 XQMuse/Root/Me/VC/LevelVC.swift | 30 + XQMuse/Root/Me/VC/BindPhone_1_VC.swift | 3 XQMuse/Root/Me/VC/BindAccountVC.xib | 2 XQMuse/Root/Me/VC/BindPhone_3_VC.xib | 3 XQMuse/Root/Me/VC/LevelVC.xib | 4 XQMuse/Root/Home/TCell/Home_Style_5_TCell.swift | 45 + XQMuse/Root/Me/VC/ContactCustomerVC.xib | 10 XQMuse/Root/Me/TCell/ContactCustomerTCell.swift | 9 52 files changed, 1,151 insertions(+), 87 deletions(-) diff --git a/XQMuse/Config/Types.swift b/XQMuse/Config/Types.swift index ac8391d..757ebbe 100644 --- a/XQMuse/Config/Types.swift +++ b/XQMuse/Config/Types.swift @@ -38,4 +38,8 @@ case forgetPwd = 3 ///第三方登录后验证手机 case threePlantform = 4 + /// 切换手机 + case exchangePhone = 5 + /// 添加银行卡 + case addBank = 6 } diff --git a/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.swift b/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.swift index 33dc2e5..8c708f9 100644 --- a/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.swift +++ b/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.swift @@ -30,4 +30,12 @@ img_vip.isHidden = model.chargeType != .vipFree } + func setCourseModel(_ model:CourseModel){ + img_cover.sd_setImage(with: URL(string: model.coverUrl)) + label_title.text = model.courseTitle + label_subTitle.text = model.briefIntroduction + label_num.text = "\(model.count)" + img_vip.isHidden = model.chargeType != .vipFree + } + } diff --git a/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.xib b/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.xib index 3117a74..7b3185e 100644 --- a/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.xib +++ b/XQMuse/Root/Home/CCell/HomeRelaxBannerCCell.xib @@ -16,7 +16,7 @@ <rect key="frame" x="0.0" y="0.0" width="165" height="218"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <subviews> - <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="u6A-Y4-rQ5"> + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="u6A-Y4-rQ5"> <rect key="frame" x="0.0" y="0.0" width="165" height="218"/> </imageView> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Emq-gn-QOX"> diff --git a/XQMuse/Root/Home/HomeVC.swift b/XQMuse/Root/Home/HomeVC.swift index ca8efef..ef4dd52 100644 --- a/XQMuse/Root/Home/HomeVC.swift +++ b/XQMuse/Root/Home/HomeVC.swift @@ -22,6 +22,7 @@ class HomeViewModel{ var homeTopMenuItems = [HomeTopMenuItem]() + var homeBottomMenuItems = [HomeTopMenuItem]() var todyModel:MeditationModel? var privateTodyModels = [MeditationModel]() var meditationList = [MeditationListModel]() @@ -155,6 +156,16 @@ self.topMenuView.menu_collectionView.reloadData() }).disposed(by: disposeBag) + Services.getCategoryListByType(type: 2).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.homeBottomMenuItems = items + self.tableView.reloadRows(at: [IndexPath(row: 3, section: 0)], with: .none) + }).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) @@ -241,6 +252,7 @@ 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 + cell.setHomeTopMenuItem(viewModel.homeBottomMenuItems) return cell }else{ let m = viewModel.meditationList[index] diff --git a/XQMuse/Root/Home/TCell/Home_Style_5_TCell.swift b/XQMuse/Root/Home/TCell/Home_Style_5_TCell.swift index 18f0ef5..f1447f0 100644 --- a/XQMuse/Root/Home/TCell/Home_Style_5_TCell.swift +++ b/XQMuse/Root/Home/TCell/Home_Style_5_TCell.swift @@ -6,18 +6,51 @@ // import UIKit +import JQTools class Home_Style_5_TCell: UITableViewCell { + private var items = [HomeTopMenuItem]() + @IBOutlet weak var btn_1: UIButton! + @IBOutlet weak var btn_2: UIButton! + @IBOutlet weak var btn_3: UIButton! + override func awakeFromNib() { super.awakeFromNib() - // Initialization code + btn_1.isHidden = true + btn_2.isHidden = true + btn_3.isHidden = true + + btn_1.addTarget(self, action: #selector(tapAction), for: .touchUpInside) + btn_2.addTarget(self, action: #selector(tapAction), for: .touchUpInside) + btn_3.addTarget(self, action: #selector(tapAction), for: .touchUpInside) + + btn_1.tag = 1000 + btn_2.tag = 1001 + btn_3.tag = 1002 } - override func setSelected(_ selected: Bool, animated: Bool) { - super.setSelected(selected, animated: animated) + func setHomeTopMenuItem(_ items:[HomeTopMenuItem]){ + self.items = items + for (index,v) in items.enumerated(){ + switch index { + case 0: + btn_1.sd_setImage(with: URL(string: v.image), for: .normal) + btn_1.isHidden = false + case 1: + btn_2.sd_setImage(with: URL(string: v.image), for: .normal) + btn_2.isHidden = false + case 2: + btn_3.sd_setImage(with: URL(string: v.image), for: .normal) + btn_3.isHidden = false + default:break + } + } + } - // Configure the view for the selected state - } - + @objc func tapAction(_ btn:UIButton){ + let index = btn.tag - 1000 + let vc = HomeItemDetailVC(id: items[index].id) + JQ_currentViewController().jq_push(vc: vc) + } } diff --git a/XQMuse/Root/Home/TCell/Home_Style_5_TCell.xib b/XQMuse/Root/Home/TCell/Home_Style_5_TCell.xib index cbb6076..9d2fd31 100644 --- a/XQMuse/Root/Home/TCell/Home_Style_5_TCell.xib +++ b/XQMuse/Root/Home/TCell/Home_Style_5_TCell.xib @@ -53,6 +53,11 @@ </constraints> </tableViewCellContentView> <viewLayoutGuide key="safeArea" id="njF-e1-oar"/> + <connections> + <outlet property="btn_1" destination="30T-1D-WNl" id="lfD-IP-ddb"/> + <outlet property="btn_2" destination="vXA-OX-SB1" id="a4n-5r-1jP"/> + <outlet property="btn_3" destination="xmc-SJ-H1U" id="uf7-FI-OON"/> + </connections> <point key="canvasLocation" x="174.04580152671755" y="68.661971830985919"/> </tableViewCell> </objects> diff --git a/XQMuse/Root/Login/LoginVC.swift b/XQMuse/Root/Login/LoginVC.swift index 041e323..47dad71 100644 --- a/XQMuse/Root/Login/LoginVC.swift +++ b/XQMuse/Root/Login/LoginVC.swift @@ -174,6 +174,7 @@ Services.loginBy(phone: viewModel.loginPhone.value, content: viewModel.loginContent.value, type: viewModel.loginType.value).subscribe(onNext: { data in if let model = data.data{ sceneDelegate?.loginSuccess() + self.dismiss(animated: true) UserViewModel.saveLoginInfo(model) diff --git a/XQMuse/Root/Me/TCell/BankInfoTCell.swift b/XQMuse/Root/Me/TCell/BankInfoTCell.swift index 321391c..f9d484b 100644 --- a/XQMuse/Root/Me/TCell/BankInfoTCell.swift +++ b/XQMuse/Root/Me/TCell/BankInfoTCell.swift @@ -14,7 +14,7 @@ @IBOutlet weak var label_title: UILabel! @IBOutlet weak var label_bankNumber: UILabel! @IBOutlet weak var img_select: UIImageView! - + override func awakeFromNib() { super.awakeFromNib() selectionStyle = .none @@ -27,4 +27,11 @@ view_content.jq_borderWidth = state ? 0:1 img_select.isHidden = !state } + + func setBankInfoModel(_ model:BankInfoModel){ + label_title.text = model.bankName + let s = model.cardNo.count - 4 + let b = model.cardNo.count + label_bankNumber.text = "**** **** **** **** " + model.cardNo.jq_substingInRange((s...b))! + } } diff --git a/XQMuse/Root/Me/TCell/ContactCustomerTCell.swift b/XQMuse/Root/Me/TCell/ContactCustomerTCell.swift index 542c536..45f51e6 100644 --- a/XQMuse/Root/Me/TCell/ContactCustomerTCell.swift +++ b/XQMuse/Root/Me/TCell/ContactCustomerTCell.swift @@ -9,8 +9,15 @@ class ContactCustomerTCell: UITableViewCell { - override func awakeFromNib() { + @IBOutlet weak var label_title: UILabel! + @IBOutlet weak var label_content: UILabel! + override func awakeFromNib() { super.awakeFromNib() selectionStyle = .none } + + func setCommonQuestionModel(_ model:CommonQuestionModel){ + label_title.text = model.questionName + label_content.text = model.questionDescription + } } diff --git a/XQMuse/Root/Me/TCell/ContactCustomerTCell.xib b/XQMuse/Root/Me/TCell/ContactCustomerTCell.xib index 8dc1400..40deec7 100644 --- a/XQMuse/Root/Me/TCell/ContactCustomerTCell.xib +++ b/XQMuse/Root/Me/TCell/ContactCustomerTCell.xib @@ -60,6 +60,10 @@ </constraints> </tableViewCellContentView> <viewLayoutGuide key="safeArea" id="njF-e1-oar"/> + <connections> + <outlet property="label_content" destination="Ufh-LH-iEl" id="E9Q-hb-p0q"/> + <outlet property="label_title" destination="aBW-dt-2rJ" id="Mgo-cr-PxJ"/> + </connections> <point key="canvasLocation" x="59.541984732824424" y="51.760563380281695"/> </tableViewCell> </objects> diff --git a/XQMuse/Root/Me/TCell/MessageTCell.swift b/XQMuse/Root/Me/TCell/MessageTCell.swift index 30c21f9..cb398b6 100644 --- a/XQMuse/Root/Me/TCell/MessageTCell.swift +++ b/XQMuse/Root/Me/TCell/MessageTCell.swift @@ -8,9 +8,27 @@ import UIKit class MessageTCell: UITableViewCell { - + @IBOutlet weak var label_title: UILabel! + @IBOutlet weak var view_isRead: UIView! + @IBOutlet weak var label_sub: UILabel! + @IBOutlet weak var label_date: UILabel! + @IBOutlet weak var image_type: UIImageView! + override func awakeFromNib() { super.awakeFromNib() selectionStyle = .none } + + func setNoticeModel(_ model:NoticeModel){ + label_title.text = model.title + view_isRead.isHidden = model.readStatus == 2 + label_sub.text = model.content + label_date.text = model.createTime + + if model.noticeType == 1{ + image_type.image = UIImage(named: "icon_msg_sys") + }else{ + image_type.image = UIImage(named: "icon_msg_user") + } + } } diff --git a/XQMuse/Root/Me/TCell/MessageTCell.xib b/XQMuse/Root/Me/TCell/MessageTCell.xib index 1c6688d..2b8d525 100644 --- a/XQMuse/Root/Me/TCell/MessageTCell.xib +++ b/XQMuse/Root/Me/TCell/MessageTCell.xib @@ -89,6 +89,13 @@ <constraint firstItem="Ong-0k-h5l" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="5.5" id="T6a-mC-31G"/> </constraints> </tableViewCellContentView> + <connections> + <outlet property="image_type" destination="RM7-YK-5IB" id="8aV-gV-e4I"/> + <outlet property="label_date" destination="Tsl-3O-mZM" id="o6S-id-nya"/> + <outlet property="label_sub" destination="Mbc-nK-0T7" id="xw6-Z9-y86"/> + <outlet property="label_title" destination="cob-eJ-7In" id="B67-gU-yqI"/> + <outlet property="view_isRead" destination="TdQ-J6-aEO" id="sI3-Wp-BR2"/> + </connections> <point key="canvasLocation" x="219.84732824427479" y="40.492957746478872"/> </tableViewCell> </objects> diff --git a/XQMuse/Root/Me/TCell/SpendingDetailContentTCell.swift b/XQMuse/Root/Me/TCell/SpendingDetailContentTCell.swift index 5584de7..e6ddf63 100644 --- a/XQMuse/Root/Me/TCell/SpendingDetailContentTCell.swift +++ b/XQMuse/Root/Me/TCell/SpendingDetailContentTCell.swift @@ -6,11 +6,28 @@ // import UIKit +import JQTools class SpendingDetailContentTCell: UITableViewCell { - override func awakeFromNib() { + @IBOutlet weak var label_title: UILabel! + @IBOutlet weak var label_datetime: UILabel! + @IBOutlet weak var label_price: UILabel! + override func awakeFromNib() { super.awakeFromNib() selectionStyle = .none } + + func setBalanceInfoModel(_ model:BalanceInfoModel){ + label_title.text = model.reason + label_datetime.text = model.createTime + + if model.changeType == .decreate{ + label_price.text = String(format: "-%.2lf", model.amount) + label_price.textColor = .black + }else{ + label_price.text = String(format: "+%.2lf", model.amount) + label_price.textColor = UIColor(hexString: "#FE3211") + } + } } diff --git a/XQMuse/Root/Me/TCell/SpendingDetailContentTCell.xib b/XQMuse/Root/Me/TCell/SpendingDetailContentTCell.xib index 55e088d..3a1b146 100644 --- a/XQMuse/Root/Me/TCell/SpendingDetailContentTCell.xib +++ b/XQMuse/Root/Me/TCell/SpendingDetailContentTCell.xib @@ -68,6 +68,11 @@ </constraints> </tableViewCellContentView> <viewLayoutGuide key="safeArea" id="njF-e1-oar"/> + <connections> + <outlet property="label_datetime" destination="RqV-gN-LrA" id="oO9-Cp-5EZ"/> + <outlet property="label_price" destination="5sc-jc-aUv" id="mKr-Tw-ONP"/> + <outlet property="label_title" destination="fed-zq-HQC" id="Czk-MG-Otw"/> + </connections> <point key="canvasLocation" x="161.83206106870227" y="32.04225352112676"/> </tableViewCell> </objects> diff --git a/XQMuse/Root/Me/VC/AddBankInfoVC.swift b/XQMuse/Root/Me/VC/AddBankInfoVC.swift index d3e7421..772b321 100644 --- a/XQMuse/Root/Me/VC/AddBankInfoVC.swift +++ b/XQMuse/Root/Me/VC/AddBankInfoVC.swift @@ -7,11 +7,73 @@ import UIKit import QMUIKit +import RxRelay +import RxSwift +import JQTools + +let AddBank_Noti = Notification.Name.init("AddBank_Noti") class AddBankInfoVC: BaseVC { + struct AddBankRequestModel{ + var bankName = BehaviorRelay<String>(value:"") + var bankNo = BehaviorRelay<String>(value:"") + var holderName = BehaviorRelay<String>(value:"") + var idCard = BehaviorRelay<String>(value:"") + var phone = BehaviorRelay<String>(value:"") + var code = BehaviorRelay<String>(value:"") + + func isAuth()->Bool{ + guard !bankName.value.isEmpty else{ + alertError(msg: "请输入开户行");return false + } + guard !bankNo.value.isEmpty else{ + alertError(msg: "请输入卡号");return false + } + guard !holderName.value.isEmpty else{ + alertError(msg: "请输入持卡人");return false + } + guard !idCard.value.isEmpty else{ + alertError(msg: "请输入身份证号");return false + } + guard idCard.value.jq_idCard() else { + alertError(msg: "请输入正确的身份证号");return false + } + guard !phone.value.isEmpty else{ + alertError(msg: "请输入手机号");return false + } + guard phone.value.jq_isPhone else { + alertError(msg: "请输入正确的手机号");return false + } + guard !code.value.isEmpty else{ + alertError(msg: "请输入验证码");return false + } + guard code.value.count == 6 else { + alertError(msg: "请输入正确的验证码");return false + } + return true + } + + func toRequest()->Dictionary<String,Any>{ + return ["bankName":bankName.value, + "cardNo":bankNo.value, + "cardholder":holderName.value, + "identityCard":idCard.value, + "cellPhone":phone.value, + "code":code.value] + } + } + + @IBOutlet weak var tf_bankName: UITextField! + @IBOutlet weak var tf_cardNo: QMUITextField! + @IBOutlet weak var tf_holderName: QMUITextField! @IBOutlet weak var tf_idcard: QMUITextField! + @IBOutlet weak var tf_phone: QMUITextField! @IBOutlet weak var btn_add: UIButton! + @IBOutlet weak var tf_code: QMUITextField! + + private var requestModel = AddBankRequestModel() + override func viewDidLoad() { super.viewDidLoad() title = "添加银行卡" @@ -23,9 +85,48 @@ tf_idcard.inputView = idCardView } + override func setRx() { + tf_bankName.rx.text.orEmpty.bind(to: requestModel.bankName).disposed(by: disposeBag) + tf_cardNo.rx.text.orEmpty.bind(to: requestModel.bankNo).disposed(by: disposeBag) + tf_holderName.rx.text.orEmpty.bind(to: requestModel.holderName).disposed(by: disposeBag) + tf_idcard.rx.text.orEmpty.bind(to: requestModel.idCard).disposed(by: disposeBag) + tf_phone.rx.text.orEmpty.bind(to: requestModel.phone).disposed(by: disposeBag) + tf_code.rx.text.orEmpty.bind(to: requestModel.code).disposed(by: disposeBag) + } + override func setUI() { view.backgroundColor = UIColor(hexString: "f6f6f6") btn_add.localGradientColor(cornerRadius: 20) } + + @IBAction func addhandleAction(_ sender: UIButton) { + view.endEditing(true) + if requestModel.isAuth(){ + Services.addBank(requestModel).subscribe(onNext: {data in + alertSuccess(msg: "添加成功") + NotificationCenter.default.post(name: AddBank_Noti, object: nil) + DispatchQueue.main.asyncAfter(delay: 1.0) { + self.navigationController?.popViewController() + } + }).disposed(by: disposeBag) + } + } + + + @IBAction func sendCodeAction(_ sender: UIButton) { + guard !requestModel.phone.value.isEmpty else { + alertError(msg: "请输入手机号");return + } + + Services.sendCode(type: .addBank).subscribe(onNext: {_ in + sender.jq_openCountDown(60, defultTitle: "发送验证码") { + sender.titleLabel?.font = UIFont.systemFont(ofSize: 12) + sender.setTitleColor(.black.withAlphaComponent(0.3), for: .normal) + } completeClouse: { + sender.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .medium) + sender.setTitleColor(UIColor(hexStr: "#96AD81"), for: .normal) + } + }).disposed(by: disposeBag) + } } diff --git a/XQMuse/Root/Me/VC/AddBankInfoVC.xib b/XQMuse/Root/Me/VC/AddBankInfoVC.xib index fbd0be1..152e270 100644 --- a/XQMuse/Root/Me/VC/AddBankInfoVC.xib +++ b/XQMuse/Root/Me/VC/AddBankInfoVC.xib @@ -12,7 +12,12 @@ <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="AddBankInfoVC" customModule="XQMuse" customModuleProvider="target"> <connections> <outlet property="btn_add" destination="Flq-AM-akx" id="ZK1-cZ-cIZ"/> + <outlet property="tf_bankName" destination="elz-Zp-tTi" id="7vA-Jq-Ypx"/> + <outlet property="tf_cardNo" destination="lfq-e1-X3C" id="G23-dz-jkD"/> + <outlet property="tf_code" destination="fdw-nZ-t66" id="VL7-ao-hB7"/> + <outlet property="tf_holderName" destination="P5B-z6-sMX" id="tRC-Ol-ton"/> <outlet property="tf_idcard" destination="c3P-PL-JWg" id="f2k-T7-8VT"/> + <outlet property="tf_phone" destination="BaQ-Md-hAN" id="zDM-Rm-72z"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> </connections> </placeholder> @@ -210,7 +215,10 @@ <nil key="highlightedColor"/> </label> <textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="fdw-nZ-t66" customClass="QMUITextField"> - <rect key="frame" x="126.33333333333334" y="14.666666666666686" width="49" height="21"/> + <rect key="frame" x="126.33333333333334" y="14.666666666666686" width="100" height="21"/> + <constraints> + <constraint firstAttribute="width" constant="100" id="d1y-dU-luk"/> + </constraints> <fontDescription key="fontDescription" type="system" pointSize="16"/> <textInputTraits key="textInputTraits" keyboardType="numberPad"/> <userDefinedRuntimeAttributes> @@ -233,6 +241,9 @@ <state key="normal" title="发送验证码"> <color key="titleColor" red="0.54117647058823526" green="0.68235294117647061" blue="0.396078431372549" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> </state> + <connections> + <action selector="sendCodeAction:" destination="-1" eventType="touchUpInside" id="nrd-RO-yRb"/> + </connections> </button> </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> @@ -272,6 +283,9 @@ <real key="value" value="20"/> </userDefinedRuntimeAttribute> </userDefinedRuntimeAttributes> + <connections> + <action selector="addhandleAction:" destination="-1" eventType="touchUpInside" id="1hn-2b-QRj"/> + </connections> </button> </subviews> <viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/> diff --git a/XQMuse/Root/Me/VC/BankWithdrawVC.swift b/XQMuse/Root/Me/VC/BankWithdrawVC.swift index 669744b..772661a 100644 --- a/XQMuse/Root/Me/VC/BankWithdrawVC.swift +++ b/XQMuse/Root/Me/VC/BankWithdrawVC.swift @@ -8,15 +8,33 @@ import UIKit import QMUIKit +let WithDrawReply_Noti = Notification.Name.init("WithDrawReply_Noti") + class BankWithdrawVC: BaseVC { @IBOutlet weak var tableView: UITableView! + @IBOutlet weak var tf_withdraw: UITextField! @IBOutlet weak var cons_height: NSLayoutConstraint! - private var selectIndexPath = IndexPath(row: 0, section: 0) + @IBOutlet weak var label_income: UILabel! + private var selectIndexPath:IndexPath? + private var bankModels = [BankInfoModel]() + private var income:CGFloat = 0 + + required init(income:Double){ + super.init(nibName: nil, bundle: nil) + self.income = income + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + override func viewDidLoad() { super.viewDidLoad() title = "收益提现" + label_income.text = "可提现余额:¥" + income.jq_formatFloat + getBanks() } override func setUI() { @@ -26,12 +44,64 @@ tableView.separatorStyle = .none tableView.backgroundColor = .clear tableView.register(UINib(nibName: "BankInfoTCell", bundle: nil), forCellReuseIdentifier: "_BankInfoTCell") - cons_height.constant = 84 * 2 + cons_height.constant = 0 + } + + override func setRx() { +// AddBank_Noti + + NotificationCenter.default.rx.notification(AddBank_Noti, object: nil).take(until: self.rx.deallocated).subscribe(onNext: { _ in + self.getBanks() + }).disposed(by: disposeBag) + + } + + private func getBanks(){ + Services.getMyBankList().subscribe(onNext: {data in + self.bankModels = data.data ?? [] + self.tableView.reloadData() + self.cons_height.constant = CGFloat(self.bankModels.count) * 84.0 + }).disposed(by: disposeBag) } @IBAction func addBankCardAction(_ sender: QMUIButton) { let vc = AddBankInfoVC() push(vc: vc) + } + + @IBAction func withdrawAllAction(_ sender: UIButton) { + tf_withdraw.resignFirstResponder() + tf_withdraw.text = income.jq_formatFloat + } + + @IBAction func withdrawHandleAction(_ sender: UIButton) { + + tf_withdraw.resignFirstResponder() + + guard selectIndexPath != nil else { + alertError(msg: "请选择提现银行卡");return + } + + guard !tf_withdraw.text!.isEmpty else { + alertError(msg: tf_withdraw.placeholder ?? "请输入提现余额");return + } + + let handleMoney = tf_withdraw.text?.toDouble ?? 0 + + + guard income >= handleMoney else { + alertError(msg: "提现余额不足");return + } + + + Services.withdraw(bankId: bankModels[selectIndexPath!.row].id, money: tf_withdraw.text!.toDouble).subscribe(onNext: {data in + self.income -= self.tf_withdraw.text!.toDouble + alertSuccess(msg: "提现申请已提交") + self.tf_withdraw.text = "" + self.label_income.text = "可提现余额:¥\(self.income.jq_formatFloat)" + NotificationCenter.default.post(name: WithDrawReply_Noti, object: nil) + self.tf_withdraw.resignFirstResponder() + }).disposed(by: disposeBag) } } @@ -45,6 +115,7 @@ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "_BankInfoTCell", for: indexPath) as! BankInfoTCell cell.isSelect(indexPath == selectIndexPath) + cell.setBankInfoModel(bankModels[indexPath.row]) return cell } @@ -53,7 +124,18 @@ } func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { + let id = bankModels[indexPath.row].id CommonAlertView.show(title: "提示", content: "是否删除此张银行卡?") { _ in + Services.deleteBank(id).subscribe(onNext: { _ in + self.tableView.beginUpdates() + self.bankModels.remove(at: indexPath.row) + self.tableView.deleteItemsAtIndexPaths([indexPath], animationStyle: .left) + self.tableView.endUpdates() + self.cons_height.constant = CGFloat(self.bankModels.count) * 84.0 + UIView.animate(withDuration: 0.4) { + self.view.layoutIfNeeded() + } + }).disposed(by: self.disposeBag) } } @@ -66,9 +148,8 @@ return "删除" } - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 2 + return bankModels.count } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { diff --git a/XQMuse/Root/Me/VC/BankWithdrawVC.xib b/XQMuse/Root/Me/VC/BankWithdrawVC.xib index 98fe438..fe65558 100644 --- a/XQMuse/Root/Me/VC/BankWithdrawVC.xib +++ b/XQMuse/Root/Me/VC/BankWithdrawVC.xib @@ -12,7 +12,9 @@ <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="BankWithdrawVC" customModule="XQMuse" customModuleProvider="target"> <connections> <outlet property="cons_height" destination="JnR-vu-dbn" id="8dW-o7-cqk"/> + <outlet property="label_income" destination="Jnw-DF-MrW" id="Geg-l9-clW"/> <outlet property="tableView" destination="ANy-Y0-lhb" id="VHQ-LH-zK3"/> + <outlet property="tf_withdraw" destination="40r-zA-9fv" id="OMX-yr-zQ0"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> </connections> </placeholder> @@ -140,6 +142,9 @@ <state key="normal" title="全部提现"> <color key="titleColor" red="0.54117647058823526" green="0.68235294117647061" blue="0.396078431372549" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> </state> + <connections> + <action selector="withdrawAllAction:" destination="-1" eventType="touchUpInside" id="b5v-FJ-iAk"/> + </connections> </button> </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> @@ -193,6 +198,9 @@ <real key="value" value="20"/> </userDefinedRuntimeAttribute> </userDefinedRuntimeAttributes> + <connections> + <action selector="withdrawHandleAction:" destination="-1" eventType="touchUpInside" id="RAk-Ln-3YP"/> + </connections> </button> </subviews> <constraints> diff --git a/XQMuse/Root/Me/VC/BindAccountVC.swift b/XQMuse/Root/Me/VC/BindAccountVC.swift index 68e4fbb..7f298a9 100644 --- a/XQMuse/Root/Me/VC/BindAccountVC.swift +++ b/XQMuse/Root/Me/VC/BindAccountVC.swift @@ -8,10 +8,13 @@ import UIKit class BindAccountVC: BaseVC { - + @IBOutlet weak var label_phone: UILabel! + @IBOutlet weak var label_wchatBindState: UILabel! + override func viewDidLoad() { super.viewDidLoad() title = "账号绑定" + label_phone.text = UserViewModel.getAvatarInfo().cellPhone.jq_blotOutPhone() } diff --git a/XQMuse/Root/Me/VC/BindAccountVC.xib b/XQMuse/Root/Me/VC/BindAccountVC.xib index 44af336..d441253 100644 --- a/XQMuse/Root/Me/VC/BindAccountVC.xib +++ b/XQMuse/Root/Me/VC/BindAccountVC.xib @@ -11,6 +11,8 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="BindAccountVC" customModule="XQMuse" customModuleProvider="target"> <connections> + <outlet property="label_phone" destination="JiT-I4-fQb" id="pqq-l5-gv0"/> + <outlet property="label_wchatBindState" destination="hyt-qR-dWk" id="BWl-xq-gRx"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> </connections> </placeholder> diff --git a/XQMuse/Root/Me/VC/BindPhone_1_VC.swift b/XQMuse/Root/Me/VC/BindPhone_1_VC.swift index 8f623b6..d3e69b8 100644 --- a/XQMuse/Root/Me/VC/BindPhone_1_VC.swift +++ b/XQMuse/Root/Me/VC/BindPhone_1_VC.swift @@ -16,6 +16,9 @@ override func viewDidLoad() { super.viewDidLoad() title = "绑定手机号" + + //原型设计漏洞,可绕过原手机号的验证,直接通过截取Token修改新手机号【产品要求:涉及到的时候再优化 2024-09-19】 + label_phone.text = UserViewModel.getAvatarInfo().cellPhone.jq_blotOutPhone() } override func viewDidLayoutSubviews() { diff --git a/XQMuse/Root/Me/VC/BindPhone_2_VC.swift b/XQMuse/Root/Me/VC/BindPhone_2_VC.swift index 2bba78f..1a9f5b2 100644 --- a/XQMuse/Root/Me/VC/BindPhone_2_VC.swift +++ b/XQMuse/Root/Me/VC/BindPhone_2_VC.swift @@ -19,16 +19,46 @@ title = "更改绑定手机" } - @IBAction func sendCodeAction(_ sender: UIButton) { - + Services.sendCode(type: .exchangePhone).subscribe(onNext: { data in + if let _ = data.data{ + sender.jq_openCountDown(60, defultTitle: "发送验证码") { + sender.titleLabel?.font = UIFont.systemFont(ofSize: 12) + sender.setTitleColor(.black.withAlphaComponent(0.3), for: .normal) + } completeClouse: { + sender.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .medium) + sender.setTitleColor(UIColor(hexStr: "#96AD81"), for: .normal) + } + } + }).disposed(by: disposeBag) } @IBAction func completeAction(_ sender: UIButton) { - let vc = BindPhone_3_VC() - vc.modalPresentationStyle = .fullScreen - present(vc, animated: true) + + view.endEditing(true) + + guard !tf_phone.text!.isEmpty else{ + alertError(msg: "请输入手机号");return + } + + guard tf_phone.text!.jq_isPhone else{ + alertError(msg: "请正确的手机号");return + } + + guard !tf_code.text!.isEmpty else{ + alertError(msg: "请输入验证码");return + } + + guard tf_code.text!.count == 6 else{ + alertError(msg: "请输入6位验证码");return + } + + Services.changePhone(phone: tf_phone.text!, code: tf_code.text!).subscribe(onNext: {data in + let vc = BindPhone_3_VC() + vc.modalPresentationStyle = .fullScreen + self.present(vc, animated: true) + }).disposed(by: disposeBag) } override func viewDidLayoutSubviews() { diff --git a/XQMuse/Root/Me/VC/BindPhone_3_VC.swift b/XQMuse/Root/Me/VC/BindPhone_3_VC.swift index 32cde78..c4f30ee 100644 --- a/XQMuse/Root/Me/VC/BindPhone_3_VC.swift +++ b/XQMuse/Root/Me/VC/BindPhone_3_VC.swift @@ -15,9 +15,14 @@ override func viewDidLoad() { super.viewDidLoad() title = "更换绑定手机" - } + @IBAction func needLoginAction(_ sender: Any) { + dismiss(animated: true) { + sceneDelegate?.needLogin() + } + } + override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() btn_relogin.jq_gradientNibColor(colorArr: [UIColor(hexStr: "#8EA47A").cgColor,UIColor(hexStr: "#AFCA98").cgColor], cornerRadius: 20) diff --git a/XQMuse/Root/Me/VC/BindPhone_3_VC.xib b/XQMuse/Root/Me/VC/BindPhone_3_VC.xib index 48cbaf9..635ee12 100644 --- a/XQMuse/Root/Me/VC/BindPhone_3_VC.xib +++ b/XQMuse/Root/Me/VC/BindPhone_3_VC.xib @@ -54,6 +54,9 @@ <real key="value" value="20"/> </userDefinedRuntimeAttribute> </userDefinedRuntimeAttributes> + <connections> + <action selector="needLoginAction:" destination="-1" eventType="touchUpInside" id="wZx-Cb-jZz"/> + </connections> </button> </subviews> <viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/> diff --git a/XQMuse/Root/Me/VC/ContactCustomerDetailVC.swift b/XQMuse/Root/Me/VC/ContactCustomerDetailVC.swift index 2d69f0f..28c88c2 100644 --- a/XQMuse/Root/Me/VC/ContactCustomerDetailVC.swift +++ b/XQMuse/Root/Me/VC/ContactCustomerDetailVC.swift @@ -10,11 +10,47 @@ class ContactCustomerDetailVC: BaseVC { + @IBOutlet weak var label_title: UILabel! + @IBOutlet weak var label_content: UILabel! @IBOutlet weak var webView: WKWebView! + @IBOutlet weak var image_qrCode: UIImageView! + + private var model:CommonQuestionModel! + private var customerImage:UIImage? + + required init(_ model:CommonQuestionModel,customerImage:UIImage?) { + super.init(nibName: nil, bundle: nil) + self.model = model + self.customerImage = customerImage + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + override func viewDidLoad() { super.viewDidLoad() title = "问题详情" + label_title.text = model.questionName + label_content.text = model.content + + Services.commonQuestionDetailBy(id: model.id).subscribe(onNext: {[weak self] data in + if let m = data.data{ + self?.webView.loadHTMLString(m.content.jq_wrapHtml(), baseURL: nil) + } + }).disposed(by: disposeBag) + + if let image = customerImage{ + self.image_qrCode.image = image + }else{ + Services.getCustomerCode().subscribe(onNext: {data in + if let m = data.data{ + self.customerImage = UIImage.jq_GenerateQRCode(with: m, width: 200) + self.image_qrCode.image = self.customerImage + } + }).disposed(by: disposeBag) + } } override func setUI() { diff --git a/XQMuse/Root/Me/VC/ContactCustomerDetailVC.xib b/XQMuse/Root/Me/VC/ContactCustomerDetailVC.xib index 8473d7f..54a8ec6 100644 --- a/XQMuse/Root/Me/VC/ContactCustomerDetailVC.xib +++ b/XQMuse/Root/Me/VC/ContactCustomerDetailVC.xib @@ -11,6 +11,9 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ContactCustomerDetailVC" customModule="XQMuse" customModuleProvider="target"> <connections> + <outlet property="image_qrCode" destination="2kC-yj-fW4" id="fPg-s8-9wb"/> + <outlet property="label_content" destination="xb7-xl-air" id="reS-4e-B9w"/> + <outlet property="label_title" destination="UU5-p7-Ba1" id="IfO-PC-kEX"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> <outlet property="webView" destination="RzU-MN-ulm" id="5nl-6O-ZZ8"/> </connections> diff --git a/XQMuse/Root/Me/VC/ContactCustomerVC.swift b/XQMuse/Root/Me/VC/ContactCustomerVC.swift index ea559d8..b23bdc7 100644 --- a/XQMuse/Root/Me/VC/ContactCustomerVC.swift +++ b/XQMuse/Root/Me/VC/ContactCustomerVC.swift @@ -6,11 +6,22 @@ // import UIKit +import RxSwift + +class ContactCustomerViewModel:RefreshInnerModel<CommonQuestionModel>{ + override func api() -> (Observable<BaseResponse<BaseResponseList<CommonQuestionModel>>>)? { + return Services.commonQuestion(page: page, pageSize: 20) + } +} class ContactCustomerVC: BaseVC { @IBOutlet weak var tableView: UITableView! + @IBOutlet weak var image_qrCode: UIImageView! + private var viewModel = ContactCustomerViewModel() + private var customerImage:UIImage? + override func viewDidLoad() { super.viewDidLoad() title = "联系客服" @@ -20,22 +31,36 @@ tableView.dataSource = self tableView.showsVerticalScrollIndicator = false tableView.register(UINib(nibName: "ContactCustomerTCell", bundle: nil), forCellReuseIdentifier: "_ContactCustomerTCell") + + viewModel.configure(tableView) + viewModel.beginRefresh() + + Services.getCustomerCode().subscribe(onNext: {data in + if let m = data.data{ + self.customerImage = UIImage.jq_GenerateQRCode(with: m, width: 200) + self.image_qrCode.image = self.customerImage + } + }).disposed(by: disposeBag) } } extension ContactCustomerVC:UITableViewDelegate & UITableViewDataSource{ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let vc = ContactCustomerDetailVC() + let model = viewModel.dataSource.value!.list[indexPath.row] + let vc = ContactCustomerDetailVC(model,customerImage: customerImage) push(vc: vc) } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCell(withIdentifier: "_ContactCustomerTCell", for: indexPath) as! ContactCustomerTCell + let model = viewModel.dataSource.value!.list[indexPath.row] + let cell = tableView.dequeueReusableCell(withIdentifier: "_ContactCustomerTCell", for: indexPath) as! + ContactCustomerTCell + cell.setCommonQuestionModel(model) return cell } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 10 + return viewModel.dataSource.value?.list.count ?? 0 } diff --git a/XQMuse/Root/Me/VC/ContactCustomerVC.xib b/XQMuse/Root/Me/VC/ContactCustomerVC.xib index 45b6eeb..56ed9d0 100644 --- a/XQMuse/Root/Me/VC/ContactCustomerVC.xib +++ b/XQMuse/Root/Me/VC/ContactCustomerVC.xib @@ -11,6 +11,7 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ContactCustomerVC" customModule="XQMuse" customModuleProvider="target"> <connections> + <outlet property="image_qrCode" destination="5jI-tQ-uLM" id="Fxg-dZ-zU2"/> <outlet property="tableView" destination="cf6-0I-xxB" id="kE1-aF-snG"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> </connections> @@ -25,10 +26,19 @@ </imageView> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Qdl-41-EV1"> <rect key="frame" x="130.33333333333331" y="106.66666666666667" width="132.33333333333331" height="132.33333333333331"/> + <subviews> + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="5jI-tQ-uLM"> + <rect key="frame" x="0.0" y="0.0" width="132.33333333333334" height="132.33333333333334"/> + </imageView> + </subviews> <color key="backgroundColor" systemColor="systemBackgroundColor"/> <constraints> <constraint firstAttribute="width" constant="132.5" id="3xI-p5-QcI"/> + <constraint firstAttribute="trailing" secondItem="5jI-tQ-uLM" secondAttribute="trailing" id="75F-nx-DFC"/> + <constraint firstItem="5jI-tQ-uLM" firstAttribute="top" secondItem="Qdl-41-EV1" secondAttribute="top" id="AvE-uP-sXr"/> + <constraint firstItem="5jI-tQ-uLM" firstAttribute="leading" secondItem="Qdl-41-EV1" secondAttribute="leading" id="DpG-ZI-XEO"/> <constraint firstAttribute="height" constant="132.5" id="ffo-MU-W1a"/> + <constraint firstAttribute="bottom" secondItem="5jI-tQ-uLM" secondAttribute="bottom" id="g7M-oD-LE2"/> </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="fc3-8Q-v5s"> diff --git a/XQMuse/Root/Me/VC/LevelVC.swift b/XQMuse/Root/Me/VC/LevelVC.swift index 1bad0b8..2f37089 100644 --- a/XQMuse/Root/Me/VC/LevelVC.swift +++ b/XQMuse/Root/Me/VC/LevelVC.swift @@ -6,16 +6,36 @@ // import UIKit +import WebKit +import JQTools class LevelVC: BaseVC { + @IBOutlet weak var image_level: UIImageView! + @IBOutlet weak var label_currentLevel: UILabel! + @IBOutlet weak var label_nextLevel: UILabel! @IBOutlet weak var progressView: UIProgressView! + @IBOutlet weak var webView: WKWebView! override func viewDidLoad() { - super.viewDidLoad() + super.viewDidLoad() title = "当前等级" - DispatchQueue.main.asyncAfter(delay: 2.0) { - self.progressView.setProgress(0.9, animated: true) - } - } + Services.userHeadingLevel().subscribe(onNext: {data in + if let m = data.data{ + + let progress = Double(m.growthValue) / Double(m.nextLevel) + DispatchQueue.main.asyncAfter(delay: 0.5) { + self.progressView.setProgress(Float(progress), animated: true) + } + + self.image_level.sd_setImage(with: URL(string: m.levelIcon)) + self.label_currentLevel.text = String(format: "%ld/%ld", m.level,10) + + self.label_nextLevel.isHidden = m.level == 10 + self.label_nextLevel.text = String(format: "你离下一等级还差%ld经验值,加油!", m.growthValue,m.nextLevel) + + self.webView.loadHTMLString(m.content.jq_wrapHtml(), baseURL: nil) + } + }).disposed(by: disposeBag) + } } diff --git a/XQMuse/Root/Me/VC/LevelVC.xib b/XQMuse/Root/Me/VC/LevelVC.xib index a4faf55..10ebc1b 100644 --- a/XQMuse/Root/Me/VC/LevelVC.xib +++ b/XQMuse/Root/Me/VC/LevelVC.xib @@ -10,8 +10,12 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="LevelVC" customModule="XQMuse" customModuleProvider="target"> <connections> + <outlet property="image_level" destination="h9t-tx-RMl" id="mBI-RZ-5bd"/> + <outlet property="label_currentLevel" destination="7JM-Vh-SUj" id="MYr-FY-PBt"/> + <outlet property="label_nextLevel" destination="ZIY-z8-gex" id="F9R-Uc-pfU"/> <outlet property="progressView" destination="vEE-PO-MmZ" id="bFu-HY-IeG"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> + <outlet property="webView" destination="fXz-og-D6V" id="ld9-Qo-ezl"/> </connections> </placeholder> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> diff --git a/XQMuse/Root/Me/VC/LogoutAccountVC.swift b/XQMuse/Root/Me/VC/LogoutAccountVC.swift index 5516299..2fdc47d 100644 --- a/XQMuse/Root/Me/VC/LogoutAccountVC.swift +++ b/XQMuse/Root/Me/VC/LogoutAccountVC.swift @@ -18,9 +18,11 @@ } @IBAction func completeAction(_ sender: UIButton) { - CommonAlertView.show(title: "提示", content: "已提交注销申请,请耐心等待平台审核", cancelStr: nil, completeStr: "确定", isSingle: true) { _ in - - } + Services.deleteUser().subscribe(onNext: {data in + CommonAlertView.show(title: "提示", content: "已提交注销申请,请耐心等待平台审核", cancelStr: nil, completeStr: "确定", isSingle: true) { _ in + sceneDelegate?.needLogin() + } + }).disposed(by: disposeBag) } override func viewDidLayoutSubviews() { diff --git a/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.swift b/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.swift index aed669b..f195af6 100644 --- a/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.swift +++ b/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.swift @@ -9,10 +9,27 @@ class NoticeCenterSysDetailVC: BaseVC { + @IBOutlet weak var label_title: UILabel! + @IBOutlet weak var label_date: UILabel! + @IBOutlet weak var label_content: UILabel! + + private var model:NoticeDetailModel! + + required init(_ model:NoticeDetailModel) { + super.init(nibName: nil, bundle: nil) + self.model = model + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + override func viewDidLoad() { super.viewDidLoad() title = "系统消息" - + label_title.text = model.title + label_content.text = model.reply + label_date.text = model.publishTime } override func setUI() { diff --git a/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.xib b/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.xib index 789a890..6a192c5 100644 --- a/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.xib +++ b/XQMuse/Root/Me/VC/NoticeCenterSysDetailVC.xib @@ -11,6 +11,9 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="NoticeCenterSysDetailVC" customModule="XQMuse" customModuleProvider="target"> <connections> + <outlet property="label_content" destination="JPR-7W-qZh" id="OVn-ry-qIR"/> + <outlet property="label_date" destination="en7-Qa-xJB" id="N6v-cR-rI3"/> + <outlet property="label_title" destination="gQK-sP-1w2" id="nXw-fW-7RU"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> </connections> </placeholder> diff --git a/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.swift b/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.swift index 8db2890..0abf1ad 100644 --- a/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.swift +++ b/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.swift @@ -8,10 +8,40 @@ import UIKit class NoticeCenterUserRepeaceDetailVC: BaseVC { + @IBOutlet weak var image_avartar: UIImageView! + @IBOutlet weak var label_name: UILabel! + @IBOutlet weak var label_content: UILabel! + @IBOutlet weak var btn_islike: UIButton! + @IBOutlet weak var image_reply_userAvartar: UIImageView! + @IBOutlet weak var label_reply_name: UILabel! + @IBOutlet weak var label_reply_content: UILabel! + @IBOutlet weak var label_reply_date: UILabel! + @IBOutlet weak var view_plantfrom: UIView! + @IBOutlet weak var view_plantfrom_reply: UILabel! + + private var model:NoticeDetailModel! + + required init(_ model:NoticeDetailModel) { + super.init(nibName: nil, bundle: nil) + self.model = model + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + override func viewDidLoad() { super.viewDidLoad() title = "回复消息" - + image_avartar.sd_setImage(with: URL(string: model.iconUrl)) + label_name.text = model.meditationTitle + label_content.text = model.coverDescription + image_reply_userAvartar.sd_setImage(with: URL(string: model.avatar)) + label_reply_name.text = model.nickname + label_reply_content.text = model.content + label_reply_date.text = model.publishTime + view_plantfrom.isHidden = model.replyContent.isEmpty + view_plantfrom_reply.text = model.reply } } diff --git a/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.xib b/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.xib index b8f2610..8bfd828 100644 --- a/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.xib +++ b/XQMuse/Root/Me/VC/NoticeCenterUserRepeaceDetailVC.xib @@ -11,7 +11,17 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="NoticeCenterUserRepeaceDetailVC" customModule="XQMuse" customModuleProvider="target"> <connections> + <outlet property="btn_islike" destination="D0U-is-fLy" id="Nol-JH-4e8"/> + <outlet property="image_avartar" destination="z1T-aN-oSN" id="EC2-yy-BZh"/> + <outlet property="image_reply_userAvartar" destination="BAp-Ga-8ex" id="90g-66-wf5"/> + <outlet property="label_content" destination="rDr-su-720" id="ual-Wr-y4F"/> + <outlet property="label_name" destination="ckR-f8-uGd" id="ETi-d0-eFM"/> + <outlet property="label_reply_content" destination="hpx-3J-7nI" id="ZhF-ia-Nmn"/> + <outlet property="label_reply_date" destination="I4t-Mk-xsI" id="vQo-sa-xEV"/> + <outlet property="label_reply_name" destination="PoX-Mz-vPh" id="ofg-uR-tbP"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> + <outlet property="view_plantfrom" destination="96T-Ma-Y0w" id="gYY-40-WMM"/> + <outlet property="view_plantfrom_reply" destination="3rx-FM-iyi" id="SO3-Mk-Z4s"/> </connections> </placeholder> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> diff --git a/XQMuse/Root/Me/VC/NoticeCenterVC.swift b/XQMuse/Root/Me/VC/NoticeCenterVC.swift index e6aa5c2..db19b43 100644 --- a/XQMuse/Root/Me/VC/NoticeCenterVC.swift +++ b/XQMuse/Root/Me/VC/NoticeCenterVC.swift @@ -6,15 +6,26 @@ // import UIKit +import RxSwift +import RxDataSources + +class NoticeCenterViewModel:RefreshInnerModel<NoticeModel>{ + override func api() -> (Observable<BaseResponse<BaseResponseList<NoticeModel>>>)? { + return Services.noticeList(page: page, pageSize: 20) + } +} class NoticeCenterVC: BaseVC { private var tableView:UITableView! + private var viewModel = NoticeCenterViewModel() override func viewDidLoad() { super.viewDidLoad() title = "消息通知" + viewModel.configure(tableView) + viewModel.beginRefresh() } override func setUI() { @@ -38,20 +49,32 @@ extension NoticeCenterVC:UITableViewDelegate & UITableViewDataSource{ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - if indexPath.row == 0{ - let vc = NoticeCenterSysDetailVC() - push(vc: vc) - } + let model = viewModel.dataSource.value!.list[indexPath.row] + model.readStatus = 2 + tableView.reloadRows(at: [indexPath], with: .none) - if indexPath.row == 1{ - let vc = NoticeCenterUserRepeaceDetailVC() - push(vc: vc) - } + Services.noticeDetailId(model.id).subscribe(onNext: {data in + if let m = data.data{ + if model.noticeType == 1{ + let vc = NoticeCenterSysDetailVC(m) + self.push(vc: vc) + } + + if model.noticeType == 2{ + let vc = NoticeCenterUserRepeaceDetailVC(m) + self.push(vc: vc) + } + } + }).disposed(by: disposeBag) + + } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let model = viewModel.dataSource.value!.list[indexPath.row] let cell = tableView.dequeueReusableCell(withIdentifier: "_MessageTCell", for: indexPath) as! MessageTCell cell.backgroundColor = .clear + cell.setNoticeModel(model) return cell } @@ -60,7 +83,7 @@ } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 10 + return viewModel.dataSource.value?.list.count ?? 0 } diff --git a/XQMuse/Root/Me/VC/SettingVC.swift b/XQMuse/Root/Me/VC/SettingVC.swift index 2af4b14..7e78a54 100644 --- a/XQMuse/Root/Me/VC/SettingVC.swift +++ b/XQMuse/Root/Me/VC/SettingVC.swift @@ -6,6 +6,7 @@ // import UIKit +import JQTools class SettingVC: BaseVC { @@ -26,11 +27,13 @@ } @IBAction func cancelCacheAction(_ sender: TapBtn) { - alertSuccess(msg: "清理成功") + JQTool.cleanCache { + alertSuccess(msg: "清理成功") + } } @IBAction func aboutUsAction(_ sender: TapBtn) { - let vc = WebVC() + let vc = WebVC(type: .aboutUs) vc.title = "关于心泉" push(vc: vc) } @@ -46,10 +49,10 @@ } @IBAction func exchangeAccountAction(_ sender: UIButton) { - + sceneDelegate?.needLogin() } @IBAction func quitAccountAction(_ sender: UIButton) { - + sceneDelegate?.needLogin() } } diff --git a/XQMuse/Root/Me/VC/SpendingDetailContentVC.swift b/XQMuse/Root/Me/VC/SpendingDetailContentVC.swift index bfa4d0c..971939e 100644 --- a/XQMuse/Root/Me/VC/SpendingDetailContentVC.swift +++ b/XQMuse/Root/Me/VC/SpendingDetailContentVC.swift @@ -7,15 +7,26 @@ import UIKit import JQTools +import RxSwift +import RxRelay + +class SpendingDetailViewModel:RefreshInnerModel<BalanceInfoModel>{ + + var state = BehaviorRelay<Int>(value: 1) + + override func api() -> (Observable<BaseResponse<BaseResponseList<BalanceInfoModel>>>)? { + return Services.balanceRecordList(page: page, pageSize: 20, state: state.value) + } +} class SpendingDetailContentVC: BaseVC { - private var page:Int! private var tableView:UITableView! + private var viewModel = SpendingDetailViewModel() - init(page:Int) { + init(state:Int) { super.init(nibName: nil, bundle: nil) - self.page = page + viewModel.state.accept(state) } required init?(coder: NSCoder) { @@ -25,7 +36,8 @@ override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view. + viewModel.configure(tableView) + viewModel.beginRefresh() } override func setUI() { @@ -45,18 +57,20 @@ extension SpendingDetailContentVC:UITableViewDelegate & UITableViewDataSource{ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let vc = SpendingDetailInfoVC() + let model = viewModel.dataSource.value!.list[indexPath.row] + let vc = SpendingDetailInfoVC(id: model.id) JQ_currentViewController().jq_push(vc: vc, animated: true) } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let model = viewModel.dataSource.value!.list[indexPath.row] let cell = tableView.dequeueReusableCell(withIdentifier: "_SpendingDetailContentTCell", for: indexPath) as! SpendingDetailContentTCell - + cell.setBalanceInfoModel(model) return cell } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 10 + return viewModel.dataSource.value?.list.count ?? 0 } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { diff --git a/XQMuse/Root/Me/VC/SpendingDetailHeaderVC.swift b/XQMuse/Root/Me/VC/SpendingDetailHeaderVC.swift index 2ef81f8..4c5f944 100644 --- a/XQMuse/Root/Me/VC/SpendingDetailHeaderVC.swift +++ b/XQMuse/Root/Me/VC/SpendingDetailHeaderVC.swift @@ -10,12 +10,14 @@ class SpendingDetailHeaderVC: BaseVC { - override func viewDidLoad() { + @IBOutlet weak var label_balance: UILabel! + var income:Double = 0 + override func viewDidLoad() { super.viewDidLoad() } @IBAction func withdrawAction(_ sender: UIButton) { - let vc = BankWithdrawVC() + let vc = BankWithdrawVC(income: income) JQ_currentViewController().jq_push(vc: vc) } } diff --git a/XQMuse/Root/Me/VC/SpendingDetailHeaderVC.xib b/XQMuse/Root/Me/VC/SpendingDetailHeaderVC.xib index 4aafcbf..1b68dbb 100644 --- a/XQMuse/Root/Me/VC/SpendingDetailHeaderVC.xib +++ b/XQMuse/Root/Me/VC/SpendingDetailHeaderVC.xib @@ -10,6 +10,7 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SpendingDetailHeaderVC" customModule="XQMuse" customModuleProvider="target"> <connections> + <outlet property="label_balance" destination="iKf-J7-77x" id="9rV-mO-0wq"/> <outlet property="view" destination="iN0-l3-epB" id="dt1-eq-STC"/> </connections> </placeholder> diff --git a/XQMuse/Root/Me/VC/SpendingDetailInfoVC.swift b/XQMuse/Root/Me/VC/SpendingDetailInfoVC.swift index 2bf8519..911a521 100644 --- a/XQMuse/Root/Me/VC/SpendingDetailInfoVC.swift +++ b/XQMuse/Root/Me/VC/SpendingDetailInfoVC.swift @@ -9,10 +9,70 @@ class SpendingDetailInfoVC: BaseVC { + + @IBOutlet weak var label_price: UILabel! + @IBOutlet weak var label_incomeType: UILabel! + @IBOutlet weak var label_datetime: UILabel! + @IBOutlet weak var label_orderNum: UILabel! + @IBOutlet weak var label_subUserName: UILabel! + @IBOutlet weak var image_subUserAvartar: UIImageView! + @IBOutlet weak var label_remakr: UILabel! + + + @IBOutlet weak var view_incomeType: UIView! + @IBOutlet weak var view_datetime: UIView! + @IBOutlet weak var view_orderNum: UIView! + @IBOutlet weak var view_subUser: UIView! + @IBOutlet weak var view_remark: UIView! + + private var id:Int! + + required 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 = "收入详情" navigationController?.navigationBar.scrollEdgeAppearance?.backgroundColor = .white + + view_incomeType.isHidden = true + view_datetime.isHidden = true + view_orderNum.isHidden = true + view_subUser.isHidden = true + view_remark.isHidden = true + + Services.balanceDetail(id: id).subscribe(onNext: {data in + if let m = data.data{ + + self.view_incomeType.isHidden = false + self.view_datetime.isHidden = false + self.view_orderNum.isHidden = false + self.view_remark.isHidden = false + + if m.changeType == .increase{ + self.label_price.text = String(format: "+%.2lf", m.amount) + self.label_price.textColor = UIColor(hexString: "#FE3211")?.withAlphaComponent(0.8) + }else{ + self.label_price.text = String(format: "-%.2lf", m.amount) + self.label_price.textColor = .black.withAlphaComponent(0.8) + } + + self.label_incomeType.text = m.type + self.label_datetime.text = m.paymentTime + self.label_orderNum.text = m.payOrderNo + self.view_subUser.isHidden = m.userName.isEmpty + self.label_subUserName.text = m.userName + self.image_subUserAvartar.sd_setImage(with: URL(string: m.avatar)) + self.label_remakr.text = m.remark + + } + }).disposed(by: disposeBag) } override func viewWillDisappear(_ animated: Bool) { super.viewDidDisappear(animated) diff --git a/XQMuse/Root/Me/VC/SpendingDetailInfoVC.xib b/XQMuse/Root/Me/VC/SpendingDetailInfoVC.xib index 9614a2d..d1d657c 100644 --- a/XQMuse/Root/Me/VC/SpendingDetailInfoVC.xib +++ b/XQMuse/Root/Me/VC/SpendingDetailInfoVC.xib @@ -11,7 +11,19 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SpendingDetailInfoVC" customModule="XQMuse" customModuleProvider="target"> <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_incomeType" destination="Vch-45-s0U" id="Fka-TJ-wqx"/> + <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_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"/> + <outlet property="view_datetime" destination="7Ym-dd-vx2" id="JUw-DQ-17I"/> + <outlet property="view_incomeType" destination="paU-qi-7Zk" id="yQ6-0X-6cq"/> + <outlet property="view_orderNum" destination="nvZ-aC-LZK" id="Ss6-sC-tZB"/> + <outlet property="view_remark" destination="Yhm-fa-EN3" id="AiJ-rj-8ZG"/> + <outlet property="view_subUser" destination="AKh-er-j4M" id="hyW-dn-tPY"/> </connections> </placeholder> <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> diff --git a/XQMuse/Root/Me/VC/SpendingDetailVC.swift b/XQMuse/Root/Me/VC/SpendingDetailVC.swift index 5ac6d50..45682f3 100644 --- a/XQMuse/Root/Me/VC/SpendingDetailVC.swift +++ b/XQMuse/Root/Me/VC/SpendingDetailVC.swift @@ -38,10 +38,24 @@ return pageViewController }() + private var balance:Double = 0 + private var income:Double = 0 + required init(balance:Double,income:Double) { + super.init(nibName: nil, bundle: nil) + self.balance = balance + self.income = income + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + override func viewDidLoad() { super.viewDidLoad() title = "余额明细" + headerVC.label_balance.text = "\(balance)" + headerVC.income = income } override func setUI() { @@ -71,7 +85,7 @@ } func pageViewController(_ pageViewConteoller: FFPageViewController, controllerForPage page: Int) -> UIViewController { - let v = SpendingDetailContentVC(page: page) + let v = SpendingDetailContentVC(state: page + 1) return v } diff --git a/XQMuse/Root/Me/VC/StudyListVC.swift b/XQMuse/Root/Me/VC/StudyListVC.swift index d1fb958..464fb98 100644 --- a/XQMuse/Root/Me/VC/StudyListVC.swift +++ b/XQMuse/Root/Me/VC/StudyListVC.swift @@ -12,14 +12,29 @@ class StudyListVC: BaseVC { @IBOutlet weak var collectionView: UICollectionView! + + private var datas:MyStudyModel? override func viewDidLoad() { super.viewDidLoad() title = "学习" + + Services.studyPage().subscribe(onNext: {data in + self.datas = data.data + self.collectionView.reloadData() + }).disposed(by: disposeBag) } override func setUI() { super.setUI() view.backgroundColor = UIColor(hexString: "#F6F6F6") + + + let layout = HoverHeaderFlowLayout() + layout.naviHeight = 0 + let w = (JQ_ScreenW - 18 * 3) / 2 + layout.itemSize = CGSize(width: w, height: w * 1.319) + layout.headerReferenceSize = CGSize(width: JQ_ScreenW, height: 59) + collectionView.collectionViewLayout = layout collectionView.delegate = self collectionView.dataSource = self collectionView.backgroundColor = UIColor(hexString: "#F6F6F6") @@ -37,25 +52,52 @@ extension StudyListVC:UICollectionViewDelegate & UICollectionViewDataSource{ + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + + var modelId:Int? + if indexPath.section == 0{ + modelId = datas?.courseList[indexPath.row].id + } + + if indexPath.section == 0{ + modelId = datas?.freeCourseList[indexPath.row].id + } + + if let id = modelId{ + let vc = CourseDetialVC(courseId: id) + push(vc: vc) + } + } + func numberOfSections(in collectionView: UICollectionView) -> Int { return 2 } + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { if indexPath.section == 0{ - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_EmptyCCell", for: indexPath) as! EmptyCCell + let count = datas?.courseList.count ?? 0 + if count == 0{ + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_EmptyCCell", for: indexPath) as! EmptyCCell + return cell + }else{ + let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_1_CCell", for: indexPath) as! HomeRelaxBanner_2_1_CCell + cell.setCourseModel(datas!.courseList[indexPath.row]) + 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]) return cell } - - let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBanner_2_1_CCell", for: indexPath) as! HomeRelaxBanner_2_1_CCell - cell.backgroundColor = .jq_randomColor - return cell } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { if section == 0{ + let count = datas?.courseList.count ?? 0 + if count > 0{return count} return 1 }else { - return 5 + return datas?.freeCourseList.count ?? 0 } } } @@ -88,7 +130,10 @@ } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { - if indexPath.section == 0{ + + let count = datas?.courseList.count ?? 0 + + if indexPath.section == 0 && count == 0{ return CGSize(width: JQ_ScreenW, height: 279) } diff --git a/XQMuse/Root/Me/VC/TreatyVC.swift b/XQMuse/Root/Me/VC/TreatyVC.swift index 08fad80..e167ea5 100644 --- a/XQMuse/Root/Me/VC/TreatyVC.swift +++ b/XQMuse/Root/Me/VC/TreatyVC.swift @@ -93,6 +93,10 @@ } func pageViewController(_ pageViewConteoller: FFPageViewController, controllerForPage page: Int) -> UIViewController { - return WebVC(url: "https://www.baidu.com") + if page == 0{ + return WebVC(type: .user) + }else{ + return WebVC(type: .privacy) + } } } diff --git a/XQMuse/Root/Me/VC/WalletVC.swift b/XQMuse/Root/Me/VC/WalletVC.swift index 77d84cf..9682f6b 100644 --- a/XQMuse/Root/Me/VC/WalletVC.swift +++ b/XQMuse/Root/Me/VC/WalletVC.swift @@ -6,20 +6,46 @@ // import UIKit +import JQTools class WalletVC: BaseVC { + @IBOutlet weak var label_balance: UILabel! + @IBOutlet weak var label_recharge: UILabel! + @IBOutlet weak var label_income: UILabel! + + private var walletModel:WalletModel? override func viewDidLoad() { super.viewDidLoad() title = "钱包" + + getData() } + + override func setRx() { + + NotificationCenter.default.rx.notification(WithDrawReply_Noti).subscribe(onNext: {_ in + self.getData() + }).disposed(by: disposeBag) + } + + private func getData(){ + Services.myWallet().subscribe(onNext: {data in + if let m = data.data{ + self.walletModel = m + self.label_balance.text = m.balance.jq_formatFloat + self.label_recharge.text = m.recharge.jq_formatFloat + self.label_income.text = m.income.jq_formatFloat + } + }).disposed(by: disposeBag) + } override func setUI() { view.backgroundColor = UIColor(hexString: "#fafafa") } @IBAction func withdrawAction(_ sender: UIButton) { - let vc = BankWithdrawVC() + let vc = BankWithdrawVC(income: walletModel?.income ?? 0) push(vc: vc) } @@ -29,7 +55,7 @@ } @IBAction func spendingDetailAction(_ sender: TapBtn) { - let vc = SpendingDetailVC() + let vc = SpendingDetailVC(balance: walletModel?.balance ?? 0, income: walletModel?.income ?? 0) push(vc: vc) } diff --git a/XQMuse/Root/Me/VC/WalletVC.xib b/XQMuse/Root/Me/VC/WalletVC.xib index 78a23b4..35ec6e8 100644 --- a/XQMuse/Root/Me/VC/WalletVC.xib +++ b/XQMuse/Root/Me/VC/WalletVC.xib @@ -11,6 +11,9 @@ <objects> <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="WalletVC" customModule="XQMuse" customModuleProvider="target"> <connections> + <outlet property="label_balance" destination="ytR-o7-C2p" id="ZJD-cY-KS9"/> + <outlet property="label_income" destination="0xP-OZ-ZWR" id="j2F-dD-gQ9"/> + <outlet property="label_recharge" destination="RPE-c0-yYK" id="XNA-Kd-EpG"/> <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> </connections> </placeholder> diff --git a/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift b/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift index d22fbf6..2c00a0e 100644 --- a/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift +++ b/XQMuse/Root/Me/VC/WatchHistoryDetailVC.swift @@ -7,53 +7,89 @@ import UIKit import JQTools +import RxRelay +import RxSwift + +class WatchHistoryViewModel:RefreshInnerModel<CourseModel>{ + + let state = BehaviorRelay<Int>(value: 1) + var type = BehaviorRelay<WatchType>(value: .collect) + + override func api() -> (Observable<BaseResponse<BaseResponseList<CourseModel>>>)? { + switch type.value { + case .history:Services.lookHistory(page: page, pageSize: 20, state: state.value) + case .collect:Services.myCollect(page: page, pageSize: 20, state: state.value) + case .payment:Services.myOrderCourse(page: page, pageSize: 20, state: state.value) + } + } +} + + class WatchHistoryDetailVC: BaseVC { - private var page:Int! - + private var viewModel = WatchHistoryViewModel() private var collectionView:UICollectionView! - init(page:Int) { + init(state:Int,type:WatchType) { super.init(nibName: nil, bundle: nil) - self.page = page + self.viewModel.type.accept(type) + self.viewModel.state.accept(state) } - + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } - - override func viewDidLoad() { - super.viewDidLoad() + + override func viewDidLoad() { + super.viewDidLoad() + let layout = UICollectionViewFlowLayout() collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) collectionView.delegate = self collectionView.dataSource = self collectionView.showsVerticalScrollIndicator = false + collectionView.backgroundColor = .clear collectionView.register(UINib(nibName: "HomeRelaxBannerCCell", bundle: nil), forCellWithReuseIdentifier: "_HomeRelaxBannerCCell") - collectionView.contentInset = UIEdgeInsets(top: 29, left: 29.5 , bottom: 0, right: 29.5) + collectionView.contentInset = UIEdgeInsets(top: 0, left: 29.5 , bottom: 0, right: 29.5) view.addSubview(collectionView) collectionView.snp.makeConstraints { make in - make.edges.equalToSuperview() + make.top.equalTo(0) + make.left.right.bottom.equalToSuperview() } - } + + viewModel.configure(collectionView) + viewModel.beginRefresh() + } } extension WatchHistoryDetailVC:UICollectionViewDelegate & UICollectionViewDataSource{ func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - return 5 + return viewModel.dataSource.value?.list.count ?? 0 } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_HomeRelaxBannerCCell", for: indexPath) as! HomeRelaxBannerCCell - cell.contentView.backgroundColor = .jq_randomColor + let m = viewModel.dataSource.value!.list[indexPath.row] + cell.setCourseModel(m) return cell } + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize { + return CGSizeMake(JQ_ScreenW, 29) + } + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { - let vc = HomeItemDetailVC(id: 0) + + let m = viewModel.dataSource.value!.list[indexPath.row] + if viewModel.state.value == 1{ + let vc = HomeItemDetailVC(id: m.id) JQ_currentViewController().jq_push(vc: vc) + }else{ + let vc = CourseDetialVC(courseId: m.id) + JQ_currentViewController().jq_push(vc: vc) + } } } diff --git a/XQMuse/Root/Me/VC/WatchHistoryVC.swift b/XQMuse/Root/Me/VC/WatchHistoryVC.swift index 0852de8..83c0ebb 100644 --- a/XQMuse/Root/Me/VC/WatchHistoryVC.swift +++ b/XQMuse/Root/Me/VC/WatchHistoryVC.swift @@ -123,6 +123,6 @@ } func pageViewController(_ pageViewConteoller: FFPageViewController, controllerForPage page: Int) -> UIViewController { - return WatchHistoryDetailVC(page: page) + return WatchHistoryDetailVC(state: page+1, type: watchType) } } diff --git a/XQMuse/Root/Network/Models.swift b/XQMuse/Root/Network/Models.swift index 4168d21..cf35c80 100644 --- a/XQMuse/Root/Network/Models.swift +++ b/XQMuse/Root/Network/Models.swift @@ -252,8 +252,8 @@ var continuity: Int = 0 var cumulative: Int = 0 var level: Int = 0 - var levelIcon: String? - var levelName: String? + var levelIcon: String = "" + var levelName: String = "" var today: Int = 0 } @@ -343,6 +343,115 @@ var indexPath:IndexPath? } +struct HeadingLevelModel:HandyJSON{ + var content: String = "" + var differenceLevel: Int = 0 + var growthValue: Int = 0 + var level: Int = 0 + var levelIcon: String = "" + var levelName: String = "" + var nextLevel: Int = 0 +} + +struct MyStudyModel:HandyJSON{ + var courseList = [CourseModel]() + var freeCourseList = [CourseModel]() +} + +struct WalletModel:HandyJSON{ + var balance:Double = 0 + var income:Double = 0 + var recharge:Double = 0 +} + +struct BankInfoModel:HandyJSON{ + var appUserId: Int = 0 + var bankName: String = "" + var cardholder: String = "" + var cardNo: String = "" + var cellPhone: String = "" + var createBy: String = "" + var createTime: String = "" + var delFlag: Int = 0 + var id: Int = 0 + var identityCard: String = "" + var updateBy: String = "" + var updateTime: String = "" +} + + +struct BalanceInfoModel:HandyJSON{ + var changeType:EnergyChangeType = .increase + var id = 0 + var reason = "" + var createTime = "" + var amount:Double = 0 +} + +struct BalanceInfoDetailModel:HandyJSON{ + var amount: Double = 0 + var avatar: String = "" + var changeType:EnergyChangeType = .increase + var id: Int = 0 + var paymentTime: String = "" + var payOrderNo: String = "" + var remark: String = "" + var type: String = "" + var userName: String = "" +} + +struct CommonQuestionModel:HandyJSON{ + var content: String = "" + var createBy: String = "" + var createTime: String = "" + var customerServiceQrCode: String = "" + var delFlag: Int = 0 + var id: Int = 0 + var questionDescription: String = "" + var questionName: String = "" + var sortNum: Int = 0 + var type: Int = 0 + var updateBy: String = "" + var updateTime: String = "" +} + +class NoticeModel:HandyJSON{ + var appUserId: Int = 0 + var content: String = "" + var createBy: String = "" + var createTime: String = "" + var delFlag: Int = 0 + var id: Int = 0 + var meditationQuestionId: Int = 0 + var noticeType: Int = 0 + var readStatus: Int = 0 + var time: String = "" + var title: String = "" + var updateBy: String = "" + var updateTime: String = "" + + required init() {} +} + +struct NoticeDetailModel:HandyJSON{ + var avatar: String = "" + var content: String = "" + var coverDescription: String = "" + var iconUrl: String = "" + var meditationQuestionId: Int = 0 + var meditationTitle: String = "" + var nickname: String = "" + var noticeType: Int = 0 + var publishTime: String = "" + var realname: String = "" + var reply: String = "" + var replyContent: String = "" + var time: String = "" + var title: String = "" + +} + + struct ResponseUserAnswerModel:HandyJSON{ var tagsId = "" //问题二 多个tagId使用英文逗号拼接字符串 var userAnswerOneDTOList = [ResponseUserAnswerDTOModel]() diff --git a/XQMuse/Root/Network/Services.swift b/XQMuse/Root/Network/Services.swift index d5fc93e..53e0ad6 100644 --- a/XQMuse/Root/Network/Services.swift +++ b/XQMuse/Root/Network/Services.swift @@ -247,6 +247,14 @@ .append(key: "apipost_id", value: "2d2eb9d23993c2") return NetworkRequest.request(params: params, method: .post, progress: true) } + + //学习 + class func studyPage()->Observable<BaseResponse<MyStudyModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/course/client/course/course/studyPage") + .append(key: "apipost_id", value: "2d2eb9d23993be") + return NetworkRequest.request(params: params, method: .post, progress: true) + } } /// 疗愈馆 @@ -351,6 +359,125 @@ .append(key: "apipost_id", value: "25c3dab9f0e025") return NetworkRequest.request(params: params, method: .post, progress: true) } + + /// 冥想等级 + class func userHeadingLevel()->Observable<BaseResponse<HeadingLevelModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/client/app-user/healingLevel") + .append(key: "apipost_id", value: "34d924b4b991f0") + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + class func myWallet()->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) + } + + class func getMyBankList()->Observable<BaseResponse<[BankInfoModel]>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/user/client/app-user/wallet") + .append(key: "apipost_id", value: "361bdf11f992d2") + return NetworkRequest.request(params: params, method: .post, progress: false) + } + + class func withdraw(bankId:Int,money:Double)->Observable<BaseResponse<SimpleModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/user/client/app-user-withdraw/withdraw") + .append(key: "apipost_id", value: "361bdf11f992d3") + .append(key: "bankId", value: bankId) + .append(key: "money", value: money) + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + //添加银行卡 + class func addBank(_ model:AddBankInfoVC.AddBankRequestModel)->Observable<BaseResponse<SimpleModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/user/client/app-user-withdraw/withdraw") + .append(key: "apipost_id", value: "361bdf11f992d1") + .append(dic: model.toRequest()) + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + //添加银行卡 + class func deleteBank(_ id:Int)->Observable<BaseResponse<SimpleModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/user/client/app-user-withdraw/deleteBank") + .append(key: "apipost_id", value: "362cb08c799646") + .append(key: "id", value: id) + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + /// 余额明细表 + /// - Parameters: + /// - state: 1全部 2收入 3支出 + class func balanceRecordList(page:Int,pageSize:Int = 20,state:Int)->Observable<BaseResponse<BaseResponseList<BalanceInfoModel>>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/user/client/app-user-wallet-record/balanceList") + .append(key: "apipost_id", value: "361bdf11b992d0") + .append(key: "pageCurr", value: page) + .append(key: "pageSize", value: pageSize) + .append(key: "state", value: state) + return NetworkRequest.request(params: params, method: .post, progress: false) + } + + + /// 观看历史 + /// - Parameters: + /// - state: 1冥想 2课程 + class func lookHistory(page:Int,pageSize:Int = 20,state:Int)->Observable<BaseResponse<BaseResponseList<CourseModel>>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/user/user/app-user-viewing-history/lookHistory") + .append(key: "apipost_id", value: "361bdf123992fb") + .append(key: "pageCurr", value: page) + .append(key: "pageSize", value: pageSize) + .append(key: "state", value: state) + return NetworkRequest.request(params: params, method: .post, progress: false) + } + + /// 我的收藏 + /// - Parameters: + /// - state: 1冥想 2课程 + class func myCollect(page:Int,pageSize:Int = 20,state:Int)->Observable<BaseResponse<BaseResponseList<CourseModel>>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/course/client/course/course/myCollect") + .append(key: "apipost_id", value: "365e099bb9988b") + .append(key: "pageCurr", value: page) + .append(key: "pageSize", value: pageSize) + .append(key: "state", value: state) + return NetworkRequest.request(params: params, method: .post, progress: false) + } + + /// 我的购买 + /// - Parameters: + /// - state: 1冥想 2课程 + class func myOrderCourse(page:Int,pageSize:Int = 20,state:Int)->Observable<BaseResponse<BaseResponseList<CourseModel>>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/order/client/order/order/myOrderCourse") + .append(key: "apipost_id", value: "365f4fc1b99030") + .append(key: "pageCurr", value: page) + .append(key: "pageSize", value: pageSize) + .append(key: "state", value: state) + return NetworkRequest.request(params: params, method: .post, progress: false) + } + + class func balanceDetail(id:Int)->Observable<BaseResponse<BalanceInfoDetailModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/user/client/app-user-wallet-record/balanceDetail") + .append(key: "apipost_id", value: "361bdf11b992cf") + .append(key: "id", value: id) + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + class func changePhone(phone:String,code:String)->Observable<BaseResponse<SimpleModel>>{ + let params = ParamsAppender.build(url: All_Url) + params.interface(url: "/user/client/app-user/changePhone") + .append(key: "apipost_id", value: "361bdf11f992e6") + .append(key: "phone", value: phone) + .append(key: "code", value: code) + return NetworkRequest.request(params: params, method: .post, progress: true) + } } @@ -447,4 +574,50 @@ return NetworkRequest.request(params: params, method: .get, progress: false) } + /// 问题列表 + class func commonQuestion(page:Int,pageSize:Int = 20)->Observable<BaseResponse<BaseResponseList<CommonQuestionModel>>>{ + let params = ParamsAppender.build(url: All_Url) + .interface(url: "/system/system/common-question/commonQuestion") + .append(key: "apipost_id", value: "36618045f991c4") + .append(key: "pageCurr", value: page) + .append(key: "pageSize", value: pageSize) + return NetworkRequest.request(params: params, method: .post, progress: false) + } + + /// 问题列表 + class func commonQuestionDetailBy(id:Int)->Observable<BaseResponse<CommonQuestionModel>>{ + let params = ParamsAppender.build(url: All_Url) + .interface(url: "/system/system/common-question/getQuestionById") + .append(key: "apipost_id", value: "366180463991c5") + .append(key: "id", value: id) + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + class func deleteUser()->Observable<BaseResponse<SimpleModel>>{ + let params = ParamsAppender.build(url: All_Url) + .interface(url: "/user/client/app-user/deleteUser") + .append(key: "apipost_id", value: "361bdf11f992e7") + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + class func noticeList(page:Int,pageSize:Int = 20)->Observable<BaseResponse<BaseResponseList<NoticeModel>>>{ + let params = ParamsAppender.build(url: All_Url) + .interface(url: "/user/client/user/notice-record/noticeList") + .append(key: "apipost_id", value: "361bdf123992f9") + .append(key: "pageCurr", value: page) + .append(key: "pageSize", value: pageSize) + return NetworkRequest.request(params: params, method: .post, progress: false) + } + + class func noticeDetailId(_ id:Int)->Observable<BaseResponse<NoticeDetailModel>>{ + let params = ParamsAppender.build(url: All_Url) + .interface(url: "/user/client/user/notice-record/noticeDetail") + .append(key: "apipost_id", value: "361bdf123992f8") + .append(key: "id", value: id) + return NetworkRequest.request(params: params, method: .post, progress: true) + } + + + + } diff --git a/XQMuse/SceneDelegate.swift b/XQMuse/SceneDelegate.swift index 441054d..b09b742 100644 --- a/XQMuse/SceneDelegate.swift +++ b/XQMuse/SceneDelegate.swift @@ -44,8 +44,9 @@ loginNav.modalPresentationStyle = .fullScreen JQ_currentViewController().present(loginNav, animated: true) } + func loginSuccess(){ - + } func sceneDidDisconnect(_ scene: UIScene) { -- Gitblit v1.7.1