Browse Source

启动页修改 以及其他资源修改

main
jasonsyf 1 year ago
parent
commit
0e010355e8
25 changed files with 501 additions and 54 deletions
  1. 1
    1
      iOSFirst.xcodeproj/xcuserdata/sunyufeng.xcuserdatad/xcschemes/xcschememanagement.plist
  2. 1
    0
      iOSFirst/Assets.xcassets/AppIcon.appiconset/Contents.json
  3. BIN
      iOSFirst/Assets.xcassets/AppIcon.appiconset/LOGO.png
  4. 23
    0
      iOSFirst/Assets.xcassets/app_logo.imageset/Contents.json
  5. BIN
      iOSFirst/Assets.xcassets/app_logo.imageset/图层 1.png
  6. BIN
      iOSFirst/Assets.xcassets/app_logo.imageset/图层 2.png
  7. BIN
      iOSFirst/Assets.xcassets/app_logo.imageset/图层 3.png
  8. 3
    1
      iOSFirst/Assets.xcassets/splash.imageset/Contents.json
  9. BIN
      iOSFirst/Assets.xcassets/splash.imageset/首页.png
  10. BIN
      iOSFirst/Assets.xcassets/splash.imageset/首页@2x.png
  11. BIN
      iOSFirst/Assets.xcassets/splash.imageset/首页@3x.png
  12. 8
    21
      iOSFirst/Launch Screen.storyboard
  13. 3
    1
      iOSFirst/Preview Content/Preview Assets.xcassets/Image.imageset/Contents.json
  14. BIN
      iOSFirst/Preview Content/Preview Assets.xcassets/Image.imageset/首页.png
  15. BIN
      iOSFirst/Preview Content/Preview Assets.xcassets/Image.imageset/首页@2x.png
  16. BIN
      iOSFirst/Preview Content/Preview Assets.xcassets/Image.imageset/首页@3x.png
  17. BIN
      iOSFirst/Preview Content/Preview Assets.xcassets/simulator_screenshot_1E921C5D-2C8A-4A9D-B20A-A5C48CD914E2.imageset/simulator_screenshot_1E921C5D-2C8A-4A9D-B20A-A5C48CD914E2.png
  18. BIN
      iOSFirst/Preview Content/Preview Assets.xcassets/截屏2022-12-20 23.22.36.imageset/截屏2022-12-20 23.22.36.png
  19. 13
    2
      iOSFirst/iOSFirstApp.swift
  20. 111
    0
      iOSFirst/login/LoginUserInfo.swift
  21. 32
    28
      iOSFirst/login/LoginView.swift
  22. 101
    0
      iOSFirst/login/LoginViewModel.swift
  23. 2
    0
      iOSFirst/login/Model.xcdatamodeld/Model.xcdatamodel/contents
  24. 139
    0
      iOSFirst/network/API.swift
  25. 64
    0
      iOSFirst/network/service/AccountService.swift

+ 1
- 1
iOSFirst.xcodeproj/xcuserdata/sunyufeng.xcuserdatad/xcschemes/xcschememanagement.plist View File

@@ -7,7 +7,7 @@
7 7
 		<key>iOSFirst.xcscheme_^#shared#^_</key>
8 8
 		<dict>
9 9
 			<key>orderHint</key>
10
-			<integer>15</integer>
10
+			<integer>18</integer>
11 11
 		</dict>
12 12
 	</dict>
13 13
 </dict>

+ 1
- 0
iOSFirst/Assets.xcassets/AppIcon.appiconset/Contents.json View File

@@ -1,6 +1,7 @@
1 1
 {
2 2
   "images" : [
3 3
     {
4
+      "filename" : "LOGO.png",
4 5
       "idiom" : "universal",
5 6
       "platform" : "ios",
6 7
       "size" : "1024x1024"

BIN
iOSFirst/Assets.xcassets/AppIcon.appiconset/LOGO.png View File


+ 23
- 0
iOSFirst/Assets.xcassets/app_logo.imageset/Contents.json View File

@@ -0,0 +1,23 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "图层 1.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "filename" : "图层 3.png",
10
+      "idiom" : "universal",
11
+      "scale" : "2x"
12
+    },
13
+    {
14
+      "filename" : "图层 2.png",
15
+      "idiom" : "universal",
16
+      "scale" : "3x"
17
+    }
18
+  ],
19
+  "info" : {
20
+    "author" : "xcode",
21
+    "version" : 1
22
+  }
23
+}

BIN
iOSFirst/Assets.xcassets/app_logo.imageset/图层 1.png View File


BIN
iOSFirst/Assets.xcassets/app_logo.imageset/图层 2.png View File


BIN
iOSFirst/Assets.xcassets/app_logo.imageset/图层 3.png View File


iOSFirst/Preview Content/Preview Assets.xcassets/simulator_screenshot_1E921C5D-2C8A-4A9D-B20A-A5C48CD914E2.imageset/Contents.json → iOSFirst/Assets.xcassets/splash.imageset/Contents.json View File

@@ -1,15 +1,17 @@
1 1
 {
2 2
   "images" : [
3 3
     {
4
+      "filename" : "首页.png",
4 5
       "idiom" : "universal",
5 6
       "scale" : "1x"
6 7
     },
7 8
     {
8
-      "filename" : "simulator_screenshot_1E921C5D-2C8A-4A9D-B20A-A5C48CD914E2.png",
9
+      "filename" : "首页@2x.png",
9 10
       "idiom" : "universal",
10 11
       "scale" : "2x"
11 12
     },
12 13
     {
14
+      "filename" : "首页@3x.png",
13 15
       "idiom" : "universal",
14 16
       "scale" : "3x"
15 17
     }

BIN
iOSFirst/Assets.xcassets/splash.imageset/首页.png View File


BIN
iOSFirst/Assets.xcassets/splash.imageset/首页@2x.png View File


BIN
iOSFirst/Assets.xcassets/splash.imageset/首页@3x.png View File


+ 8
- 21
iOSFirst/Launch Screen.storyboard View File

@@ -15,34 +15,21 @@
15 15
                         <rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
16 16
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
17 17
                         <subviews>
18
-                            <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd" userLabel="就是玩">
19
-                                <rect key="frame" x="0.0" y="832" width="393" height="0.0"/>
20
-                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
21
-                                <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
22
-                                <nil key="highlightedColor"/>
23
-                            </label>
24
-                            <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="哈哈哈这是启动页" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
25
-                                <rect key="frame" x="0.0" y="263.66666666666669" width="393" height="43"/>
26
-                                <fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
27
-                                <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
28
-                                <nil key="highlightedColor"/>
29
-                            </label>
18
+                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" fixedFrame="YES" image="splash" translatesAutoresizingMaskIntoConstraints="NO" id="hRc-gQ-Ggl">
19
+                                <rect key="frame" x="0.0" y="59" width="393" height="759"/>
20
+                                <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
21
+                            </imageView>
30 22
                         </subviews>
31 23
                         <viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
32 24
                         <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
33
-                        <constraints>
34
-                            <constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
35
-                            <constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="GJd-Yh-RWb" secondAttribute="centerX" id="Q3B-4B-g5h"/>
36
-                            <constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" symbolic="YES" id="SfN-ll-jLj"/>
37
-                            <constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
38
-                            <constraint firstItem="GJd-Yh-RWb" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="bottom" multiplier="1/3" constant="1" id="moa-c2-u7t"/>
39
-                            <constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" symbolic="YES" id="x7j-FC-K8j"/>
40
-                        </constraints>
41 25
                     </view>
42 26
                 </viewController>
43 27
                 <placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
44 28
             </objects>
45
-            <point key="canvasLocation" x="53" y="375"/>
29
+            <point key="canvasLocation" x="52.671755725190835" y="374.64788732394368"/>
46 30
         </scene>
47 31
     </scenes>
32
+    <resources>
33
+        <image name="splash" width="399" height="639"/>
34
+    </resources>
48 35
 </document>

iOSFirst/Preview Content/Preview Assets.xcassets/截屏2022-12-20 23.22.36.imageset/Contents.json → iOSFirst/Preview Content/Preview Assets.xcassets/Image.imageset/Contents.json View File

@@ -1,15 +1,17 @@
1 1
 {
2 2
   "images" : [
3 3
     {
4
+      "filename" : "首页.png",
4 5
       "idiom" : "universal",
5 6
       "scale" : "1x"
6 7
     },
7 8
     {
8
-      "filename" : "截屏2022-12-20 23.22.36.png",
9
+      "filename" : "首页@2x.png",
9 10
       "idiom" : "universal",
10 11
       "scale" : "2x"
11 12
     },
12 13
     {
14
+      "filename" : "首页@3x.png",
13 15
       "idiom" : "universal",
14 16
       "scale" : "3x"
15 17
     }

BIN
iOSFirst/Preview Content/Preview Assets.xcassets/Image.imageset/首页.png View File


BIN
iOSFirst/Preview Content/Preview Assets.xcassets/Image.imageset/首页@2x.png View File


BIN
iOSFirst/Preview Content/Preview Assets.xcassets/Image.imageset/首页@3x.png View File


BIN
iOSFirst/Preview Content/Preview Assets.xcassets/simulator_screenshot_1E921C5D-2C8A-4A9D-B20A-A5C48CD914E2.imageset/simulator_screenshot_1E921C5D-2C8A-4A9D-B20A-A5C48CD914E2.png View File


BIN
iOSFirst/Preview Content/Preview Assets.xcassets/截屏2022-12-20 23.22.36.imageset/截屏2022-12-20 23.22.36.png View File


+ 13
- 2
iOSFirst/iOSFirstApp.swift View File

@@ -7,13 +7,24 @@
7 7
 
8 8
 import SwiftUI
9 9
 
10
+class AppDelegate: NSObject, UIApplicationDelegate {
11
+    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
12
+        Thread.sleep(forTimeInterval: 2)
13
+        return true
14
+    }
15
+    func applicationDidReceiveMemoryWarning(_ application: UIApplication) {
16
+        print("log-DidReceiveMemoryWarning")
17
+    }
18
+}
19
+
10 20
 @main
11 21
 struct iOSFirstApp: App {
12
-    
22
+    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
13 23
     var body: some Scene {
14 24
         WindowGroup {
15
-            ContentView()
25
+            LoginView()
16 26
             SUIToastViewContainer(stackOverlap: .overlap)
17 27
         }
18 28
     }
29
+    
19 30
 }

+ 111
- 0
iOSFirst/login/LoginUserInfo.swift View File

@@ -0,0 +1,111 @@
1
+//
2
+//  LoginUserInfo.swift
3
+//  iOSFirst
4
+//
5
+//  Created by 孙宇峰 on 2023/2/3.
6
+//
7
+
8
+import Foundation
9
+import HandyJSON
10
+
11
+class LoginUserInfo: HandyJSON{
12
+    
13
+        //用户表
14
+        var userid:Int?
15
+        
16
+        //姓名
17
+        var username:String?
18
+        
19
+        //登录帐号
20
+        var  loginname:String?
21
+        
22
+        //登录密码
23
+        var  loginpwd:String?
24
+        
25
+        //学生学号
26
+        var  studentno:String?
27
+        
28
+        //用户手机号
29
+        var  userphone:String?
30
+        
31
+        //出生日期
32
+        var  userbirthday:Int?
33
+        
34
+        //身份证号
35
+        var  cardid:String?
36
+        
37
+        //头像地址
38
+        var  headpic:String?
39
+        
40
+        //用户类型999超级管理员0学校管理员1老师2学生
41
+        var  usertype:Int?
42
+        
43
+        //用户状态1正常2删除
44
+        var  userstate:Int?
45
+        
46
+        //是否绑定硬件地址0不绑定1绑定
47
+        var  bindmac:Int?
48
+        
49
+        //硬件地址
50
+        var  mac:String?
51
+        
52
+        //硬件地址绑定的帐号
53
+        var  macname:String?
54
+        
55
+        //学校是否绑定硬件地址0不绑定1绑定
56
+        var  sbindmac:Int?
57
+        
58
+        //操作密码(教师操作密码)
59
+        var  opepassword:String?
60
+        
61
+        //创建人id
62
+        var  createid:Int?
63
+        
64
+        //创建人姓名
65
+        var  createname:String?
66
+        
67
+        //创建时间
68
+        var  createtime:Int?
69
+        
70
+        //删除人id
71
+        var  deleteid:Int?
72
+        
73
+        //删除时间
74
+        var  deletetime:Int?
75
+        
76
+        //学校id
77
+        var  schoolid:Int?
78
+        
79
+        var  schoolname:String?
80
+        
81
+        //学校阶段1小学2初中3高中4大学
82
+        var  schoollevel:Int?
83
+        
84
+        //学校状态1正常10删除
85
+        var  schoolstate:Int?
86
+        
87
+        //错误率%
88
+        var  errorrate:Int?
89
+        
90
+        //当前年份
91
+        var  year:Int?
92
+        
93
+        //性别1男2女
94
+        var  usersex:Int?
95
+        
96
+        //区域码
97
+        var  cloudcode:String?
98
+        
99
+        //班级id
100
+        var  classid:Int?
101
+        
102
+        //
103
+        var  xznum:Int?
104
+
105
+        // token
106
+        var  token_value:String?
107
+    
108
+        required init(){}
109
+
110
+}
111
+

iOSFirst/ContentView.swift → iOSFirst/login/LoginView.swift View File

@@ -7,8 +7,11 @@
7 7
 
8 8
 import SwiftUI
9 9
 
10
-struct ContentView: View {
10
+struct LoginView: View {
11
+   
12
+    
11 13
     var body: some View {
14
+        
12 15
         VStack(alignment:.leading,spacing: 0) {
13 16
             HStack{
14 17
                 Spacer()
@@ -27,16 +30,17 @@ struct ContentView: View {
27 30
             
28 31
             
29 32
             HStack{
30
-                Text("logo")
31
-                    .foregroundColor(.gray)
32
-                    .font(.system(size: 30))
33
-                    .multilineTextAlignment(.center)
34
-                    .bold()
33
+                Image("app_logo")
34
+                    .imageScale(.large)
35
+                    .foregroundColor(.accentColor)
36
+                    .scaledToFit()
37
+                    .frame(width: 40)
38
+                
35 39
                 Image("txtlogo")
36 40
                     .imageScale(.large)
37 41
                     .foregroundColor(.accentColor)
38 42
                     .frame(width: 240,height: 35)
39
-            }
43
+            }.frame(height: 40)
40 44
             .padding(.top,20)
41 45
             .padding(.bottom,100)
42 46
             
@@ -80,10 +84,10 @@ struct ContentView: View {
80 84
                         let msg="点击了登录按钮"
81 85
                         print(msg)
82 86
                         SUIToast.show(messageItem: .init(
83
-                                            message: msg,
84
-                                            bgColor: .gray,
85
-                                            messageColor: .white
86
-                                        ))
87
+                            message: msg,
88
+                            bgColor: .gray,
89
+                            messageColor: .white
90
+                        ))
87 91
                     }) {
88 92
                         Text("登录")
89 93
                             .font(.system(size: 17))
@@ -96,7 +100,7 @@ struct ContentView: View {
96 100
                     }
97 101
                     
98 102
                 }
99
-                	
103
+                
100 104
             }
101 105
             
102 106
             HStack{
@@ -104,20 +108,20 @@ struct ContentView: View {
104 108
                     let msg="点击了验证码登录"
105 109
                     print(msg)
106 110
                     SUIToast.show(messageItem: .init(
107
-                                        message: msg,
108
-                                        bgColor: .gray,
109
-                                        messageColor: .white
110
-                                    ))
111
+                        message: msg,
112
+                        bgColor: .gray,
113
+                        messageColor: .white
114
+                    ))
111 115
                 }
112 116
                 Spacer ()
113 117
                 Text("忘记密码?").font(.system(size:15)).onTapGesture {
114 118
                     let msg="点击了密码"
115 119
                     print(msg)
116 120
                     SUIToast.show(messageItem: .init(
117
-                                        message: msg,
118
-                                        bgColor: .gray,
119
-                                        messageColor: .white
120
-                                    ))
121
+                        message: msg,
122
+                        bgColor: .gray,
123
+                        messageColor: .white
124
+                    ))
121 125
                     
122 126
                     
123 127
                 }.padding(.vertical,20).font(.system(size: 15))
@@ -125,17 +129,17 @@ struct ContentView: View {
125 129
                 
126 130
             }
127 131
             Spacer()
128
-        
132
+            
129 133
         }.padding()
130
-        .frame(width: .infinity,height: .infinity)
134
+            .frame(width: .infinity,height: .infinity)
131 135
     }
132 136
     
133 137
 }
134
-    
135
-    struct ContentView_Previews: PreviewProvider {
136
-        static var previews: some View {
137
-            ContentView()
138
-        }
138
+
139
+struct ContentView_Previews: PreviewProvider {
140
+    static var previews: some View {
141
+        LoginView()
139 142
     }
140
-    
143
+}
144
+
141 145
 

+ 101
- 0
iOSFirst/login/LoginViewModel.swift View File

@@ -0,0 +1,101 @@
1
+////
2
+////  LoginViewModel.swift
3
+////  iOSFirst
4
+////
5
+////  Created by 孙宇峰 on 2023/2/3.
6
+////
7
+//
8
+//import Foundation
9
+//import Moya
10
+//import RxSwift
11
+//import RxCocoa
12
+//import RxRelay
13
+//
14
+//struct LoginViewModel  {
15
+//
16
+//    struct Input {
17
+//        private let service:MoyaProvider<AccountService>
18
+//        let loginTrigger: PublishSubject<Void>
19
+//    }
20
+//
21
+//    struct Output {
22
+//    }
23
+//
24
+//    // 用户名称
25
+//    let username = BehaviorRelay(value: "admin")
26
+//    // 用户密码
27
+//    let password = BehaviorRelay(value: "123456")
28
+//
29
+//   
30
+//
31
+//    // 当前用户信息保存
32
+//    var userInfoSaved = PublishSubject<Void>()
33
+//
34
+//    func transform(input: Input) -> Output {
35
+//        let result = input.self.service.rx.request(AccountService.login(username, password, true))
36
+//                    .map(BaseModel<LoginUserInfo>.self)
37
+//                    .map{ $0.data }
38
+//                    .compactMap { $0 }
39
+//                    .asObservable()
40
+//                    .asSingle()
41
+//        let loginRequest = input.loginTrigger.flatMapLatest { [weak self] in
42
+//            guard let self = self else { return Observable.just(RxSwift.Event.next(TokenEnhancer())) }
43
+//            return self.httpRequest.requestAccessToken(username: self.username.value, password: self.password.value)
44
+//                .trackActivity(self.loading)
45
+//                .materialize()
46
+//        }.share()
47
+//
48
+//        // 登录成功
49
+//        loginRequest.elements().subscribe(onNext: { [weak self] tokenEnhancer in
50
+//            AuthManager.setTokenEnhancer(tokenEnhancer: tokenEnhancer)
51
+//            self?.userInfoSaved.onNext(())
52
+//        }).disposed(by: rx.disposeBag)
53
+//
54
+//        // 获取当前用户信息
55
+//        let getUserInfo = userInfoSaved.flatMapLatest { [weak self] in
56
+//            guard let self = self else { return Observable.just(RxSwift.Event.next(BaseResultResponseObject<User>())) }
57
+//            return self.httpRequest.getUserInfo()
58
+//                .trackActivity(self.loading)
59
+//                .materialize()
60
+//        }.share()
61
+//
62
+//        // 获取用户成功
63
+//        getUserInfo.elements().subscribe(onNext: { [weak self] result in
64
+//            guard let self = self else { return }
65
+//            if result.code == result.SUCCESS, let user = result.data {
66
+//                user.saveUserInfo()
67
+//                let application: Application = DIContainer.shared.resolve()
68
+//                let homeTabBarVC: HomeTabBarViewController = HomeTabBarViewController(viewModel: HomeTabBarViewModel())
69
+//                let initialSplitVC: InitialSplitViewController = InitialSplitViewController(viewModel: nil)
70
+//                let navigationC = NavigationController(rootViewController: initialSplitVC)
71
+//                let splitVC = SplitViewController()
72
+//                splitVC.viewControllers = [homeTabBarVC, navigationC]
73
+//
74
+//                // xxx:临时解决方案 RAMAnimatedTabBarController 首次加载需适配当前设备,会导致短暂闪白,延长动画时间
75
+//                UIView.transition(with: application.window!,
76
+//                                  duration: UserDefaults.standard.integer(forKey: Configs.CacheKey.firstLoadKey) == 0 ? 2.3 : 0.5,
77
+//                                  options: .transitionCrossDissolve, animations: {
78
+//                    application.window!.rootViewController = splitVC
79
+//                }, completion: nil)
80
+//
81
+//                // 更新首次加载状态
82
+//                if UserDefaults.standard.integer(forKey: Configs.CacheKey.firstLoadKey) == 0 {
83
+//                    UserDefaults.standard.set(1, forKey: Configs.CacheKey.firstLoadKey)
84
+//                }
85
+//            } else {
86
+//                self.requestError.onNext(ApiError(result.code, result.msg))
87
+//            }
88
+//        }).disposed(by: rx.disposeBag)
89
+//
90
+//        // 登录失败
91
+//        loginRequest.errors().bind(to: bindConverRequestError).disposed(by: rx.disposeBag)
92
+//        // 获取用户失败
93
+//        getUserInfo.errors().bind(to: bindConverRequestError).disposed(by: rx.disposeBag)
94
+//        requestError.subscribe(onNext: { (error) in
95
+//            User.removeUserInfo()
96
+//            AuthManager.removeTokenEnhancer()
97
+//        }).disposed(by: rx.disposeBag)
98
+//
99
+//        return Output()
100
+//    }
101
+//}

+ 2
- 0
iOSFirst/login/Model.xcdatamodeld/Model.xcdatamodel/contents View File

@@ -0,0 +1,2 @@
1
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21513" systemVersion="22D49" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""/>

+ 139
- 0
iOSFirst/network/API.swift View File

@@ -0,0 +1,139 @@
1
+//
2
+//  API.swift
3
+//  iOSFirst
4
+//
5
+//  Created by 孙宇峰 on 2023/2/3.
6
+//
7
+
8
+import Foundation
9
+enum Api {
10
+    /// baseUrl
11
+    static let shoolurl = "https://schooltestapi.xhkjedu.com/"
12
+    
13
+    static let fileurl = "https://schoolteststatic.xhkjedu.com/static/"
14
+    
15
+    static let rzurl = "http://scapitest.xhkjedu.com/"
16
+    
17
+    static let wsExamUrl = "wss://wsexamtest.xhkjedu.com/ws"
18
+}
19
+
20
+extension Api {
21
+    /// 用户登录注册登出 登录注册为post 登出为get
22
+    enum Account {
23
+        ///教师帐号登录
24
+        static let loginTeacher = "suser/user/login_teacher"
25
+        ///获取手机验证码
26
+        static let loginCode = "suser/user/login_code"
27
+        ///绑定手机获取手机验证码
28
+        static let bindCode = "suser/user/bind_code"
29
+        ///手机号码登录
30
+        static let loginByCode = "suser/user/login_byCode"
31
+        ///获取手机验证码 用于重置密码
32
+        static let updateCode = "suser/user/update_code"
33
+        /// 重置密码
34
+        static let updatePwdCode = "suser/user/update_pwd_byCode"
35
+        /// 绑定手机   2.2.3帐号安全--绑定手机
36
+        static let bindUserPhone = "suser/user/bind_userphone"
37
+        ///2.2.4帐号安全--验证身份
38
+        static let checkUser = "suser/user/check_user"
39
+    }
40
+}
41
+
42
+extension Api {
43
+    /// 首页 queryKeyword是post请求 其他的是get请求
44
+    enum Home {
45
+        
46
+        static let banner = "banner/json"
47
+
48
+        static let topArticle = "article/top/json"
49
+
50
+        static let normalArticle = "article/list/"
51
+
52
+        static let hotKey = "hotkey/json"
53
+
54
+        static let queryKeyword = "article/query/"
55
+    }
56
+}
57
+
58
+extension Api {
59
+    /// 项目 均是get请求
60
+    enum Project {
61
+        static let tags = "project/tree/json"
62
+        
63
+        static let tagList = "project/list/"
64
+    }
65
+}
66
+
67
+extension Api {
68
+    /// 公众号 均是get请求
69
+    enum PublicNumber {
70
+        static let tags = "wxarticle/chapters/json"
71
+
72
+        static let tagList = "wxarticle/list/"
73
+    }
74
+}
75
+
76
+
77
+
78
+
79
+extension Api {
80
+    /// 体系 均是get请求
81
+    enum Tree {
82
+        
83
+        static let tags = "tree/json"
84
+
85
+        static let tagList = "article/list/"
86
+    }
87
+}
88
+
89
+extension Api {
90
+    /// 我的 取消收藏和点击收藏操作为post,其他为get
91
+    enum My {
92
+        static let coinRank = "coin/rank/"
93
+        
94
+        static let userCoinInfo = "lg/coin/userinfo/json"
95
+        
96
+        static let myCoinList = "lg/coin/list/"
97
+        
98
+        static let collectArticleList = "lg/collect/list/"
99
+        
100
+        static let collectArticle = "lg/collect/"
101
+
102
+        static let unCollectArticle = "lg/uncollect_originId/"
103
+        
104
+        static let unreadCount = "message/lg/count_unread/json"
105
+        
106
+        static let unreadList = "message/lg/unread_list/"
107
+        
108
+        static let readList = "message/lg/readed_list/"
109
+    }
110
+}
111
+
112
+extension Api {
113
+    enum Other {
114
+        static let tools = "tools/list/json"
115
+        
116
+        /// 问答和工具在数据结构与页面样式一模一样,所以就不再不停的重复写了
117
+        static let questionAndAnswer = "wenda/list/"
118
+        
119
+        /// 常用网站
120
+        static let friend = "friend/json"
121
+        
122
+        /// 导航
123
+        static let navi = "navi/json"
124
+    }
125
+}
126
+
127
+extension Api {
128
+    enum Course {
129
+        static let tags = "chapter/547/sublist/json"
130
+        
131
+        static let tagList = "article/list/"
132
+    }
133
+}
134
+
135
+extension Api {
136
+    enum Mock {
137
+        static let mourn = "mourn/json"
138
+    }
139
+}

+ 64
- 0
iOSFirst/network/service/AccountService.swift View File

@@ -0,0 +1,64 @@
1
+//
2
+//  AccountService.swift
3
+//  iOSFirst
4
+//
5
+//  Created by 孙宇峰 on 2023/2/3.
6
+//
7
+
8
+import Foundation
9
+import Moya
10
+
11
+enum AccountService {
12
+    case login(_ username: String, _ password: String, _ showLoading: Bool)
13
+   
14
+}
15
+
16
+extension AccountService: TargetType {
17
+    
18
+    var baseURL: URL {
19
+        return URL(string: Api.shoolurl)!
20
+    }
21
+    
22
+    var path: String {
23
+        switch self {
24
+        case .login:
25
+            return Api.Account.loginTeacher
26
+        }
27
+    }
28
+    
29
+    var method: Moya.Method {
30
+        switch self {
31
+        case .login:
32
+            return .post
33
+        default:
34
+            return .post
35
+        }
36
+    }
37
+    
38
+    var sampleData: Data {
39
+        return Data()
40
+    }
41
+    
42
+    var task: Task {
43
+        switch self {
44
+        case .login(let username, let password, _):
45
+            return .requestParameters(parameters: ["loginname": username,
46
+                                                   "loginpwd": password,
47
+                                                   "ultype":"p_phone_t",
48
+                                                   "versionnum":"1.0.0"],
49
+                                      encoding: URLEncoding.default)
50
+        }
51
+        
52
+    }
53
+    
54
+    var headers: [String : String]? {
55
+        
56
+        switch self {
57
+        case .login(_, _, let showLoading):
58
+            return ["showLoading": "\(showLoading)"]
59
+        default:
60
+            return nil
61
+        }
62
+        
63
+    }
64
+}

Loading…
Cancel
Save