| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:link/constants.dart';
- import 'package:link/utils/global.dart';
- import 'package:link/utils/util.dart';
- import 'package:link/view/component/code.dart';
- import 'package:link/view/component/link_btn.dart';
- import 'package:link/view/component/toast.dart';
- import '../utils/api.dart';
- import '../utils/http_utils.dart';
- import '../utils/size_fit.dart';
- import 'component/top_container.dart';
- class InviteCode extends StatefulWidget {
- const InviteCode({Key? key}) : super(key: key);
- @override
- State<InviteCode> createState() => _InviteCodeState();
- }
- class _InviteCodeState extends State<InviteCode> {
- String code = '';
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- code = Global().code;
- Util().setPageTitle('invite');
- }
- tapBegin() {
- if (code.length != 4) {
- Toast().showInfoText('邀请码错误,请重新输入', context: context);
- setState(() {
- code = '';
- });
- return;
- }
- checkCode();
- //
- }
- Future checkCode() async {
- Map<String, dynamic> data = await HttpUtils.get(Api.inviteCodeExist,params: {
- 'invite_code':code
- });
- if (data['success']==false){
- Toast().showInfoText(data['message'], context: context);
- return;
- }
- Get.toNamed('/signup',parameters: {'code':code});
- }
- updateCode(strCode) {
- setState(() {
- code = strCode;
- });
- }
- @override
- Widget build(BuildContext context) {
- SizeFit.initialize(context);
- return Material(
- color: kBgColor,
- child: TopContainer(
- child: Stack(children: [
- // Positioned(
- // left: 0,
- // top: 0,
- // right: 0,
- // child: Container(
- // padding: EdgeInsets.only(
- // left: 12.px, right: 12.px, top: 14.px, bottom: 14.px),
- // alignment: Alignment.topLeft,
- // child: Image.asset(
- // 'assets/images/navi_back.png',
- // width: 20.px,
- // height: 20.px,
- // ),
- // )),
- Container(
- padding: EdgeInsets.only(top: 47.px),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Image.asset(
- 'assets/images/logo.png',
- width: 167.px,
- height: 64.px,
- ),
- SizedBox(
- height: 20.px,
- ),
- Text(
- '如果你已获得邀请码且尚未注册,请输入邀请码\n如果你尚未获得邀请码,请耐心等待',
- textAlign: TextAlign.center,
- style: TextStyle(
- color: const Color(0xFF74747A),
- fontSize: 14.px,
- height: 1.71),
- ),
- SizedBox(
- height: 12.px,
- ),
- Code(
- type: 1,
- code: code,
- changed: (e) {
- updateCode(e);
- }),
- SizedBox(
- height: 24.px,
- ),
- LinkButton(
- title: '使用邀请码·开始注册',
- disable: false,
- isBlack: false,
- callback: () {
- tapBegin();
- }),
- SizedBox(
- height: 52.px,
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text('如果你已完成注册,请点击',
- style: TextStyle(
- color: const Color(0xFF444447),
- fontSize: 14.px)),
- GestureDetector(
- onTap: (){Get.toNamed('/login');},
- child: Text(
- '前往登录',
- style: TextStyle(color: kBtnColor, fontSize: 14.px),
- ),
- )
- ],
- )
- ]))
- ])));
- }
- }
|