|
@@ -5,6 +5,7 @@
|
|
|
import Foundation
|
|
|
import ObjectMapper
|
|
|
import Kingfisher
|
|
|
+import SwiftyJSON
|
|
|
|
|
|
|
|
|
public class UserModel : NSObject, NSCoding, Mappable{
|
|
@@ -17,19 +18,19 @@ public class UserModel : NSObject, NSCoding, Mappable{
|
|
|
return _sharedInstance
|
|
|
}
|
|
|
|
|
|
- var accessToken : String?
|
|
|
- var avatarurl : String?
|
|
|
- var gender : Int?
|
|
|
- var isPassword : Int?
|
|
|
- var mobile : String?
|
|
|
- var token : String?
|
|
|
- var tokenTtl : Int?
|
|
|
- var uid : Int?
|
|
|
- var username : String?
|
|
|
- var isFollowSuggestTopic : Int?
|
|
|
- var isNewMember : Int?
|
|
|
- var inviteUid : Int?
|
|
|
- var inviteCode : String?
|
|
|
+ var accessToken : String? = ""
|
|
|
+ var avatarurl : String? = ""
|
|
|
+ var gender : Int? = nil
|
|
|
+ var isPassword : Int? = nil
|
|
|
+ var mobile : String? = ""
|
|
|
+ var token : String? = ""
|
|
|
+ var tokenTtl : Int? = nil
|
|
|
+ var uid : Int? = nil
|
|
|
+ var username : String? = ""
|
|
|
+ var isFollowSuggestTopic : Int? = nil
|
|
|
+ var isNewMember : Int? = nil
|
|
|
+ var inviteUid : Int? = nil
|
|
|
+ var inviteCode : String? = ""
|
|
|
var bindWeixinUserModel : BindThirdPartyUserModel?
|
|
|
var bindQQUserModel : BindThirdPartyUserModel?
|
|
|
|
|
@@ -199,9 +200,43 @@ public class UserModel : NSObject, NSCoding, Mappable{
|
|
|
//获取当前时间
|
|
|
let userModel = getModel()
|
|
|
userModel?.version = AppInfo.clientVersion
|
|
|
+
|
|
|
var userInfoDic = Dictionary<String,Any>()
|
|
|
userInfoDic.updateValue("userInfo", forKey: "type")
|
|
|
- userInfoDic.updateValue(userModel?.toJSON() as Any, forKey: "params")
|
|
|
+ var userModelDic = Dictionary<String,Any>()
|
|
|
+ if userModel?.gender == nil {
|
|
|
+ userModelDic.updateValue("" as Any, forKey: "gender")
|
|
|
+ }
|
|
|
+ if userModel?.isPassword == nil {
|
|
|
+ userModelDic.updateValue("" as Any, forKey: "is_password")
|
|
|
+ }
|
|
|
+ if userModel?.tokenTtl == nil {
|
|
|
+ userModelDic.updateValue("" as Any, forKey: "token_ttl")
|
|
|
+ }
|
|
|
+ if userModel?.uid == nil {
|
|
|
+ userModelDic.updateValue("" as Any, forKey: "uid")
|
|
|
+ }
|
|
|
+ if userModel?.isFollowSuggestTopic == nil {
|
|
|
+ userModelDic.updateValue("" as Any, forKey: "is_follow_suggest_topic")
|
|
|
+ }
|
|
|
+ if userModel?.isNewMember == nil {
|
|
|
+ userModelDic.updateValue("" as Any, forKey: "is_new_member")
|
|
|
+ }
|
|
|
+ if userModel?.inviteUid == nil {
|
|
|
+ userModelDic.updateValue("" as Any, forKey: "invite_uid")
|
|
|
+ }
|
|
|
+
|
|
|
+ if userModel?.bindWeixinUserModel == nil {
|
|
|
+ userModel?.bindWeixinUserModel = BindThirdPartyUserModel()
|
|
|
+ }
|
|
|
+
|
|
|
+ if userModel?.bindQQUserModel == nil {
|
|
|
+ userModel?.bindQQUserModel = BindThirdPartyUserModel()
|
|
|
+ }
|
|
|
+
|
|
|
+ userModelDic.append(dict: (userModel?.toJSON())!)
|
|
|
+ userInfoDic.updateValue(userModelDic as Any, forKey: "params")
|
|
|
+ NXLLog(JSON(userInfoDic).debugDescription)
|
|
|
return userInfoDic
|
|
|
}
|
|
|
|
|
@@ -226,15 +261,15 @@ public class UserModel : NSObject, NSCoding, Mappable{
|
|
|
|
|
|
class BindThirdPartyUserModel : NSObject, NSCoding, Mappable{
|
|
|
|
|
|
- var openId : String?
|
|
|
- var unionId : String?
|
|
|
+ var openId : String? = ""
|
|
|
+ var unionId : String? = ""
|
|
|
|
|
|
|
|
|
class func newInstance(map: Map) -> Mappable?{
|
|
|
return BindThirdPartyUserModel()
|
|
|
}
|
|
|
required init?(map: Map){}
|
|
|
- private override init(){}
|
|
|
+ override init(){}
|
|
|
|
|
|
func mapping(map: Map)
|
|
|
{
|