import 'package:ef/ef.dart'; import 'package:flutter/material.dart'; import 'package:get_storage/get_storage.dart'; import 'package:vbvs_app/common/color/appConstants.dart'; import 'package:vbvs_app/common/color/appFontsize.dart'; import 'package:vbvs_app/common/color/app_uri_status.dart'; import 'package:vbvs_app/common/util/CheckNetwork.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; import 'package:vbvs_app/component/tool/TopSlideNotification.dart'; import 'package:vbvs_app/controller/time/countdown_controller.dart'; import 'package:vbvs_app/controller/user_info_controller.dart'; import 'package:vbvs_app/model/api_response.dart'; import 'package:vbvs_app/pages/mh_page/user/controller/bind_tel_controller.dart'; import 'package:vbvs_app/pages/mh_page/user/controller/mht_login_controller.dart'; class BindTelWidget extends GetView { BoxConstraints? bodysize; Map img; final scaffoldKey = GlobalKey(); BindTelWidget({super.key, required this.img}); @override Widget build(BuildContext context) { return LayoutBuilder(builder: (context, cc) { bodysize = cc; return Container( // onTap: () => FocusScope.of(context).unfocus(), decoration: BoxDecoration( image: DecorationImage( image: AssetImage((img!['img'] == null || "" == img!['img']) ? 'assets/images/new_background.png' : img!['img']!), fit: BoxFit.fill, ), ), child: Scaffold( resizeToAvoidBottomInset: false, key: scaffoldKey, backgroundColor: Colors.transparent, appBar: AppBar( backgroundColor: Colors.transparent, automaticallyImplyLeading: false, iconTheme: IconThemeData(color: Colors.white), title: Container( width: double.infinity, height: 180.rpx, child: Stack( alignment: Alignment.center, children: [ Text( '绑定手机号码'.tr, style: TextStyle( fontFamily: 'Readex Pro', color: themeController.currentColor.sc3, letterSpacing: 0, fontSize: 30.rpx, ), ), Positioned( left: 0.rpx, child: returnIconButtomNew(), ), ], ), ), actions: [], centerTitle: false, ), body: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 1, child: Column( mainAxisSize: MainAxisSize.max, children: [ Expanded( child: Padding( padding: EdgeInsetsDirectional.fromSTEB(49.rpx, 0, 49.rpx, 0), child: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 0.886, decoration: BoxDecoration(), child: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 1, decoration: BoxDecoration(), child: Column( mainAxisSize: MainAxisSize.max, children: [ Padding( padding: EdgeInsetsDirectional.fromSTEB(0, 92, 0, 0), child: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 0.05, decoration: BoxDecoration(), child: Align( alignment: AlignmentDirectional(-1, 0), child: Text( '绑定手机号码'.tr, style: TextStyle( fontFamily: 'Readex Pro', color: stringToColor("#84F5FF"), fontSize: 24, letterSpacing: 0.0, ), ), ), ), ), Flexible( child: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 0.06, decoration: BoxDecoration(), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( '为了您的账号安全,验证手机号码后,可直接使用此手机号登录。'.tr, style: TextStyle( fontFamily: 'Readex Pro', color: Colors.white, letterSpacing: 0.0, ), ), // Text( // '', // style: TextStyle( // fontFamily: 'Readex Pro', // color: Colors.white, // letterSpacing: 0.0, // ), // ), ], ), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0, 16, 0, 0), child: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 0.06, decoration: BoxDecoration(), child: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 0.06, decoration: BoxDecoration( color: Color(0xFFF3F5F6), borderRadius: BorderRadius.circular(12), ), child: Align( alignment: AlignmentDirectional(0, 0), child: TextFormField( onChanged: (value) { controller.model.phone = value; }, obscureText: false, decoration: InputDecoration( labelStyle: TextStyle( fontFamily: 'Readex Pro', fontSize: AppFontsize.normal_text_size, letterSpacing: 0.0, ), hintText: '请输入手机号'.tr, hintStyle: TextStyle( fontFamily: 'Readex Pro', color: Color(0xFFD2D2D2), fontSize: AppFontsize.normal_text_size, letterSpacing: 0.0, ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, errorBorder: InputBorder.none, focusedErrorBorder: InputBorder.none, contentPadding: EdgeInsetsDirectional.fromSTEB( 10, 0, 0, 5), ), style: TextStyle( fontFamily: 'Readex Pro', fontSize: 13, letterSpacing: 0.0, ), ), ), ), ), ), Obx(() { controller.model.code; return Visibility( visible: true, child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 0, 17, 0, 0), child: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 0.06, decoration: BoxDecoration(), child: Stack( children: [ Align( alignment: AlignmentDirectional(0, 0), child: Container( width: MediaQuery.sizeOf(context) .width, height: bodysize!.maxHeight * 0.06, decoration: BoxDecoration( color: Color(0xFFF3F5F6), borderRadius: BorderRadius.circular(12), ), child: Align( alignment: AlignmentDirectional(0, 0), child: TextFormField( // focusNode: _focusNode4, onChanged: (value) { controller.model.code = value; }, obscureText: false, decoration: InputDecoration( labelStyle: TextStyle( fontFamily: 'Readex Pro', fontSize: AppFontsize .normal_text_size, letterSpacing: 0, ), hintText: '请输入验证码', hintStyle: TextStyle( fontFamily: 'Readex Pro', color: Color(0xFFD2D2D2), fontSize: AppFontsize .normal_text_size, letterSpacing: 0, ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, errorBorder: InputBorder.none, focusedErrorBorder: InputBorder.none, contentPadding: EdgeInsetsDirectional .fromSTEB( 10, 0, 0, 5), ), style: TextStyle( fontFamily: 'Readex Pro', fontSize: AppFontsize .normal_text_size, letterSpacing: 0, ), ), ), ), ), Align( alignment: AlignmentDirectional(0.2, 0.1), child: Container( width: 3, height: 30, decoration: BoxDecoration( color: Color(0xFFD3D3D3), ), ), ), Align( alignment: AlignmentDirectional(0.9, 0), child: Container( width: MediaQuery.sizeOf(context) .width * 0.157, height: MediaQuery.sizeOf(context) .height * 0.014, constraints: BoxConstraints( minWidth: 118, minHeight: 30, ), decoration: BoxDecoration(), child: Align( alignment: AlignmentDirectional(0, 0), child: Obx(() { final CountdownController countdownController = Get.find< CountdownController>(); return InkWell( onTap: () async { if (countdownController .countdown.value != 0) { return; } String msg = await controller .getCode(context,img); if (msg.isNotEmpty) { return; } countdownController .countdown .value == 0 ? countdownController .startCountdown( AppConstants .code_time) : null; }, child: Text( countdownController .countdown .value == 0 ? '获取验证码' : '${countdownController.countdown.value}秒', style: TextStyle( fontFamily: 'Readex Pro', color: Color(0xFF333333), fontSize: AppFontsize .normal_text_size, letterSpacing: 0, ), ), ); }), ), ), ), ], ), ), ), ); }), Padding( padding: EdgeInsetsDirectional.fromSTEB(0, 19, 0, 0), child: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 0.022, constraints: BoxConstraints( minWidth: 466, minHeight: 30, ), decoration: BoxDecoration(), ), ), Padding( padding: EdgeInsetsDirectional.fromSTEB(0, 29, 0, 0), child: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 0.056, decoration: BoxDecoration(), child: Container( width: bodysize!.maxWidth, height: bodysize!.maxHeight * 0.056, decoration: BoxDecoration( borderRadius: BorderRadius.circular(0), ), // child: FFButtonWidget( // onPressed: () async { // //todo 提交绑定请求 // String msg = await controller.bindTel(); // if (msg == null || msg.isEmpty) { // MHTLoginController loginController = // Get.find(); // //TODO 微信回调监听操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听 // loginController.fluwxCancelable // ?.cancel(); // // 登录成功移出网络检查监听 // Checknetwork.subscription?.cancel(); // final box = GetStorage(); // box.remove('countdown'); // CountdownController // countdownController = Get.find(); // countdownController.countdown = 0.obs; // Get.offAndToNamed( // "/mianPageBottomChange"); // } else { // showToast(msg); // } // }, // text: '确定', // options: FFButtonOptions( // height: 40, // padding: EdgeInsetsDirectional.fromSTEB( // 24, 0, 24, 0), // iconPadding: // EdgeInsetsDirectional.fromSTEB( // 0, 0, 0, 0), // color: stringToColor("#84F5FF"), // textStyle: TextStyle( // fontFamily: 'Readex Pro', // color: Colors.white, // fontSize: 13, // letterSpacing: 0.0, // ), // elevation: 3, // borderSide: BorderSide( // color: Colors.transparent, // width: 1, // ), // borderRadius: // BorderRadius.circular(20.rpx), // ), // ), child: CustomCard( borderRadius: 16.rpx, gradientDirection: GradientDirection.vertical, onTap: () async { // String msg = await controller.bindTel(); // if (msg == null || msg.isEmpty) { // MHTLoginController loginController = // Get.find(); // //TODO 微信回调监听操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听 // loginController.fluwxCancelable // ?.cancel(); // // 登录成功移出网络检查监听 // Checknetwork.subscription?.cancel(); // final box = GetStorage(); // box.remove('countdown'); // CountdownController // countdownController = Get.find(); // countdownController.countdown = 0.obs; // Get.offAndToNamed( // "/mianPageBottomChange"); // } else { // showToast(msg); // } ApiResponse apiResponse = await controller.updateUserPhone(); if (apiResponse.code == HttpStatusCodes.ok) { UserInfoController userInfoController = Get.find(); await userInfoController.getUserInfo(); MHTLoginController loginController = Get.find(); //TODO 微信回调监听操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听 loginController.fluwxCancelable ?.cancel(); // 登录成功移出网络检查监听 Checknetwork.subscription?.cancel(); final box = GetStorage(); box.remove('countdown'); CountdownController countdownController = Get.find(); countdownController.countdown = 0.obs; Get.offAndToNamed( "/mianPageBottomChange"); } else { TopSlideNotification.show(context, textColor: themeController .currentColor.sc9, text: apiResponse.msg ?? '失败'.tr); } }, colors: const [ Color(0xFFFCFCFC), Color(0xFFF8FAF9), Color(0XFFECF6F3), Color(0XFFD9F0E9), Color(0xFFCEECE3) ], child: Container( width: double.infinity, height: 90.rpx, alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(16.rpx), ), child: Text( "提交".tr, style: TextStyle( fontFamily: 'Readex Pro', color: Color(0XFF003058), letterSpacing: 0, fontSize: 26.rpx, ), ), ), ), ), ), ), ], ), ), ), ), ), ], ), ), ), ); }); } }