LoginFirst.dart 6.4 KB

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