registered_page.dart 29 KB

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