registered_page.dart 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. import 'dart:convert';
  2. import 'dart:io';
  3. import 'package:bbyyy/beans/upload_image_bean_entity.dart';
  4. import 'package:bbyyy/https/my_request.dart';
  5. import 'package:bbyyy/my_tools/my_colors.dart';
  6. import 'package:bbyyy/my_tools/my_tools.dart';
  7. import 'package:bbyyy/my_tools/my_views.dart';
  8. import 'package:bbyyy/paegs/login_page/login_page.dart';
  9. import 'package:flutter/cupertino.dart';
  10. import 'package:flutter/gestures.dart';
  11. import 'package:flutter/material.dart';
  12. import 'package:flutter/services.dart';
  13. import 'package:flutter_svg/svg.dart';
  14. import 'package:image_cropper/image_cropper.dart';
  15. import 'package:image_picker/image_picker.dart';
  16. class RegisteredPage extends StatefulWidget {
  17. @override
  18. _RegisteredPageState createState() => _RegisteredPageState();
  19. }
  20. class _RegisteredPageState extends State<RegisteredPage> {
  21. TextEditingController _phoneNum = TextEditingController(text: '');
  22. TextEditingController _nickname = TextEditingController(text: '');
  23. TextEditingController _pw = TextEditingController(text: '');
  24. int focus = -1;
  25. bool haveRead = false;
  26. File _image;
  27. final picker = ImagePicker();
  28. @override
  29. Widget build(BuildContext context) {
  30. return GestureDetector(
  31. onTap: () {
  32. MyTools().hideKeyboard(context);
  33. setState(() {
  34. focus = -1;
  35. });
  36. },
  37. child: Scaffold(
  38. body: SingleChildScrollView(
  39. child: Column(
  40. children: [
  41. Column(
  42. children: [
  43. Container(
  44. height: MediaQuery.of(context).size.width * (506 / 750),
  45. child: Stack(
  46. children: [
  47. Image.asset(
  48. 'images/bg_1.png',
  49. width: MediaQuery.of(context).size.width,
  50. height:
  51. MediaQuery.of(context).size.width * (506 / 750),
  52. ),
  53. Positioned(
  54. top: 67,
  55. child: Column(
  56. children: [
  57. Stack(
  58. children: [
  59. Image.asset(
  60. 'images/yuan_bg.png',
  61. height: 147,
  62. width: 147,
  63. ),
  64. GestureDetector(
  65. child: _image == null
  66. ? SvgPicture.asset(
  67. 'images/svg/头像上传.svg',
  68. height: 75,
  69. width: 75,
  70. )
  71. : ClipRRect(
  72. child: Image.file(
  73. _image,
  74. height: 75,
  75. width: 75,
  76. ),
  77. borderRadius: BorderRadius.all(
  78. Radius.circular(75 / 2)),
  79. ),
  80. onTap: () async {
  81. final pickedFile =
  82. await picker.getImage(
  83. source: ImageSource.gallery);
  84. print('pickedFile---${pickedFile.path}');
  85. if (pickedFile != null) {
  86. File cropperImg =
  87. await ImageCropper.cropImage(
  88. sourcePath: pickedFile.path,
  89. cropStyle: CropStyle.rectangle,
  90. aspectRatio: CropAspectRatio(ratioX: 1,ratioY: 1),
  91. aspectRatioPresets: [
  92. CropAspectRatioPreset
  93. .square,
  94. ],
  95. androidUiSettings:
  96. AndroidUiSettings(
  97. toolbarTitle: '图片剪裁',
  98. toolbarColor:
  99. MyColors.cFF4233,
  100. toolbarWidgetColor:
  101. Colors.white,
  102. initAspectRatio:
  103. CropAspectRatioPreset
  104. .square,
  105. lockAspectRatio:
  106. true),
  107. iosUiSettings: IOSUiSettings(
  108. minimumAspectRatio: 1.0,
  109. resetAspectRatioEnabled:false,
  110. rotateButtonsHidden: true
  111. ));
  112. if (cropperImg != null) {
  113. setState(() {
  114. print('cropperImg---${cropperImg.path}');
  115. _image = cropperImg;
  116. print('_image---${_image.path}');
  117. });
  118. }
  119. }
  120. },
  121. behavior: HitTestBehavior.translucent,
  122. )
  123. ],
  124. alignment: Alignment.center,
  125. ),
  126. Container(
  127. child: Text(
  128. '头像上传',
  129. style: TextStyle(
  130. color: Colors.white, fontSize: 14),
  131. ),
  132. margin: EdgeInsets.only(top: 6),
  133. )
  134. ],
  135. ),
  136. )
  137. ],
  138. alignment: Alignment.topCenter,
  139. ),
  140. ),
  141. Container(
  142. padding: EdgeInsets.only(left: 47, right: 47, top: 26),
  143. child: Column(
  144. children: [
  145. Container(
  146. child: Text(
  147. 'Hello Welcome !',
  148. style: TextStyle(
  149. color: MyColors.cFF4233, fontSize: 24),
  150. ),
  151. margin: EdgeInsets.only(bottom: 25),
  152. ),
  153. Row(
  154. children: [
  155. Container(
  156. child: SvgPicture.asset(
  157. 'images/svg/手机.svg',
  158. height: 22,
  159. width: 22,
  160. ),
  161. height: 22,
  162. width: 22,
  163. ),
  164. Expanded(
  165. child: TextField(
  166. controller: _phoneNum,
  167. inputFormatters: [
  168. onlyInputNumberAndWorkFormatter(),
  169. LengthLimitingTextInputFormatter(11)
  170. ],
  171. cursorColor: MyColors.cFF4233,
  172. cursorWidth: 1.0,
  173. onTap: () {
  174. setState(() {
  175. focus = 0;
  176. });
  177. },
  178. decoration: InputDecoration(
  179. border: InputBorder.none,
  180. disabledBorder: InputBorder.none,
  181. enabledBorder: InputBorder.none,
  182. focusedBorder: InputBorder.none,
  183. isDense: true,
  184. hintText: '请输入手机号',
  185. hintStyle: TextStyle(
  186. color: MyColors.c999999,
  187. fontSize: 16),
  188. contentPadding: const EdgeInsets.fromLTRB(
  189. 14, 4.5, 8, 4.5),
  190. ),
  191. maxLines: 1,
  192. style: TextStyle(
  193. color: MyColors.c333333,
  194. fontSize: 16,
  195. height: 1.3,
  196. letterSpacing: 0.2),
  197. keyboardType: TextInputType.number,
  198. onChanged: (t) {},
  199. ),
  200. )
  201. ],
  202. ),
  203. Container(
  204. height: 1,
  205. color: focus == 0
  206. ? MyColors.cFF4233
  207. : MyColors.cD7D7D7,
  208. margin: EdgeInsets.only(top: 8, bottom: 39),
  209. ),
  210. Row(
  211. children: [
  212. Container(
  213. child: SvgPicture.asset(
  214. 'images/svg/昵称.svg',
  215. height: 22,
  216. width: 22,
  217. ),
  218. height: 22,
  219. width: 22,
  220. ),
  221. Expanded(
  222. child: TextField(
  223. inputFormatters: [
  224. LengthLimitingTextInputFormatter(12)
  225. ],
  226. controller: _nickname,
  227. cursorColor: MyColors.cFF4233,
  228. cursorWidth: 1.0,
  229. onTap: () {
  230. setState(() {
  231. focus = 2;
  232. });
  233. },
  234. decoration: InputDecoration(
  235. border: InputBorder.none,
  236. disabledBorder: InputBorder.none,
  237. enabledBorder: InputBorder.none,
  238. focusedBorder: InputBorder.none,
  239. hintText: '请输入昵称',
  240. hintStyle: TextStyle(
  241. color: MyColors.c999999,
  242. fontSize: 16),
  243. isDense: true,
  244. contentPadding:
  245. const EdgeInsets.fromLTRB(
  246. 14, 4.5, 8, 4.5)),
  247. maxLines: 1,
  248. style: TextStyle(
  249. color: MyColors.c333333,
  250. fontSize: 16,
  251. height: 1.3,
  252. letterSpacing: 0.2),
  253. keyboardType: TextInputType.text,
  254. onChanged: (t) {},
  255. ),
  256. ),
  257. ],
  258. ),
  259. // Row(
  260. // children: [
  261. // Container(
  262. // child: SvgPicture.asset(
  263. // 'images/svg/验证码.svg',
  264. // height: 22,
  265. // width: 22,
  266. // ),
  267. // height: 22,
  268. // width: 22,
  269. // ),
  270. // Expanded(
  271. // child: TextField(
  272. // controller: _verificationCode,
  273. // cursorColor: MyColors.cFF4233,
  274. // cursorWidth: 1.0,
  275. // onTap: () {
  276. // setState(() {
  277. // focus = 1;
  278. // });
  279. // },
  280. // decoration: InputDecoration(
  281. // border: InputBorder.none,
  282. // disabledBorder: InputBorder.none,
  283. // enabledBorder: InputBorder.none,
  284. // focusedBorder: InputBorder.none,
  285. // hintText: '请输入验证码',
  286. // hintStyle: TextStyle(
  287. // color: MyColors.c999999, fontSize: 16),
  288. // isDense: true,
  289. // contentPadding:
  290. // const EdgeInsets.fromLTRB(14, 4.5, 8, 4.5)),
  291. // maxLines: 1,
  292. // style: TextStyle(
  293. // color: MyColors.c333333,
  294. // fontSize: 16,
  295. // height: 1.3,
  296. // letterSpacing: 0.2),
  297. // keyboardType: TextInputType.text,
  298. // onChanged: (t) {},
  299. // ),
  300. // ),
  301. // Container(
  302. // decoration: BoxDecoration(
  303. // color: MyColors.c19FF4233,
  304. // borderRadius:
  305. // BorderRadius.all(Radius.circular(4))),
  306. // height: 34,
  307. // width: 90,
  308. // )
  309. // ],
  310. // ),
  311. Container(
  312. height: 1,
  313. color: focus == 2
  314. ? MyColors.cFF4233
  315. : MyColors.cD7D7D7,
  316. margin: EdgeInsets.only(top: 8, bottom: 39),
  317. ),
  318. Row(
  319. children: [
  320. Container(
  321. child: SvgPicture.asset(
  322. 'images/svg/密码.svg',
  323. height: 22,
  324. width: 22,
  325. ),
  326. height: 22,
  327. width: 22,
  328. ),
  329. Expanded(
  330. child: TextField(
  331. controller: _pw,
  332. inputFormatters: [
  333. onlyInputNumberAndWorkFormatter(),
  334. LengthLimitingTextInputFormatter(8)
  335. ],
  336. cursorColor: MyColors.cFF4233,
  337. cursorWidth: 1.0,
  338. onTap: () {
  339. setState(() {
  340. focus = 1;
  341. });
  342. },
  343. decoration: InputDecoration(
  344. border: InputBorder.none,
  345. disabledBorder: InputBorder.none,
  346. enabledBorder: InputBorder.none,
  347. focusedBorder: InputBorder.none,
  348. hintText: '请输入密码(6到8位)',
  349. hintStyle: TextStyle(
  350. color: MyColors.c999999,
  351. fontSize: 16),
  352. isDense: true,
  353. contentPadding:
  354. const EdgeInsets.fromLTRB(
  355. 14, 4.5, 8, 4.5)),
  356. maxLines: 1,
  357. style: TextStyle(
  358. color: MyColors.c333333,
  359. fontSize: 16,
  360. height: 1.3,
  361. letterSpacing: 0.2),
  362. keyboardType: TextInputType.visiblePassword,
  363. obscureText: true,
  364. onChanged: (t) {},
  365. ),
  366. )
  367. ],
  368. ),
  369. Container(
  370. height: 1,
  371. color: focus == 1
  372. ? MyColors.cFF4233
  373. : MyColors.cD7D7D7,
  374. margin: EdgeInsets.only(top: 8, bottom: 20),
  375. ),
  376. Row(
  377. children: [
  378. Checkbox(value: haveRead, onChanged: (v){
  379. setState(() {
  380. haveRead = v;
  381. });
  382. }, activeColor: MyColors.cFF4233,),
  383. RichText(
  384. text: TextSpan(
  385. text: '我已阅读并同意',
  386. style: TextStyle(
  387. color: MyColors.c999999, fontSize: 12),
  388. children: [
  389. TextSpan(
  390. text: '《使用协议》和《隐私政策》',
  391. style: TextStyle(
  392. color: MyColors.cFF4233,
  393. fontSize: 12),
  394. recognizer: TapGestureRecognizer()
  395. ..onTap = () {
  396. MyTools().toPage(context, PrivacyPolicyPage(), (then){});
  397. }),
  398. ]),
  399. ),
  400. ],
  401. mainAxisAlignment: MainAxisAlignment.end,
  402. ),
  403. GestureDetector(
  404. onTap: () {
  405. if (_phoneNum.text.isEmpty ||
  406. _phoneNum.text.length != 11) {
  407. showToast('请填写正确的手机号');
  408. return;
  409. }
  410. if (_pw.text.isEmpty || _pw.text.length < 6) {
  411. showToast('请填写正确的密码(由数字和字母组合的至少6位的组合)');
  412. return;
  413. }
  414. if (_nickname.text.isEmpty) {
  415. showToast('请填写昵称');
  416. return;
  417. }
  418. if (_image == null) {
  419. showToast('请设置头像');
  420. return;
  421. }
  422. if(!haveRead){
  423. showToast('请阅读并同意《隐私政策》');
  424. return;
  425. }
  426. uploadAvatar();
  427. },
  428. behavior: HitTestBehavior.translucent,
  429. child: Container(
  430. margin: EdgeInsets.only(top:20),
  431. decoration: BoxDecoration(
  432. borderRadius: BorderRadius.all(
  433. Radius.circular(20),
  434. ),
  435. gradient: LinearGradient(
  436. colors: MyColors.lg,
  437. ),
  438. ),
  439. height: 44,
  440. child: Text(
  441. '注 册',
  442. style: TextStyle(
  443. color: Colors.white, fontSize: 17),
  444. ),
  445. alignment: Alignment.center,
  446. padding: EdgeInsets.only(bottom: 2),
  447. ),
  448. ),
  449. Container(
  450. alignment: Alignment.centerRight,
  451. child: GestureDetector(
  452. onTap: () {
  453. MyTools().toPage(
  454. context, LoginPage(), (then) {},
  455. noBack: true);
  456. },
  457. behavior: HitTestBehavior.translucent,
  458. child: Container(
  459. child: Text(
  460. '已有账号,去登录',
  461. style: TextStyle(
  462. color: MyColors.cFF4233, fontSize: 13),
  463. ),
  464. padding: EdgeInsets.all(8),
  465. margin: EdgeInsets.only(top: 20),
  466. ),
  467. ),
  468. ),
  469. ],
  470. crossAxisAlignment: CrossAxisAlignment.start,
  471. ),
  472. ),
  473. ],
  474. ),
  475. ],
  476. ),
  477. ),
  478. ),
  479. );
  480. }
  481. void uploadAvatar() {
  482. upload(_image, (r, hasError) {
  483. if (!hasError) {
  484. UploadImageBeanEntity data =
  485. UploadImageBeanEntity().fromJson(json.decode(r.data.toString()));
  486. registered(data);
  487. }
  488. }, (error) {});
  489. }
  490. void registered(UploadImageBeanEntity data) {
  491. registeredAccountNumber({
  492. 'mobile':_phoneNum.text,
  493. 'name':_nickname.text,
  494. 'password':MyTools.base64Encode(_pw.text),
  495. 'picture':data.data[0].path,
  496. }, (re, hasError) {
  497. if(!hasError){
  498. showToast('注册成功');
  499. MyTools().toPage(
  500. context, LoginPage(), (then) {},
  501. noBack: true);
  502. }
  503. }, (error) {});
  504. }
  505. }
  506. class PrivacyPolicyPage extends StatefulWidget {
  507. @override
  508. _PrivacyPolicyPageState createState() => _PrivacyPolicyPageState();
  509. }
  510. class _PrivacyPolicyPageState extends State<PrivacyPolicyPage> {
  511. @override
  512. Widget build(BuildContext context) {
  513. return Scaffold(body: Column(children: [
  514. MyViews().myAppBar('隐私政策', context, []),
  515. Expanded(child: SingleChildScrollView(child: Padding(
  516. padding: const EdgeInsets.all(8.0),
  517. child: Text('''
  518.   梆梆鱼尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确、更有个性化的服务,梆梆鱼会按照本隐私权政策的规定使用和披露您的个人信息。但梆梆鱼将以高度的勤勉、审慎义务对待这些信息。除本隐私权政策另有规定外,在未征得您事先许可的情况下,梆梆鱼不会将这些信息对外披露或向第三方提供。梆梆鱼会不时更新本隐私权政策。 您在同意梆梆鱼服务使用协议之时,即视为您已经同意本隐私权政策全部内容。本隐私权政策属于梆梆鱼服务使用协议不可分割的一部分。
  519.   \n1. 适用范围
  520.   \na) 在您注册梆梆鱼帐号时,您根据梆梆鱼要求提供的个人注册信息;
  521.   \nb) 在您使用梆梆鱼网络服务,或访问梆梆鱼平台网页时,梆梆鱼自动接收并记录的您的浏览器和计算机上的信息,包括但不限于您的IP地址、浏览器的类型、使用的语言、访问日期和时间、软硬件特征信息及您需求的网页记录等数据;
  522.   \nc) 梆梆鱼通过合法途径从商业伙伴处取得的用户个人数据。
  523.   您了解并同意,以下信息不适用本隐私权政策:
  524.   \na) 您在使用梆梆鱼平台提供的搜索服务时输入的关键字信息;
  525.   \nb) 梆梆鱼收集到的您在梆梆鱼发布的有关信息数据,包括但不限于参与活动、成交信息及评价详情;
  526.   \nc) 违反法律规定或违反梆梆鱼规则行为及梆梆鱼已对您采取的措施。
  527.   \n2. 信息使用
  528.   \na) 梆梆鱼不会向任何无关第三方提供、出售、出租、分享或交易您的个人信息,除非事先得到您的许可,或该第三方和梆梆鱼(含梆梆鱼关联公司)单独或共同为您提供服务,且在该服务结束后,其将被禁止访问包括其以前能够访问的所有这些资料。
  529.   \nb) 梆梆鱼亦不允许任何第三方以任何手段收集、编辑、出售或者无偿传播您的个人信息。任何梆梆鱼平台用户如从事上述活动,一经发现,梆梆鱼有权立即终止与该用户的服务协议。
  530.   \nc) 为服务用户的目的,梆梆鱼可能通过使用您的个人信息,向您提供您感兴趣的信息,包括但不限于向您发出产品和服务信息,或者与梆梆鱼合作伙伴共享信息以便他们向您发送有关其产品和服务的信息(后者需要您的事先同意)。
  531.   \n3. 信息披露
  532.   在如下情况下,梆梆鱼将依据您的个人意愿或法律的规定全部或部分的披露您的个人信息:
  533.   \na) 经您事先同意,向第三方披露;
  534.   \nb) 为提供您所要求的产品和服务,而必须和第三方分享您的个人信息;
  535.   \nc) 根据法律的有关规定,或者行政或司法机构的要求,向第三方或者行政、司法机构披露;
  536.   \nd) 如您出现违反中国有关法律、法规或者梆梆鱼服务协议或相关规则的情况,需要向第三方披露;
  537.   \ne) 如您是适格的知识产权投诉人并已提起投诉,应被投诉人要求,向被投诉人披露,以便双方处理可能的权利纠纷;
  538.   \nf) 在梆梆鱼平台上创建的某一交易中,如交易任何一方履行或部分履行了交易义务并提出信息披露请求的,梆梆鱼有权决定向该用户提供其交易对方的联络方式等必要信息,以促成交易的完成或纠纷的解决。
  539.   \ng) 其它梆梆鱼根据法律、法规或者网站政策认为合适的披露。
  540.   \n4. 信息存储和交换
  541.   梆梆鱼收集的有关您的信息和资料将保存在梆梆鱼及(或)其关联公司的服务器上,这些信息和资料可能传送至您所在国家、地区或梆梆鱼收集信息和资料所在地的境外并在境外被访问、存储和展示。
  542.   \n5. Cookie的使用
  543.   \na) 在您未拒绝接受cookies的情况下,梆梆鱼会在您的计算机上设定或取用cookies ,以便您能登录或使用依赖于cookies的梆梆鱼平台服务或功能。梆梆鱼使用cookies可为您提供更加周到的个性化服务,包括推广服务。 b) 您有权选择接受或拒绝接受cookies。您可以通过修改浏览器设置的方式拒绝接受cookies。但如果您选择拒绝接受cookies,则您可能无法登录或使用依赖于cookies的梆梆鱼网络服务或功能。
  544.   \nc) 通过梆梆鱼所设cookies所取得的有关信息,将适用本政策。
  545.   \n6. 信息安全
  546.   \na) 梆梆鱼帐号均有安全保护功能,请妥善保管您的用户名及密码信息。梆梆鱼将通过对用户密码进行加密等安全措施确保您的信息不丢失,不被滥用和变造。尽管有前述安全措施,但同时也请您注意在信息网络上不存在“完善的安全措施”。
  547.   \nb) 在使用梆梆鱼网络服务进行网上交易时,您不可避免的要向交易对方或潜在的交易对方披露自己的个人信息,如联络方式或者邮政地址。请您妥善保护自己的个人信息,仅在必要的情形下向他人提供。如您发现自己的个人信息泄密,尤其是梆梆鱼用户名及密码发生泄露,请您立即联络梆梆鱼客服,以便梆梆鱼采取相应措施。
  548. '''),
  549. ),))
  550. ],),);
  551. }
  552. }