| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- //
- // PasswordLoginUIView.swift
- // fiveConstant
- //
- // Created by 李建 on 2023/1/14.
- //
- import SwiftUI
- import SwiftyUserDefaults
- struct PasswordLoginUIView: View {
- @State private var phoneNumber: String = ""
- @State private var password: String = ""
- @State private var isAllow: Bool = false
- @EnvironmentObject var proState: ProgressState;
- @Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
-
- var body: some View {
- VStack(spacing: 50) {
- Spacer()
- VStack(alignment: .leading, spacing: 60) {
- VStack(alignment: .leading, spacing: 10.0) {
- Text("密码登录")
- .font(.title)
- .fontWeight(.bold)
- }
- VStack {
- VStack(alignment: .center, spacing: 15) {
- VStack {
- HStack(spacing: 3) {
- Image(systemName: "phone.fill")
- .foregroundColor(Color("MainColor"))
- TextField("请输入您的手机号", text: $phoneNumber)
- .disableAutocorrection(true)
- .padding(8)
- }
- Divider().foregroundColor(Color.gray)
- .opacity(0.5)
- }
- VStack {
- ZStack(alignment: .trailing) {
- HStack(spacing: 3) {
- Image(systemName: "lock.fill")
- .foregroundColor(Color("MainColor"))
- SecureField("请输入密码", text: $password)
- .disableAutocorrection(true)
- .padding(8)
- }
- NavigationLink{
- ResetPasswordUIView()
- } label: {
- Text("忘记密码?").foregroundColor(Color("MainColor"))
- }
- }
- Divider().foregroundColor(Color.gray).opacity(0.5)
- }
- }.padding(.bottom, 20)
- Button(action: {
- let params = PasswordLoginReq(phone: self.phoneNumber, password: password)
- HttpRequest<SMSLoginResp>.loadData(target: LoginAPI.passwordLogin(param: params)) { returnData in
- Defaults[\.token]? = returnData.access_token
- if returnData.app_first_login {
- // 跳转设置密码
- proState.isNeedLogin = false
- } else {
- proState.isNeedLogin = false
- }
- } failure: { _, msg in
- HUD.show(title: msg!)
- }
- }, label: {
- Text("登录")
- .foregroundColor(.white)
- .padding()
- .frame(maxWidth: .infinity)
- .background(
- Color("MainColor")
- .cornerRadius(8)
- )
- .border(Color("MainColor"), width: 0)
-
- }
- )
- Spacer()
- HStack (spacing: 0){
- RadioButton(selected: $isAllow)
- Text("我已阅读并同意")
- .font(.caption)
- Text("《用户服务协议》")
- .font(.caption)
- .foregroundColor(Color("MainColor"))
- Text("以及")
- .font(.caption)
- Text("《隐私协议》")
- .font(.caption)
- .foregroundColor(Color("MainColor"))
- }
- }
- }
- }.padding()
- .navigationBarBackButtonHidden(true)
- .navigationBarItems(leading: Button(action: {
- self.presentationMode.wrappedValue.dismiss()
- }, label: {
- Image(systemName: "chevron.left")
- .foregroundColor(.gray)
- }))
- }
- }
- struct PasswordLoginUIView_Previews: PreviewProvider {
- static var previews: some View {
- PasswordLoginUIView()
- }
- }
|