@@ -2015,7 +2043,7 @@
2015 2043
 				CLANG_ENABLE_OBJC_WEAK = YES;
2016 2044
 				CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
2017 2045
 				CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
2018
-				CODE_SIGN_IDENTITY = "";
2046
+				CODE_SIGN_IDENTITY = "iPhone Developer";
2019 2047
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
2020 2048
 				CODE_SIGN_STYLE = Automatic;
2021 2049
 				CURRENT_PROJECT_VERSION = 1;
@@ -2059,7 +2087,7 @@
2059 2087
 				CLANG_ENABLE_OBJC_WEAK = YES;
2060 2088
 				CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
2061 2089
 				CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
2062
-				CODE_SIGN_IDENTITY = "";
2090
+				CODE_SIGN_IDENTITY = "iPhone Developer";
2063 2091
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
2064 2092
 				CODE_SIGN_STYLE = Automatic;
2065 2093
 				CURRENT_PROJECT_VERSION = 1;
@@ -2084,7 +2112,7 @@
2084 2112
 				SKIP_INSTALL = YES;
2085 2113
 				SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
2086 2114
 				SWIFT_VERSION = 5.0;
2087
-				TARGETED_DEVICE_FAMILY = "1,2";
2115
+				TARGETED_DEVICE_FAMILY = 1;
2088 2116
 				VERSIONING_SYSTEM = "apple-generic";
2089 2117
 				VERSION_INFO_PREFIX = "";
2090 2118
 			};
@@ -2098,7 +2126,7 @@
2098 2126
 				CLANG_ENABLE_OBJC_WEAK = YES;
2099 2127
 				CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
2100 2128
 				CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
2101
-				CODE_SIGN_IDENTITY = "";
2129
+				CODE_SIGN_IDENTITY = "iPhone Developer";
2102 2130
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
2103 2131
 				CODE_SIGN_STYLE = Automatic;
2104 2132
 				CURRENT_PROJECT_VERSION = 1;
@@ -2122,7 +2150,7 @@
2122 2150
 				PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
2123 2151
 				SKIP_INSTALL = YES;
2124 2152
 				SWIFT_VERSION = 5.0;
2125
-				TARGETED_DEVICE_FAMILY = "1,2";
2153
+				TARGETED_DEVICE_FAMILY = 1;
2126 2154
 				VERSIONING_SYSTEM = "apple-generic";
2127 2155
 				VERSION_INFO_PREFIX = "";
2128 2156
 			};
@@ -2247,14 +2275,15 @@
2247 2275
 		6CEBD1121CA8D680004DBDE0 /* Debug */ = {
2248 2276
 			isa = XCBuildConfiguration;
2249 2277
 			buildSettings = {
2250
-				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
2278
+				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
2251 2279
 				ALWAYS_SEARCH_USER_PATHS = NO;
2252 2280
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
2253 2281
 				CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
2254 2282
 				CLANG_ENABLE_MODULES = NO;
2255 2283
 				CODE_SIGN_ENTITLEMENTS = PaiAi/PaiAi.entitlements;
2256
-				CODE_SIGN_IDENTITY = "iPhone Distribution: Beijing Jiayilai Trade Co., Ltd. (Q38447SL4M)";
2284
+				CODE_SIGN_IDENTITY = "iPhone Developer";
2257 2285
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
2286
+				CODE_SIGN_STYLE = Automatic;
2258 2287
 				DEFINES_MODULE = YES;
2259 2288
 				DEVELOPMENT_TEAM = Q38447SL4M;
2260 2289
 				ENABLE_BITCODE = NO;
@@ -2294,14 +2323,15 @@
2294 2323
 		6CEBD1131CA8D680004DBDE0 /* Release */ = {
2295 2324
 			isa = XCBuildConfiguration;
2296 2325
 			buildSettings = {
2297
-				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
2326
+				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
2298 2327
 				ALWAYS_SEARCH_USER_PATHS = NO;
2299 2328
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
2300 2329
 				CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
2301 2330
 				CLANG_ENABLE_MODULES = NO;
2302 2331
 				CODE_SIGN_ENTITLEMENTS = PaiAi/PaiAi.entitlements;
2303
-				CODE_SIGN_IDENTITY = "iPhone Distribution: Beijing Jiayilai Trade Co., Ltd. (Q38447SL4M)";
2332
+				CODE_SIGN_IDENTITY = "iPhone Developer";
2304 2333
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
2334
+				CODE_SIGN_STYLE = Automatic;
2305 2335
 				DEBUG_INFORMATION_FORMAT = dwarf;
2306 2336
 				DEFINES_MODULE = YES;
2307 2337
 				DEVELOPMENT_TEAM = Q38447SL4M;

BIN
PaiAi/Paiai.xcodeproj/project.xcworkspace/xcuserdata/FFIB.xcuserdatad/UserInterfaceState.xcuserstate


+ 5 - 1
PaiAi/Paiai.xcodeproj/xcuserdata/FFIB.xcuserdatad/xcschemes/PaiAi.xcscheme

@@ -1,7 +1,7 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <Scheme
3 3
    LastUpgradeVersion = "1020"
4
-   version = "1.3">
4
+   version = "1.7">
5 5
    <BuildAction
6 6
       parallelizeBuildables = "YES"
7 7
       buildImplicitDependencies = "YES">
@@ -81,6 +81,10 @@
81 81
       </EnvironmentVariables>
82 82
       <AdditionalOptions>
83 83
       </AdditionalOptions>
84
+      <LocationScenarioReference
85
+         identifier = "com.apple.dt.IDEFoundation.CurrentLocationScenarioIdentifier"
86
+         referenceType = "1">
87
+      </LocationScenarioReference>
84 88
    </LaunchAction>
85 89
    <ProfileAction
86 90
       buildConfiguration = "Debug"

+ 19 - 33
PaiAi/Paiai/AppDelegate.swift

@@ -47,55 +47,41 @@ class AppDelegate: UIResponder, UIApplicationDelegate, WXApiDelegate {
47 47
             return true
48 48
     }
49 49
 
50
-    func application(_ app: UIApplication, open url: URL,
51
-                     options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
52
-        var result: Bool = false
53
-        #if !((arch(i386) || arch(x86_64)))
54
-            switch sharedPlatform {
55
-            case 0:
56
-                result =  WXApi.handleOpen(url, delegate: self)
57
-            case 1:
58
-                result = TencentOAuth.handleOpen(url)
59
-            case 2:
60
-                result = WeiboSDK.handleOpen(url, delegate: nil)
61
-            default:
62
-                assert(false, "\((#file as NSString).lastPathComponent)[\(#line)], \(#function): share error")
63
-            }
64
-        #endif
65
-        return result
66
-    }
67 50
 
68 51
     func application(_ application: UIApplication, open url: URL,
69 52
                      sourceApplication: String?, annotation: Any) -> Bool {
70 53
         var result: Bool = false
71 54
         #if !((arch(i386) || arch(x86_64)))
72
-            switch sharedPlatform {
73
-            case 0:
74
-                result =  WXApi.handleOpen(url, delegate: self)
75
-            case 1:
76
-                result = TencentOAuth.handleOpen(url)
77
-            case 2:
78
-                result = WeiboSDK.handleOpen(url, delegate: nil)
79
-            default:
80
-                assert(false, "\((#file as NSString).lastPathComponent)[\(#line)], \(#function): share error")
81
-            }
55
+//            switch sharedPlatform {
56
+//            case 0:
57
+//                result =  WXApi.handleOpen(url, delegate: self)
58
+//            case 1:
59
+//                result = TencentOAuth.handleOpen(url)
60
+//            case 2:
61
+//                result = WeiboSDK.handleOpen(url, delegate: nil)
62
+//            default:
63
+//                assert(false, "\((#file as NSString).lastPathComponent)[\(#line)], \(#function): share error")
64
+//            }
82 65
 
83 66
         #endif
84
-        return result
67
+        return WXApi.handleOpen(url, delegate: self)
85 68
     }
86 69
 
87 70
     #if !((arch(i386) || arch(x86_64)))
88 71
     func onResp(_ resp: BaseResp!) {
89 72
         if let resp = resp as? PayResp {
90
-            var userInfo: [String: Int] = ["code": resp.errCode]
73
+            let userInfo: [String: Int] = ["code": Int(resp.errCode)]
91 74
             NotificationCenter.default.post(name: Notification.wxNotification.payDidFinish, object: nil, userInfo: userInfo)
92
-//        } else if let resp = resp as? SendAuthResp, let code = resp.code {
93
-//            NotificationCenter.default.post(name: , object: nil, userInfo: userInfo)
94
-////            wxLoginJumpFinishCallback?(["code": code as AnyObject], nil)
95
-////            wxLoginJumpFinishCallback = nil
75
+        } else if let resp = resp as? SendAuthResp {
76
+            let userInfo: [String: AnyObject] = ["errCode": Int(resp.errCode) as AnyObject, "code": resp.code as AnyObject]
77
+            NotificationCenter.default.post(name: Notification.wxNotification.login, object: nil, userInfo: userInfo)
96 78
         }
97 79
     }
98 80
     #endif
81
+    
82
+    func application(_ application: UIApplication, handleOpen url: URL) -> Bool {
83
+        return WXApi.handleOpen(url, delegate: self)
84
+    }
99 85
 }
100 86
 
101 87
 private let WIFIUploadOriginal = "WIFIUploadOriginal"

+ 4 - 4
PaiAi/Paiai/Info.plist

@@ -9,7 +9,7 @@
9 9
 	<key>CFBundleExecutable</key>
10 10
 	<string>$(EXECUTABLE_NAME)</string>
11 11
 	<key>CFBundleIdentifier</key>
12
-	<string>com.Paiai.Paiai</string>
12
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13 13
 	<key>CFBundleInfoDictionaryVersion</key>
14 14
 	<string>1.0</string>
15 15
 	<key>CFBundleName</key>
@@ -17,7 +17,7 @@
17 17
 	<key>CFBundlePackageType</key>
18 18
 	<string>APPL</string>
19 19
 	<key>CFBundleShortVersionString</key>
20
-	<string>1.1.2</string>
20
+	<string>2.0</string>
21 21
 	<key>CFBundleSignature</key>
22 22
 	<string>????</string>
23 23
 	<key>CFBundleURLTypes</key>
@@ -85,10 +85,10 @@
85 85
 	</dict>
86 86
 	<key>NSCameraUsageDescription</key>
87 87
 	<string>App需要您的同意,才能进行拍摄</string>
88
-	<key>NSPhotoLibraryUsageDescription</key>
89
-	<string>App需要您的同意,才能进行查看相册</string>
90 88
 	<key>NSPhotoLibraryAddUsageDescription</key>
91 89
 	<string>cc</string>
90
+	<key>NSPhotoLibraryUsageDescription</key>
91
+	<string>App需要您的同意,才能进行查看相册</string>
92 92
 	<key>UILaunchStoryboardName</key>
93 93
 	<string>LaunchScreen</string>
94 94
 	<key>UIRequiredDeviceCapabilities</key>

+ 0 - 2
PaiAi/PaiaiDataKit/DataLayer/Repositories/Remote/Reusable/ContentResource.swift

@@ -10,8 +10,6 @@ import Foundation
10 10
 import RxSwift
11 11
 import ObjectMapper
12 12
 
13
-struct NonMoreDataError: Error {}
14
-
15 13
 struct ContentResource<Content>: Resource {
16 14
     typealias Model = Content
17 15
     

+ 33 - 41
PaiAi/PaiaiDataKit/DataLayer/Repositories/Remote/Reusable/NetWork/NetworkApi.swift

@@ -13,43 +13,9 @@ import RxSwift
13 13
 class NetworkApi {
14 14
 
15 15
     public static let share = NetworkApi()
16
-    
17
-    private var synQueues = [OperationQueue]()
18
-
19
-    typealias FailureHandler = ((HTTPURLResponse?) -> Void)
20
-    typealias ProgressHandler = (() -> Void)
21
-    typealias FinishHandler = (() -> Void)
22 16
 
23 17
     private let sessionManager: Session
24 18
     private let session: Session
25
-
26
-    var finishHander: FinishHandler = {}
27
-
28
-    var failureHandler: FailureHandler = { response in
29
-        guard let status = response?.statusCode else {
30
-            return
31
-        }
32
-        let manager = NetworkReachabilityManager()
33
-        manager?.listener = { networkStatus in
34
-//            guard let visibleView = UIApplication.shared.keyWindow else {
35
-//                    return
36
-//            }
37
-
38
-            if networkStatus == .notReachable || networkStatus == .unknown {
39
-//                FFToastView.showToast(inView: visibleView, withText: "当前网络状态不好")
40
-                return
41
-            }
42
-
43
-            if status >= 500 {
44
-//                FFToastView.showToast(inView: visibleView, withText: "服务器出现异常")
45
-            } else if status >= 400 {
46
-                assert(true, "客户端问题")
47
-            } else if status >= 300 {
48
-                assert(true, "重定向问题")
49
-            }
50
-        }
51
-    }
52
-
53 19
     init() {
54 20
         sessionManager = Session.default
55 21
         session = Session.default
@@ -59,15 +25,37 @@ class NetworkApi {
59 25
 //        sessionManager.retrier = OAuthHandler()
60 26
     }
61 27
     
62
-    public func createSynQueue(identifier: String) {
63
-        let queue = OperationQueue()
64
-        queue.name = identifier
65
-        queue.maxConcurrentOperationCount = 1
66
-        queue.qualityOfService = .utility
67
-        queue.isSuspended = true
68
-        synQueues.append(queue)
28
+    private func handlingError(error: Error) {
29
+        guard let err = error as? AFError else {
30
+            Toast.show(message: "网络出现未知错误")
31
+            return
32
+        }
33
+        
34
+        if err.isSessionDeinitializedError
35
+            || err.isSessionInvalidatedError
36
+            || err.isInvalidURLError
37
+            || err.isRequestAdaptationError {
38
+            Toast.show(message: "客户端网络请求出错")
39
+        } else if err.isParameterEncoderError || err.isParameterEncodingError {
40
+            Toast.show(message: "客户端参数编码出错")
41
+        } else if err.isMultipartEncodingError {
42
+            Toast.show(message: "客户端上传或者下载参数编码出错")
43
+        } else if err.isResponseValidationError {
44
+            Toast.show(message: "服务器返回参数出错")
45
+        } else if err.isResponseSerializationError {
46
+            Toast.show(message: "服务器返回数据出错")
47
+        } else if err.isServerTrustEvaluationError {
48
+            Toast.show(message: "服务器验证错误")
49
+        } else if err.isRequestRetryError {
50
+            Toast.show(message: "客户端重试出错")
51
+        } else if err.isExplicitlyCancelledError {
52
+            return
53
+        } else {
54
+            Toast.show(message: "网络出现未知错误")
55
+        }
69 56
     }
70 57
     
58
+    
71 59
     public func post<A: Resource>(resource: A) -> Single<A.Model> {
72 60
         return Single<A.Model>.create(subscribe: { observer in
73 61
             let request = self.session.request(resource.host + resource.path.rawValue,
@@ -91,6 +79,7 @@ class NetworkApi {
91 79
                         }
92 80
                         
93 81
                     case .failure(let error):
82
+                        self.handlingError(error: error)
94 83
                         observer(.error(error))
95 84
                     }
96 85
             }
@@ -106,6 +95,7 @@ class NetworkApi {
106 95
                 .responseJSON { (res) in
107 96
                     switch res.result {
108 97
                     case .success(let json):
98
+                        print(json)
109 99
                         guard let json = json as? [String: AnyObject],
110 100
                             let data = resource.parse(json) else {
111 101
                                 observer(.error(ParseError()))
@@ -113,6 +103,7 @@ class NetworkApi {
113 103
                         }
114 104
                         observer(.success(data))
115 105
                     case .failure(let error):
106
+                        self.handlingError(error: error)
116 107
                         observer(.error(error))
117 108
                     }
118 109
             }
@@ -156,6 +147,7 @@ class NetworkApi {
156 147
                             observer(.error(BusinessError(id: status)))
157 148
                         }
158 149
                     case .failure(let error):
150
+                        self.handlingError(error: error)
159 151
                         observer(.error(error))
160 152
                     }
161 153
                 })

+ 72 - 111
PaiAi/PaiaiDataKit/DataLayer/Repositories/Remote/WXUserInfoRemoteAPI.swift

@@ -12,64 +12,28 @@ import RxSwift
12 12
 fileprivate let WXAppid = "wx4e22a0c8ae6d766d"
13 13
 fileprivate let WXSecret = "636ac848016c593575d11143c55c8333"
14 14
 
15
-//fileprivate protocol WXUserInfoParse: Parsable where Model == JSON {}
16
-//
17
-//extension DefaultResource: WXUserInfoParse {
18
-//    func parse(_ json: JSON) -> JSON? { return json }
19
-//}
20
-//
21
-//fileprivate struct WXResource: Resource, Parsable {
22
-//    typealias Model = UserInfo
23
-//
24
-//    var path: Interfaces { return .authorize }
25
-//    var parameter: Parameter = [:]
26
-//
27
-//    func parse(_ json: JSON) -> UserInfo? {
28
-//        guard let result = json["data"] as? JSON else { return nil }
29
-//        return UserInfo(json: result)
30
-//    }
31
-//}
32
-
33
-class WXUserInfoRemoteAPI: UserInfoRemoteAPI {
34
-    
35
-    typealias Model = UserInfo
36
-//    fileprivate var wxResource: WXResource
37
-//    fileprivate var wxTokenResource: DefaultResource
38
-//    fileprivate var wxUserInfoResource: DefaultResource
15
+struct WXUserInfoRemoteAPI: UserInfoRemoteAPI {
39 16
     
40
-    init() {
41
-        let wxUrl = "https://api.weixin.qq.com"
42
-//        self.wxResource = WXResource()
43
-//        self.wxTokenResource = DefaultResource(host: wxUrl, path: .wxAccessToken, parameter: [:])
44
-//        self.wxUserInfoResource = DefaultResource(host: wxUrl, path: .wxUserInfo, parameter: [:])
45
-    }
17
+    init() {}
46 18
     
47 19
     func login() -> Single<UserInfo> {
20
+        #if (arch(i386) || arch(x86_64))
48 21
         return Single.create(subscribe: { (observer) in
49 22
             observer(.success(UserInfo(json: ["user_id": "fiDz2Ms" as AnyObject, "userName": "郑剑飞" as AnyObject, "photoPath": "https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTJibSYLgvXpMakvD9FaCqfiaWqcMiaiaz905YxWPuO4hy8F2lGheV7kVr9vKKXFgmL1S5s4QJgxwuwtVw/132" as AnyObject])))
50 23
             return Disposables.create()
51 24
         })
52
-        return Single.create(subscribe: { (observer) -> Disposable in
53
-            
54
-//            let wxLoginObserver = self.addWXLoginDidFinish()
55
-//            let wxTokenObserver = self.getWXToken()
56
-//            let wxUserInfoObserver = self.getWXUserInfo()
57
-//            let loginObserver = self.wxLogin()
58
-//            
59
-//            Single.of(wxLoginObserver,
60
-//                          wxTokenObserver,
61
-//                          wxUserInfoObserver)
62
-//                .concat().asSingle()
63
-//                .subscribe({_ in
64
-//                    loginObserver.asSingle()
65
-//                        .subscribe(onNext: { (userInfo) in
66
-//                            observer.onNext(userInfo)
67
-//                            self.removeWXLoginDidFinish()
68
-//                    }).dispose()
69
-//                }).dispose()
70
-            
71
-            return Disposables.create()
25
+        #else
26
+        loginWithWeChat()
27
+        return addWXLoginDidFinish().flatMap({
28
+            return self.getWXToken(param: $0)
29
+        }).flatMap({
30
+            return self.getWXUserInfo(param: $0)
31
+        }).flatMap({
32
+            return self.wxLogin(param: $0)
33
+        }).do(onSuccess: { res in
34
+            print(res)
72 35
         })
36
+        #endif
73 37
     }
74 38
     
75 39
     fileprivate func loginWithWeChat() {
@@ -80,68 +44,65 @@ class WXUserInfoRemoteAPI: UserInfoRemoteAPI {
80 44
         WXApi.send(request)
81 45
     }
82 46
     
83
-//    fileprivate func addWXLoginDidFinish() -> Completable {
84
-//        return Single.create { (observer) in
85
-////            NotificationCenter.default.addObserver(forName: Notification.WXLoginNotification, object: nil, queue: nil) { (notification) in
86
-////                guard let userInfo = notification.userInfo,
87
-////                    let code = userInfo["code"] as? String else { return }
88
-////                self.wxTokenResource.parameter = ["appid": WXAppid, "secret": WXSecret,
89
-////                                                  "code": code, "grant_type": "authorization_code"]
90
-////                observer.onCompleted()
91
-////            }
92
-////
93
-//            return Disposables.create()
94
-//        }
95
-//    }
96
-//
97
-//    fileprivate func getWXToken() -> Completable {
98
-//        return Single.create({ (observer) in
99
-////            let resource = ContentResource.init(host:"https://api.weixin.qq.com",
100
-////                                                path: .wxAccessToken,
101
-////                                                parameter: <#T##Parameter#>, parseJSON: <#T##(JSON) -> _?#>)
102
-////            NetworkApi.share.get(resource: self.wxTokenResource) { (result) in
103
-////                guard case let .success(data) = result,
104
-////                    let token = data["access_token"] as? String,
105
-////                    let openId = data["openid"] as? String else { return }
106
-////                self.wxUserInfoResource.parameter = ["access_token": token, "openid": openId]
107
-////                observer.onCompleted()
108
-////            }
109
-//
110
-//            return Disposables.create()
111
-//        })
112
-//    }
113
-//
114
-//    fileprivate func getWXUserInfo() -> Completable {
115
-//        return Single.create({ (observer) in
116
-////            NetworkApi.share.get(resource: self.wxUserInfoResource) { (result) in
117
-////                guard case let .success(data) = result else { return }
118
-////                if let errcode = data["errcode"] as? Int,
119
-////                    errcode == 40003 { return }
120
-////                self.wxResource.parameter = data
121
-////                observer.onCompleted()
122
-////            }
123
-//
124
-//            return Disposables.create()
125
-//        })
126
-//    }
127
-//
128
-//    fileprivate func wxLogin() -> Single<UserInfo> {
129
-//        return Single.create({ (observer) in
130
-////            NetworkApi.share.post(resource: self.wxResource) { (result) in
131
-////                guard case let .success(data) = result else { return }
132
-////                observer.onNext(data)
133
-////                observer.onCompleted()
134
-////            }
135
-////
136
-//            return Disposables.create()
137
-//        })
138
-//    }
47
+    fileprivate func addWXLoginDidFinish() -> Single<[String: String]> {
48
+        return Single.create(subscribe: { observer -> Disposable in
49
+            NotificationCenter.default.addObserver(forName: Notification.wxNotification.login, object: nil, queue: nil, using: { notification in
50
+                guard let userInfo = notification.userInfo,
51
+                    let errcode = userInfo["errCode"] as? Int,
52
+                    let code = userInfo["code"] as? String else {
53
+                        Toast.show(message: "获取code失败")
54
+                        return observer(.error(ParseError()))
55
+                }
56
+                switch errcode {
57
+                case 0:
58
+                    observer(.success(["appid": WXAppid, "secret": WXSecret,
59
+                                       "code": code, "grant_type": "authorization_code"]))
60
+                case -4:
61
+                    Toast.show(message: "您拒绝授权,登录失败")
62
+                    break
63
+                case -2:
64
+                    Toast.show(message: "您取消了登录,登录失败")
65
+                    break
66
+                default:
67
+                    Toast.show(message: "发生未知错误,登录失败")
68
+                    break
69
+                }
70
+                return observer(.error(BusinessError(id: errcode)))
71
+            })
72
+            return Disposables.create()
73
+        })
74
+    }
75
+
76
+    fileprivate func parseWxToken(json: JSON) -> [String: String]? {
77
+        guard let token = json["access_token"] as? String,
78
+            let openId = json["openid"] as? String else { return nil }
79
+        return ["access_token": token, "openid": openId]
80
+    }
81
+    
82
+    fileprivate func getWXToken(param: [String: String]) -> Single<[String: String]> {
83
+        let resource = ContentResource<[String: String]>(host: "https://api.weixin.qq.com",
84
+                                                      path: .wxAccessToken,
85
+                                                      parameter: param,
86
+                                                      parseJSON: parseWxToken)
87
+        
88
+        return NetworkApi.share.get(resource: resource)
89
+    }
90
+
91
+    fileprivate func getWXUserInfo(param: [String: String]) -> Single<[String: Any]> {
92
+        let resource = ContentResource<[String: Any]>(host: "https://api.weixin.qq.com",
93
+                                                      path: .wxUserInfo,
94
+                                                      parameter: param,
95
+                                                      parseJSON: { $0 })
96
+        return NetworkApi.share.get(resource: resource)
97
+    }
139 98
     
140
-    fileprivate func removeWXLoginDidFinish() {
141
-        NotificationCenter.default.removeObserver(self, name: Notification.WXLoginNotification, object: nil)
99
+    fileprivate func parseAuthorize(json: JSON) -> UserInfo? {
100
+        guard let data = json["data"] as? [String: AnyObject] else { return nil }
101
+        return UserInfo(json: data)
142 102
     }
143
-}
144 103
 
145
-extension Notification {
146
-    static let WXLoginNotification = Notification.Name("WXLoginDidFinishNotification")
104
+    fileprivate func wxLogin(param: [String: Any]) -> Single<UserInfo> {
105
+        let resource = ContentResource<UserInfo>(path: .authorize, parameter: param, parseJSON: parseAuthorize)
106
+        return resource.loadContent()
107
+    }
147 108
 }

+ 6 - 0
PaiAi/PaiaiDataKit/PresentLayer/UserInfoViewModel.swift

@@ -77,11 +77,17 @@ public class UserInfoViewModel {
77 77
     }
78 78
     
79 79
     public func wxLogin() {
80
+        Toast.showActivity(message: "正在登陆")
80 81
         repository.wxLogin().subscribe(onSuccess: { (userInfo) in
81 82
             self.shareUserInfo.accept(userInfo)
82 83
             self._loginCompleted.onNext(())
83 84
         }) { (error) in
85
+            print(error)
84 86
             #warning("错误处理")
85 87
         }.disposed(by: disposeBag)
86 88
     }
89
+    
90
+    deinit {
91
+        print("销毁")
92
+    }
87 93
 }

+ 1 - 0
PaiAi/PaiaiDataKit/Resuable/Extension/Notification+wxPay.swift

@@ -11,5 +11,6 @@ import Foundation
11 11
 public extension Notification {
12 12
     struct wxNotification {
13 13
         public static let payDidFinish = Notification.Name("WXPayDidFinishNotification")
14
+        public static let login = Notification.Name("WXLoginDidFinishNotification")
14 15
     }
15 16
 }

+ 0 - 1
PaiAi/Paiai_iOS/App/LoginViewController.swift

@@ -83,6 +83,5 @@ extension LoginViewController {
83 83
                     self.guestLoginBtn.isHidden = false
84 84
                 }
85 85
             }).disposed(by: disposeBag)
86
-        
87 86
     }
88 87
 }

kodo - Gogs: Go Git Service

Нет описания

Brightcells: b65f84e502 Duplicate entry лет %!s(int64=10): %!d(string=назад)
..
0001_initial.py 4defb80fdc gogs first init лет %!s(int64=11): %!d(string=назад)
0002_auto_20151113_1419.py 4defb80fdc gogs first init лет %!s(int64=11): %!d(string=назад)
0003_uuidinfo.py 52ce35cbfc add api uuid_init/uuid лет %!s(int64=11): %!d(string=назад)
0004_photosinfo_photo_name.py 52ce35cbfc add api uuid_init/uuid лет %!s(int64=11): %!d(string=назад)
0005_auto_20151207_1811.py 4a8b4f8819 add watermark лет %!s(int64=11): %!d(string=назад)
0006_auto_20160120_1830.py a121b75ff2 add db_index=True for status field лет %!s(int64=10): %!d(string=назад)
0007_auto_20160422_1322.py 102152ca4a add api lensman_photo_bought & modify api wx_order_create_api and adjust return field лет %!s(int64=10): %!d(string=назад)
0008_auto_20160901_1439.py 6199c8f7ad add api lensman_origin_wanted_api/lensman_origin_photo_upload_api лет %!s(int64=10): %!d(string=назад)
0009_auto_20160907_1018.py b65f84e502 Duplicate entry лет %!s(int64=10): %!d(string=назад)
__init__.py 4defb80fdc gogs first init лет %!s(int64=11): %!d(string=назад)