| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676 |
- import 'dart:convert';
- import 'dart:io';
- import 'package:bbyyy/beans/app_store_review_bean_entity.dart';
- import 'package:bbyyy/beans/login_information_bean_entity.dart';
- import 'package:bbyyy/https/MyDio.dart';
- import 'package:bbyyy/https/my_request.dart';
- import 'package:bbyyy/my_tools/easy_loading/easy_loading.dart';
- import 'package:bbyyy/my_tools/event_bus.dart';
- import 'package:bbyyy/my_tools/my_apis.dart';
- import 'package:bbyyy/my_tools/my_colors.dart';
- import 'package:bbyyy/my_tools/my_cookie.dart';
- import 'package:bbyyy/my_tools/my_tools.dart';
- import 'package:bbyyy/my_tools/my_views.dart';
- import 'package:bbyyy/my_tools/protocol.dart';
- import 'package:bbyyy/paegs/forget_password_page/forget_password_page.dart';
- import 'package:bbyyy/paegs/guest_login_page/root_page.dart';
- import 'package:bbyyy/paegs/registered_page/registered_page.dart';
- import 'package:bbyyy/paegs/root_page/root_page.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/gestures.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_svg/flutter_svg.dart';
- class LoginPage extends StatefulWidget {
- @override
- _LoginPageState createState() => _LoginPageState();
- }
- class _LoginPageState extends State<LoginPage> {
- TextEditingController _phoneNum = TextEditingController(text: '');
- TextEditingController _pw = TextEditingController(text: '');
- int focus = -1;
- bool showBrowse = false;
- bool obscureText = true;
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- print('MyCookie().reNum===========${MyCookie().reNum}');
- EventBus().on('服务器异常,请稍后再试', (arg) {
- qAPP();
- });
- Future.delayed(Duration.zero, () {
- MyCookie().reNum = 0;
- checkAuditStatus();
- if (MyCookie().prefs.getBool('同意协议') == null) {
- showDialog(
- context: context,
- builder: (BuildContext context) {
- return Material(
- color: Colors.transparent,
- child: Center(
- child: Container(
- height: 220,
- margin: EdgeInsets.symmetric(horizontal: 20),
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(15),
- ),
- child: Column(
- children: [
- Container(
- child:
- MyViews().myText('使用协议和隐私政策', MyColors.c333333, 18),
- margin: EdgeInsets.only(top: 12),
- ),
- Expanded(
- child: Container(
- margin: EdgeInsets.all(12),
- child: RichText(
- text: TextSpan(
- children: [
- TextSpan(
- text: '《使用协议》',
- style: TextStyle(
- color: MyColors.cFF4233,
- fontSize: 14),
- recognizer: TapGestureRecognizer()
- ..onTap = () {
- MyTools().toPage(
- context,
- PrivacyPolicyPage(
- '使用协议', serviceAgreement),
- (then) {});
- }),
- TextSpan(
- text: '和',
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 14)),
- TextSpan(
- text: '《隐私政策》',
- style: TextStyle(
- color: MyColors.cFF4233,
- fontSize: 14),
- recognizer: TapGestureRecognizer()
- ..onTap = () {
- MyTools().toPage(
- context,
- PrivacyPolicyPage(
- '隐私政策', privacyPolicy),
- (then) {});
- }),
- TextSpan(
- text: '了解详细信息。如你同意,请点击"同意开始接受我们的服务',
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 14)),
- ],
- text:
- '请你务必审慎阅读、充分理解"使用协议“和“隐私政策"各条款,你可以在"设置"中查看、变更、删除个人信息并管理你的授权。你可阅读',
- style: TextStyle(
- color: MyColors.c333333, fontSize: 14)),
- ),
- ),
- ),
- Container(
- height: 0.5,
- color: MyColors.cBFBFBF,
- ),
- Row(
- children: [
- Expanded(
- child: GestureDetector(
- onTap: () async {
- await SystemChannels.platform
- .invokeMethod('SystemNavigator.pop');
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- height: 50,
- child: Text(
- '暂不使用',
- style: TextStyle(
- color: MyColors.c333333, fontSize: 20),
- ),
- alignment: Alignment.center,
- ),
- ),
- ),
- Expanded(
- child: GestureDetector(
- onTap: () {
- Navigator.pop(context);
- MyCookie().prefs.setBool('同意协议', true);
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- height: 50,
- child: Text(
- '同意',
- style: TextStyle(
- color: MyColors.cFF4233, fontSize: 20),
- ),
- alignment: Alignment.center,
- ),
- ),
- ),
- ],
- )
- ],
- ),
- ),
- ),
- );
- },
- );
- }
- });
- }
- @override
- void dispose() {
- // TODO: implement dispose
- super.dispose();
- EventBus().off('服务器异常,请稍后再试');
- }
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: () {
- MyTools().hideKeyboard(context);
- setState(() {
- focus = -1;
- });
- },
- child: Scaffold(
- body: SingleChildScrollView(
- child: Column(
- children: [
- Container(
- height: MediaQuery.of(context).size.height,
- child: Column(
- children: [
- Container(
- height: MediaQuery.of(context).size.width * (506 / 750),
- child: Stack(
- children: [
- Image.asset(
- 'images/bg_1.png',
- width: MediaQuery.of(context).size.width,
- height:
- MediaQuery.of(context).size.width * (506 / 750),
- ),
- Positioned(
- top: 67,
- child: Stack(
- children: [
- Image.asset(
- 'images/yuan_bg.png',
- height: 147,
- width: 147,
- ),
- Image.asset(
- 'images/logo.png',
- height: 90,
- width: 90,
- )
- ],
- alignment: Alignment.center,
- ),
- )
- ],
- alignment: Alignment.topCenter,
- ),
- ),
- Expanded(
- child: Container(
- padding: EdgeInsets.only(left: 47, right: 47, top: 26),
- child: Column(
- children: [
- Container(
- child: Text(
- 'Hello Welcome !',
- style: TextStyle(
- color: MyColors.cFF4233, fontSize: 24),
- ),
- margin: EdgeInsets.only(bottom: 25),
- ),
- Row(
- children: [
- Container(
- width: 22,
- height: 22,
- child: SvgPicture.asset(
- 'images/svg/手机.svg',
- height: 22,
- width: 22,
- ),
- ),
- Expanded(
- child: TextField(
- controller: _phoneNum,
- cursorColor: MyColors.cFF4233,
- cursorWidth: 1.0,
- onTap: () {
- setState(() {
- focus = 0;
- });
- },
- decoration: InputDecoration(
- border: InputBorder.none,
- disabledBorder: InputBorder.none,
- enabledBorder: InputBorder.none,
- focusedBorder: InputBorder.none,
- isDense: true,
- hintText: '请输入手机号',
- hintStyle: TextStyle(
- color: MyColors.c999999,
- fontSize: 16),
- contentPadding: const EdgeInsets.fromLTRB(
- 14, 4.5, 8, 4.5),
- ),
- maxLines: 1,
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 16,
- height: 1.3,
- letterSpacing: 0.2),
- keyboardType: TextInputType.number,
- onChanged: (t) {},
- ),
- )
- ],
- ),
- Container(
- height: 1,
- color: focus == 0
- ? MyColors.cFF4233
- : MyColors.cD7D7D7,
- margin: EdgeInsets.only(top: 8, bottom: 35),
- ),
- Row(
- children: [
- Container(
- child: SvgPicture.asset(
- 'images/svg/密码.svg',
- height: 22,
- width: 22,
- ),
- height: 22,
- width: 22,
- ),
- Expanded(
- child: TextField(
- controller: _pw,
- cursorColor: MyColors.cFF4233,
- cursorWidth: 1.0,
- onTap: () {
- setState(() {
- focus = 1;
- });
- },
- decoration: InputDecoration(
- border: InputBorder.none,
- disabledBorder: InputBorder.none,
- enabledBorder: InputBorder.none,
- focusedBorder: InputBorder.none,
- hintText: '请输入密码',
- hintStyle: TextStyle(
- color: MyColors.c999999,
- fontSize: 16),
- isDense: true,
- contentPadding:
- const EdgeInsets.fromLTRB(
- 14, 4.5, 8, 4.5)),
- maxLines: 1,
- style: TextStyle(
- color: MyColors.c333333,
- fontSize: 16,
- height: 1.3,
- letterSpacing: 0.2),
- keyboardType: TextInputType.visiblePassword,
- obscureText: obscureText,
- onChanged: (t) {},
- ),
- ),
- GestureDetector(
- onTap: () {
- setState(() {
- obscureText = !obscureText;
- });
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- height: 35,
- width: 35,
- padding: EdgeInsets.all(6.5),
- child: SvgPicture.asset(obscureText
- ? 'images/svg/不显示.svg'
- : 'images/svg/显示.svg'),
- ),
- ),
- ],
- ),
- Container(
- height: 1,
- color: focus == 1
- ? MyColors.cFF4233
- : MyColors.cD7D7D7,
- margin: EdgeInsets.only(top: 8, bottom: 39),
- ),
- Row(
- children: [
- Expanded(
- child: GestureDetector(
- onTap: () {
- if (_phoneNum.text.isEmpty ||
- _phoneNum.text.length != 11) {
- showToast('请填写正确的手机号');
- return;
- }
- if (_pw.text.isEmpty) {
- showToast('请填写密码');
- return;
- }
- login();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(
- Radius.circular(22),
- ),
- gradient: LinearGradient(
- colors: MyColors.lg,
- ),
- ),
- height: 44,
- child: Text(
- '登 录',
- style: TextStyle(
- color: Colors.white, fontSize: 17),
- ),
- alignment: Alignment.center,
- padding: EdgeInsets.only(bottom: 2),
- ),
- ),
- ),
- Visibility(
- child: Container(
- width: 20,
- ),
- visible: showBrowse,
- ),
- Visibility(
- visible: showBrowse,
- child: Expanded(
- child: GestureDetector(
- onTap: () {
- guestLogin();
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(
- Radius.circular(22),
- ),
- gradient: LinearGradient(
- colors: MyColors.lg,
- ),
- ),
- height: 44,
- child: Text(
- '游客登录',
- style: TextStyle(
- color: Colors.white,
- fontSize: 17),
- ),
- alignment: Alignment.center,
- padding: EdgeInsets.only(bottom: 2),
- ),
- ),
- ),
- ),
- ],
- ),
- // GestureDetector(
- // onTap: () {
- // wechatLogin();
- // },
- // behavior: HitTestBehavior.translucent,
- // child: Container(
- // decoration: BoxDecoration(
- // borderRadius: BorderRadius.all(
- // Radius.circular(22),
- // ),
- // border: Border.all(
- // color: MyColors.c333333, width: 1)),
- // height: 44,
- // child: Row(
- // children: [
- // Container(
- // child:
- // SvgPicture.asset('images/svg/微信.svg'),
- // margin: EdgeInsets.only(right: 20),
- // ),
- // Text(
- // '微信登录',
- // style: TextStyle(
- // color: MyColors.c333333,
- // fontSize: 17),
- // ),
- // ],
- // mainAxisAlignment: MainAxisAlignment.center,
- // ),
- // alignment: Alignment.center,
- // padding: EdgeInsets.only(bottom: 2),
- // margin: EdgeInsets.only(top: 10),
- // ),
- // ),
- // Container(
- // alignment: Alignment.centerRight,
- // child: GestureDetector(
- // onTap: () {
- // MyTools().toPage(
- // context, RegisteredPage(), (then) {},
- // noBack: true);
- // },
- // behavior: HitTestBehavior.translucent,
- // child: Container(
- // child: Text(
- // '没有账号,去注册',
- // style: TextStyle(
- // color: MyColors.cFF4233, fontSize: 13),
- // ),
- // padding: EdgeInsets.all(8),
- // margin: EdgeInsets.only(top: 22),
- // ),
- // ),
- // ),
- Expanded(
- child: SafeArea(
- bottom: true,
- child: Container(
- padding: EdgeInsets.only(bottom: 50),
- alignment: Alignment.bottomCenter,
- child: Row(
- children: [
- GestureDetector(
- onTap: () {
- MyTools().toPage(context,
- RegisteredPage(), (then) {},
- noBack: true);
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- padding: EdgeInsets.all(8),
- child: Text(
- '注册账号',
- style: TextStyle(
- color: MyColors.c666666,
- fontSize: 14),
- ),
- ),
- ),
- Container(
- height: 13,
- width: 2,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.all(
- Radius.circular(1)),
- color: MyColors.cFF4233,
- ),
- margin: EdgeInsets.only(
- left: 27, right: 27),
- ),
- GestureDetector(
- onTap: () {
- MyTools().toPage(context,
- ForgetPasswordPage(), (then) {},
- noBack: true);
- },
- behavior: HitTestBehavior.translucent,
- child: Container(
- padding: EdgeInsets.all(8),
- child: Text(
- '忘记密码',
- style: TextStyle(
- color: MyColors.c666666,
- fontSize: 14),
- ),
- ),
- ),
- ],
- mainAxisAlignment: MainAxisAlignment.center,
- ),
- ),
- ),
- )
- ],
- crossAxisAlignment: CrossAxisAlignment.start,
- ),
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
- void login() {
- EasyLoading.show();
- print(MyCookie().switching);
- loginAccount({
- 'user': _phoneNum.text,
- 'password': MyTools.base64Encode(_pw.text),
- 'version': MyCookie().packageInfo.version,
- 'phone': Platform.isAndroid ? 'Android' : 'IOS',
- 'seq': int.parse(MyCookie().prefs.getString('serverID'))
- }, (r, hE) {
- if (!hE) {
- EasyLoading.dismiss();
- LoginInformationBeanEntity entity =
- LoginInformationBeanEntity.fromJson(json.decode(r.data.toString()));
- MyCookie().saveLoginInformationBeanEntity(entity);
- MyDio().initDio();
- MyTools().toPage(context, RootPage(), (then) {}, noBack: true);
- }
- }, (e) {});
- }
- void checkAuditStatus() {
- EasyLoading.show();
- MyDio().post(MyApis.getApi('appStoreReview'),
- {'version': MyCookie().packageInfo.version}, (response, hasError) {
- if (!hasError) {
- EasyLoading.dismiss();
- AppStoreReviewBeanEntity e = AppStoreReviewBeanEntity.fromJson(
- json.decode(response.data.toString()));
- print(e.data);
- if (e.data && Platform.isIOS) {
- setState(() {
- showBrowse = true;
- MyCookie().underReview = showBrowse;
- });
- }
- }
- }, (error) {});
- }
- void guestLogin() {
- MyTools().toPage(context, RootPage1(), (then) {});
- }
- void qAPP() {
- showDialog(
- context: context,
- builder: (BuildContext context) {
- return Material(
- color: Colors.black12,
- child: Center(
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(16),
- color: Colors.white,
- ),
- height: 180,
- margin: EdgeInsets.symmetric(horizontal: 18),
- padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
- child: Column(
- children: [
- Center(
- child: Container(
- height: 100,
- child: MyViews()
- .myText('网络链接异常,请检查您的网络。', MyColors.c333333, 14),
- margin: EdgeInsets.symmetric(horizontal: 20),
- alignment: Alignment.center,
- ),
- ),
- Container(
- height: 0.5,
- color: MyColors.cE7E7E7,
- margin: EdgeInsets.only(bottom: 12),
- ),
- Container(
- margin: EdgeInsets.symmetric(horizontal: 10),
- child: GestureDetector(
- behavior: HitTestBehavior.translucent,
- onTap: () async {
- await SystemChannels.platform
- .invokeMethod('SystemNavigator.pop');
- },
- child: Container(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(20),
- color: MyColors.cFF4233),
- height: 40,
- child: MyViews().myText('退 出', Colors.white, 14),
- alignment: Alignment.center,
- ),
- ),
- )
- ],
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- ),
- ),
- ),
- );
- },
- );
- }
- void wechatLogin() {
- }
- }
|