import 'dart:convert'; import 'dart:io'; import 'package:bbyyy/beans/upload_image_bean_entity.dart'; import 'package:bbyyy/https/my_request.dart'; import 'package:bbyyy/my_tools/my_colors.dart'; import 'package:bbyyy/my_tools/my_tools.dart'; import 'package:bbyyy/my_tools/my_views.dart'; import 'package:bbyyy/paegs/login_page/login_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/svg.dart'; import 'package:image_cropper/image_cropper.dart'; import 'package:image_picker/image_picker.dart'; class RegisteredPage extends StatefulWidget { @override _RegisteredPageState createState() => _RegisteredPageState(); } class _RegisteredPageState extends State { TextEditingController _phoneNum = TextEditingController(text: ''); TextEditingController _nickname = TextEditingController(text: ''); TextEditingController _pw = TextEditingController(text: ''); int focus = -1; bool haveRead = false; File _image; final picker = ImagePicker(); @override Widget build(BuildContext context) { return GestureDetector( onTap: () { MyTools().hideKeyboard(context); setState(() { focus = -1; }); }, child: Scaffold( body: SingleChildScrollView( child: Column( children: [ 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: Column( children: [ Stack( children: [ Image.asset( 'images/yuan_bg.png', height: 147, width: 147, ), GestureDetector( child: _image == null ? SvgPicture.asset( 'images/svg/头像上传.svg', height: 75, width: 75, ) : ClipRRect( child: Image.file( _image, height: 75, width: 75, ), borderRadius: BorderRadius.all( Radius.circular(75 / 2)), ), onTap: () async { final pickedFile = await picker.getImage( source: ImageSource.gallery); print('pickedFile---${pickedFile.path}'); if (pickedFile != null) { File cropperImg = await ImageCropper.cropImage( sourcePath: pickedFile.path, aspectRatioPresets: [ CropAspectRatioPreset .square, ], androidUiSettings: AndroidUiSettings( toolbarTitle: '图片剪裁', toolbarColor: MyColors.cFF4233, toolbarWidgetColor: Colors.white, initAspectRatio: CropAspectRatioPreset .square, lockAspectRatio: true), iosUiSettings: IOSUiSettings( minimumAspectRatio: 1.0, )); if (cropperImg != null) { setState(() { print('cropperImg---${cropperImg.path}'); _image = cropperImg; print('_image---${_image.path}'); }); } } }, behavior: HitTestBehavior.translucent, ) ], alignment: Alignment.center, ), Container( child: Text( '头像上传', style: TextStyle( color: Colors.white, fontSize: 14), ), margin: EdgeInsets.only(top: 6), ) ], ), ) ], alignment: Alignment.topCenter, ), ), 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( child: SvgPicture.asset( 'images/svg/手机.svg', height: 22, width: 22, ), height: 22, width: 22, ), Expanded( child: TextField( controller: _phoneNum, inputFormatters: [ onlyInputNumberAndWorkFormatter(), LengthLimitingTextInputFormatter(11) ], 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: 39), ), Row( children: [ Container( child: SvgPicture.asset( 'images/svg/昵称.svg', height: 22, width: 22, ), height: 22, width: 22, ), Expanded( child: TextField( controller: _nickname, cursorColor: MyColors.cFF4233, cursorWidth: 1.0, onTap: () { setState(() { focus = 2; }); }, 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.text, onChanged: (t) {}, ), ), ], ), // Row( // children: [ // Container( // child: SvgPicture.asset( // 'images/svg/验证码.svg', // height: 22, // width: 22, // ), // height: 22, // width: 22, // ), // Expanded( // child: TextField( // controller: _verificationCode, // 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.text, // onChanged: (t) {}, // ), // ), // Container( // decoration: BoxDecoration( // color: MyColors.c19FF4233, // borderRadius: // BorderRadius.all(Radius.circular(4))), // height: 34, // width: 90, // ) // ], // ), Container( height: 1, color: focus == 2 ? MyColors.cFF4233 : MyColors.cD7D7D7, margin: EdgeInsets.only(top: 8, bottom: 39), ), Row( children: [ Container( child: SvgPicture.asset( 'images/svg/密码.svg', height: 22, width: 22, ), height: 22, width: 22, ), Expanded( child: TextField( controller: _pw, inputFormatters: [ onlyInputNumberAndWorkFormatter(), LengthLimitingTextInputFormatter(8) ], 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: '请输入密码(6到8位)', 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: true, onChanged: (t) {}, ), ) ], ), Container( height: 1, color: focus == 1 ? MyColors.cFF4233 : MyColors.cD7D7D7, margin: EdgeInsets.only(top: 8, bottom: 39), ), GestureDetector( onTap: () { if (_phoneNum.text.isEmpty || _phoneNum.text.length != 11) { showToast('请填写正确的手机号'); return; } if (_pw.text.isEmpty || _pw.text.length < 6) { showToast('请填写正确的密码(由数字和字母组合的至少6位的组合)'); return; } if (_nickname.text.isEmpty) { showToast('请填写昵称'); return; } if (_image == null) { showToast('请设置头像'); return; } if(!haveRead){ showToast('请阅读并同意《隐私政策》'); return; } uploadAvatar(); }, behavior: HitTestBehavior.translucent, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(20), ), gradient: LinearGradient( colors: MyColors.lg, ), ), height: 44, child: Text( '注 册', style: TextStyle( color: Colors.white, fontSize: 17), ), alignment: Alignment.center, padding: EdgeInsets.only(bottom: 2), ), ), Container( alignment: Alignment.centerRight, child: GestureDetector( onTap: () { MyTools().toPage( context, LoginPage(), (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), ), ), ), Row( children: [ Checkbox(value: haveRead, onChanged: (v){ setState(() { haveRead = v; }); }, activeColor: MyColors.cFF4233,), RichText( text: TextSpan( text: '我已阅读并同意', style: TextStyle( color: MyColors.c999999, fontSize: 12), children: [ TextSpan( text: '《使用协议》和《隐私政策》', style: TextStyle( color: MyColors.cFF4233, fontSize: 12), recognizer: TapGestureRecognizer() ..onTap = () { MyTools().toPage(context, PrivacyPolicyPage(), (then){}); }), ]), ), ], mainAxisAlignment: MainAxisAlignment.end, ), ], crossAxisAlignment: CrossAxisAlignment.start, ), ), ], ), ], ), ), ), ); } void uploadAvatar() { upload(_image, (r, hasError) { if (!hasError) { UploadImageBeanEntity data = UploadImageBeanEntity().fromJson(json.decode(r.data.toString())); registered(data); } }, (error) {}); } void registered(UploadImageBeanEntity data) { registeredAccountNumber({ 'mobile':_phoneNum.text, 'name':_nickname.text, 'password':MyTools.base64Encode(_pw.text), 'picture':data.data[0].path, }, (re, hasError) { if(!hasError){ showToast('注册成功'); MyTools().toPage( context, LoginPage(), (then) {}, noBack: true); } }, (error) {}); } } class PrivacyPolicyPage extends StatefulWidget { @override _PrivacyPolicyPageState createState() => _PrivacyPolicyPageState(); } class _PrivacyPolicyPageState extends State { @override Widget build(BuildContext context) { return Scaffold(body: Column(children: [ MyViews().myAppBar('隐私政策', context, []), Expanded(child: SingleChildScrollView(child: Padding( padding: const EdgeInsets.all(8.0), child: Text('''   梆梆鱼尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确、更有个性化的服务,梆梆鱼会按照本隐私权政策的规定使用和披露您的个人信息。但梆梆鱼将以高度的勤勉、审慎义务对待这些信息。除本隐私权政策另有规定外,在未征得您事先许可的情况下,梆梆鱼不会将这些信息对外披露或向第三方提供。梆梆鱼会不时更新本隐私权政策。 您在同意梆梆鱼服务使用协议之时,即视为您已经同意本隐私权政策全部内容。本隐私权政策属于梆梆鱼服务使用协议不可分割的一部分。   \n1. 适用范围   \na) 在您注册梆梆鱼帐号时,您根据梆梆鱼要求提供的个人注册信息;   \nb) 在您使用梆梆鱼网络服务,或访问梆梆鱼平台网页时,梆梆鱼自动接收并记录的您的浏览器和计算机上的信息,包括但不限于您的IP地址、浏览器的类型、使用的语言、访问日期和时间、软硬件特征信息及您需求的网页记录等数据;   \nc) 梆梆鱼通过合法途径从商业伙伴处取得的用户个人数据。   您了解并同意,以下信息不适用本隐私权政策:   \na) 您在使用梆梆鱼平台提供的搜索服务时输入的关键字信息;   \nb) 梆梆鱼收集到的您在梆梆鱼发布的有关信息数据,包括但不限于参与活动、成交信息及评价详情;   \nc) 违反法律规定或违反梆梆鱼规则行为及梆梆鱼已对您采取的措施。   \n2. 信息使用   \na) 梆梆鱼不会向任何无关第三方提供、出售、出租、分享或交易您的个人信息,除非事先得到您的许可,或该第三方和梆梆鱼(含梆梆鱼关联公司)单独或共同为您提供服务,且在该服务结束后,其将被禁止访问包括其以前能够访问的所有这些资料。   \nb) 梆梆鱼亦不允许任何第三方以任何手段收集、编辑、出售或者无偿传播您的个人信息。任何梆梆鱼平台用户如从事上述活动,一经发现,梆梆鱼有权立即终止与该用户的服务协议。   \nc) 为服务用户的目的,梆梆鱼可能通过使用您的个人信息,向您提供您感兴趣的信息,包括但不限于向您发出产品和服务信息,或者与梆梆鱼合作伙伴共享信息以便他们向您发送有关其产品和服务的信息(后者需要您的事先同意)。   \n3. 信息披露   在如下情况下,梆梆鱼将依据您的个人意愿或法律的规定全部或部分的披露您的个人信息:   \na) 经您事先同意,向第三方披露;   \nb) 为提供您所要求的产品和服务,而必须和第三方分享您的个人信息;   \nc) 根据法律的有关规定,或者行政或司法机构的要求,向第三方或者行政、司法机构披露;   \nd) 如您出现违反中国有关法律、法规或者梆梆鱼服务协议或相关规则的情况,需要向第三方披露;   \ne) 如您是适格的知识产权投诉人并已提起投诉,应被投诉人要求,向被投诉人披露,以便双方处理可能的权利纠纷;   \nf) 在梆梆鱼平台上创建的某一交易中,如交易任何一方履行或部分履行了交易义务并提出信息披露请求的,梆梆鱼有权决定向该用户提供其交易对方的联络方式等必要信息,以促成交易的完成或纠纷的解决。   \ng) 其它梆梆鱼根据法律、法规或者网站政策认为合适的披露。   \n4. 信息存储和交换   梆梆鱼收集的有关您的信息和资料将保存在梆梆鱼及(或)其关联公司的服务器上,这些信息和资料可能传送至您所在国家、地区或梆梆鱼收集信息和资料所在地的境外并在境外被访问、存储和展示。   \n5. Cookie的使用   \na) 在您未拒绝接受cookies的情况下,梆梆鱼会在您的计算机上设定或取用cookies ,以便您能登录或使用依赖于cookies的梆梆鱼平台服务或功能。梆梆鱼使用cookies可为您提供更加周到的个性化服务,包括推广服务。 b) 您有权选择接受或拒绝接受cookies。您可以通过修改浏览器设置的方式拒绝接受cookies。但如果您选择拒绝接受cookies,则您可能无法登录或使用依赖于cookies的梆梆鱼网络服务或功能。   \nc) 通过梆梆鱼所设cookies所取得的有关信息,将适用本政策。   \n6. 信息安全   \na) 梆梆鱼帐号均有安全保护功能,请妥善保管您的用户名及密码信息。梆梆鱼将通过对用户密码进行加密等安全措施确保您的信息不丢失,不被滥用和变造。尽管有前述安全措施,但同时也请您注意在信息网络上不存在“完善的安全措施”。   \nb) 在使用梆梆鱼网络服务进行网上交易时,您不可避免的要向交易对方或潜在的交易对方披露自己的个人信息,如联络方式或者邮政地址。请您妥善保护自己的个人信息,仅在必要的情形下向他人提供。如您发现自己的个人信息泄密,尤其是梆梆鱼用户名及密码发生泄露,请您立即联络梆梆鱼客服,以便梆梆鱼采取相应措施。 '''), ),)) ],),); } }