//
|
// MeVC.swift
|
// DolphinEnglishLearnStudent
|
//
|
// Created by 无故事王国 on 2024/5/22.
|
//
|
|
import UIKit
|
import QMUIKit
|
|
let MeUserInfoUpdate_Noti = Notification.Name.init("MeUserInfoUpdate_Noti")
|
|
class MeVC: BaseVC {
|
@IBOutlet weak var btn_address: QMUIButton!
|
@IBOutlet weak var btn_coinRecord: QMUIButton!
|
@IBOutlet weak var btn_exchangeRecord: QMUIButton!
|
@IBOutlet weak var btn_share: QMUIButton!
|
@IBOutlet weak var btn_etudyRecord: QMUIButton!
|
@IBOutlet weak var btn_loginoff: QMUIButton!
|
@IBOutlet weak var imge_cover: UIImageView!
|
@IBOutlet weak var label_name: UILabel!
|
@IBOutlet weak var label_info: UILabel!
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
getData()
|
}
|
|
override func setUI() {
|
super.setUI()
|
label_info.text = ""
|
btn_address.spacingBetweenImageAndTitle = 11
|
btn_coinRecord.spacingBetweenImageAndTitle = 11
|
btn_exchangeRecord.spacingBetweenImageAndTitle = 11
|
btn_share.spacingBetweenImageAndTitle = 11
|
btn_etudyRecord.spacingBetweenImageAndTitle = 11
|
btn_loginoff.spacingBetweenImageAndTitle = 11
|
|
btn_address.imagePosition = .top
|
btn_coinRecord.imagePosition = .top
|
btn_exchangeRecord.imagePosition = .top
|
btn_share.imagePosition = .top
|
btn_etudyRecord.imagePosition = .top
|
btn_loginoff.imagePosition = .top
|
|
}
|
|
override func setRx() {
|
NotificationCenter.default.rx.notification(MeUserInfoUpdate_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] _ in
|
self?.getData()
|
}).disposed(by: disposeBag)
|
}
|
|
private func getData(){
|
Services.userInfo().subscribe(onNext: {result in
|
var items = Array<String>()
|
|
if let model = result.data?.user{
|
self.imge_cover.sd_setImage(with: URL(string: model.headImg))
|
self.label_name.text = model.name
|
items.append("剩余积分:\(model.integral)")
|
UserViewModel.saveUserInfo(result.data!)
|
}
|
|
if let model = result.data?.userStudy{
|
items.append("学习进度:周目\(model.week.jq_cn)")
|
items.append("学习总时长:\(model.totalStudy)小时")
|
}
|
self.label_info.text = items.joined(separator: "|")
|
|
}).disposed(by: disposeBag)
|
}
|
|
/// 地址管理
|
@IBAction func addressManageAction(_ sender: QMUIButton) {
|
let vc = AddressManageVC(type: .handle)
|
vc.title = "地址管理"
|
push(vc: vc)
|
}
|
|
@IBAction func coinHistoryAction(_ sender: QMUIButton) {
|
let vc = CoinRecordHistoryVC()
|
vc.title = "积分明细"
|
push(vc: vc)
|
}
|
|
@IBAction func exchangeHistoryAction(_ sender: QMUIButton) {
|
let vc = ExchangeRecordHistoryVC()
|
vc.title = "兑换记录"
|
push(vc: vc)
|
}
|
|
@IBAction func studyRecord(_ sender: QMUIButton) {
|
let vc = StudyVC()
|
vc.title = "学习记录"
|
push(vc: vc)
|
}
|
|
@IBAction func shareAction(_ sender: QMUIButton) {
|
if WXApi.isWXAppInstalled(){
|
ShareView.show()
|
}else{
|
let urlStr = "https://dollearn.com/"
|
if let url = URL(string: urlStr) {
|
let activityVC = UIActivityViewController(activityItems: [url], applicationActivities: nil)
|
activityVC.popoverPresentationController?.sourceView = self.view
|
|
let senderCenter = sender.convert(sender.bounds, to: self.view)
|
activityVC.popoverPresentationController?.sourceRect = CGRect(origin:senderCenter.center, size: CGSize(width: 1, height: 1))
|
present(activityVC, animated: true, completion: nil)
|
}
|
}
|
}
|
|
@IBAction func quitAction(_ sender: UIButton) {
|
CommonAlertView.show(content: "确认退出当前账户吗?") {
|
sceneDelegate?.needLogin()
|
Services.logoutStudy().subscribe(onNext: {result in
|
|
}).disposed(by: self.disposeBag)
|
}
|
}
|
|
@IBAction func loginoffAction(_ sender: UIButton) {
|
let vc = UserLoginOffVC()
|
vc.title = "注销账号"
|
push(vc: vc)
|
}
|
|
|
@IBAction func becomeVIPAction(_ sender: Any) {
|
let vc = VIPCenterVC()
|
vc.title = "会员中心"
|
push(vc: vc)
|
}
|
}
|