|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/data/base_data.dart';
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart';
|
|
|
|
import 'package:huixiang/utils/font_weight.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
|
|
class BindingAssistantCard extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _BindingAssistantCard();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _BindingAssistantCard extends State<BindingAssistantCard> {
|
|
|
|
TextEditingController nameController = TextEditingController();
|
|
|
|
TextEditingController mobileController = TextEditingController();
|
|
|
|
TextEditingController addressController = TextEditingController();
|
|
|
|
TextEditingController houseNumberController = TextEditingController();
|
|
|
|
|
|
|
|
ApiService? apiService;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
SharedPreferences.getInstance().then((value) => {
|
|
|
|
apiService = ApiService(Dio(),
|
|
|
|
context: context, token: value.getString('token')),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
///绑定副卡
|
|
|
|
queryBindSecondCard(phone) async {
|
|
|
|
BaseData? baseData = await apiService?.bindSecondCard(phone).catchError((onError) {});
|
|
|
|
if (baseData?.isSuccess ?? false) {
|
|
|
|
SmartDialog.showToast("绑定成功", alignment: Alignment.center);
|
|
|
|
Navigator.of(context).pop(true);
|
|
|
|
} else {
|
|
|
|
SmartDialog.showToast("${baseData?.msg}", alignment: Alignment.center);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: MyAppBar(
|
|
|
|
title: S.of(context).bangdingfuka,
|
|
|
|
titleColor: Colors.black,
|
|
|
|
leadingColor: Colors.black,
|
|
|
|
background: Colors.transparent,
|
|
|
|
),
|
|
|
|
body: Stack(
|
|
|
|
children: [
|
|
|
|
Column(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
margin: EdgeInsets.only(bottom: 26.h),
|
|
|
|
padding: EdgeInsets.only(top: 16.h, bottom: 16.h),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(left: 16, right: 16),
|
|
|
|
child: Text(
|
|
|
|
S.of(context).jinxingfukabangding,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.black,
|
|
|
|
fontWeight: MyFontWeight.medium,
|
|
|
|
fontSize: 21.sp,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
left: 16, right: 16, top: 8, bottom: 32),
|
|
|
|
child: Text(
|
|
|
|
"主卡最多只能绑定5位副卡,只能解绑3次",
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color(0xFFFF7A1A),
|
|
|
|
fontWeight: MyFontWeight.regular,
|
|
|
|
fontSize: 12.sp,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
editItem(
|
|
|
|
S.of(context).fukashoujihao,
|
|
|
|
"",
|
|
|
|
S.of(context).qingshurushoujihao,
|
|
|
|
mobileController,
|
|
|
|
false),
|
|
|
|
Container(
|
|
|
|
margin:
|
|
|
|
EdgeInsets.symmetric(horizontal: 16, vertical: 5),
|
|
|
|
width: double.infinity,
|
|
|
|
height: 1,
|
|
|
|
color: Color(0xFFF4F4F4),
|
|
|
|
),
|
|
|
|
// Row(
|
|
|
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
// mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
// children: [
|
|
|
|
// Expanded(
|
|
|
|
// child: InkWell(
|
|
|
|
// onTap: () {},
|
|
|
|
// child: editItem(
|
|
|
|
// "验证码",
|
|
|
|
// "",
|
|
|
|
// S.of(context).qingshuruyanzhengma,
|
|
|
|
// addressController,
|
|
|
|
// false),
|
|
|
|
// )),
|
|
|
|
// Padding(
|
|
|
|
// padding: EdgeInsets.only(right: 16, top: 10),
|
|
|
|
// child: GestureDetector(
|
|
|
|
// onTap: () {},
|
|
|
|
// child: Text(
|
|
|
|
// "发送验证",
|
|
|
|
// style: TextStyle(
|
|
|
|
// fontSize: 14.sp,
|
|
|
|
// fontWeight: FontWeight.bold,
|
|
|
|
// color: Color(0xFF32A060),
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
// )),
|
|
|
|
// ],
|
|
|
|
// ),
|
|
|
|
Container(
|
|
|
|
margin:
|
|
|
|
EdgeInsets.symmetric(horizontal: 16, vertical: 5),
|
|
|
|
width: double.infinity,
|
|
|
|
height: 1,
|
|
|
|
color: Color(0xFFF4F4F4),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
queryBindSecondCard(mobileController.text);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
color: Color(0xFF32A060),
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
padding: EdgeInsets.all(16),
|
|
|
|
height: 54,
|
|
|
|
alignment: Alignment.center,
|
|
|
|
child: Text(
|
|
|
|
S.of(context).querenbangding,
|
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
fontSize: 16.sp,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget editItem(start, text, hide, controller, isClick) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 5),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
start,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16.sp,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: Color(0xFF353535),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
TextField(
|
|
|
|
controller: controller,
|
|
|
|
enabled: start != S.of(context).dizhi,
|
|
|
|
keyboardType:
|
|
|
|
start == S.of(context).dianhua ? TextInputType.phone : TextInputType.text,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border: InputBorder.none,
|
|
|
|
hintText: hide,
|
|
|
|
hintStyle: TextStyle(
|
|
|
|
color: Color(0xFFA29E9E),
|
|
|
|
fontSize: 14.sp,
|
|
|
|
),
|
|
|
|
contentPadding: EdgeInsets.all(0),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|