123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- import 'package:flutter/material.dart';
- import 'package:sport/bean/bind_info.dart';
- import 'package:sport/pages/setting/bind_phone_page.dart';
- import 'package:sport/pages/setting/reset_password.dart';
- import 'package:sport/router/navigator_util.dart';
- import 'package:sport/services/api/inject_api.dart';
- import 'package:sport/sharesdk/tencent.dart';
- import 'package:sport/sharesdk/wechat.dart';
- import 'package:sport/utils/toast.dart';
- import 'package:sport/widgets/appbar.dart';
- import 'package:sport/widgets/dialog/request_dialog.dart';
- import 'package:sport/widgets/image.dart';
- import 'package:sport/widgets/list_tile.dart';
- import 'package:sport/widgets/loading.dart';
- class AccountPage extends StatefulWidget {
- @override
- State<StatefulWidget> createState() => _PageState();
- }
- class _PageState extends State<AccountPage> with InjectLoginApi, TencentMixin, WechatMixin {
- BindInfoData _data;
- bool _loading = true;
- @override
- void initState() {
- super.initState();
- initData();
- }
- initData() async {
- BindInfo bindInfo = await loginApi.getBindInfo();
- setState(() {
- _loading = false;
- _data = bindInfo.data;
- });
- }
- @override
- Widget build(BuildContext context) {
- const contentPadding = EdgeInsets.symmetric(horizontal: 0.0);
- return Scaffold(
- backgroundColor: Colors.white,
- body: LoadingWidget(
- loading: _loading,
- child: CustomScrollView(
- slivers: <Widget>[
- buildSliverAppBar(context, "帐号管理"),
- _data == null
- ? SliverToBoxAdapter(
- child: Container(),
- )
- : SliverPadding(
- padding: const EdgeInsets.symmetric(horizontal: 12),
- sliver: SliverToBoxAdapter(
- child: Column(
- children: <Widget>[
- ListView(
- padding: EdgeInsets.zero,
- physics: NeverScrollableScrollPhysics(),
- shrinkWrap: true,
- children: divideTiles(
- includeLast: true,
- context: context,
- tiles: [
- if (_data?.phone?.isNotEmpty == true)
- ListTile(
- title: Text('重置密码'),
- trailing: arrowRight5(),
- contentPadding: contentPadding,
- onTap: () {
- Navigator.push(context, MaterialPageRoute(builder: (context) {
- return RestPasswordWidget(_data.password);
- }));
- },
- ),
- ListTile(
- title: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text("绑定手机号"),
- Text(
- _data.phone != null ? "${_data.phone}" : " ",
- style: Theme.of(context).textTheme.bodyText2,
- )
- ],
- ),
- contentPadding: contentPadding,
- trailing: arrowRight5(),
- onTap: () async {
- var result = await NavigatorUtil.goPage(context, (context) => BindPhonePage());
- if (result == true) {
- await initData();
- ToastUtil.show("绑定成功");
- }
- },
- ),
- ListTile(
- title: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text("绑定微信"),
- _data.weixin
- ? Text(
- "已绑定",
- style: Theme.of(context).textTheme.bodyText2,
- )
- : Text(
- "未绑定",
- style: Theme.of(context).textTheme.bodyText2,
- ),
- ],
- ),
- contentPadding: contentPadding,
- trailing: arrowRight5(),
- onTap: () {
- wechatLogin((code) async {
- if (code == null) {
- ToastUtil.show("请先安装最新版的微信客户端");
- return;
- }
- await request(context, () async {
- var data = await loginApi.bindWx(code);
- if (data["code"] == 0) {
- ToastUtil.show("绑定成功");
- setState(() {
- _data.weixin = true;
- });
- }
- });
- });
- },
- ),
- ListTile(
- title: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: <Widget>[
- Text("绑定QQ"),
- _data.qq
- ? Text(
- "已绑定",
- style: Theme.of(context).textTheme.bodyText2,
- )
- : Text(
- "未绑定",
- style: Theme.of(context).textTheme.bodyText2,
- ),
- ],
- ),
- contentPadding: contentPadding,
- trailing: arrowRight5(),
- onTap: () {
- qqlogin((login, userInfo) async {
- if (userInfo == null) {
- return;
- }
- await request(context, () async {
- String openid = login.openid;
- var data = await loginApi.bindQQ(openid);
- if (data["code"] == 0) {
- ToastUtil.show("绑定成功");
- setState(() {
- _data.qq = true;
- });
- }
- });
- });
- },
- ),
- ],
- ).toList(),
- ),
- ],
- ),
- ),
- ),
- ],
- ),
- ));
- }
- }
|