LoginFirst.dart 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import '../styles/colors.dart';
  4. import 'dart:ui';
  5. import '../styles/totast.dart';
  6. import 'LoginSecond.dart';
  7. import '../utils/Utils.dart';
  8. import '../widget/LinearButton.dart';
  9. import '../net/HttpManager.dart';
  10. import '../net/Result.dart';
  11. class LoginFirst extends StatefulWidget {
  12. @override
  13. LoginFirstState createState() => LoginFirstState();
  14. }
  15. class LoginFirstState extends State<LoginFirst> {
  16. String inputVal;
  17. @override
  18. Widget build(BuildContext context) {
  19. return WillPopScope(
  20. child: Scaffold(
  21. body: Container(
  22. color: BG_SUB_COLOR,
  23. child: CustomScrollView(
  24. slivers: <Widget>[
  25. SliverAppBar(
  26. backgroundColor: BG_SUB_COLOR,
  27. centerTitle: true,
  28. elevation: 0,
  29. leading: Container(),
  30. ),
  31. SliverToBoxAdapter(
  32. child: Container(
  33. width: double.infinity,
  34. padding: EdgeInsets.symmetric(vertical: 20, horizontal: 15),
  35. color: BG_SUB_COLOR,
  36. child: Column(
  37. crossAxisAlignment: CrossAxisAlignment.start,
  38. children: <Widget>[
  39. // Text(
  40. // 'LOGO',
  41. // style: TextStyle(
  42. // color: Colors.white,
  43. // fontSize: 64,
  44. // ),
  45. // ),
  46. Image.asset('images/icon_logo.png'),
  47. Container(
  48. margin: EdgeInsets.only(top: 30),
  49. child: Text('手机账号登录', style: TextStyle(color: Colors.white, fontSize: 28, fontWeight: FontWeight.w500)),
  50. ),
  51. Container(
  52. margin: EdgeInsets.only(top: 20),
  53. child: TextField(
  54. autofocus: true,
  55. keyboardType: TextInputType.phone,
  56. maxLength: 11,
  57. style: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w500),
  58. decoration: InputDecoration(
  59. hintText: '输入手机号',
  60. hintStyle: TextStyle(
  61. fontSize: 16,
  62. color: Color(0xFF727785),
  63. ),
  64. prefixIcon: Container(
  65. padding: EdgeInsets.all(10),
  66. // color: PRIMARY_COLOR,
  67. child: Image.asset(
  68. 'images/list_icon_shouji.png',
  69. width: 20,
  70. ),
  71. ),
  72. // suffixIcon:Container(
  73. // padding: EdgeInsets.all(10),
  74. // // color: PRIMARY_COLOR,
  75. // child: Image.asset(
  76. // 'images/list_icon_shouji.png',
  77. // width: 20,
  78. // ),
  79. // ),
  80. counterStyle: TextStyle(color: BG_SUB_COLOR, fontSize: 0)),
  81. onChanged: (value) {
  82. inputVal = value;
  83. })),
  84. // Text('未注册的手机号验证后自动创建账户', style: TextStyle(color: Color(0xFF727785), fontSize: 13)),
  85. Container(
  86. height: 52,
  87. ),
  88. LinearButton(
  89. btntext: '下一步',
  90. onTapHomeMenu: () async {
  91. if (!checkPhone(inputVal)) {
  92. Toast.show(context, '手机号格式错误', 1500, 'info');
  93. } else {
  94. final Result res = await HttpManager.get('userInfo/getOne', data: {'phone': inputVal});
  95. if (res.data != null && res.data['id'] != null) {
  96. Navigator.push(
  97. context,
  98. CupertinoPageRoute(
  99. builder: (context) => LoginSecond(phone: inputVal, userId: res.data['id']),
  100. ),
  101. );
  102. } else {
  103. Navigator.push(
  104. context,
  105. CupertinoPageRoute(
  106. builder: (context) => LoginSecond(phone: inputVal, userId: 0),
  107. ),
  108. );
  109. }
  110. }
  111. }),
  112. // FlatButton(
  113. // textColor: Colors.white,
  114. // color: PRIMARY_COLOR,
  115. // highlightColor: Color(0xFF763434),
  116. // child: Text('下一步'),
  117. // onPressed: () {
  118. // if (!checkPhone(inputVal)) {
  119. // Toast.show(context, '手机号格式错误', 1500, 'info');
  120. // } else {
  121. // Navigator.push(
  122. // context,
  123. // CupertinoPageRoute(
  124. // builder: (context) => LoginSecond(phone: inputVal),
  125. // ),
  126. // );
  127. // }
  128. // },
  129. // ),
  130. ],
  131. ),
  132. ),
  133. )
  134. ],
  135. ),
  136. )),
  137. onWillPop: () {
  138. Toast.hide();
  139. // Navigator.pop(context);
  140. return Future.value(false);
  141. });
  142. }
  143. }