Commit 7209ed34 authored by skeyboy's avatar skeyboy

登录页新增用户协议检测校验

parent 70d05346
import 'dart:async';
import 'dart:io';
import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
import 'package:flutter/material.dart';
......@@ -28,6 +29,9 @@ class SignInController extends GetxController {
RxBool loginBtnEable = false.obs;
RxString codeTileStr = "获取验证码".obs;
// 隐私政策是否勾选
RxBool privactChecked = false.obs;
/// 倒计时的计时器。
late Timer _timer;
......@@ -45,6 +49,7 @@ class SignInController extends GetxController {
// ----------------------------------------------------------------
// email的控制器
final TextEditingController emailController = TextEditingController();
// 密码的控制器
final TextEditingController passController = TextEditingController();
......@@ -67,8 +72,11 @@ class SignInController extends GetxController {
// 执行登录操作
handleSignIn() async {
if(!GetUtils.isPhoneNumber(mobileMemberController.text)) {
if (Platform.isAndroid && privactChecked == false) {
EasyLoading.showToast("请阅读并同意《用户协议》《隐私政策》");
return;
}
if (!GetUtils.isPhoneNumber(mobileMemberController.text)) {
EasyLoading.showToast("请输入手机号");
return;
}
......@@ -188,11 +196,11 @@ class SignInController extends GetxController {
}
chageCodeStatus() async {
if(!mobileMemberController.text.isNotEmpty) {
if (!mobileMemberController.text.isNotEmpty) {
EasyLoading.showToast('请先输入手机号');
return;
}
if(codeEnable.value == false) {
if (codeEnable.value == false) {
EasyLoading.show(status: "验证码发送太过频繁,请稍后再试");
return;
}
......@@ -213,7 +221,6 @@ class SignInController extends GetxController {
} else if (!chinaPhoneNumber(mobileMemberController.text)) {
EasyLoading.showToast("手机号输入有误");
// EasyLoading.show(status: "手机号输入有误");
} else {
EasyLoading.showToast("验证码已发送");
}
......
......@@ -590,169 +590,235 @@ class SignInPage extends GetView<SignInController> {
}
Widget buildAndroidSigin(BuildContext buildContext) {
return WillPopScope(onWillPop: () async{
return false;
},child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () => Focus.of(buildContext).unfocus(),
child: Container(
height: Get.height,
decoration: BoxDecoration(
image: DecorationImage(
image: Image.asset("assets/images/background.png").image,
fit: BoxFit.cover),
),
child: Stack(
children: [
Positioned(
child: GestureDetector(
onTap: () => Get.back(), child: Icon(Icons.arrow_back)),
top: 45,
left: 35,
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(height: defaultPadding * 8),
Column(
children: [
Row(
children: [
const Spacer(),
SizedBox(
height: 75,
width: 75,
child: Image.asset(
"assets/images/ic_launcher.png",
fit: BoxFit.fill,
),
),
const Spacer(),
],
),
SizedBox(height: defaultPadding * 6),
],
),
Row(
children: [
Spacer(),
Expanded(
flex: 8,
child: Form(
child: Column(
children: [
TextFormField(
controller: controller.mobileMemberController,
keyboardType: TextInputType.phone,
textInputAction: TextInputAction.next,
cursorColor: kPrimaryColor,
onSaved: (email) {},
style:
const TextStyle(color: Color(0xFF6F35A5)),
decoration: const InputDecoration(
labelStyle: TextStyle(color: Colors.black),
fillColor: kPrimaryLightColor,
iconColor: Color(0xFF6F35A5),
prefixIconColor: Color(0xFF6F35A5),
filled: true,
contentPadding:
EdgeInsets.fromLTRB(10, 10, 10, 10),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(30)),
borderSide: BorderSide.none,
),
hintText: "输入手机号",
hintStyle:
TextStyle(color: Color(0xFF6F35A5)),
prefixIcon: Padding(
padding: EdgeInsets.only(
left: defaultPadding,
right: defaultPadding),
child: Icon(Icons.phone_android),
),
),
return WillPopScope(
onWillPop: () async {
return false;
},
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () => Focus.of(buildContext).unfocus(),
child: Container(
height: Get.height,
decoration: BoxDecoration(
image: DecorationImage(
image: Image.asset("assets/images/background.png").image,
fit: BoxFit.cover),
),
child: Stack(
children: [
Positioned(
child: GestureDetector(
onTap: () => Get.back(), child: Icon(Icons.arrow_back)),
top: 45,
left: 35,
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
SizedBox(height: defaultPadding * 8),
Column(
children: [
Row(
children: [
const Spacer(),
SizedBox(
height: 75,
width: 75,
child: Image.asset(
"assets/images/ic_launcher.png",
fit: BoxFit.fill,
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: defaultPadding * 1.5),
child: TextFormField(
controller: controller.codeController,
keyboardType: TextInputType.number,
textInputAction: TextInputAction.done,
obscureText: true,
),
const Spacer(),
],
),
SizedBox(height: defaultPadding * 6),
],
),
Row(
children: [
Spacer(),
Expanded(
flex: 8,
child: Form(
child: Column(
children: [
TextFormField(
controller: controller.mobileMemberController,
keyboardType: TextInputType.phone,
textInputAction: TextInputAction.next,
cursorColor: kPrimaryColor,
style: TextStyle(color: Color(0xFF6F35A5)),
onSaved: (email) {},
style:
const TextStyle(color: Color(0xFF6F35A5)),
decoration: const InputDecoration(
labelStyle: TextStyle(color: Colors.black),
fillColor: kPrimaryLightColor,
contentPadding:
EdgeInsets.fromLTRB(10, 10, 10, 10),
iconColor: Color(0xFF6F35A5),
prefixIconColor: Color(0xFF6F35A5),
filled: true,
contentPadding:
EdgeInsets.fromLTRB(10, 10, 10, 10),
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(30)),
BorderRadius.all(Radius.circular(30)),
borderSide: BorderSide.none,
),
hintText: "输入验证码",
hintText: "输入手机号",
hintStyle:
TextStyle(color: Color(0xFF6F35A5)),
TextStyle(color: Color(0xFF6F35A5)),
prefixIcon: Padding(
padding: EdgeInsets.all(defaultPadding),
child: Icon(Icons.lock),
padding: EdgeInsets.only(
left: defaultPadding,
right: defaultPadding),
child: Icon(Icons.phone_android),
),
),
),
),
const SizedBox(height: defaultPadding),
Row(
children: [
Flexible(child: Container()),
GestureDetector(
onTap: () => controller.chageCodeStatus(),
child: Obx(()=>Text(
controller.codeTileStr.value,
style: const TextStyle(
color: Colors.white54, fontSize: 12),
)),
)
],
),
const SizedBox(height: defaultPadding * 6),
Hero(
tag: "login_btn",
child: GestureDetector(
onTap: () => controller.handleSignIn(),
child: Container(
width: Get.width - 40,
height: 50,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(45 / 2.0)),
color: Color(0xFF6F35A5)),
child: Text(
"登录".toUpperCase(),
Padding(
padding: const EdgeInsets.symmetric(
vertical: defaultPadding * 1.5),
child: TextFormField(
controller: controller.codeController,
keyboardType: TextInputType.number,
textInputAction: TextInputAction.done,
obscureText: true,
cursorColor: kPrimaryColor,
style: TextStyle(color: Color(0xFF6F35A5)),
decoration: const InputDecoration(
labelStyle: TextStyle(color: Colors.black),
fillColor: kPrimaryLightColor,
contentPadding:
EdgeInsets.fromLTRB(10, 10, 10, 10),
iconColor: Color(0xFF6F35A5),
prefixIconColor: Color(0xFF6F35A5),
filled: true,
border: OutlineInputBorder(
borderRadius:
BorderRadius.all(Radius.circular(30)),
borderSide: BorderSide.none,
),
hintText: "输入验证码",
hintStyle:
TextStyle(color: Color(0xFF6F35A5)),
prefixIcon: Padding(
padding: EdgeInsets.all(defaultPadding),
child: Icon(Icons.lock),
),
),
),
),
),
const SizedBox(height: defaultPadding),
],
const SizedBox(height: defaultPadding),
Row(
children: [
Flexible(child: Container()),
GestureDetector(
onTap: () => controller.chageCodeStatus(),
child: Obx(() => Text(
controller.codeTileStr.value,
style: const TextStyle(
color: Colors.white54,
fontSize: 12),
)),
)
],
),
const SizedBox(height: defaultPadding * 6),
Hero(
tag: "login_btn",
child: GestureDetector(
onTap: () => controller.handleSignIn(),
child: Container(
width: Get.width - 40,
height: 50,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(45 / 2.0)),
color: Color(0xFF6F35A5)),
child: Text(
"登录".toUpperCase(),
),
),
),
),
const SizedBox(height: defaultPadding),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Obx(() => Checkbox(
shape: const CircleBorder(),
value: controller.privactChecked.value,
checkColor: kPrimaryColor,
onChanged: (onChanged) => controller
.privactChecked
.value = onChanged ?? false)),
RichText(
text: TextSpan(children: <InlineSpan>[
const TextSpan(
text: '请阅读并同意',
style:
TextStyle(color: Colors.white)),
TextSpan(
text: '《用户协议》',
style:
const TextStyle(color: Colors.grey),
recognizer: TapGestureRecognizer()
..onTap = () {
Get.toNamed(AppRoutes.USER_PRIVACT);
},
),
TextSpan(
text: '《隐私政策》',
style:
const TextStyle(color: Colors.grey),
recognizer: TapGestureRecognizer()
..onTap = () {
Get.toNamed(AppRoutes.PRIVACT);
},
),
]),
)
],
)
],
),
),
),
),
Spacer(),
],
),
],
)
],
Spacer(),
// Row(
// children: [
// Spacer(),
// RichText(
// text: TextSpan(children: [
// const TextSpan(text: "同意"),
// TextSpan(
// text: "《服务协议》",
// recognizer: TapGestureRecognizer()
// ..onTap = () {
// Get.toNamed(AppRoutes.PRIVACT);
// }),
// const TextSpan(text: " "),
// TextSpan(
// text: "《隐私政策》",
// recognizer: TapGestureRecognizer()
// ..onTap = () {
// Get.toNamed(AppRoutes.USER_PRIVACT);
// }),
// ]),
// )
// ],
// )
],
),
],
)
],
),
),
),
),);
);
// return GestureDetector(
// behavior: HitTestBehavior.translucent,
// onTap: () => FocusScope.of(buildContext).unfocus(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment