|
@@ -13,7 +13,9 @@ import RxRelay
|
13
|
13
|
struct LoginView: View {
|
14
|
14
|
private var viewModel = LoginViewModel()
|
15
|
15
|
var bag = DisposeBag()
|
16
|
|
-
|
|
16
|
+ @State private var inputAccountMessage:String = ""
|
|
17
|
+ @State private var isPresent:Bool = false
|
|
18
|
+ @State private var inputPasswordMessage:String = ""
|
17
|
19
|
|
18
|
20
|
var body: some View {
|
19
|
21
|
|
|
@@ -47,8 +49,8 @@ struct LoginView: View {
|
47
|
49
|
.foregroundColor(.accentColor)
|
48
|
50
|
.frame(width: 240,height: 35)
|
49
|
51
|
}.frame(height: 40)
|
50
|
|
- .padding(.top,20)
|
51
|
|
- .padding(.bottom,100)
|
|
52
|
+ .padding(.top,20)
|
|
53
|
+ .padding(.bottom,100)
|
52
|
54
|
|
53
|
55
|
VStack(alignment: .leading, spacing: 400) {
|
54
|
56
|
HStack(alignment: .center, spacing: 15) {
|
|
@@ -56,8 +58,8 @@ struct LoginView: View {
|
56
|
58
|
.imageScale(.large)
|
57
|
59
|
.foregroundColor(.accentColor)
|
58
|
60
|
|
59
|
|
- TextField("请输入手机号",text:.constant(""))
|
60
|
|
- .id("etPhoneNum")
|
|
61
|
+ TextField("请输入手机号",text:$inputAccountMessage)
|
|
62
|
+ .keyboardType(UIKeyboardType.namePhonePad)
|
61
|
63
|
.font(.system(size: 16))
|
62
|
64
|
.frame(maxWidth: .infinity,alignment: .center)
|
63
|
65
|
|
|
@@ -73,8 +75,9 @@ struct LoginView: View {
|
73
|
75
|
.imageScale(.large)
|
74
|
76
|
.foregroundColor(.accentColor)
|
75
|
77
|
|
76
|
|
- TextField("请输入密码",text:.constant(""))
|
77
|
|
- .id("etPassword")
|
|
78
|
+ SecureField("请输入密码",text:$inputPasswordMessage)
|
|
79
|
+ .textContentType(.oneTimeCode)
|
|
80
|
+ .keyboardType(UIKeyboardType.namePhonePad)
|
78
|
81
|
.font(.system(size: 16))
|
79
|
82
|
.frame(maxWidth: .infinity,alignment: .center)
|
80
|
83
|
|
|
@@ -88,15 +91,25 @@ struct LoginView: View {
|
88
|
91
|
VStack(alignment: .trailing, spacing: 400) {
|
89
|
92
|
|
90
|
93
|
VStack(alignment: .center, spacing: 15) {
|
|
94
|
+
|
91
|
95
|
Button(action: {
|
92
|
|
-// let msg="点击了登录按钮"
|
93
|
|
-// print(msg)
|
94
|
|
- viewModel.loginUser()
|
95
|
|
-// SUIToast.show(messageItem: .init(
|
96
|
|
-// message: msg,
|
97
|
|
-// bgColor: .gray,
|
98
|
|
-// messageColor: .white
|
99
|
|
-// ))
|
|
96
|
+ if(inputAccountMessage.isEmpty){
|
|
97
|
+ SUIToast.show(messageItem: .init(
|
|
98
|
+ message: "账号不能为空",
|
|
99
|
+ bgColor: .gray,
|
|
100
|
+ messageColor: .white
|
|
101
|
+ ))
|
|
102
|
+ }else if(inputPasswordMessage.isEmpty){
|
|
103
|
+ SUIToast.show(messageItem: .init(
|
|
104
|
+ message: "密码不能为空",
|
|
105
|
+ bgColor: .gray,
|
|
106
|
+ messageColor: .white
|
|
107
|
+ ))
|
|
108
|
+ }else {
|
|
109
|
+ viewModel.loginUser(username: inputAccountMessage, password: inputPasswordMessage)
|
|
110
|
+ isPresent=true
|
|
111
|
+ }
|
|
112
|
+
|
100
|
113
|
}) {
|
101
|
114
|
Text("登录")
|
102
|
115
|
.font(.system(size: 17))
|
|
@@ -106,6 +119,8 @@ struct LoginView: View {
|
106
|
119
|
.foregroundColor(.white)
|
107
|
120
|
.background(.blue)
|
108
|
121
|
.cornerRadius(30)
|
|
122
|
+ }.fullScreenCover(isPresented: $isPresent) {
|
|
123
|
+ TestView(settingPagePresented: $isPresent)
|
109
|
124
|
}
|
110
|
125
|
|
111
|
126
|
}
|
|
@@ -141,7 +156,7 @@ struct LoginView: View {
|
141
|
156
|
}.padding()
|
142
|
157
|
.frame(width: .infinity,height: .infinity)
|
143
|
158
|
}
|
144
|
|
-
|
|
159
|
+
|
145
|
160
|
}
|
146
|
161
|
|
147
|
162
|
struct ContentView_Previews: PreviewProvider {
|