Browse Source

1.增加注销页面

tags/0.0.3+2
“yanghuaxuan” 3 years ago
parent
commit
8887298b66
9 changed files with 477 additions and 29 deletions
  1. +2
    -2
      example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java
  2. +166
    -0
      lib/pages/account_delete_page/account_delete_page.dart
  3. +50
    -0
      lib/pages/account_delete_page/account_delete_page_bloc.dart
  4. +149
    -0
      lib/pages/account_delete_page/model/account_delete_page_model.dart
  5. +64
    -0
      lib/pages/security_page/models/security_style_model.dart
  6. +35
    -26
      lib/pages/security_page/security_page.dart
  7. +1
    -0
      lib/pages/security_page/security_page_bloc.dart
  8. +5
    -1
      lib/pages/setting_page/setting_page.dart
  9. +5
    -0
      lib/register.dart

+ 2
- 2
example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java View File

@@ -88,9 +88,9 @@ public class MainActivity extends FlutterActivity implements ZhiyingFlutterCommN
@Override
public Map getSetting() {
Map map = new HashMap();
map.put("domain", "http://inapi.izhyin.cn"); //"http://120.76.175.204:8989");
map.put("domain", "http://inapi.izhyin.cn/"); //"http://120.76.175.204:8989");
// map.put("domain", "http://192.168.0.113:5000");
map.put("master_id", "template_database");
map.put("master_id", "123456");
map.put("secret_key", "123456");
// map.put("token", "123465");
return map;


+ 166
- 0
lib/pages/account_delete_page/account_delete_page.dart View File

@@ -0,0 +1,166 @@
import 'package:flutter/material.dart';
import 'package:zhiying_base_widget/pages/account_delete_page/account_delete_page_bloc.dart';
import 'package:zhiying_base_widget/pages/account_delete_page/model/account_delete_page_model.dart';
import 'package:zhiying_base_widget/utils/contants.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/util/extension/color.dart';
import 'package:zhiying_comm/util/global_config.dart';

class AccountDeletePage extends StatelessWidget {
final Map<String, dynamic> model;

const AccountDeletePage(this.model, {Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return BlocProvider(
bloc: AccountDeletePageBloc(),
child: AccountDeletePageContainer(
model: model,
));
}
}

class AccountDeletePageContainer extends StatefulWidget {
final Map<String, dynamic> model;

const AccountDeletePageContainer({Key key, this.model}) : super(key: key);

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

class _AccountDeletePageContainerState extends State<AccountDeletePageContainer> {
AccountDeletePageBloc _bloc;

@override
void initState() {
_bloc = BlocProvider.of<AccountDeletePageBloc>(context);
_bloc.loadData(widget.model[GlobalConfig.SKIP_IDENTIFIER]);
super.initState();
}

@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: _bloc.outData,
builder: (context, asycn) {
AccountDeletePageModel model = asycn.data;
return Scaffold(
appBar: AppBar(
elevation: 0,
leading: Navigator.canPop(context)
? IconButton(
icon: Icon(
Icons.arrow_back_ios,
color: HexColor.fromHex(model?.appBarNameColor),
size: 22,
),
onPressed: () {
Navigator.pop(context);
})
: Container(),
backgroundColor: HexColor.fromHex(model?.appBarBgColor),
centerTitle: true,
title: Text(
model?.appBarName ?? "",
style: TextStyle(color: HexColor.fromHex(model?.appBarNameColor), fontSize: 15, fontWeight: FontWeight.w600),
),
),
body: Column(
children: <Widget>[
Expanded(
child: ListView(
shrinkWrap: true,
children: <Widget>[
Container(
margin: EdgeInsets.only(left: 12, right: 12, top: 8),
padding: EdgeInsets.all(12),
decoration: BoxDecoration(color: HexColor.fromHex(model?.bgColor ?? ""), borderRadius: BorderRadius.circular(8)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
model?.tips?.title ?? "",
style: TextStyle(color: HexColor.fromHex(model?.tips?.titleColor ?? ""), fontSize: 15, fontWeight: FontWeight.w600),
),
Text(
model?.tips?.subtitle ?? "",
style: TextStyle(color: HexColor.fromHex(model?.tips?.subtitleColor ?? ""), fontSize: 14, fontWeight: FontWeight.w600),
),
ListView.builder(
itemCount: model?.tips?.textList?.length ?? 0,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
var item = model?.tips?.textList[index];
return Container(
margin: EdgeInsets.only(top: 4, bottom: 4),
child: Row(
children: <Widget>[
Expanded(
child: Text(
item?.text ?? "",
style: TextStyle(color: HexColor.fromHex(item?.color ?? ""), fontSize: 13, fontWeight: FontWeight.w600),
),
)
],
),
);
})
],
),
)
],
)),
Row(
children: <Widget>[
SizedBox(
width: 12,
),
Expanded(
child: Container(
height: 45,
child: FlatButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)),
color: HexColor.fromHex(model?.buttom?.left?.bgColor ?? ""),
onPressed: () {
_bloc.deleteAccount(context);
},
child: Text(
model?.buttom?.left?.text ?? "",
style: TextStyle(color: HexColor.fromHex(model?.buttom?.left?.textColor)),
)),
),
),
SizedBox(
width: 8,
),
Expanded(
child: Container(
height: 45,
child: FlatButton(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(40)),
color: HexColor.fromHex(model?.buttom?.right?.bgColor ?? ""),
onPressed: () {
Navigator.pop(context);
},
child: Text(
model?.buttom?.right?.text ?? "",
style: TextStyle(color: HexColor.fromHex(model?.buttom?.right?.textColor)),
)),
),
),
SizedBox(
width: 12,
),
],
),
SizedBox(
height: 16,
)
],
));
});
}
}

+ 50
- 0
lib/pages/account_delete_page/account_delete_page_bloc.dart View File

@@ -0,0 +1,50 @@


import 'dart:async';
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:zhiying_base_widget/dialog/tip_dialog/tip_dialog.dart';
import 'package:zhiying_comm/util/base_bloc.dart';
import 'package:zhiying_comm/util/log/let_log.dart';
import 'package:zhiying_comm/util/net_util.dart';
import 'package:zhiying_comm/zhiying_comm.dart';
import 'model/account_delete_page_model.dart';
import 'package:provider/provider.dart';

class AccountDeletePageBloc extends BlocBase{

AccountDeletePageModel _style;
Map<String, dynamic> securityStatus;

StreamController<AccountDeletePageModel> _styleController = StreamController<AccountDeletePageModel>.broadcast();

Stream<AccountDeletePageModel> get outData => _styleController.stream;

@override
void dispose() {
// TODO: implement dispose
}

loadData(String skipIdentifier){
NetUtil.request('/api/v1/mod/${skipIdentifier.toString()}',onSuccess: (data){
Logger.log(json.encode(data));
var mob=data['mod_list'][0];
_style=AccountDeletePageModel.fromJson(json.decode(mob['data']));
_styleController.add(_style);
});
}

deleteAccount(BuildContext context) async {
NetUtil.request("/api/v1/user/delete",method: NetMethod.POST,onSuccess: (data) async {
Logger.debug('退出登录');
await Provider.of<UserInfoNotifier>(context, listen: false).unLogin();
await showDialog(context: context,child: TipDialog(content: "账号注销成功",));
Navigator.pop(context,true);
},onError: (e){
showDialog(context: context,child: TipDialog(content: "账号注销失败!"+e.toString(),));
});
}
}

+ 149
- 0
lib/pages/account_delete_page/model/account_delete_page_model.dart View File

@@ -0,0 +1,149 @@
class AccountDeletePageModel {
String appBarName;
String appBarNameColor;
String appBarBgColor;
String bgColor;
Tips tips;
Buttom buttom;

AccountDeletePageModel(
{this.appBarName,
this.appBarNameColor,
this.appBarBgColor,
this.bgColor,
this.tips,
this.buttom});

AccountDeletePageModel.fromJson(Map<String, dynamic> json) {
appBarName = json['app_bar_name'];
appBarNameColor = json['app_bar_name_color'];
appBarBgColor = json['app_bar_bg_color'];
bgColor = json['bg_color'];
tips = json['tips'] != null ? new Tips.fromJson(json['tips']) : null;
buttom =
json['buttom'] != null ? new Buttom.fromJson(json['buttom']) : null;
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['app_bar_name'] = this.appBarName;
data['app_bar_name_color'] = this.appBarNameColor;
data['app_bar_bg_color'] = this.appBarBgColor;
data['bg_color'] = this.bgColor;
if (this.tips != null) {
data['tips'] = this.tips.toJson();
}
if (this.buttom != null) {
data['buttom'] = this.buttom.toJson();
}
return data;
}
}

class Tips {
String bgColor;
String title;
String titleColor;
String subtitle;
String subtitleColor;
List<TextList> textList;

Tips(
{this.bgColor,
this.title,
this.titleColor,
this.subtitle,
this.subtitleColor,
this.textList});

Tips.fromJson(Map<String, dynamic> json) {
bgColor = json['bg_color'];
title = json['title'];
titleColor = json['title_color'];
subtitle = json['subtitle'];
subtitleColor = json['subtitle_color'];
if (json['text_list'] != null) {
textList = new List<TextList>();
json['text_list'].forEach((v) {
textList.add(new TextList.fromJson(v));
});
}
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['bg_color'] = this.bgColor;
data['title'] = this.title;
data['title_color'] = this.titleColor;
data['subtitle'] = this.subtitle;
data['subtitle_color'] = this.subtitleColor;
if (this.textList != null) {
data['text_list'] = this.textList.map((v) => v.toJson()).toList();
}
return data;
}
}

class TextList {
String text;
String color;

TextList({this.text, this.color});

TextList.fromJson(Map<String, dynamic> json) {
text = json['text'];
color = json['color'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['text'] = this.text;
data['color'] = this.color;
return data;
}
}

class Buttom {
Left left;
Left right;

Buttom({this.left, this.right});

Buttom.fromJson(Map<String, dynamic> json) {
left = json['left'] != null ? new Left.fromJson(json['left']) : null;
right = json['right'] != null ? new Left.fromJson(json['right']) : null;
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.left != null) {
data['left'] = this.left.toJson();
}
if (this.right != null) {
data['right'] = this.right.toJson();
}
return data;
}
}

class Left {
String text;
String textColor;
String bgColor;

Left({this.text, this.textColor, this.bgColor});

Left.fromJson(Map<String, dynamic> json) {
text = json['text'];
textColor = json['text_color'];
bgColor = json['bg_color'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['text'] = this.text;
data['text_color'] = this.textColor;
data['bg_color'] = this.bgColor;
return data;
}
}

+ 64
- 0
lib/pages/security_page/models/security_style_model.dart View File

@@ -1,3 +1,5 @@
import 'dart:convert';

import 'package:zhiying_comm/zhiying_comm.dart';

class SecurityStyleModel {
@@ -8,6 +10,7 @@ class SecurityStyleModel {
String accountDeleteTextColor;
String settingsBgColor;
List<SecurityStyleItemModel> settings;
AccountDelete accountDelete;

SecurityStyleModel(
{this.appBarName,
@@ -31,6 +34,9 @@ class SecurityStyleModel {
settings.add(new SecurityStyleItemModel.fromJson(v));
});
}
accountDelete = json['account_delete'] != null
? new AccountDelete.fromJson(json['account_delete'])
: null;
}

Map<String, dynamic> toJson() {
@@ -78,3 +84,61 @@ class SecurityStyleItemModel extends SkipModel {
return data;
}
}


class Settings {
List<String> dataKeys;
String name;
String nameColor;
String descColor;
String skipIdentifier;

Settings(
{this.dataKeys,
this.name,
this.nameColor,
this.descColor,
this.skipIdentifier});

Settings.fromJson(Map<String, dynamic> json) {
dataKeys = json['data_keys'].cast<String>();
name = json['name'];
nameColor = json['name_color'];
descColor = json['desc_color'];
skipIdentifier = json['skip_identifier'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['data_keys'] = this.dataKeys;
data['name'] = this.name;
data['name_color'] = this.nameColor;
data['desc_color'] = this.descColor;
data['skip_identifier'] = this.skipIdentifier;
return data;
}
}

class AccountDelete {
String text;
String textColor;
String skipIdentifier;
String isShow;

AccountDelete({this.text, this.textColor, this.skipIdentifier});

AccountDelete.fromJson(Map<String, dynamic> json) {
text = json['text'];
textColor = json['text_color'];
skipIdentifier = json['skip_identifier'];
isShow=json['is_show'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['text'] = this.text;
data['text_color'] = this.textColor;
data['skip_identifier'] = this.skipIdentifier;
return data;
}
}

+ 35
- 26
lib/pages/security_page/security_page.dart View File

@@ -31,8 +31,7 @@ class _SecurityPageState extends State<SecurityPage> {
class _SecurityContainer extends StatefulWidget {
final Map<String, dynamic> data;

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

@@ -46,7 +45,9 @@ class _SecurityContainerState extends State<_SecurityContainer> {

@override
void didChangeDependencies() {
_user = Provider.of<UserInfoNotifier>(context).userInfo;
_user = Provider
.of<UserInfoNotifier>(context)
.userInfo;
super.didChangeDependencies();
}

@@ -68,10 +69,13 @@ class _SecurityContainerState extends State<_SecurityContainer> {

List<Widget> widgets = List();
widgets.addAll(style?.settings?.map((item) {
return _createItem(item);
})?.toList() ??
return _createItem(item);
})?.toList() ??
[]);
// widgets.add(_createLogout());
if((style?.accountDelete?.isShow??"0")=="1"){
widgets.add(_createLogout(style));
}


return Scaffold(
backgroundColor: Color(0xfff9f9f9),
@@ -96,19 +100,19 @@ class _SecurityContainerState extends State<_SecurityContainer> {
backgroundColor: HexColor.fromHex(style?.appBarBgColor ?? '#ffffff'),
leading: Navigator.canPop(context)
? GestureDetector(
child: Container(
padding: EdgeInsets.zero,
child: Icon(
Icons.arrow_back_ios,
size: 20,
),
),
onTap: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
)
child: Container(
padding: EdgeInsets.zero,
child: Icon(
Icons.arrow_back_ios,
size: 20,
),
),
onTap: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
)
: Container(),
middle: Text(
style?.appBarName ?? '账号安全',
@@ -159,12 +163,12 @@ class _SecurityContainerState extends State<_SecurityContainer> {
),
onTap: () async {
// 淘宝授权不跳转
if(item.skipIdentifier == 'pub.flutter.account_security_toabao_auth'){
if(_user == null || EmptyUtil.isEmpty(_user.token)){
if (item.skipIdentifier == 'pub.flutter.account_security_toabao_auth') {
if (_user == null || EmptyUtil.isEmpty(_user.token)) {
RouterUtil.goLogin(context);
return;
}
if( !(_user?.isTBAuth ?? false)) {
if (!(_user?.isTBAuth ?? false)) {
// 淘宝授权
await TaobaoAuth.auth(context);
}
@@ -180,19 +184,19 @@ class _SecurityContainerState extends State<_SecurityContainer> {
);
}

Widget _createLogout() {
Widget _createLogout([SecurityStyleModel style]) {
return GestureDetector(
child: Container(
color: Colors.white,
color: HexColor.fromHex("#FFFFFF"),
width: double.infinity,
height: 50,
margin: EdgeInsets.only(top: 10),
child: Center(
child: Text(
'账号注销',
style?.accountDelete?.text ?? "",
style: TextStyle(
fontSize: 13,
color: Color(0xffff4242),
color: HexColor.fromHex(style?.accountDelete?.textColor ?? ""),
fontWeight: FontWeight.bold,
),
),
@@ -200,6 +204,11 @@ class _SecurityContainerState extends State<_SecurityContainer> {
),
onTap: () {
Logger.debug('账号注销');
RouterUtil.route(SkipModel(skipIdentifier: style?.accountDelete?.skipIdentifier ?? ""), style?.accountDelete?.toJson(), context).then((value) {
if(value!=null&&value){
Navigator.pop(context,true);
}
} );
},
);
}


+ 1
- 0
lib/pages/security_page/security_page_bloc.dart View File

@@ -26,6 +26,7 @@ class SecurityPageBloc extends BlocBase {
_loadData(data);
}, onSuccess: (data) async {
securityStatus = Map<String, dynamic>.from(await _getStatus());
Logger.log(convert.json.encode(data));
_loadData(data);
});
}


+ 5
- 1
lib/pages/setting_page/setting_page.dart View File

@@ -164,7 +164,11 @@ class _SettingContainerState extends State<_SettingContainer> {
),
),
onTap: () {
RouterUtil.route(item, item.toJson(), context);
RouterUtil.route(item, item.toJson(), context).then((value) {
if(value!=null&&value){
Navigator.maybePop(context);
}
});
},
);
}


+ 5
- 0
lib/register.dart View File

@@ -5,6 +5,7 @@ import 'package:sharesdk_plugin/sharesdk_interface.dart';
import 'package:sharesdk_plugin/sharesdk_register.dart';
import 'package:zhiying_base_widget/models/app_config_model.dart';
import 'package:zhiying_base_widget/pages/about_us_page/about_us_page.dart';
import 'package:zhiying_base_widget/pages/account_delete_page/account_delete_page.dart';
import 'package:zhiying_base_widget/pages/bil_detail_page/bil_detail_page.dart';
import 'package:zhiying_base_widget/pages/brand_detail_page/brand_detail_page.dart';
import 'package:zhiying_base_widget/pages/brand_detail_page/brand_detail_page_skeleton.dart';
@@ -202,6 +203,7 @@ class BaseWidgetRegister {

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

/// 订单页面
PageFactory.regist('pub.flutter.my_order', (model) => OrdersPage(model));
PageFactory.regist('pub.flutter.account_security', (model) => SecurityPage(model));
@@ -237,6 +239,9 @@ class BaseWidgetRegister {
/// 隐私设置
PageFactory.regist('pub.flutter.privacy_settings', (model) => PrivacySettingsPage(model));

/// 注销账号页
PageFactory.regist('pub.flutter.account_delete', (model) => AccountDeletePage(model));

/// 消息设置
PageFactory.regist('pub.flutter.message_settings', (model) => MessageSettingsPage(model));



Loading…
Cancel
Save