Procházet zdrojové kódy

更新会员中心

tags/0.0.1
Weller před 4 roky
rodič
revize
16f7349c33
10 změnil soubory, kde provedl 140 přidání a 62 odebrání
  1. +1
    -1
      .dart_tool/package_config.json
  2. +3
    -0
      lib/pages/mine_detail_page/mine_detail_page.dart
  3. +17
    -0
      lib/pages/setting_page/setting_page.dart
  4. +22
    -11
      lib/register.dart
  5. +44
    -33
      lib/widgets/mine/mine_data/mine_data.dart
  6. +38
    -0
      lib/widgets/mine/mine_data/mine_data_container.dart
  7. +5
    -0
      lib/widgets/mine/mine_data/model/mine_data_model.dart
  8. +6
    -0
      lib/widgets/mine/mine_data/model/mine_data_model.g.dart
  9. +1
    -15
      lib/widgets/mine/mine_header/mine_header.dart
  10. +3
    -2
      lib/widgets/mine/mine_header/mine_header_container.dart

+ 1
- 1
.dart_tool/package_config.json Zobrazit soubor

@@ -710,7 +710,7 @@
"languageVersion": "2.1"
}
],
"generated": "2020-09-17T03:20:15.312540Z",
"generated": "2020-09-17T12:08:09.612292Z",
"generator": "pub",
"generatorVersion": "2.7.2"
}

+ 3
- 0
lib/pages/mine_detail_page/mine_detail_page.dart Zobrazit soubor

@@ -94,6 +94,9 @@ class _MineDetailContainerState extends State<_MineDetailContainer> {
stream: _bloc.outData,
builder: (BuildContext context, AsyncSnapshot snapshot) {
MineDetailModel user = snapshot.data;
if (user == null) {
return Container();
}
int birthday = int.tryParse(user?.birthday) ?? 0;
int registTime = int.tryParse(user?.registerTime) ?? 0;
_nickController.text = user?.nickname ?? '';


+ 17
- 0
lib/pages/setting_page/setting_page.dart Zobrazit soubor

@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';

class SettingPage extends StatefulWidget {
final Map<String, dynamic> data;

const SettingPage(this.data, {Key key}) : super(key: key);

@override
_SettingPageState createState() => _SettingPageState();
}

class _SettingPageState extends State<SettingPage> {
@override
Widget build(BuildContext context) {
return Scaffold();
}
}

+ 22
- 11
lib/register.dart Zobrazit soubor

@@ -1,6 +1,7 @@
import 'package:zhiying_base_widget/pages/home_page/home_page.dart';
import 'package:zhiying_base_widget/pages/main_page/main_page.dart';
import 'package:zhiying_base_widget/pages/mine_detail_page/mine_detail_page.dart';
import 'package:zhiying_base_widget/pages/setting_page/setting_page.dart';
import 'package:zhiying_base_widget/pages/wallet_page/wallet_page.dart';
import 'package:zhiying_base_widget/widgets/home/home_banner/home_banner_creater.dart';
import 'package:zhiying_base_widget/widgets/home/home_banner/home_banner_widget.dart';
@@ -20,7 +21,6 @@ import 'package:zhiying_comm/zhiying_comm.dart';

import 'widgets/home/home_quick_entry/home_quick_entry.dart';


class BaseWidgetRegister {
/// 初始化方法
static void init() {
@@ -41,6 +41,7 @@ class BaseWidgetRegister {

PageFactory.regist(
'pub.flutter.profile_settings', (model) => MineDetailPage());
PageFactory.regist('pub.flutter.settings', (model) => SettingPage(model));
}

// 注册控件
@@ -58,7 +59,8 @@ class BaseWidgetRegister {
WidgetFactory.regist('index_carousel', HomeSlideBannerCreater());
WidgetFactory.regist('index_recommend_list', GoodsListCreater());
// /// 首页快速入口
WidgetFactory.regist('multi_nav', DefaultWidgetCreater((model) => HomeQuickEntry(model)));
WidgetFactory.regist(
'multi_nav', DefaultWidgetCreater((model) => HomeQuickEntry(model)));
//
// /// 不可以滚动banner
WidgetFactory.regist('index_banner_one', HomeBannerCreater());
@@ -66,17 +68,26 @@ class BaseWidgetRegister {

// ==================== 个人中心
WidgetFactory.regist('profile_appbar', MineNavCreater());
WidgetFactory.regist('profile_background', DefaultWidgetCreater((model) => MineNavBg(model)));
WidgetFactory.regist('profile_header', DefaultWidgetCreater((model) => MineHeader(model)));
WidgetFactory.regist('profile_earning', DefaultWidgetCreater((model) => MineData(model)));
WidgetFactory.regist('profile_functions', DefaultWidgetCreater((model) => MineQuickEntry(model)));
WidgetFactory.regist('profile_my_functions', DefaultWidgetCreater((model) => MineQuickEntry(model)));
WidgetFactory.regist('profile_carousel', DefaultWidgetCreater((model) => HomeBannerWidget(model)));
WidgetFactory.regist('profile_background',
DefaultWidgetCreater((model) => MineNavBg(model)));
WidgetFactory.regist(
'profile_header', DefaultWidgetCreater((model) => MineHeader(model)));
WidgetFactory.regist(
'profile_earning', DefaultWidgetCreater((model) => MineData(model)));
WidgetFactory.regist('profile_functions',
DefaultWidgetCreater((model) => MineQuickEntry(model)));
WidgetFactory.regist('profile_my_functions',
DefaultWidgetCreater((model) => MineQuickEntry(model)));
WidgetFactory.regist('profile_carousel',
DefaultWidgetCreater((model) => HomeBannerWidget(model)));

// ==================== 钱包
WidgetFactory.regist('wallet_data', DefaultWidgetCreater((model) => WalletData()));
WidgetFactory.regist('wallet_detail', DefaultWidgetCreater((model) => WalletDetail()));
WidgetFactory.regist(
'wallet_data', DefaultWidgetCreater((model) => WalletData()));
WidgetFactory.regist(
'wallet_detail', DefaultWidgetCreater((model) => WalletDetail()));

WidgetFactory.regist('wallet_income', DefaultWidgetCreater((model) => WalletIncome()));
WidgetFactory.regist(
'wallet_income', DefaultWidgetCreater((model) => WalletIncome()));
}
}

+ 44
- 33
lib/widgets/mine/mine_data/mine_data.dart Zobrazit soubor

@@ -1,9 +1,15 @@
import 'dart:convert' as convert;

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_container.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_sk.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_widget.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_data/model/mine_data_model.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_bloc.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class MineData extends StatefulWidget {
final Map<String, dynamic> data;
@@ -15,43 +21,48 @@ class MineData extends StatefulWidget {
}

class _MineDataState extends State<MineData> {
UserInfoModel _user;
bool _isSketelon = true;

@override
Widget build(BuildContext context) {
if (_isSketelon) {
Provider.of<UserInfoNotifier>(context).getUserInfoModel().then((user) {
setState(() {
_user = user;
_isSketelon = false;
});
});
}

if (_isSketelon) {
return MineDataSkeleton();
}
if (_user == null) {
String value = '123';
int result = int.tryParse(value);

// 未登录
String d = widget.data['data'];
Map json = convert.jsonDecode(d);
MineDataModel style =
MineDataModel.fromJson(Map<String, dynamic>.from(json));
MineProfileModel profile = MineProfileModel(
'',
'',
'',
'',
'',
'¥0',
style.datas.map((item) {
return MineProfileDataModel(item.name, '¥0');
}).toList(),
);
return MineDataWidget(profile, widget.data);
}
return BlocProvider<MineHeaderBloc>(
bloc: MineHeaderBloc(),
child: _MineDataContainer(widget.data),
child: MineDataContainer(widget.data),
);
}
}

class _MineDataContainer extends StatefulWidget {
final Map<String, dynamic> data;

const _MineDataContainer(this.data, {Key key}) : super(key: key);

@override
_MineDataContainerState createState() => _MineDataContainerState();
}

class _MineDataContainerState extends State<_MineDataContainer> {
MineHeaderBloc _bloc;

@override
void initState() {
_bloc = BlocProvider.of<MineHeaderBloc>(context);
_bloc.loadData();
super.initState();
}

@override
Widget build(BuildContext context) {
return StreamBuilder<MineProfileModel>(
stream: _bloc.outData,
builder: (BuildContext context, AsyncSnapshot snapshot) {
MineProfileModel profile = snapshot.data;
return profile == null
? MineDataSkeleton()
: MineDataWidget(profile, widget.data);
});
}
}

+ 38
- 0
lib/widgets/mine/mine_data/mine_data_container.dart Zobrazit soubor

@@ -0,0 +1,38 @@
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_sk.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_data/mine_data_widget.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_header/mine_header_bloc.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart';
import 'package:zhiying_comm/util/base_bloc.dart';

class MineDataContainer extends StatefulWidget {
final Map<String, dynamic> data;

const MineDataContainer(this.data, {Key key}) : super(key: key);

@override
_MineDataContainerState createState() => _MineDataContainerState();
}

class _MineDataContainerState extends State<MineDataContainer> {
MineHeaderBloc _bloc;

@override
void initState() {
_bloc = BlocProvider.of<MineHeaderBloc>(context);
_bloc.loadData();
super.initState();
}

@override
Widget build(BuildContext context) {
return StreamBuilder<MineProfileModel>(
stream: _bloc.outData,
builder: (BuildContext context, AsyncSnapshot snapshot) {
MineProfileModel profile = snapshot.data;
return profile == null
? MineDataSkeleton()
: MineDataWidget(profile, widget.data);
});
}
}

+ 5
- 0
lib/widgets/mine/mine_data/model/mine_data_model.dart Zobrazit soubor

@@ -1,4 +1,5 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:zhiying_base_widget/widgets/mine/mine_header/model/mine_profile_model.dart';

part 'mine_data_model.g.dart';

@@ -40,6 +41,9 @@ class MineDataModel extends Object {
@JsonKey(name: 'grid_view_value_color')
String gridViewValueColor;

@JsonKey(name: 'grid_view')
List<MineProfileDataModel> datas;

MineDataModel(
this.accumulatedEarningsNameColor,
this.accumulatedEarningsColor,
@@ -53,6 +57,7 @@ class MineDataModel extends Object {
this.gridViewBgColor,
this.gridViewNameColor,
this.gridViewValueColor,
this.datas,
);

factory MineDataModel.fromJson(Map<String, dynamic> srcJson) =>


+ 6
- 0
lib/widgets/mine/mine_data/model/mine_data_model.g.dart Zobrazit soubor

@@ -20,6 +20,11 @@ MineDataModel _$MineDataModelFromJson(Map<String, dynamic> json) {
json['grid_view_bg_color'] as String,
json['grid_view_name_color'] as String,
json['grid_view_value_color'] as String,
(json['grid_view'] as List)
?.map((e) => e == null
? null
: MineProfileDataModel.fromJson(e as Map<String, dynamic>))
?.toList(),
);
}

@@ -37,4 +42,5 @@ Map<String, dynamic> _$MineDataModelToJson(MineDataModel instance) =>
'grid_view_bg_color': instance.gridViewBgColor,
'grid_view_name_color': instance.gridViewNameColor,
'grid_view_value_color': instance.gridViewValueColor,
'grid_view': instance.datas,
};

+ 1
- 15
lib/widgets/mine/mine_header/mine_header.dart Zobrazit soubor

@@ -21,23 +21,8 @@ class _MineHeaderState extends State<MineHeader> {
UserInfoModel _user;
bool _isSketelon = true;

@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
// return Consumer<UserInfoNotifier>(builder: (context, user, child) {
// print('user ${user.toString()}');
// if (user == null) {
// return MineStaticContainer(widget.data);
// }
// return BlocProvider<MineHeaderBloc>(
// bloc: MineHeaderBloc(),
// child: MineHeaderContainer(widget.data),
// );
// });
if (_isSketelon) {
Provider.of<UserInfoNotifier>(context).getUserInfoModel().then((user) {
setState(() {
@@ -51,6 +36,7 @@ class _MineHeaderState extends State<MineHeader> {
return MineHeaderSkeleton();
}
if (_user == null) {
// 未登录
return MineStaticContainer(widget.data);
}
return BlocProvider<MineHeaderBloc>(


+ 3
- 2
lib/widgets/mine/mine_header/mine_header_container.dart Zobrazit soubor

@@ -63,8 +63,9 @@ class _MineHeaderContainerState extends State<MineHeaderContainer> {
),
),
),
onTap: () {
RouterUtil.route(widget.json, context);
onTap: () async {
await RouterUtil.route(widget.json, context);
_bloc.loadData();
},
),
Expanded(


Načítá se…
Zrušit
Uložit