Browse Source

绑定 , 立即绑定 up

openlockPPP 1 year ago
parent
commit
16571aee79

+ 16 - 0
JiaPeiManage.xcodeproj/project.pbxproj

@@ -185,6 +185,10 @@
 		90E65C902A7A590E0055B09C /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 90E65C8F2A7A590D0055B09C /* Security.framework */; };
 		90E65C922A7A59250055B09C /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 90E65C912A7A59250055B09C /* WebKit.framework */; };
 		90E65C942A7A59770055B09C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 90E65C932A7A59770055B09C /* CoreGraphics.framework */; };
+		90E65C962A7B4B820055B09C /* BindingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90E65C952A7B4B820055B09C /* BindingViewController.swift */; };
+		90E65C982A7B4BD60055B09C /* BindingViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 90E65C972A7B4BD60055B09C /* BindingViewController.xib */; };
+		90E65C9A2A7B56070055B09C /* NYWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90E65C992A7B56070055B09C /* NYWindow.swift */; };
+		90E65C9C2A7B93AE0055B09C /* AuthorizationDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90E65C9B2A7B93AE0055B09C /* AuthorizationDataModel.swift */; };
 		FD091E28E4C2EF8E654AE2C6 /* Pods_JiaPeiManage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FC2879EF62A9D4DF6777C62 /* Pods_JiaPeiManage.framework */; };
 /* End PBXBuildFile section */
 
@@ -381,6 +385,10 @@
 		90E65C8F2A7A590D0055B09C /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
 		90E65C912A7A59250055B09C /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
 		90E65C932A7A59770055B09C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+		90E65C952A7B4B820055B09C /* BindingViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BindingViewController.swift; sourceTree = "<group>"; };
+		90E65C972A7B4BD60055B09C /* BindingViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BindingViewController.xib; sourceTree = "<group>"; };
+		90E65C992A7B56070055B09C /* NYWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NYWindow.swift; sourceTree = "<group>"; };
+		90E65C9B2A7B93AE0055B09C /* AuthorizationDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthorizationDataModel.swift; sourceTree = "<group>"; };
 		A8171123E8F401C7CF842A4C /* Pods-JiaPeiManage.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JiaPeiManage.debug.xcconfig"; path = "Target Support Files/Pods-JiaPeiManage/Pods-JiaPeiManage.debug.xcconfig"; sourceTree = "<group>"; };
 		D9F65764266FE5C95D1940F5 /* Pods-JiaPeiManage.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JiaPeiManage.release.xcconfig"; path = "Target Support Files/Pods-JiaPeiManage/Pods-JiaPeiManage.release.xcconfig"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
@@ -747,6 +755,7 @@
 				908FEEA42A42D62A00BEB81C /* StuTmsSignDataModel.swift */,
 				908FEEAE2A42FA4F00BEB81C /* StuLogFacDataModel.swift */,
 				90971E772A499BF200267B7F /* StuCountDataModel.swift */,
+				90E65C9B2A7B93AE0055B09C /* AuthorizationDataModel.swift */,
 			);
 			path = Models;
 			sourceTree = "<group>";
@@ -759,6 +768,7 @@
 				90CE52402A36E5170033BD06 /* NYFitReal.swift */,
 				90CE52412A36E5170033BD06 /* NYNumber.swift */,
 				90CE52422A36E5170033BD06 /* NYImage.swift */,
+				90E65C992A7B56070055B09C /* NYWindow.swift */,
 			);
 			path = Constants;
 			sourceTree = "<group>";
@@ -1048,6 +1058,8 @@
 			children = (
 				90CE52E82A36E85C0033BD06 /* LoginViewController.swift */,
 				90CE52EA2A36E8680033BD06 /* LoginViewController.xib */,
+				90E65C952A7B4B820055B09C /* BindingViewController.swift */,
+				90E65C972A7B4BD60055B09C /* BindingViewController.xib */,
 			);
 			path = Controllers;
 			sourceTree = "<group>";
@@ -1154,6 +1166,7 @@
 				90971E7F2A4A7F4900267B7F /* Main.storyboard in Resources */,
 				90CE52842A36E5460033BD06 /* SearchBarView.xib in Resources */,
 				90CE52F52A36EDCF0033BD06 /* NYArticleNavBar.xib in Resources */,
+				90E65C982A7B4BD60055B09C /* BindingViewController.xib in Resources */,
 				908FEEA12A42CC1E00BEB81C /* MeTraineeDetails04Cell.xib in Resources */,
 				90CE52252A36C0720033BD06 /* LaunchScreen.storyboard in Resources */,
 				90BC4BE02A3C46C4006FD683 /* MeTraineeDetailsPageViewController.xib in Resources */,
@@ -1282,6 +1295,7 @@
 				90CE52A02A36E59A0033BD06 /* Data+Cache.swift in Sources */,
 				90CE52A12A36E59A0033BD06 /* DefaultsKeys+Key.swift in Sources */,
 				90CE52462A36E5170033BD06 /* NYNumber.swift in Sources */,
+				90E65C962A7B4B820055B09C /* BindingViewController.swift in Sources */,
 				90CE527C2A36E5460033BD06 /* LWPlayerFullScreenViewController.swift in Sources */,
 				90CE52E92A36E85C0033BD06 /* LoginViewController.swift in Sources */,
 				90CE52392A36E4720033BD06 /* MainTabBarController.swift in Sources */,
@@ -1292,6 +1306,7 @@
 				90CE52B42A36E5A40033BD06 /* Logger.swift in Sources */,
 				90CE52EF2A36EC950033BD06 /* NYArticleViewController.swift in Sources */,
 				90CE52D72A36E6000033BD06 /* Snap.swift in Sources */,
+				90E65C9C2A7B93AE0055B09C /* AuthorizationDataModel.swift in Sources */,
 				90CE52882A36E5460033BD06 /* PopOverView.swift in Sources */,
 				90E65C8A2A7A4E330055B09C /* NYWXApiManager.swift in Sources */,
 				90971E6B2A493DE500267B7F /* MeTabBarViewReactor.swift in Sources */,
@@ -1367,6 +1382,7 @@
 				90CE52A62A36E59A0033BD06 /* String+BoundingRect.swift in Sources */,
 				908FEEA32A42D35000BEB81C /* BaseGroupTableViewController.swift in Sources */,
 				90CE527E2A36E5460033BD06 /* NetAnimationLoadable.swift in Sources */,
+				90E65C9A2A7B56070055B09C /* NYWindow.swift in Sources */,
 				90CE52D62A36E6000033BD06 /* NYSwRouter.swift in Sources */,
 				90CE52AB2A36E59A0033BD06 /* UIViewController+NetAnimation.swift in Sources */,
 				9043ADB12A569309005F6F81 /* DES3Util.m in Sources */,

+ 23 - 0
JiaPeiManage/Assets.xcassets/Modules/Login/login_biand_wx.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "filename" : "组 1816.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "组 1816@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "组 1816@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
JiaPeiManage/Assets.xcassets/Modules/Login/login_biand_wx.imageset/组 1816.png


BIN
JiaPeiManage/Assets.xcassets/Modules/Login/login_biand_wx.imageset/组 1816@2x.png


BIN
JiaPeiManage/Assets.xcassets/Modules/Login/login_biand_wx.imageset/组 1816@3x.png


+ 27 - 0
JiaPeiManage/Sources/Constants/NYWindow.swift

@@ -0,0 +1,27 @@
+//
+//  NYWindow.swift
+//  JiaPeiManage
+//
+//  Created by Ning.ge on 2023/8/3.
+//
+
+import UIKit
+
+struct NYWindow {
+    ///获取当前控制器
+   static func currentVc() ->UIViewController{
+        var vc = UIApplication.shared.keyWindow?.rootViewController
+
+        if (vc?.isKind(of: UITabBarController.self))! {
+            vc = (vc as! UITabBarController).selectedViewController
+        }else if (vc?.isKind(of: UINavigationController.self))!{
+            vc = (vc as! UINavigationController).visibleViewController
+        }else if ((vc?.presentedViewController) != nil){
+            vc =  vc?.presentedViewController
+        }
+            
+        return vc!
+    }
+
+}
+

+ 1 - 0
JiaPeiManage/Sources/Main/Base/BaseViewController.swift

@@ -124,4 +124,5 @@ class BaseViewController: UIViewController, NetAnimationLoadable {
     }
     
 
+    
 }

+ 36 - 0
JiaPeiManage/Sources/Models/AuthorizationDataModel.swift

@@ -0,0 +1,36 @@
+//
+//  AuthorizationDataModel.swift
+//  JiaPeiManage
+//
+//  Created by Ning.ge on 2023/8/3.
+//
+
+import ObjectMapper
+
+
+struct AuthorizationDataInfoModel : ImmutableMappable{
+    
+    var coach : UserInfo?
+    var openid : String!
+
+    init(map: Map) throws {
+        coach = try? map.value("coach")
+        openid = try map.value("openid") ?? ""
+    }
+    
+}
+
+
+struct AuthorizationDataModel : ImmutableMappable{
+
+    var code : Int!
+    var data : AuthorizationDataInfoModel!
+    var msg : String!
+
+    init(map: Map) throws {
+        code = try map.value("code") ?? 0
+        data = try map.value("data")
+        msg = try map.value("msg") ?? ""
+    }
+    
+}

+ 4 - 2
JiaPeiManage/Sources/Models/UserInfoModel.swift

@@ -156,7 +156,7 @@ struct UserInfo :ImmutableMappable,Codable{
     var address:String  = ""
     var photo:Int  = 0
     var fingerPrint:String  = ""
-    var drilicence:Int  = 0
+    var drilicence:String  = ""
     var expireTime:String  = ""
     var fstdrilicDate:String  = ""
     var occupationNo:String  = ""
@@ -190,6 +190,7 @@ struct UserInfo :ImmutableMappable,Codable{
     var isAgree:Int  = 0
     var classType:Int  = 0
     var dqbh:String  = ""
+    var openid:String  = ""
 
     var isLogin: Bool {
         set {
@@ -278,7 +279,7 @@ struct UserInfo :ImmutableMappable,Codable{
         address = try map.value("address") ?? ""
         photo = try map.value("photo") ?? 0
         fingerPrint = try map.value("fingerPrint") ?? ""
-        drilicence = try map.value("drilicence") ?? 0
+        drilicence = try map.value("drilicence") ?? ""
         expireTime = try map.value("expireTime") ?? ""
         fstdrilicDate = try map.value("fstdrilicDate") ?? ""
         occupationNo = try map.value("occupationNo") ?? ""
@@ -312,6 +313,7 @@ struct UserInfo :ImmutableMappable,Codable{
         isAgree = try map.value("isAgree") ?? 0
         classType = try map.value("classType") ?? 0
         dqbh = try map.value("dqbh") ?? ""
+        openid = try map.value("openid") ?? ""
     }
 }
 

+ 210 - 0
JiaPeiManage/Sources/Modulars/Login/Controllers/BindingViewController.swift

@@ -0,0 +1,210 @@
+//
+//  BindingViewController.swift
+//  JiaPeiManage
+//
+//  Created by Ning.ge on 2023/8/3.
+//
+
+import UIKit
+import RxSwift
+import RxCocoa
+import SwiftyUserDefaults
+
+final class BindingViewController: BaseViewController {
+    
+    // MARK: 服务属性
+    private let loginService: LoginServiceType = LoginService(networking: LoginNetworking())
+    
+    // MARK: UI属性
+    
+    // 账号
+    @IBOutlet weak var username_textField: QMUITextField!
+    //密码
+    @IBOutlet weak var userpassword_textField: QMUITextField!
+    //显示密码
+    @IBOutlet weak var pwdshow_button: QMUIButton!
+    //定位arrow
+    @IBOutlet weak var location_button: QMUIButton!
+    @IBOutlet weak var location_button_btn: UIButton!
+    //区域
+    @IBOutlet weak var userlocation_textField: QMUITextField!
+    //登录按钮
+    @IBOutlet weak var login_button: UIButton!
+    //已同意
+    @IBOutlet weak var agree_button: QMUIButton!
+
+    
+    
+    var city:String = ""
+    var cityPower:String = ""  //地区权限
+    var cityItems:[CityItem] = []
+    var citys: [String:String] = [:]
+    var selectedItemIndex = 0
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        setupUI()
+        //biand绑定
+        biandView()
+        //获取字典数据
+        loginService.dictRequest(dictType: "coach_city").subscribe(onSuccess: { [unowned self] cityItems in
+            self.cityItems = cityItems
+            for cityItem in cityItems {
+                self.citys[cityItem.dictLabel] = cityItem.dictValue
+            }
+        },onError: { Error in
+        }).disposed(by: disposeBag)
+    }
+    // MARK: 私有方法
+    func setupUI(){
+        self.view.backgroundColor = .db_theme
+//        self.username_textField.placeholderColor = .db_place
+//        self.userpassword_textField.placeholderColor = .db_place
+//        self.userlocation_textField.placeholderColor = .db_place
+    }
+    func biandView(){
+//        //判断账号的输入是否可用
+//        let accountValid = username_textField.rx.text.orEmpty.map{ value in
+//            return value.count >= 18
+//        }
+//        //判断密码的输入是否可用
+//        let passwordValid = userpassword_textField.rx.text.orEmpty.map{ value in
+//            return value.count >= 6
+//        }
+//        
+//        //判断同意
+//        let agreeValid = agree_button.rx.tap.map { [unowned self] in
+//            NSLog("agreeValid")
+//                return self.agree_button.isSelected
+//        }
+//        //同意
+//        agree_button.rx.tap.subscribe ({ [unowned self] (_)  in
+//            NSLog("tap.subscribe")
+//            self.agree_button.isSelected = !self.agree_button.isSelected
+//        }).disposed(by: disposeBag)
+//        //登录按钮的可用与否
+//        let loginObserver = Observable.combineLatest(accountValid,passwordValid,agreeValid){(account,password,agree) in
+//            account && password && agree
+//        }
+//
+//        //绑定按钮
+//        loginObserver.bind(to: login_button.rx.isEnabled).disposed(by: disposeBag)
+//        loginObserver.subscribe(onNext: { [unowned self] valid in
+//            NSLog("loginObserver")
+//            self.login_button.alpha = valid ? 1 : 0.5
+//        }).disposed(by: disposeBag)
+//        
+//        //用户协议
+//        userprotocol_button.rx.tap.subscribe ({ [unowned self] (_)  in
+//            //跳web
+//            navigator.push("https://ys.zzxcx.net/xy_jlgj.html")
+//        }).disposed(by: disposeBag)
+//        //隐私
+//        userprivacy_button.rx.tap.subscribe ({ [unowned self] (_)  in
+//            //跳web
+//            navigator.push("https://ys.zzxcx.net/xy_jlgj.html")
+//        }).disposed(by: disposeBag)
+//        //显示密码
+//        pwdshow_button.rx.tap.subscribe ({ [unowned self] (_)  in
+//            self.pwdshow_button.isSelected = !self.pwdshow_button.isSelected;
+//            self.userpassword_textField.isSecureTextEntry = !self.pwdshow_button.isSelected
+//        }).disposed(by: disposeBag)
+//        //选择区域
+//        location_button.rx.tap.subscribe ({ [unowned self] (_)  in
+//            NSLog("点击了:选择区域- \(Thread.isMainThread)")
+//            self.showDialog()
+//        }).disposed(by: disposeBag)
+//        location_button_btn.rx.tap.subscribe ({ [unowned self] (_)  in
+//            self.showDialog()
+//        }).disposed(by: disposeBag)
+//        //wxin_button
+//        wxin_button.rx.tap.subscribe ({ [unowned self] (_)  in
+//            
+//        }).disposed(by: disposeBag)
+//        //登录
+//        login_button.rx.tap
+//                    .asObservable()
+//                    .withLatestFrom(loginObserver)
+//                    .do(onNext: {
+//                        [unowned self]_ in
+//                        self.login_button.isEnabled = false
+//                        self.view.endEditing(true)
+//                    })
+//                    .subscribe(onNext: {[unowned self]isLogin in
+//                        NSLog("登录 - 登录: login %@","123")
+//                        self.login_button.isEnabled = true
+//                        //保存用户信息
+//                        var account:String = self.username_textField.text!
+//                        var password:String = self.userpassword_textField.text!
+//                        if city=="" {
+//                            NYTips.showMsg(txt: "请选择地区!")
+//                            return
+//                        }
+//                        LocalManager.userInfo.userAccount = account
+//                        LocalManager.userInfo.password = password
+//                        LocalManager.userInfo.city = city
+//                        LocalManager.userInfo.cityPower = cityPower
+//                        //登录api RX 订阅 观察 销毁 三部曲
+//                        NYTips.show()
+//                        self.loginService.loginRequest(user_name: account, user_password: password,city: city)
+//                            .subscribe(onSuccess: { userinfo in
+//                                NYTips.hide()
+//                                LocalManager.userInfo = userinfo
+//                                LocalManager.userInfo.isLogin = true //设置已经登录
+//                                NYAccountManager.shared.addUserinfo(user: userinfo)//添加用户信息
+//                                print("登录成功:%@", userinfo)
+//                                self.dismiss(animated: true)
+//                            }, onError: { error in
+//                                NYTips.hide()
+//                                NYTips.showErr(txt: (error as! RequestError).errorDescription)
+//                                print("%@",error)
+//                            })
+//                            .disposed(by: disposeBag)
+//                        
+//                    })
+//                    .disposed(by: disposeBag)
+//        //添加手势
+//        let tapBackground = UITapGestureRecognizer()
+//        tapBackground.rx.event
+//        .subscribe(onNext: { [weak self] _ in
+//            self?.view.endEditing(true)
+//        })
+//        .disposed(by: disposeBag)
+//        view.addGestureRecognizer(tapBackground)
+    }
+    
+    
+    func showDialog(){
+        
+        let dialogViewController = QMUIDialogSelectionViewController()
+        dialogViewController.title = "请选择地区"
+        dialogViewController.items = Array(citys.keys)
+        dialogViewController.selectedItemIndex = selectedItemIndex
+        dialogViewController.addCancelButton(withText: "取消", block: nil)
+        dialogViewController.addSubmitButton(withText: "确定") { [weak self] dialogViewController in
+            guard let dialogViewController:QMUIDialogSelectionViewController = dialogViewController as? QMUIDialogSelectionViewController else { return }
+            if dialogViewController.selectedItemIndex == QMUIDialogSelectionViewControllerSelectedItemIndexNone {
+                NYTips.showErr(txt: "请至少选一个")
+                return
+            }
+            self?.selectedItemIndex = dialogViewController.selectedItemIndex
+            let keyname = dialogViewController.items![self!.selectedItemIndex]
+//            self.citys[cityItem.dictLabel] = cityItem.dictValue
+            var item:CityItem?
+            for cityItem in self!.cityItems {
+                if cityItem.dictLabel == keyname {
+                    item = cityItem
+                    break
+                }
+            }
+            self?.city = item!.dictValue //编码
+            self?.cityPower = item!.remark //地区权重
+            self?.userlocation_textField.text = item?.dictLabel
+            dialogViewController.hide()
+        }
+        dialogViewController.show()
+
+    }
+
+    
+    
+}

+ 265 - 0
JiaPeiManage/Sources/Modulars/Login/Controllers/BindingViewController.xib

@@ -0,0 +1,265 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina5_9" orientation="portrait" appearance="light"/>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21678"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="System colors in document resources" minToolsVersion="11.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="BindingViewController" customModule="JiaPeiManage" customModuleProvider="target">
+            <connections>
+                <outlet property="view" destination="iN0-l3-epB" id="rnj-Vy-rbC"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB">
+            <rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dRI-X8-kQG">
+                    <rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
+                    <subviews>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="6ve-8a-5wn" userLabel="View-content">
+                            <rect key="frame" x="0.0" y="0.0" width="375" height="700"/>
+                            <subviews>
+                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="login_biand_wx" translatesAutoresizingMaskIntoConstraints="NO" id="ap2-6X-Dyy">
+                                    <rect key="frame" x="21" y="78" width="333" height="113"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="113" id="OOa-z5-Kix"/>
+                                    </constraints>
+                                    <userDefinedRuntimeAttributes>
+                                        <userDefinedRuntimeAttribute type="boolean" keyPath="aLRatio" value="YES"/>
+                                    </userDefinedRuntimeAttributes>
+                                </imageView>
+                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="eYE-nE-IRp">
+                                    <rect key="frame" x="15" y="236" width="345" height="380"/>
+                                    <subviews>
+                                        <button opaque="NO" clipsSubviews="YES" alpha="0.5" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="EJi-fK-0p4">
+                                            <rect key="frame" x="28" y="285" width="289" height="45"/>
+                                            <color key="backgroundColor" red="0.20784313730000001" green="0.74901960779999999" blue="0.36862745099999999" alpha="1" colorSpace="calibratedRGB"/>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="45" id="xlq-e0-ZlO"/>
+                                            </constraints>
+                                            <state key="normal" title="立即绑定"/>
+                                            <userDefinedRuntimeAttributes>
+                                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                    <real key="value" value="5"/>
+                                                </userDefinedRuntimeAttribute>
+                                                <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                    <real key="value" value="0.0"/>
+                                                </userDefinedRuntimeAttribute>
+                                            </userDefinedRuntimeAttributes>
+                                        </button>
+                                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="I8s-bJ-2lf" userLabel="View-input">
+                                            <rect key="frame" x="25" y="40" width="295" height="45"/>
+                                            <subviews>
+                                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="login_ID" translatesAutoresizingMaskIntoConstraints="NO" id="W1o-wo-2YQ">
+                                                    <rect key="frame" x="20" y="9.6666666666666856" width="32" height="26"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="width" constant="32" id="3dZ-sH-qMs"/>
+                                                        <constraint firstAttribute="height" constant="26" id="iOM-xd-559"/>
+                                                    </constraints>
+                                                </imageView>
+                                                <textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入身份证号" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="hP1-v2-PLq" customClass="QMUITextField">
+                                                    <rect key="frame" x="62" y="0.0" width="218" height="45"/>
+                                                    <color key="textColor" red="0.83137254900000002" green="0.86666666670000003" blue="0.90196078430000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                    <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                    <textInputTraits key="textInputTraits"/>
+                                                </textField>
+                                            </subviews>
+                                            <color key="backgroundColor" red="0.14901960780000001" green="0.28235294119999998" blue="0.41960784309999999" alpha="1" colorSpace="calibratedRGB"/>
+                                            <constraints>
+                                                <constraint firstAttribute="trailing" secondItem="hP1-v2-PLq" secondAttribute="trailing" constant="15" id="CiA-Hs-aK3"/>
+                                                <constraint firstItem="hP1-v2-PLq" firstAttribute="leading" secondItem="W1o-wo-2YQ" secondAttribute="trailing" constant="10" id="ERY-lg-8mA"/>
+                                                <constraint firstAttribute="height" constant="45" id="Kxw-Ok-anL"/>
+                                                <constraint firstItem="W1o-wo-2YQ" firstAttribute="leading" secondItem="I8s-bJ-2lf" secondAttribute="leading" constant="20" id="Tj7-4j-cMo"/>
+                                                <constraint firstAttribute="bottom" secondItem="hP1-v2-PLq" secondAttribute="bottom" id="WG8-CX-Ia9"/>
+                                                <constraint firstItem="hP1-v2-PLq" firstAttribute="top" secondItem="I8s-bJ-2lf" secondAttribute="top" id="che-jW-2xw"/>
+                                                <constraint firstItem="W1o-wo-2YQ" firstAttribute="centerY" secondItem="I8s-bJ-2lf" secondAttribute="centerY" id="jlQ-fY-j89"/>
+                                            </constraints>
+                                            <userDefinedRuntimeAttributes>
+                                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                    <real key="value" value="5"/>
+                                                </userDefinedRuntimeAttribute>
+                                            </userDefinedRuntimeAttributes>
+                                        </view>
+                                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VvG-ss-dbf" userLabel="View-input">
+                                            <rect key="frame" x="25" y="105" width="295" height="45"/>
+                                            <subviews>
+                                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="login_pwd" translatesAutoresizingMaskIntoConstraints="NO" id="opV-Bq-rHd">
+                                                    <rect key="frame" x="25" y="9.6666666666666856" width="22" height="26"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="width" constant="22" id="8Q3-74-CFB"/>
+                                                        <constraint firstAttribute="height" constant="26" id="f85-Jn-IJD"/>
+                                                    </constraints>
+                                                </imageView>
+                                                <textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入密码" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="7Yx-vl-07y" customClass="QMUITextField">
+                                                    <rect key="frame" x="61" y="0.0" width="176" height="45"/>
+                                                    <color key="textColor" red="0.83137254900000002" green="0.86666666670000003" blue="0.90196078430000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                    <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                    <textInputTraits key="textInputTraits" secureTextEntry="YES"/>
+                                                </textField>
+                                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cMu-ej-fDA" customClass="QMUIButton">
+                                                    <rect key="frame" x="247" y="0.0" width="22" height="45"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="width" constant="22" id="86J-GQ-RgS"/>
+                                                        <constraint firstAttribute="height" constant="45" id="WCc-21-B8a"/>
+                                                    </constraints>
+                                                    <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                                    <state key="normal" image="login_hide"/>
+                                                    <state key="selected" image="login_show"/>
+                                                </button>
+                                            </subviews>
+                                            <color key="backgroundColor" red="0.14901960780000001" green="0.28235294119999998" blue="0.41960784309999999" alpha="1" colorSpace="calibratedRGB"/>
+                                            <constraints>
+                                                <constraint firstAttribute="height" constant="45" id="0EF-Dr-ivw"/>
+                                                <constraint firstItem="cMu-ej-fDA" firstAttribute="leading" secondItem="7Yx-vl-07y" secondAttribute="trailing" constant="10" id="1Jp-Bh-ocb"/>
+                                                <constraint firstItem="7Yx-vl-07y" firstAttribute="top" secondItem="VvG-ss-dbf" secondAttribute="top" id="KgR-9w-ppr"/>
+                                                <constraint firstAttribute="bottom" secondItem="7Yx-vl-07y" secondAttribute="bottom" id="Mj6-Zp-Sne"/>
+                                                <constraint firstItem="opV-Bq-rHd" firstAttribute="centerY" secondItem="VvG-ss-dbf" secondAttribute="centerY" id="QTv-kb-qRy"/>
+                                                <constraint firstItem="7Yx-vl-07y" firstAttribute="leading" secondItem="opV-Bq-rHd" secondAttribute="trailing" constant="14" id="UKv-EX-7sh"/>
+                                                <constraint firstItem="cMu-ej-fDA" firstAttribute="centerY" secondItem="VvG-ss-dbf" secondAttribute="centerY" id="nY9-Rk-Vmf"/>
+                                                <constraint firstItem="opV-Bq-rHd" firstAttribute="leading" secondItem="VvG-ss-dbf" secondAttribute="leading" constant="25" id="xAX-qM-FIL"/>
+                                                <constraint firstAttribute="trailing" secondItem="cMu-ej-fDA" secondAttribute="trailing" constant="26" id="yfL-W4-rdl"/>
+                                            </constraints>
+                                            <userDefinedRuntimeAttributes>
+                                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                    <real key="value" value="5"/>
+                                                </userDefinedRuntimeAttribute>
+                                            </userDefinedRuntimeAttributes>
+                                        </view>
+                                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mVu-Hc-WdF" userLabel="View-input">
+                                            <rect key="frame" x="25" y="170" width="295" height="45"/>
+                                            <subviews>
+                                                <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="login_location" translatesAutoresizingMaskIntoConstraints="NO" id="ls0-DO-cge">
+                                                    <rect key="frame" x="25" y="9.6666666666666856" width="21" height="26"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="height" constant="26" id="bGy-wb-a4X"/>
+                                                        <constraint firstAttribute="width" constant="21" id="lDQ-wL-cih"/>
+                                                    </constraints>
+                                                </imageView>
+                                                <textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请选择地区" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="4Ib-QF-0bd" customClass="QMUITextField">
+                                                    <rect key="frame" x="64" y="5.6666666666666856" width="137" height="34"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="height" constant="34" id="IT4-al-h3z"/>
+                                                        <constraint firstAttribute="width" constant="137" id="ZH9-jy-ZeQ"/>
+                                                    </constraints>
+                                                    <color key="textColor" red="0.83137254900000002" green="0.86666666670000003" blue="0.90196078430000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                    <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                                    <textInputTraits key="textInputTraits" keyboardType="numberPad"/>
+                                                </textField>
+                                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="h2F-xd-s0h" customClass="QMUIButton">
+                                                    <rect key="frame" x="250" y="0.0" width="16" height="45"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="height" constant="45" id="DRf-zv-iyu"/>
+                                                        <constraint firstAttribute="width" constant="16" id="wzb-ht-bnf"/>
+                                                    </constraints>
+                                                    <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                                    <state key="normal" image="login_arrow"/>
+                                                    <state key="selected" image="login_arrow"/>
+                                                </button>
+                                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pvK-s6-zf7">
+                                                    <rect key="frame" x="64" y="5.6666666666666856" width="137" height="34"/>
+                                                    <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
+                                                </button>
+                                            </subviews>
+                                            <color key="backgroundColor" red="0.14901960780000001" green="0.28235294119999998" blue="0.41960784309999999" alpha="1" colorSpace="calibratedRGB"/>
+                                            <constraints>
+                                                <constraint firstItem="h2F-xd-s0h" firstAttribute="centerY" secondItem="mVu-Hc-WdF" secondAttribute="centerY" id="121-xj-UhE"/>
+                                                <constraint firstItem="ls0-DO-cge" firstAttribute="leading" secondItem="mVu-Hc-WdF" secondAttribute="leading" constant="25" id="7yX-aA-9aw"/>
+                                                <constraint firstItem="pvK-s6-zf7" firstAttribute="leading" secondItem="4Ib-QF-0bd" secondAttribute="leading" id="A6S-V5-Zwh"/>
+                                                <constraint firstItem="4Ib-QF-0bd" firstAttribute="centerY" secondItem="mVu-Hc-WdF" secondAttribute="centerY" id="SiA-yo-bhN"/>
+                                                <constraint firstItem="ls0-DO-cge" firstAttribute="centerY" secondItem="mVu-Hc-WdF" secondAttribute="centerY" id="YRY-XY-d2G"/>
+                                                <constraint firstAttribute="trailing" secondItem="h2F-xd-s0h" secondAttribute="trailing" constant="29" id="ZxH-nw-aJg"/>
+                                                <constraint firstItem="4Ib-QF-0bd" firstAttribute="leading" secondItem="ls0-DO-cge" secondAttribute="trailing" constant="18" id="aA6-yS-b5b"/>
+                                                <constraint firstItem="pvK-s6-zf7" firstAttribute="trailing" secondItem="4Ib-QF-0bd" secondAttribute="trailing" id="ewY-aV-juZ"/>
+                                                <constraint firstItem="pvK-s6-zf7" firstAttribute="top" secondItem="4Ib-QF-0bd" secondAttribute="top" id="hhs-5B-imj"/>
+                                                <constraint firstAttribute="height" constant="45" id="m3B-oQ-5gc"/>
+                                                <constraint firstItem="h2F-xd-s0h" firstAttribute="leading" secondItem="4Ib-QF-0bd" secondAttribute="trailing" constant="49" id="oyG-oC-80A"/>
+                                                <constraint firstItem="pvK-s6-zf7" firstAttribute="bottom" secondItem="4Ib-QF-0bd" secondAttribute="bottom" id="pxK-fP-BvL"/>
+                                            </constraints>
+                                            <userDefinedRuntimeAttributes>
+                                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                    <real key="value" value="5"/>
+                                                </userDefinedRuntimeAttribute>
+                                            </userDefinedRuntimeAttributes>
+                                        </view>
+                                    </subviews>
+                                    <color key="backgroundColor" red="0.043137254899999998" green="0.16862745100000001" blue="0.30196078430000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                    <constraints>
+                                        <constraint firstItem="EJi-fK-0p4" firstAttribute="leading" secondItem="eYE-nE-IRp" secondAttribute="leading" constant="28" id="0MM-4y-ZIs"/>
+                                        <constraint firstAttribute="trailing" secondItem="VvG-ss-dbf" secondAttribute="trailing" constant="25" id="5sl-BR-qAp"/>
+                                        <constraint firstItem="EJi-fK-0p4" firstAttribute="centerX" secondItem="VvG-ss-dbf" secondAttribute="centerX" id="6Ye-rz-ubj"/>
+                                        <constraint firstItem="I8s-bJ-2lf" firstAttribute="leading" secondItem="eYE-nE-IRp" secondAttribute="leading" constant="25" id="9hD-04-n5k"/>
+                                        <constraint firstItem="VvG-ss-dbf" firstAttribute="top" secondItem="I8s-bJ-2lf" secondAttribute="bottom" constant="20" id="B3J-PZ-NaE"/>
+                                        <constraint firstAttribute="bottom" secondItem="EJi-fK-0p4" secondAttribute="bottom" constant="50" id="Eeo-Xi-dj9"/>
+                                        <constraint firstItem="EJi-fK-0p4" firstAttribute="top" secondItem="mVu-Hc-WdF" secondAttribute="bottom" constant="70" id="F9R-2e-JcA"/>
+                                        <constraint firstItem="VvG-ss-dbf" firstAttribute="top" secondItem="I8s-bJ-2lf" secondAttribute="bottom" constant="20" id="Iha-K1-svL"/>
+                                        <constraint firstAttribute="trailing" secondItem="mVu-Hc-WdF" secondAttribute="trailing" constant="25" id="PB4-vT-Krg"/>
+                                        <constraint firstAttribute="trailing" secondItem="I8s-bJ-2lf" secondAttribute="trailing" constant="25" id="UuL-mQ-fx3"/>
+                                        <constraint firstAttribute="height" constant="380" id="at4-6l-amg"/>
+                                        <constraint firstItem="mVu-Hc-WdF" firstAttribute="top" secondItem="VvG-ss-dbf" secondAttribute="bottom" constant="20" id="lnu-hz-BDq"/>
+                                        <constraint firstItem="VvG-ss-dbf" firstAttribute="leading" secondItem="eYE-nE-IRp" secondAttribute="leading" constant="25" id="nGW-Ae-6fQ"/>
+                                        <constraint firstItem="EJi-fK-0p4" firstAttribute="centerX" secondItem="mVu-Hc-WdF" secondAttribute="centerX" id="p6h-QN-6o2"/>
+                                        <constraint firstItem="EJi-fK-0p4" firstAttribute="centerX" secondItem="eYE-nE-IRp" secondAttribute="centerX" id="rWa-pN-nXm"/>
+                                        <constraint firstItem="mVu-Hc-WdF" firstAttribute="leading" secondItem="eYE-nE-IRp" secondAttribute="leading" constant="25" id="sLd-SC-GHe"/>
+                                        <constraint firstItem="mVu-Hc-WdF" firstAttribute="top" secondItem="VvG-ss-dbf" secondAttribute="bottom" constant="20" id="sqp-PE-KZ6"/>
+                                        <constraint firstItem="EJi-fK-0p4" firstAttribute="centerX" secondItem="I8s-bJ-2lf" secondAttribute="centerX" id="tsf-fI-73t"/>
+                                        <constraint firstItem="I8s-bJ-2lf" firstAttribute="top" secondItem="eYE-nE-IRp" secondAttribute="top" constant="40" id="uHx-uM-x6U"/>
+                                    </constraints>
+                                    <userDefinedRuntimeAttributes>
+                                        <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                            <real key="value" value="5"/>
+                                        </userDefinedRuntimeAttribute>
+                                    </userDefinedRuntimeAttributes>
+                                </view>
+                            </subviews>
+                            <color key="backgroundColor" red="0.023529411760000001" green="0.12549019610000001" blue="0.2274509804" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                            <constraints>
+                                <constraint firstAttribute="height" constant="700" id="D8i-7f-ykn"/>
+                                <constraint firstAttribute="trailing" secondItem="eYE-nE-IRp" secondAttribute="trailing" constant="15" id="O3G-c2-N0Z"/>
+                                <constraint firstItem="eYE-nE-IRp" firstAttribute="leading" secondItem="6ve-8a-5wn" secondAttribute="leading" constant="15" id="PJr-is-kmv"/>
+                                <constraint firstAttribute="trailing" secondItem="ap2-6X-Dyy" secondAttribute="trailing" constant="21" id="edD-sm-hXs"/>
+                                <constraint firstItem="eYE-nE-IRp" firstAttribute="top" secondItem="ap2-6X-Dyy" secondAttribute="bottom" constant="45" id="fC6-Wv-rdh"/>
+                                <constraint firstItem="ap2-6X-Dyy" firstAttribute="leading" secondItem="6ve-8a-5wn" secondAttribute="leading" constant="21" id="leI-mU-NuS"/>
+                                <constraint firstItem="ap2-6X-Dyy" firstAttribute="top" secondItem="6ve-8a-5wn" secondAttribute="top" constant="78" id="qLv-bv-SKX"/>
+                            </constraints>
+                        </view>
+                    </subviews>
+                    <color key="backgroundColor" red="0.023529411760000001" green="0.12549019610000001" blue="0.2274509804" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                    <constraints>
+                        <constraint firstItem="6ve-8a-5wn" firstAttribute="leading" secondItem="dRI-X8-kQG" secondAttribute="leading" id="0Nt-Vw-HpN"/>
+                        <constraint firstItem="6ve-8a-5wn" firstAttribute="top" secondItem="dRI-X8-kQG" secondAttribute="top" id="XFJ-3d-vIB"/>
+                        <constraint firstItem="6ve-8a-5wn" firstAttribute="centerX" secondItem="dRI-X8-kQG" secondAttribute="centerX" id="g6H-E9-17L"/>
+                        <constraint firstAttribute="bottom" secondItem="6ve-8a-5wn" secondAttribute="bottom" constant="2" id="qUg-uT-xWj"/>
+                        <constraint firstAttribute="trailing" secondItem="6ve-8a-5wn" secondAttribute="trailing" id="vW6-Az-Lhc"/>
+                    </constraints>
+                </scrollView>
+            </subviews>
+            <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
+            <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+            <constraints>
+                <constraint firstItem="dRI-X8-kQG" firstAttribute="trailing" secondItem="vUN-kp-3ea" secondAttribute="trailing" id="2f3-p0-MQ5"/>
+                <constraint firstItem="dRI-X8-kQG" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="3AZ-Td-bbp"/>
+                <constraint firstAttribute="bottom" secondItem="dRI-X8-kQG" secondAttribute="bottom" id="LiF-wQ-3V7"/>
+                <constraint firstItem="dRI-X8-kQG" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="b80-aD-1Cc"/>
+            </constraints>
+            <point key="canvasLocation" x="59" y="-12"/>
+        </view>
+    </objects>
+    <resources>
+        <image name="login_ID" width="32" height="26"/>
+        <image name="login_arrow" width="16" height="12"/>
+        <image name="login_biand_wx" width="318.66665649414062" height="79"/>
+        <image name="login_hide" width="22" height="11.333333015441895"/>
+        <image name="login_location" width="21" height="26"/>
+        <image name="login_pwd" width="21.666666030883789" height="26"/>
+        <image name="login_show" width="22.333333969116211" height="13.666666984558105"/>
+        <systemColor name="systemBackgroundColor">
+            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
+    </resources>
+</document>

+ 41 - 7
JiaPeiManage/Sources/Modulars/Login/Controllers/LoginViewController.swift

@@ -108,8 +108,9 @@ final class LoginViewController: BaseViewController {
         
         //用户协议
         userprotocol_button.rx.tap.subscribe ({ [unowned self] (_)  in
+            NYSwRouter.push(NYSwPushType.login_biand_wx.path)
             //跳web
-            navigator.push("https://ys.zzxcx.net/xy_jlgj.html")
+//            navigator.push("https://ys.zzxcx.net/xy_jlgj.html")
         }).disposed(by: disposeBag)
         //隐私
         userprivacy_button.rx.tap.subscribe ({ [unowned self] (_)  in
@@ -124,14 +125,14 @@ final class LoginViewController: BaseViewController {
         //选择区域
         location_button.rx.tap.subscribe ({ [unowned self] (_)  in
             NSLog("点击了:选择区域- \(Thread.isMainThread)")
-            self.showDialog()
+            self.showDialog(type: 0)
         }).disposed(by: disposeBag)
         location_button_btn.rx.tap.subscribe ({ [unowned self] (_)  in
-            self.showDialog()
+            self.showDialog(type: 0)
         }).disposed(by: disposeBag)
         //wxin_button
         wxin_button.rx.tap.subscribe ({ [unowned self] (_)  in
-            
+            self.showDialog(type: 1)
         }).disposed(by: disposeBag)
         //登录
         login_button.rx.tap
@@ -175,6 +176,35 @@ final class LoginViewController: BaseViewController {
                         
                     })
                     .disposed(by: disposeBag)
+                        
+        //获取wx绑定
+        NYWXApiManager.shared.blockSubject.subscribe(onNext: {[unowned self] code in
+            NYTips.show()
+            self.loginService.authorizationRequest(code: code, city: NYWXApiManager.shared.city).subscribe(onSuccess: {[unowned self] model in
+                NYTips.hide()
+                //判断是否有 openid
+                let data = model.data as AuthorizationDataInfoModel
+                if data.openid == "" {
+                    //已经绑定直接登录
+                    LocalManager.userInfo.userAccount = data.coach?.idcard
+                    LocalManager.userInfo.password = data.coach?.password
+                    LocalManager.userInfo.city = self.city
+                    LocalManager.userInfo.cityPower = self.cityPower
+                    LocalManager.userInfo = data.coach!
+                    LocalManager.userInfo.isLogin = true //设置已经登录
+                    NYAccountManager.shared.addUserinfo(user: data.coach!)//添加用户信息
+                    self.dismiss(animated: true)
+                }else{
+                    //未绑定-跳转绑定
+                    NYSwRouter.push(NYSwPushType.login_biand_wx.path)
+                }
+            }, onError: { error in
+                NYTips.hide()
+                //NYTips.showErr(txt: (error as! RequestError).errorDescription)
+                print("%@",error)
+            })
+            .disposed(by: disposeBag)
+        }).disposed(by: disposeBag)
         //添加手势
         let tapBackground = UITapGestureRecognizer()
         tapBackground.rx.event
@@ -186,7 +216,7 @@ final class LoginViewController: BaseViewController {
     }
     
     
-    func showDialog(){
+    func showDialog(type:Int){
         
         let dialogViewController = QMUIDialogSelectionViewController()
         dialogViewController.title = "请选择地区"
@@ -211,13 +241,17 @@ final class LoginViewController: BaseViewController {
             }
             self?.city = item!.dictValue //编码
             self?.cityPower = item!.remark //地区权重
+            if (type==1){//微信登录
+                let city = item!.dictValue //编码
+                NYWXApiManager.shared.sendWxapi(city: city)
+                dialogViewController.hide()
+                return
+            }
             self?.userlocation_textField.text = item?.dictLabel
             dialogViewController.hide()
         }
         dialogViewController.show()
 
     }
-
-    
     
 }

+ 38 - 2
JiaPeiManage/Sources/Services/LoginAPI.swift

@@ -15,6 +15,12 @@ enum LoginAPI {
     case updateUser(user_name:String, user_password:String, new_password:String,city:String)
     //根据字典类型查询字典数据信息
     case dictUser(dictType:String)
+    //授权
+    case authorizationCode(code:String,city:String)
+    //绑定
+    case biandUser(idcard:String, user_password:String, openid:String,city:String)
+    //解绑
+    case unbiandUser(idcard:String, user_password:String, city:String)
     
 }
 
@@ -23,7 +29,8 @@ extension LoginAPI: TargetType {
     var isShowLoading:Bool { return true }
     var baseURL: URL {
         switch self {
-        case .loginUser,.updateUser,.dictUser:
+        case .loginUser,.updateUser,.dictUser
+            ,.authorizationCode,.biandUser,.unbiandUser:
             return URL(string: HttpRequest.api.path)!
         }
     }
@@ -34,6 +41,12 @@ extension LoginAPI: TargetType {
             return "/jsjp-admin/open-api/tms/coachInfo/coachInfoLogin"
         case .updateUser(_,_,_,_):
             return "/jsjp-admin/open-api/tms/coachInfo/updateCoachPassword"
+        case .authorizationCode(_,_):
+            return "/jsjp-admin/login/code"
+        case .biandUser(_,_,_,_):
+            return "/jsjp-admin/open-api/tms/coachInfo/bindCoachOpenid"
+        case .unbiandUser(_,_,_):
+            return "/jsjp-admin/open-api/tms/coachInfo/unBindCoachOpenid"
         case .dictUser(_):
             if let parameters = parameters {
                 return "/jsjp-admin/open-api/gzpt/userInfo/type/\(parameters["dictType"] ?? "")"
@@ -48,6 +61,12 @@ extension LoginAPI: TargetType {
             return .get
         case .updateUser:
             return .put
+        case .biandUser:
+            return .put
+        case .unbiandUser:
+            return .put
+        case .authorizationCode:
+            return .post
         default:
             return .get
         }
@@ -71,12 +90,17 @@ extension LoginAPI: TargetType {
             return .requestPlain
         case .dictUser(_):
             return .requestPlain
+        default :
+            if let parameters = parameters {
+                return .requestParameters(parameters: parameters, encoding: URLEncoding.default)
+            }
+            return .requestPlain
         }
     }
     
     var headers: [String: String]? {
         switch self {
-        case .updateUser:
+        case .updateUser,.authorizationCode:
             return ["Content-Type":"application/x-www-form-urlencoded"]
         default:
             return ["Content-Type":"application/json"]
@@ -95,6 +119,18 @@ extension LoginAPI: TargetType {
                     "idcard": user_name,
                     "password":user_password,
                     "newPassword":new_password,]
+        case let .authorizationCode(code, city):
+            return ["authorizationCode": code,
+                    "city": city,]
+        case let .biandUser(idcard, user_password, openid, city):
+            return ["idcard": idcard,
+                    "password": user_password,
+                    "openid": openid,
+                    "city": city,]
+        case let .unbiandUser(idcard, user_password, city):
+            return ["idcard": idcard,
+                    "password": user_password,
+                    "city": city,]
         case let .dictUser(dictType):
             return ["dictType": dictType]
         default:

+ 23 - 1
JiaPeiManage/Sources/Services/LoginService.swift

@@ -17,10 +17,17 @@ protocol LoginServiceType {
     
     func dictRequest(dictType:String) -> Single<[CityItem]>
     
+    //授权
+    func authorizationRequest(code: String, city:String) -> Single<AuthorizationDataModel>
+    //绑定
+    func biandUserRequest(idcard:String, user_password:String, openid:String,city:String) -> Single<AuthorizationDataModel>
+    //解绑
+    func unbiandUserRequest(idcard:String, user_password:String, city:String) -> Single<AuthorizationDataModel>
+    
 }
 
 final class LoginService: LoginServiceType {
-
+    
     private let networking : LoginNetworking
     
     init(networking: LoginNetworking) {
@@ -45,4 +52,19 @@ final class LoginService: LoginServiceType {
         let api = LoginAPI.dictUser(dictType: dictType)
         return networking.request(api).map(CityItem.self)
     }
+    
+    func authorizationRequest(code: String, city: String) -> RxSwift.Single<AuthorizationDataModel> {
+        let api = LoginAPI.authorizationCode(code: code, city: city)
+        return networking.request(api).map(AuthorizationDataModel.self,isModel: true)
+    }
+    
+    func biandUserRequest(idcard: String, user_password: String, openid: String, city: String) -> RxSwift.Single<AuthorizationDataModel> {
+        let api = LoginAPI.biandUser(idcard: idcard, user_password: user_password, openid: openid, city: city)
+        return networking.request(api).map(AuthorizationDataModel.self,isModel: true)
+    }
+    
+    func unbiandUserRequest(idcard: String, user_password: String, city: String) -> RxSwift.Single<AuthorizationDataModel> {
+        let api = LoginAPI.unbiandUser(idcard: idcard, user_password: user_password, city: city)
+        return networking.request(api).map(AuthorizationDataModel.self,isModel: true)
+    }
 }

+ 7 - 2
JiaPeiManage/Sources/Utils/NYAccountManager.swift

@@ -22,7 +22,7 @@ struct AccountInfo :ImmutableMappable,Codable{
     var address:String  = ""
     var photo:Int  = 0
     var fingerPrint:String  = ""
-    var drilicence:Int  = 0
+    var drilicence:String  = ""
     var expireTime:String  = ""
     var fstdrilicDate:String  = ""
     var occupationNo:String  = ""
@@ -57,6 +57,7 @@ struct AccountInfo :ImmutableMappable,Codable{
     var password:String = ""
     var city:String = ""
     var cityPower:String = ""
+    var openid:String = ""
     
     // Implement the encode(to:) method to specify how the object should be encoded
     func encode(to encoder: Encoder) throws {
@@ -70,6 +71,7 @@ struct AccountInfo :ImmutableMappable,Codable{
         try container.encode(city, forKey: .city)
         try container.encode(cityPower, forKey: .cityPower)
         try container.encode(dqbh, forKey: .dqbh)
+        try container.encode(openid, forKey: .openid)
     }
 
     enum CodingKeys: String, CodingKey {
@@ -82,6 +84,7 @@ struct AccountInfo :ImmutableMappable,Codable{
         case city
         case cityPower
         case dqbh
+        case openid
     }
     
     init(from decoder: Decoder) throws {
@@ -95,6 +98,7 @@ struct AccountInfo :ImmutableMappable,Codable{
         city = try container.decode(String.self, forKey: .city)
         cityPower = try container.decode(String.self, forKey: .cityPower)
         dqbh = try container.decode(String.self, forKey: .dqbh)
+        openid = try container.decode(String.self, forKey: .openid)
     }
     
     init(){}
@@ -111,7 +115,7 @@ struct AccountInfo :ImmutableMappable,Codable{
         address = try map.value("address") ?? ""
         photo = try map.value("photo") ?? 0
         fingerPrint = try map.value("fingerPrint") ?? ""
-        drilicence = try map.value("drilicence") ?? 0
+        drilicence = try map.value("drilicence") ?? ""
         expireTime = try map.value("expireTime") ?? ""
         fstdrilicDate = try map.value("fstdrilicDate") ?? ""
         occupationNo = try map.value("occupationNo") ?? ""
@@ -144,6 +148,7 @@ struct AccountInfo :ImmutableMappable,Codable{
         classType = try map.value("classType") ?? 0
         dqbh = try map.value("dqbh") ?? ""
         password = try map.value("password") ?? ""
+        openid = try map.value("openid") ?? ""
     }
 }
 

+ 3 - 0
JiaPeiManage/Sources/Utils/NYSwRouter.swift

@@ -22,6 +22,7 @@ enum NYSwPushType {
     case trainee_statistics_official
     case coach_qrcode
     case coach_qrcode_download
+    case login_biand_wx
 }
 
 
@@ -60,6 +61,8 @@ extension NYSwPushType {
             return "JiaPeiManage://me/coach/qrcode"
         case .coach_qrcode_download:
             return "JiaPeiManage://me/coach/qrcode/download"
+        case .login_biand_wx:
+            return "JiaPeiManage://login/coach/biand/wx"
         }
     }
 }

+ 60 - 7
JiaPeiManage/Sources/Utils/NYWXApiManager.swift

@@ -7,11 +7,14 @@
 
 import Foundation
 import SwiftyJSON
-
+import RxSwift
 
 class NYWXApiManager : NSObject {
-
     
+    //rxcode 回调
+    let blockSubject = PublishSubject<String>()
+    var city:String = ""
+    var code:String = ""
     // 静态属性,用于存储单例实例
     static let shared = NYWXApiManager()
     override init() {
@@ -19,16 +22,42 @@ class NYWXApiManager : NSObject {
     }
     
     func registerApp(){
+        //在register之前打开log, 后续可以根据log排查问题
+        WXApi.startLog(by: WXLogLevel.detail) { log in
+            NSLog("WeChatSDK: %@", log);
+        }
         //微信绑定
         let isSuccess = WXApi.registerApp(NYMacros.wxappid, universalLink: NYMacros.universalLink)
         if  isSuccess {
             print("微信初始化成功")
         }
+        //调用自检函数
+        WXApi.checkUniversalLinkReady { step, result in
+            print("%@, %u, %@, %@", step, result.success, result.errorInfo, result.suggestion)
+        }
     }
     
     //发起微信send
-    func sendWxapi(){
-        
+    func sendWxapi(city:String){
+        self.city = city
+        if WXApi.isWXAppInstalled() {
+             let rep = SendAuthReq()
+             //这两个参数 可以照抄 第一个是固定的,第二个随意写
+             rep.scope = "snsapi_userinfo"
+             rep.state = "wx_oauth_authorization_state"
+             WXApi.send(rep, completion: nil)
+           }
+        else {
+            //未安装跳网页
+            let rep = SendAuthReq()
+            //这两个参数 可以照抄 第一个是固定的,第二个随意写
+            rep.scope = "snsapi_userinfo"
+            rep.state = "wx_oauth_authorization_state"
+            DispatchQueue.main.async {
+                let vc = NYWindow.currentVc()
+                WXApi.sendAuthReq(rep, viewController: vc, delegate: self)
+            }
+        }
     }
     
     func handleOpenUrl(url:URL){
@@ -43,13 +72,37 @@ class NYWXApiManager : NSObject {
 
 extension NYWXApiManager :WXApiDelegate {
 
-    // WXApiDelegate method (you should implement this as per your requirement)
+    //MARK:微信回调
     func onResp(_ resp: BaseResp) {
-        // Handle WeChat SDK responses here
+        if resp.isKind(of: PayResp.self) {
+         //这里是微信支付的回调
+        }  else if resp.isKind(of: SendAuthResp.self)        {
+         //这里是授权登录的回调
+            let aresp = resp as! SendAuthResp
+            DispatchQueue.main.async { [unowned self] in
+                if aresp.errCode == 0 {
+                    if let code = aresp.code {
+                        self.code = code
+                        //这里拿到code之后 对接服务器接口
+                        //这步 相当于账号密码登录的流程 返回用户信息
+                        //后端这个接口返回的数据需要判断是第一次授权还是 不是第一次授权,第一次授权需要去绑定手机号界面,不是第一次授权就直接跳转到首页,登录成功
+                        //如果是第一次授权,服务器再给个绑定手机号的接口
+                        //大概就这个流程
+                        self.blockSubject.onNext(code) //发送rx消息
+                    }
+                    else {
+                        NYTips.showMsg(txt: "微信授权失败")
+                    }
+                }
+                else {
+                    NYTips.showMsg(txt: "微信授权失败")
+                }
+            }
+        }
     }
     
     func onReq(_ req: BaseReq) {
-        
+        print("%@",req)
     }
 }
 

+ 5 - 0
JiaPeiManage/Sources/Utils/URLNavigationMap.swift

@@ -109,6 +109,11 @@ final class URLNavigationMap {
             
             return switchAccountViewController
         }
+        navigator.register(NYSwPushType.login_biand_wx.path) { (url, values, context) -> UIViewController? in
+
+            let bindingViewController = BindingViewController(nibName: "BindingViewController")
+            return bindingViewController ?? UIViewController()
+        }
         
         //open api
         navigator.register("http://<path:_>",self.webViewControllerFactory)