瀏覽代碼

添加退出 方法

jsonwang 4 年之前
父節點
當前提交
18146a0915

+ 12 - 0
MusicVideoPlus/MusicVideoPlus/Classes/Modules/Login/ViewModels/PQMineViewModel.swift

@@ -71,6 +71,18 @@ class PQMineViewModel: NSObject {
         }
     }
 
+    /// 退出登录
+    /// - Returns: description
+   public class func quitLogin(completeHander: @escaping completeHander) {
+        SWNetRequest.postRequestData(url: PQENVUtil.shared.longvideoapi + logoutUrl, parames: nil) { _, _, _, _ in
+            // 取消别名绑定
+
+            BFLoginUserInfo.shared.resetData(isClear: true)
+            completeHander(nil, nil)
+       
+        }
+    }
+
     /// Apple账号登录
     /// - Parameters:
     ///   - token: token

+ 19 - 0
MusicVideoPlus/MusicVideoPlus/Classes/Modules/Setting/Controllers/MVSettingController.swift

@@ -68,10 +68,29 @@ class MVSettingController: MVBaseController{
         view.addSubview(protocolLab)
         view.addSubview(logoutBtn)
         addLayout()
+        
+    
+        logoutBtn.isHidden = !BFLoginUserInfo.shared.isLogin()
+        
     }
     
     @objc func btnClick() {
         BFLog(message: "logout ")
+        let remindData:PQBaseModel = PQBaseModel()
+        remindData.title = "退出?"
+        
+        let remindView = PQRemindView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
+        UIApplication.shared.keyWindow?.addSubview(remindView)
+        remindView.remindData = remindData
+        remindView.remindBlock = { [weak self] sender, _ in
+            if sender.tag == 2 {
+                PQMineViewModel.quitLogin { [weak self] _, _ in
+                    postNotification(name: cQuitSuccesssNotiKey)
+                    self?.logoutBtn.isHidden = true
+                    self?.navigationController?.popViewController(animated: true)
+                }
+            }
+        }
     }