123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329 |
- import 'dart:io';
- import 'package:flutter/material.dart';
- import 'package:liftmanager/res/gaps.dart';
- import 'package:liftmanager/net/api_service.dart';
- import 'package:liftmanager/utils/toast.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/internal/search/search_router.dart';
- import 'package:liftmanager/widgets/app_search_bar.dart';
- import 'package:liftmanager/utils/image_utils.dart';
- import 'package:liftmanager/res/resources.dart';
- import 'package:liftmanager/routers/fluro_navigator.dart';
- import 'package:liftmanager/widgets/load_image.dart';
- import 'package:liftmanager/internal/bbs/bbs_router.dart';
- import 'package:liftmanager/widgets/click_item.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:provider/provider.dart';
- import 'package:liftmanager/internal/account/account_router.dart';
- import 'package:liftmanager/common/common.dart';
- import 'package:liftmanager/internal/account/provider/user_provider.dart';
- import 'package:liftmanager/internal/account/model/user_info_entity.dart';
- import 'package:liftmanager/internal/team/team_router.dart';
- import 'package:liftmanager/common/user_db.dart';
- import 'package:liftmanager/internal/wode/page/edit_text_page.dart';
- import 'package:image_picker/image_picker.dart';
- import 'package:liftmanager/utils/utils.dart';
- import 'package:liftmanager/internal/wode/wode_router.dart';
- import 'package:flustars/flustars.dart' as FlutterStars;
- import 'package:liftmanager/widgets/text_field_item.dart';
- class BandAccount extends StatefulWidget {
- @override
- State<StatefulWidget> createState() {
- return BandAccountState();
- }
- }
- class BandAccountState extends State<BandAccount>
- with AutomaticKeepAliveClientMixin {
- // PersonalPageState({Key key}) : super(key: key);
- UserProvider provider = UserProvider();
- TextEditingController _nameController = new TextEditingController();
- TextEditingController _alipayController = new TextEditingController();
- @override
- void initState() {
- super.initState();
- getUserInfo();
- }
- ///获取用户信息
- void getUserInfo() {
- ApiService().userInfo(
- onSuccess: (data) {
- setUser(data);
- },
- onError: (code, msg) {});
- }
- void setUser(UserInfoEntity user) {
- provider.setUser(user);
- }
- updateUser(){
- NewApiService().updateUser({
- "userId":FlutterStars.SpUtil.getString(Constant.userId),
- "alipayAccount":_alipayController.text,
- "alipayRealName":_nameController.text
- }, onSuccess: (res) {
- getUserInfo();
- setState(() {});
- }, onError: (code, msg) {
- toasts(msg);
- });
- }
- @override
- void dispose() {
- // provider.dispose();
- super.dispose();
- }
- @override
- Widget build(BuildContext context) {
- double width = MediaQuery.of(context).size.width;
- double height = MediaQuery.of(context).size.height;
- return ChangeNotifierProvider<UserProvider>(
- create: (_) => provider,
- child: Container(
- child: Scaffold(
- resizeToAvoidBottomPadding: false,
- appBar: MyAppBar(
- centerTitle: "绑定账号",
- ),
- body: Consumer<UserProvider>(builder: (_, provider, __) {
- return ListView(
- padding: EdgeInsets.all(0.0),
- children: <Widget>[
-
- ClickItem(
- title: "支付宝账号",
- content: "${provider.user?.alipayAccount ?? ""}",
- onTap: () {
- // NavigatorUtils.push(context, BbsRouter.videoDetail);
- // Navigator.of(context).push(
- // MaterialPageRoute(
- // builder: (context) {
- // return EditTextPage(
- // title: "编辑支付宝账号",
- // value: provider.user?.alipayAccount ?? "",
- // mType: 0,
- // );
- // },
- // ),
- // ).then(
- // (value) {
- // if (value != null) {
- // print(value);
- // updateUser(value);
- // }
- // },
- // );
- if(provider.user?.alipayAccount != null){
- _alipayController.text = provider.user?.alipayAccount;
- }
- if(provider.user?.alipayRealName != null){
- _nameController.text = provider.user?.alipayRealName;
- }
-
-
- // showDialog(
- // context: context,
- // barrierDismissible: true, // 是否可以点击底部遮罩层取消dialog
- // // child: Text('data')
- // builder: (context) {
- // return Container(
- // color:Colors.white,
- // width: 300,
- // // width: width*0.6,
- // height: 300,
- // // height: height*0.6,
- // child: Column(
- // children: <Widget>[
- // TextFieldItem(
- // title: "支付宝账号",
- // isMust: true,
- // content: _alipayController.text,
- // controller: _alipayController,
- // hintText: "请输入您的支付宝账号",
-
- // ),
- // TextFieldItem(
- // title: "真实姓名",
- // isMust: true,
- // content: _nameController.text,
- // controller: _nameController,
- // hintText: "请输入您的真实姓名",
-
- // ),
- // Container(
- // child: Row(
- // children: <Widget>[
- // FlatButton(
- // color: Color(0xffcccccc),
- // child: Text('取消',style: TextStyle(color:Colors.white),),
- // onPressed: (){
- // Navigator.maybePop(context);
- // _nameController.text = "";
- // _alipayController.text = "";
- // },
- // ),
- // Container(
- // height:36,
- // decoration: BoxDecoration(
- // gradient: const LinearGradient(
- // colors: [Color(0xFF00D9FF), Color(0xFF0287FF)]),
- // ),
- // child: FlatButton(
- // child: Text('确认',style: TextStyle(color:Colors.white),),
- // onPressed: (){
- // if(_alipayController.text == null || _alipayController.text.trim()==""){
- // toasts("请输入您的支付宝账号");
- // return;
- // }
- // if(_nameController.text == null || _nameController.text.trim()==""){
- // toasts("请输入您的真实姓名");
- // return;
- // }
- // updateUser();
- // },
- // ),
- // ),
- // ],
- // ),
- // )
- // ],
- // )
- // );
- // }
- // );
- showDialog(
- context: context,
- builder: (context) {
- return new AlertDialog(
- // title: new Text(""),
- content: Container(
- child:
- // Text("123")
- Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Container(
- child: Text(
- "您的支付宝账号:",
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(18),
- ),
- ),
- ),
- SizedBox(
- height:10
- ),
- Container(
- height: ScreenUtil().setWidth(30),
- child: TextField(
- controller: _alipayController,
- decoration: InputDecoration(
- contentPadding: EdgeInsets.only(left:ScreenUtil().setWidth(10),right:ScreenUtil().setWidth(5),),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(2.0),
- ),
- hintText: '请输入您的支付宝账号', // hint 暗示
- errorBorder: InputBorder.none, // 当error时的border
- filled: false, // 背景色
- focusedBorder: OutlineInputBorder(), // 当focus时的border
- ),
- cursorColor: Color(0xFF999999),
- obscureText: false, // 输入变成**
- onChanged: (val) {
- // xxx
- },
- ),
- ),
- SizedBox(
- height:20
- ),
- Container(
- child: Text(
- "您的真实姓名:",
- textAlign: TextAlign.left,
- style: TextStyle(
- fontSize: ScreenUtil().setSp(18),
- ),
- ),
- ),
- SizedBox(
- height:10
- ),
- Container(
- height: ScreenUtil().setWidth(30),
- child: TextField(
- controller: _nameController,
- decoration: InputDecoration(
- contentPadding: EdgeInsets.only(left:ScreenUtil().setWidth(10),right:ScreenUtil().setWidth(5),),
- border: OutlineInputBorder(
- borderRadius: BorderRadius.circular(2.0),
- ),
- hintText: '请输入您的真实姓名', // hint 暗示
- errorBorder: InputBorder.none, // 当error时的border
- filled: false, // 背景色
- focusedBorder: OutlineInputBorder(), // 当focus时的border
- ),
- cursorColor: Color(0xFF999999),
- obscureText: false, // 输入变成**
- onChanged: (val) {
- // xxx
- },
- ),
- ),
-
-
- ],
- ),
- ),
- actions: <Widget>[
- new FlatButton(
- onPressed: () {
- Navigator.of(context).pop();
- _nameController.text = "";
- _alipayController.text = "";
- },
- child: new Text("取消"),
- ),
- new FlatButton(
- onPressed: () {
- if(_alipayController.text == null || _alipayController.text.trim()==""){
- toasts("请输入您的支付宝账号");
- return;
- }
- if(_nameController.text == null || _nameController.text.trim()==""){
- toasts("请输入您的真实姓名");
- return;
- }
- updateUser();
- Navigator.of(context).pop();
- },
- child: new Text("确认"),
- ),
-
- ],
- );
- });
- },
- ),
-
- ]);
- })),
- ));
- }
- @override
- bool get wantKeepAlive => true;
- }
|