From 8887298b6632184e79e0e2bb08638b6c8f0c134d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Thu, 31 Dec 2020 14:34:29 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E6=B3=A8=E9=94=80=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MainActivity.java | 4 +- .../account_delete_page.dart | 166 ++++++++++++++++++ .../account_delete_page_bloc.dart | 50 ++++++ .../model/account_delete_page_model.dart | 149 ++++++++++++++++ .../models/security_style_model.dart | 64 +++++++ lib/pages/security_page/security_page.dart | 61 ++++--- .../security_page/security_page_bloc.dart | 1 + lib/pages/setting_page/setting_page.dart | 6 +- lib/register.dart | 5 + 9 files changed, 477 insertions(+), 29 deletions(-) create mode 100644 lib/pages/account_delete_page/account_delete_page.dart create mode 100644 lib/pages/account_delete_page/account_delete_page_bloc.dart create mode 100644 lib/pages/account_delete_page/model/account_delete_page_model.dart diff --git a/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java b/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java index 67db9d6..699cf05 100644 --- a/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java +++ b/example/android/app/src/main/java/cn/zhios/zhiying_base_widget_example/MainActivity.java @@ -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; diff --git a/lib/pages/account_delete_page/account_delete_page.dart b/lib/pages/account_delete_page/account_delete_page.dart new file mode 100644 index 0000000..4c45afb --- /dev/null +++ b/lib/pages/account_delete_page/account_delete_page.dart @@ -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 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 model; + + const AccountDeletePageContainer({Key key, this.model}) : super(key: key); + + @override + _AccountDeletePageContainerState createState() => _AccountDeletePageContainerState(); +} + +class _AccountDeletePageContainerState extends State { + AccountDeletePageBloc _bloc; + + @override + void initState() { + _bloc = BlocProvider.of(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: [ + Expanded( + child: ListView( + shrinkWrap: true, + children: [ + 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: [ + 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: [ + Expanded( + child: Text( + item?.text ?? "", + style: TextStyle(color: HexColor.fromHex(item?.color ?? ""), fontSize: 13, fontWeight: FontWeight.w600), + ), + ) + ], + ), + ); + }) + ], + ), + ) + ], + )), + Row( + children: [ + 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, + ) + ], + )); + }); + } +} diff --git a/lib/pages/account_delete_page/account_delete_page_bloc.dart b/lib/pages/account_delete_page/account_delete_page_bloc.dart new file mode 100644 index 0000000..7a6f26e --- /dev/null +++ b/lib/pages/account_delete_page/account_delete_page_bloc.dart @@ -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 securityStatus; + + StreamController _styleController = StreamController.broadcast(); + + Stream 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(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(),)); + }); + } + +} \ No newline at end of file diff --git a/lib/pages/account_delete_page/model/account_delete_page_model.dart b/lib/pages/account_delete_page/model/account_delete_page_model.dart new file mode 100644 index 0000000..1005948 --- /dev/null +++ b/lib/pages/account_delete_page/model/account_delete_page_model.dart @@ -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 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 toJson() { + final Map data = new Map(); + 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; + + Tips( + {this.bgColor, + this.title, + this.titleColor, + this.subtitle, + this.subtitleColor, + this.textList}); + + Tips.fromJson(Map 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(); + json['text_list'].forEach((v) { + textList.add(new TextList.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + 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 json) { + text = json['text']; + color = json['color']; + } + + Map toJson() { + final Map data = new Map(); + data['text'] = this.text; + data['color'] = this.color; + return data; + } +} + +class Buttom { + Left left; + Left right; + + Buttom({this.left, this.right}); + + Buttom.fromJson(Map json) { + left = json['left'] != null ? new Left.fromJson(json['left']) : null; + right = json['right'] != null ? new Left.fromJson(json['right']) : null; + } + + Map toJson() { + final Map data = new Map(); + 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 json) { + text = json['text']; + textColor = json['text_color']; + bgColor = json['bg_color']; + } + + Map toJson() { + final Map data = new Map(); + data['text'] = this.text; + data['text_color'] = this.textColor; + data['bg_color'] = this.bgColor; + return data; + } +} diff --git a/lib/pages/security_page/models/security_style_model.dart b/lib/pages/security_page/models/security_style_model.dart index d0315a6..69d1323 100644 --- a/lib/pages/security_page/models/security_style_model.dart +++ b/lib/pages/security_page/models/security_style_model.dart @@ -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 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 toJson() { @@ -78,3 +84,61 @@ class SecurityStyleItemModel extends SkipModel { return data; } } + + +class Settings { + List dataKeys; + String name; + String nameColor; + String descColor; + String skipIdentifier; + + Settings( + {this.dataKeys, + this.name, + this.nameColor, + this.descColor, + this.skipIdentifier}); + + Settings.fromJson(Map json) { + dataKeys = json['data_keys'].cast(); + name = json['name']; + nameColor = json['name_color']; + descColor = json['desc_color']; + skipIdentifier = json['skip_identifier']; + } + + Map toJson() { + final Map data = new Map(); + 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 json) { + text = json['text']; + textColor = json['text_color']; + skipIdentifier = json['skip_identifier']; + isShow=json['is_show']; + } + + Map toJson() { + final Map data = new Map(); + data['text'] = this.text; + data['text_color'] = this.textColor; + data['skip_identifier'] = this.skipIdentifier; + return data; + } +} diff --git a/lib/pages/security_page/security_page.dart b/lib/pages/security_page/security_page.dart index c2923eb..f3a88c6 100644 --- a/lib/pages/security_page/security_page.dart +++ b/lib/pages/security_page/security_page.dart @@ -31,8 +31,7 @@ class _SecurityPageState extends State { class _SecurityContainer extends StatefulWidget { final Map 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(context).userInfo; + _user = Provider + .of(context) + .userInfo; super.didChangeDependencies(); } @@ -68,10 +69,13 @@ class _SecurityContainerState extends State<_SecurityContainer> { List 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); + } + } ); }, ); } diff --git a/lib/pages/security_page/security_page_bloc.dart b/lib/pages/security_page/security_page_bloc.dart index be295ba..85332f1 100644 --- a/lib/pages/security_page/security_page_bloc.dart +++ b/lib/pages/security_page/security_page_bloc.dart @@ -26,6 +26,7 @@ class SecurityPageBloc extends BlocBase { _loadData(data); }, onSuccess: (data) async { securityStatus = Map.from(await _getStatus()); + Logger.log(convert.json.encode(data)); _loadData(data); }); } diff --git a/lib/pages/setting_page/setting_page.dart b/lib/pages/setting_page/setting_page.dart index 290c52d..891d404 100644 --- a/lib/pages/setting_page/setting_page.dart +++ b/lib/pages/setting_page/setting_page.dart @@ -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); + } + }); }, ); } diff --git a/lib/register.dart b/lib/register.dart index dc912d3..eef3cb7 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -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));