From 9722200498ae79463db92d2fbc7f8fd50e33d8d8 Mon Sep 17 00:00:00 2001 From: "23028876916@qq.com" Date: Mon, 18 Jan 2021 17:34:43 +0800 Subject: [PATCH] =?UTF-8?q?0118=20=E5=BE=AE=E4=BF=A1=E5=AF=BC=E5=B8=88?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=8A=BD=E5=87=BA=E5=8E=BB=EF=BC=8C=E8=BF=99?= =?UTF-8?q?=E9=87=8C=E7=9A=84=E8=BF=9B=E8=A1=8C=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/android/app/build.gradle | 54 +-- .../bloc/wechat_teacher_bloc.dart | 62 --- .../bloc/wechat_teacher_event.dart | 14 - .../bloc/wechat_teacher_repository.dart | 89 ---- .../bloc/wechat_teacher_state.dart | 25 -- .../model/wechat_teacher_data_model.dart | 32 -- .../model/wechat_teacher_style_model.dart | 293 ------------- .../wechat_teacher_page.dart | 411 ------------------ .../widgets/wechat_teacher_item.dart | 137 ------ lib/register.dart | 3 - 10 files changed, 27 insertions(+), 1093 deletions(-) delete mode 100644 lib/pages/wechat_teacher_page/bloc/wechat_teacher_bloc.dart delete mode 100644 lib/pages/wechat_teacher_page/bloc/wechat_teacher_event.dart delete mode 100644 lib/pages/wechat_teacher_page/bloc/wechat_teacher_repository.dart delete mode 100644 lib/pages/wechat_teacher_page/bloc/wechat_teacher_state.dart delete mode 100644 lib/pages/wechat_teacher_page/model/wechat_teacher_data_model.dart delete mode 100644 lib/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart delete mode 100644 lib/pages/wechat_teacher_page/wechat_teacher_page.dart delete mode 100644 lib/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 5f0544e..07706a4 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -108,33 +108,33 @@ android { // 应用信息配置 - productFlavors { - // 智夜生活 - zhiying { - applicationId "cn.zhios.zhiying" - versionCode 28 - dimension "app" - versionName '1.2.28' - // 签名信息 - signingConfig signingConfigs.zhiying - } - } - - // 打包脚本 - android.applicationVariants.all { variant -> - if (variant.buildType.name != "debug") { - variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk") - } - - variant.outputs.all { output -> - def outputFile = output.outputFile - if (outputFile != null && outputFile.name.endsWith('.apk')) { - //这里修改apk文件名 - def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk" - outputFileName = fileName - } - } - } +// productFlavors { +// // 智夜生活 +// zhiying { +// applicationId "cn.zhios.zhiying" +// versionCode 28 +// dimension "app" +// versionName '1.2.28' +// // 签名信息 +// signingConfig signingConfigs.zhiying +// } +// } +// +// // 打包脚本 +// android.applicationVariants.all { variant -> +// if (variant.buildType.name != "debug") { +// variant.getPackageApplicationProvider().get().outputDirectory = new File(project.rootDir.absolutePath + "/app/build/outputs/apk") +// } +// +// variant.outputs.all { output -> +// def outputFile = output.outputFile +// if (outputFile != null && outputFile.name.endsWith('.apk')) { +// //这里修改apk文件名 +// def fileName = "${variant.productFlavors[0].name}_${releaseTime()}01_&V${variant.productFlavors[0].versionCode}.apk" +// outputFileName = fileName +// } +// } +// } configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> diff --git a/lib/pages/wechat_teacher_page/bloc/wechat_teacher_bloc.dart b/lib/pages/wechat_teacher_page/bloc/wechat_teacher_bloc.dart deleted file mode 100644 index 19d8457..0000000 --- a/lib/pages/wechat_teacher_page/bloc/wechat_teacher_bloc.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'dart:async'; - -import 'package:bloc/bloc.dart'; -import 'package:zhiying_base_widget/pages/wechat_teacher_page/bloc/wechat_teacher_repository.dart'; -import 'wechat_teacher_event.dart'; -import 'wechat_teacher_state.dart'; -import 'package:zhiying_comm/zhiying_comm.dart'; - -class WechatTeacherBloc extends Bloc { - @override - WechatTeacherState get initialState => WechatTeacherInitial(); - - WechatTeacherRepository repository; - - WechatTeacherBloc(this.repository); - - @override - Stream mapEventToState( - WechatTeacherEvent event, - ) async* { - /// 初始化 - if (event is WechatTeacherInitEvent) { - yield* _mapInitEventToState(event); - } - - /// 绑定微信导师 - if (event is WechatTeacherBindEvent) { - yield* _mapBindEventToState(event); - } - } - - /// 初始化 - Stream _mapInitEventToState(WechatTeacherInitEvent event) async* { - var cacheStyle = await repository.fetchCachedStyle(); - if (!EmptyUtil.isEmpty(cacheStyle)) { - yield WechatTeacherLoadedState(dataModel: null, styleModel: cacheStyle); - } - var netStyle = await repository.fetchInitStyle(); - if (!EmptyUtil.isEmpty(netStyle)) { - yield WechatTeacherLoadedState(dataModel: null, styleModel: netStyle); - } - var data = await repository.fetchInitData(); - if (!EmptyUtil.isEmpty(data) && (!EmptyUtil.isEmpty(cacheStyle) || !EmptyUtil.isEmpty(netStyle))) { - yield WechatTeacherLoadedState(styleModel: !EmptyUtil.isEmpty(netStyle) ? netStyle : cacheStyle, dataModel: data); - } else { - yield WechatTeacherInitErrorState(); - } - } - - /// 绑定微信导师 - Stream _mapBindEventToState(WechatTeacherBindEvent event) async* { - var style = repository.styleModel; - var result = await repository.bindTeacher(event?.teacherWxChat); - if (!EmptyUtil.isEmpty(result)) { - yield WechatTeacherBindSuccessState(); - yield WechatTeacherLoadedState(styleModel: style, dataModel: result); - } else { - yield WechatTeacherBindErrorState(); - yield WechatTeacherLoadedState(styleModel: style, dataModel: null); - } - } -} diff --git a/lib/pages/wechat_teacher_page/bloc/wechat_teacher_event.dart b/lib/pages/wechat_teacher_page/bloc/wechat_teacher_event.dart deleted file mode 100644 index 090b9b5..0000000 --- a/lib/pages/wechat_teacher_page/bloc/wechat_teacher_event.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:meta/meta.dart'; - -@immutable -abstract class WechatTeacherEvent {} - -/// 初始化 -class WechatTeacherInitEvent extends WechatTeacherEvent {} - -/// 绑定邀请人 -class WechatTeacherBindEvent extends WechatTeacherEvent { - String teacherWxChat; - - WechatTeacherBindEvent({this.teacherWxChat}); -} diff --git a/lib/pages/wechat_teacher_page/bloc/wechat_teacher_repository.dart b/lib/pages/wechat_teacher_page/bloc/wechat_teacher_repository.dart deleted file mode 100644 index 19824df..0000000 --- a/lib/pages/wechat_teacher_page/bloc/wechat_teacher_repository.dart +++ /dev/null @@ -1,89 +0,0 @@ -import 'dart:convert'; - -import 'package:zhiying_base_widget/pages/wechat_teacher_page/model/wechat_teacher_data_model.dart'; -import 'package:zhiying_base_widget/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart'; -import 'package:zhiying_comm/zhiying_comm.dart'; - -class WechatTeacherRepository { - final Map data; - - WechatTeacherRepository(this.data); - - WechatTeacherStyleModel _styleModel; - WechatTeacherDataModel _dataModel; - - WechatTeacherStyleModel get styleModel => _styleModel; - - WechatTeacherDataModel get dataModel => _dataModel; - - /// 初始化 - Future fetchInitStyle() async { - try { - String skipIdentifier = - !EmptyUtil.isEmpty(data) && data.containsKey('skip_identifier') && !EmptyUtil.isEmpty(data['skip_identifier']) ? data['skip_identifier'] : 'pub.flutter.wechat_teacher'; - - var result = await NetUtil.post('/api/v1/mod/$skipIdentifier', method: NetMethod.GET, cache: true); - if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { - return handleStyleModel(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); - } - } catch (e, s) { - Logger.error(e, s); - } - return null; - } - - Future fetchCachedStyle() async { - try { - String skipIdentifier = - !EmptyUtil.isEmpty(data) && data.containsKey('skip_identifier') && !EmptyUtil.isEmpty(data['skip_identifier']) ? data['skip_identifier'] : 'pub.flutter.wechat_teacher'; - var result = await NetUtil.getRequestCachedData('/api/v1/mod/$skipIdentifier'); - if (!EmptyUtil.isEmpty(result)) { - return handleStyleModel(result); - } - } catch (e, s) { - Logger.error(e, s); - } - return null; - } - - WechatTeacherStyleModel handleStyleModel(final Map result) { - var modListData = result['mod_list'][0]['data']; - if (!EmptyUtil.isEmpty(modListData)) { - WechatTeacherStyleModel model = WechatTeacherStyleModel.fromJson(modListData is String ? jsonDecode(modListData) : modListData); - if (!EmptyUtil.isEmpty(model)) { - _styleModel = model; - } - return _styleModel; - } - return null; - } - - Future fetchInitData() async { - try { - var result = await NetUtil.post('/api/v1/user/wx_teacher', method: NetMethod.GET); - if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { - WechatTeacherDataModel model = WechatTeacherDataModel.fromJson(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]); - if (!EmptyUtil.isEmpty(model)) { - _dataModel = model; - } - return _dataModel; - } - } catch (e, s) { - Logger.error(e, s); - } - return null; - } - - /// 绑定导师 - Future bindTeacher(final String wxchatAccount) async { - try { - var result = await NetUtil.post('/api/v1/user/myteam/relate', method: NetMethod.POST, params: {'invite_code': wxchatAccount}); - if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) { - return await fetchInitData(); - } - } catch (e, s) { - Logger.error(e, s); - } - return null; - } -} diff --git a/lib/pages/wechat_teacher_page/bloc/wechat_teacher_state.dart b/lib/pages/wechat_teacher_page/bloc/wechat_teacher_state.dart deleted file mode 100644 index 642920e..0000000 --- a/lib/pages/wechat_teacher_page/bloc/wechat_teacher_state.dart +++ /dev/null @@ -1,25 +0,0 @@ -import 'package:meta/meta.dart'; -import 'package:zhiying_base_widget/pages/wechat_teacher_page/model/wechat_teacher_data_model.dart'; -import 'package:zhiying_base_widget/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart'; - -@immutable -abstract class WechatTeacherState {} - -class WechatTeacherInitial extends WechatTeacherState {} - -/// 数据加载成功 -class WechatTeacherLoadedState extends WechatTeacherState { - WechatTeacherDataModel dataModel; - WechatTeacherStyleModel styleModel; - - WechatTeacherLoadedState({this.dataModel, this.styleModel}); -} - -/// 初始化失败 -class WechatTeacherInitErrorState extends WechatTeacherState {} - -/// 绑定导师成功 -class WechatTeacherBindSuccessState extends WechatTeacherState {} - -/// 绑定导师失败 -class WechatTeacherBindErrorState extends WechatTeacherState {} diff --git a/lib/pages/wechat_teacher_page/model/wechat_teacher_data_model.dart b/lib/pages/wechat_teacher_page/model/wechat_teacher_data_model.dart deleted file mode 100644 index fbc33c5..0000000 --- a/lib/pages/wechat_teacher_page/model/wechat_teacher_data_model.dart +++ /dev/null @@ -1,32 +0,0 @@ -class WechatTeacherDataModel { - String isBindTeacher; - String teacherAvatar; - String teacherUsername; - String teacherWechatAccount; - String teacherWxQrCode; - - WechatTeacherDataModel( - {this.isBindTeacher, - this.teacherAvatar, - this.teacherUsername, - this.teacherWechatAccount, - this.teacherWxQrCode}); - - WechatTeacherDataModel.fromJson(Map json) { - isBindTeacher = json['is_bind_teacher']; - teacherAvatar = json['teacher_avatar']; - teacherUsername = json['teacher_username']; - teacherWechatAccount = json['teacher_wechat_account']; - teacherWxQrCode = json['teacher_wx_qr_code']; - } - - Map toJson() { - final Map data = new Map(); - data['is_bind_teacher'] = this.isBindTeacher; - data['teacher_avatar'] = this.teacherAvatar; - data['teacher_username'] = this.teacherUsername; - data['teacher_wechat_account'] = this.teacherWechatAccount; - data['teacher_wx_qr_code'] = this.teacherWxQrCode; - return data; - } -} diff --git a/lib/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart b/lib/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart deleted file mode 100644 index 0d2c659..0000000 --- a/lib/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart +++ /dev/null @@ -1,293 +0,0 @@ -class WechatTeacherStyleModel { - String appBarName; - String appBarNameColor; - String appBarBgColor; - String bgColor; - String bgImg; - String teacherDialogTitle; - String teacherDialogTitleColor; - String teacherDialogBgColor; - CommStyle commStyle; - NobindTeacherDialog nobindTeacherDialog; - MyTeacher myTeacher; - BindTeacherDialog bindTeacherDialog; - String chatDialogImg; - OfficalWxchat officalWxchat; - - WechatTeacherStyleModel({ - this.appBarName, - this.appBarNameColor, - this.appBarBgColor, - this.bgColor, - this.bgImg, - this.teacherDialogTitle, - this.teacherDialogTitleColor, - this.teacherDialogBgColor, - this.commStyle, - this.nobindTeacherDialog, - this.myTeacher, - this.bindTeacherDialog, - this.chatDialogImg, - this.officalWxchat, - }); - - WechatTeacherStyleModel.fromJson(Map json) { - appBarName = json['app_bar_name']; - appBarNameColor = json['app_bar_name_color']; - appBarBgColor = json['app_bar_bg_color']; - bgColor = json['bg_color']; - bgImg = json['bg_img']; - teacherDialogTitle = json['teacher_dialog_title']; - teacherDialogTitleColor = json['teacher_dialog_title_color']; - teacherDialogBgColor = json['teacher_dialog_bg_color']; - commStyle = json['comm_style'] != null ? new CommStyle.fromJson(json['comm_style']) : null; - nobindTeacherDialog = json['nobind_teacher_dialog'] != null ? new NobindTeacherDialog.fromJson(json['nobind_teacher_dialog']) : null; - myTeacher = json['my_teacher'] != null ? new MyTeacher.fromJson(json['my_teacher']) : null; - bindTeacherDialog = json['bind_teacher_dialog'] != null ? new BindTeacherDialog.fromJson(json['bind_teacher_dialog']) : null; - chatDialogImg = json['chat_dialog_img']; - officalWxchat = json['offical_wxchat'] != null ? new OfficalWxchat.fromJson(json['offical_wxchat']) : 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; - data['bg_img'] = this.bgImg; - data['teacher_dialog_title'] = this.teacherDialogTitle; - data['teacher_dialog_title_color'] = this.teacherDialogTitleColor; - data['teacher_dialog_bg_color'] = this.teacherDialogBgColor; - if (this.commStyle != null) { - data['comm_style'] = this.commStyle.toJson(); - } - if (this.nobindTeacherDialog != null) { - data['nobind_teacher_dialog'] = this.nobindTeacherDialog.toJson(); - } - if (this.myTeacher != null) { - data['my_teacher'] = this.myTeacher.toJson(); - } - if (this.bindTeacherDialog != null) { - data['bind_teacher_dialog'] = this.bindTeacherDialog.toJson(); - } - data['chat_dialog_img'] = this.chatDialogImg; - if (this.officalWxchat != null) { - data['offical_wxchat'] = this.officalWxchat.toJson(); - } - return data; - } -} - -class CommStyle { - String wechatAccountColor; - String btnTextColor; - String btnBgColor; - - CommStyle({ - this.wechatAccountColor, - this.btnTextColor, - this.btnBgColor, - }); - - CommStyle.fromJson(Map json) { - wechatAccountColor = json['wechat_account_color']; - btnTextColor = json['btn_text_color']; - btnBgColor = json['btn_bg_color']; - } - - Map toJson() { - final Map data = new Map(); - data['wechat_account_color'] = this.wechatAccountColor; - data['btn_text_color'] = this.btnTextColor; - data['btn_bg_color'] = this.btnBgColor; - return data; - } -} - -class NobindTeacherDialog { - String inputHintText; - String inputHintTextColor; - String inputLineColor; - String btnText; - - NobindTeacherDialog({ - this.inputHintText, - this.inputHintTextColor, - this.inputLineColor, - this.btnText, - }); - - NobindTeacherDialog.fromJson(Map json) { - inputHintText = json['input_hint_text']; - inputHintTextColor = json['input_hint_text_color']; - inputLineColor = json['input_line_color']; - btnText = json['btn_text']; - } - - Map toJson() { - final Map data = new Map(); - data['input_hint_text'] = this.inputHintText; - data['input_hint_text_color'] = this.inputHintTextColor; - data['input_line_color'] = this.inputLineColor; - data['btn_text'] = this.btnText; - return data; - } -} - -class MyTeacher { - String teacherType; - DefalutTeacher defalutTeacher; - - MyTeacher({this.teacherType, this.defalutTeacher}); - - MyTeacher.fromJson(Map json) { - teacherType = json['teacher_type']; - defalutTeacher = json['defalut_teacher'] != null ? new DefalutTeacher.fromJson(json['defalut_teacher']) : null; - } - - Map toJson() { - final Map data = new Map(); - data['teacher_type'] = this.teacherType; - if (this.defalutTeacher != null) { - data['defalut_teacher'] = this.defalutTeacher.toJson(); - } - return data; - } -} - -class DefalutTeacher { - String avatar; - String qrcode; - String wxAccount; - - DefalutTeacher({this.avatar, this.qrcode, this.wxAccount}); - - DefalutTeacher.fromJson(Map json) { - avatar = json['avatar']; - qrcode = json['qrcode']; - wxAccount = json['wx_account']; - } - - Map toJson() { - final Map data = new Map(); - data['avatar'] = this.avatar; - data['qrcode'] = this.qrcode; - data['wx_account'] = this.wxAccount; - return data; - } -} - -class BindTeacherDialog { - List dataKeys; - String btnText; - String btnTextColor; - String btnBgColor; - String qrcodeText; - String qrcodeTextColor; - - BindTeacherDialog({ - this.dataKeys, - this.btnText, - this.btnTextColor, - this.btnBgColor, - this.qrcodeText, - this.qrcodeTextColor, - }); - - BindTeacherDialog.fromJson(Map json) { - dataKeys = json['data_keys'].cast(); - btnText = json['btn_text']; - btnTextColor = json['btn_text_color']; - btnBgColor = json['btn_bg_color']; - qrcodeText = json['qrcode_text']; - qrcodeTextColor = json['qrcode_text_color']; - } - - Map toJson() { - final Map data = new Map(); - data['data_keys'] = this.dataKeys; - data['btn_text'] = this.btnText; - data['btn_text_color'] = this.btnTextColor; - data['btn_bg_color'] = this.btnBgColor; - data['qrcode_text'] = this.qrcodeText; - data['qrcode_text_color'] = this.qrcodeTextColor; - return data; - } -} - -class OfficalWxchat { - String qrcodeText; - String qrcodeTextColor; - String bgColor; - String title; - String titleColor; - String btnText; - List list; - - OfficalWxchat({ - this.qrcodeText, - this.qrcodeTextColor, - this.bgColor, - this.title, - this.titleColor, - this.btnText, - this.list, - }); - - OfficalWxchat.fromJson(Map json) { - qrcodeText = json['qrcode_text']; - qrcodeTextColor = json['qrcode_text_color']; - bgColor = json['bg_color']; - title = json['title']; - titleColor = json['title_color']; - btnText = json['btn_text']; - if (json['list'] != null) { - list = new List(); - json['list'].forEach((v) { - list.add(new OfficalWxchatList.fromJson(v)); - }); - } - } - - Map toJson() { - final Map data = new Map(); - data['qrcode_text'] = this.qrcodeText; - data['qrcode_text_color'] = this.qrcodeTextColor; - data['bg_color'] = this.bgColor; - data['title'] = this.title; - data['title_color'] = this.titleColor; - data['btn_text'] = this.btnText; - if (this.list != null) { - data['list'] = this.list.map((v) => v.toJson()).toList(); - } - return data; - } -} - -class OfficalWxchatList { - String index; - String text; - String subText; - String wechatAccount; - String qrcode; - - OfficalWxchatList({this.index, this.text, this.subText, this.wechatAccount, this.qrcode}); - - OfficalWxchatList.fromJson(Map json) { - index = json['index']; - text = json['text']; - subText = json['sub_text']; - wechatAccount = json['wechat_account']; - qrcode = json['qrcode']; - } - - Map toJson() { - final Map data = new Map(); - data['index'] = this.index; - data['text'] = this.text; - data['sub_text'] = this.subText; - data['wechat_account'] = this.wechatAccount; - data['qrcode'] = this.qrcode; - return data; - } -} diff --git a/lib/pages/wechat_teacher_page/wechat_teacher_page.dart b/lib/pages/wechat_teacher_page/wechat_teacher_page.dart deleted file mode 100644 index c236b86..0000000 --- a/lib/pages/wechat_teacher_page/wechat_teacher_page.dart +++ /dev/null @@ -1,411 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:fluttertoast/fluttertoast.dart'; -import 'package:zhiying_base_widget/pages/wechat_teacher_page/bloc/wechat_teacher_bloc.dart'; -import 'package:zhiying_base_widget/pages/wechat_teacher_page/bloc/wechat_teacher_repository.dart'; -import 'package:zhiying_base_widget/pages/wechat_teacher_page/model/wechat_teacher_data_model.dart'; -import 'package:zhiying_base_widget/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart'; -import 'package:zhiying_base_widget/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart'; -import 'package:zhiying_comm/zhiying_comm.dart'; - -import 'bloc/wechat_teacher_event.dart'; -import 'bloc/wechat_teacher_state.dart'; -import 'package:url_launcher/url_launcher.dart'; - -/// -/// 微信导师 -/// -class WechatTeacherPage extends StatelessWidget { - final Map data; - - WechatTeacherPage(this.data); - - @override - Widget build(BuildContext context) { - return BlocProvider( - create: (_) => WechatTeacherBloc(WechatTeacherRepository(data))..add(WechatTeacherInitEvent()), - child: _WechatTeacherPageContainer(), - ); - } -} - -class _WechatTeacherPageContainer extends StatefulWidget { - @override - _WechatTeacherPageContainerState createState() => _WechatTeacherPageContainerState(); -} - -class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer> { - TextEditingController _editingController; - - /// 是否绑定中 - bool _isBinding = false; - - /// 绑定邀请人 - void _bindTeacher() { - if (!_isBinding) { - String wxAccount = _editingController?.text?.toString(); - if (EmptyUtil.isEmpty(wxAccount)) { - Fluttertoast.showToast(msg: '请输入邀请码或者手机号码'); - return; - } - setState(() { - _isBinding = true; - }); - BlocProvider.of(context).add(WechatTeacherBindEvent(teacherWxChat: wxAccount)); - } - } - - /// 拷贝 - void _copyText(String text) async { - if (!EmptyUtil.isEmpty(text)) { - await Clipboard.setData(ClipboardData(text: text)); - Fluttertoast.showToast(msg: '复制成功~'); - String url = "weixin://"; - if (await canLaunch(url)) { - await launch(url); - } else { - throw 'Could not launch $url'; - } - } else { - Fluttertoast.showToast(msg: '内容不能为空~'); - } - } - - /// 长按保存图片 - void _longClickSaveImage(String url) async { - Logger.log('长按保存图片'); - if (!EmptyUtil.isEmpty(url)) { - var msg = await Download().fileToGallery(url); - Fluttertoast.showToast(msg: msg); - } - } - - @override - void initState() { - _editingController = TextEditingController(); - super.initState(); - } - - @override - void dispose() { - _editingController?.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) {}, - buildWhen: (prov, current) { - if (current is WechatTeacherInitErrorState) { - return false; - } - if (current is WechatTeacherBindErrorState) { - _isBinding = false; - return false; - } - if (current is WechatTeacherBindSuccessState) { - _isBinding = false; - Fluttertoast.showToast(msg: '绑定成功'); - return false; - } - return true; - }, - builder: (context, state) { - if (state is WechatTeacherLoadedState) { - return _createMainWidget(state?.styleModel, state?.dataModel); - } - return _createMainWidget(null, null); - }, - ); - } - - Widget _createMainWidget(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { - return Scaffold( - appBar: _createNav(styleModel), - backgroundColor: HexColor.fromHex(styleModel?.bgColor ?? '#FFF5F5F5'), - body: SafeArea( - child: SingleChildScrollView( - child: Column( - children: [ - _createHeader(styleModel, dataModel), - Padding( - padding: const EdgeInsets.only(top: 15), - child: CachedNetworkImage( - imageUrl: styleModel?.chatDialogImg ?? '', - width: double.infinity, - )), - _createWechat(styleModel), - ], - ), - ), - ), - ); - } - - // 导航栏 - Widget _createNav(WechatTeacherStyleModel styleModel) { - return CupertinoNavigationBar( - border: Border( - bottom: BorderSide( - width: 0.0, // One physical pixel. - style: BorderStyle.none, - ), - ), - backgroundColor: HexColor.fromHex(styleModel?.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); - } - }, - ) - : Container(), - middle: Text( - styleModel?.appBarName ?? '微信导师', - style: TextStyle( - fontSize: 15, - color: HexColor.fromHex(styleModel?.appBarNameColor ?? '#333333'), - ), - ), - ); - } - - /// 没绑定的UI - Widget _createNoBindWidget(WechatTeacherStyleModel styleModel) { - return Column( - children: [ - Container( - margin: EdgeInsets.only(top: 8, bottom: 2), - child: CupertinoTextField( - onSubmitted: (val) => _bindTeacher(), - controller: _editingController, - placeholder: styleModel?.nobindTeacherDialog?.inputHintText ?? '请填写邀请人邀请码/手机号码', - placeholderStyle: TextStyle(fontSize: 14), - decoration: BoxDecoration(), - ), - ), - Container( - height: 0.5, - color: Color(0xffd5d5d5), - ), - GestureDetector( - onTap: () => _bindTeacher(), - child: Center( - child: Container( - margin: EdgeInsets.only(top: 10), - width: 130, - height: 30, - decoration: BoxDecoration( - color: HexColor.fromHex(styleModel?.commStyle?.btnBgColor ?? '#FF5A5A'), - borderRadius: BorderRadius.circular(15), - ), - child: Center( - child: Text( - _isBinding ? '绑定中...' : styleModel?.nobindTeacherDialog?.btnText ?? '绑定邀请人', - style: TextStyle( - color: HexColor.fromHex(styleModel?.commStyle?.btnTextColor ?? '#FFFFFFF'), fontSize: 14), - ), - ), - ), - ), - ) - ], - ); - } - - /// 绑定的UI - Widget _createBindWidget(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { - return Container( - width: double.infinity, - height: double.infinity, - margin: const EdgeInsets.only(top: 10), - child: Row( - children: [ - Container( - width: 50, - height: 50, - // color: Colors.red, - child: CircleAvatar( - child: CachedNetworkImage( - imageUrl: dataModel?.teacherAvatar ?? '', - )), - ), - const SizedBox(width: 13), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - Text(dataModel?.teacherUsername ?? '', - style: TextStyle( - fontSize: 15, color: HexColor.fromHex(styleModel?.teacherDialogTitleColor ?? '#3C3C3C'))), - Text('微信号: ${dataModel?.teacherWechatAccount ?? ''}', - style: TextStyle( - fontSize: 15, color: HexColor.fromHex(styleModel?.commStyle?.wechatAccountColor ?? '#FF5050'))), - GestureDetector( - onTap: () => _copyText(dataModel?.teacherWechatAccount), - child: UnconstrainedBox( - child: Container( - decoration: BoxDecoration( - // color: Color(0xffffdada), - color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnBgColor ?? '#FFDADA'), - borderRadius: BorderRadius.circular(20), - ), - padding: EdgeInsets.only(left: 9, right: 9, top: 4, bottom: 4), - child: Text( - styleModel?.bindTeacherDialog?.btnText ?? '复制去微信添加', - style: TextStyle( - fontSize: 13, - color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnTextColor ?? '#FF0000')), - ), - ), - ), - ), - ], - ), - Expanded( - child: Align( - alignment: Alignment.centerRight, - child: GestureDetector( - onLongPress: () => _longClickSaveImage( - dataModel?.teacherWxQrCode ?? styleModel?.myTeacher?.defalutTeacher?.qrcode ?? ''), - child: Column( - children: [ - Container( - width: 56, - height: 56, - // color: Colors.red, - child: CachedNetworkImage( - imageUrl: dataModel?.teacherWxQrCode ?? styleModel?.myTeacher?.defalutTeacher?.qrcode ?? '', - ), - ), - const SizedBox(height: 9), - Text( - styleModel?.officalWxchat?.qrcodeText ?? '长按保存二维码', - style: TextStyle( - fontSize: 13, - color: HexColor.fromHex(styleModel?.officalWxchat?.qrcodeTextColor ?? '#999999')), - ), - ], - ), - ), - ), - ) - ], - ), - ); - } - - Widget _createHeader(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) { - return Container( - width: double.infinity, - height: 283, - child: Stack( - children: [ - // 背景图 - Container( - width: double.infinity, - height: 185, - // color: Colors.redAccent, - child: CachedNetworkImage( - imageUrl: styleModel?.bgImg ?? '', - fit: BoxFit.contain, - ), - ), - - // 中间弹窗 - Align( - alignment: Alignment.bottomCenter, - child: Container( - width: double.infinity, - height: 138, - margin: EdgeInsets.only(left: 10, right: 10), - padding: EdgeInsets.all(12), - decoration: BoxDecoration( - color: HexColor.fromHex(styleModel?.teacherDialogBgColor ?? '#FFFFFF'), - borderRadius: BorderRadius.circular(10), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - styleModel?.teacherDialogTitle ?? '我的导师', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 15, - color: HexColor.fromHex(styleModel?.teacherDialogTitleColor ?? '#3C3C3C'), - ), - ), - Expanded( - child: Visibility( - visible: dataModel?.isBindTeacher == '1', - replacement: _createNoBindWidget(styleModel), - child: _createBindWidget(styleModel, dataModel), - ), - ) - ], - ), - ), - ), - ], - ), - ); - } - - Widget _createWechat(WechatTeacherStyleModel styleModel) { - return Container( - width: double.infinity, - margin: EdgeInsets.only(left: 10, right: 10, top: 0, bottom: 22), - padding: EdgeInsets.all(12), - decoration: BoxDecoration( - color: HexColor.fromHex(styleModel?.officalWxchat?.bgColor ?? '#FFFFFF'), - borderRadius: BorderRadius.circular(10), - ), - child: Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - styleModel?.officalWxchat?.title ?? '官方微信', - style: TextStyle( - color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#3C3C3C'), - fontSize: 15, - fontWeight: FontWeight.bold, - ), - ), - _createOfficalWxchatListWidget(styleModel), - ], - ), - ); - } - - Widget _createOfficalWxchatListWidget(WechatTeacherStyleModel styleModel) { - List widgets = []; - int length = styleModel?.officalWxchat?.list?.length ?? 0; - if (length > 0) { - styleModel.officalWxchat.list.forEach((element) { - widgets.add(WechatTeachetItem(element, styleModel)); - widgets.add(Container( - margin: EdgeInsets.only(top: 4, bottom: 4), width: double.infinity, height: 0.5, color: Color(0xffebebeb))); - }); - widgets.removeLast(); - } else { - widgets.add(Container()); - } - - return Column( - children: widgets, - ); - } -} diff --git a/lib/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart b/lib/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart deleted file mode 100644 index b996b23..0000000 --- a/lib/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart +++ /dev/null @@ -1,137 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:zhiying_base_widget/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart'; -import 'package:zhiying_comm/zhiying_comm.dart'; -import 'package:fluttertoast/fluttertoast.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class WechatTeachetItem extends StatelessWidget { - OfficalWxchatList itemStyleModel; - WechatTeacherStyleModel styleModel; - - WechatTeachetItem(this.itemStyleModel, this.styleModel); - - /// 拷贝 - void _copyText(String text) async { - if (!EmptyUtil.isEmpty(text)) { - await Clipboard.setData(ClipboardData(text: text)); - Fluttertoast.showToast(msg: '复制成功~'); - String url = "weixin://"; - if (await canLaunch(url)) { - await launch(url); - } else { - throw 'Could not launch $url'; - } - } else { - Fluttertoast.showToast(msg: '内容不能为空~'); - } - } - - /// 长按保存图片 - void _longClickSaveImage(String url) async { - Logger.log('长按保存图片'); - if (!EmptyUtil.isEmpty(url)) { - - - var msg = await Download().fileToGallery(url); - Fluttertoast.showToast(msg: msg); - } - } - - @override - Widget build(BuildContext context) { - - return Container( - margin: EdgeInsets.only(top: 8, bottom: 8), - child: Row( - children: [ - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Text( - // itemStyleModel?.text ?? '微信公众号 智莺生活公众号', - // style: TextStyle( - // fontSize: 14, - // color: Color(0xff3c3c3c), - // fontWeight: FontWeight.bold, - // ), - // ), - - RichText( - text: TextSpan(children: [ - TextSpan( - text: itemStyleModel?.text ?? '', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 14, - color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#FF3C3C3C'))), - TextSpan( - text: ' ${itemStyleModel?.subText ?? ''}', - style: TextStyle( - fontWeight: FontWeight.bold, - fontSize: 11, - color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#FF3C3C3C'))), - ]), - ), - - Padding( - padding: const EdgeInsets.only(top: 8.0, bottom: 8), - child: Text( - '微信号:${itemStyleModel?.wechatAccount ?? ''}', - style: TextStyle( - fontSize: 13, - // color: Color(0xffff5050), - color: HexColor.fromHex(styleModel?.commStyle?.wechatAccountColor ?? '#FF5050'), - fontWeight: FontWeight.bold, - ), - ), - ), - GestureDetector( - onTap: () => _copyText(itemStyleModel?.wechatAccount), - child: UnconstrainedBox( - child: Container( - decoration: BoxDecoration( - // color: Color(0xffffdada), - color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnBgColor ?? '#FFDADA'), - borderRadius: BorderRadius.circular(20), - ), - padding: EdgeInsets.only(left: 9, right: 9, top: 4, bottom: 4), - child: Text( - styleModel?.bindTeacherDialog?.btnText ?? '复制去微信添加', - style: TextStyle( - fontSize: 13, - color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnTextColor ?? '#FF0000')), - ), - ), - ), - ), - ], - ), - ), - GestureDetector( - onLongPress: () => _longClickSaveImage(itemStyleModel?.qrcode), - child: Column( - children: [ - Container( - margin: EdgeInsets.only(bottom: 4), - width: 55, - height: 55, - // color: Colors.redAccent, - child: CachedNetworkImage( - imageUrl: itemStyleModel?.qrcode ?? '', - ), - ), - Text( - styleModel?.officalWxchat?.qrcodeText ?? '长按保存二维码', - style: TextStyle( - fontSize: 13, color: HexColor.fromHex(styleModel?.officalWxchat?.qrcodeTextColor ?? '#999999')), - ), - ], - ), - ) - ], - ), - ); - } -} diff --git a/lib/register.dart b/lib/register.dart index ff8fdea..9c1c88a 100644 --- a/lib/register.dart +++ b/lib/register.dart @@ -33,7 +33,6 @@ import 'package:zhiying_base_widget/pages/setting_page/setting_page.dart'; import 'package:zhiying_base_widget/pages/team_details_page/team_details_page.dart'; import 'package:zhiying_base_widget/pages/team_page/team_page.dart'; import 'package:zhiying_base_widget/pages/webview/base_webview.dart'; -import 'package:zhiying_base_widget/pages/wechat_teacher_page/wechat_teacher_page.dart'; import 'package:zhiying_base_widget/pages/withdraw_page/withdraw_page.dart'; import 'package:zhiying_base_widget/utils/mob_push_util.dart'; import 'package:zhiying_base_widget/widgets/custom/banner/custom_banner_widget.dart'; @@ -200,8 +199,6 @@ class BaseWidgetRegister { /// 反馈列表页 PageFactory.regist('pub.flutter.feedback_list', (model) => FeedbackRecordPage(model)); - /// 微信导师 - PageFactory.regist('pub.flutter.wechat_teacher', (model) => WechatTeacherPage(model)); /// 提现页 PageFactory.regist('pub.flutter.cash_out', (model) => WithdrawPage(model));