Browse Source

0118 微信导师模块抽出去,这里的进行删除

tags/0.0.4+4
23028876916@qq.com 3 years ago
parent
commit
9722200498
10 changed files with 27 additions and 1093 deletions
  1. +27
    -27
      example/android/app/build.gradle
  2. +0
    -62
      lib/pages/wechat_teacher_page/bloc/wechat_teacher_bloc.dart
  3. +0
    -14
      lib/pages/wechat_teacher_page/bloc/wechat_teacher_event.dart
  4. +0
    -89
      lib/pages/wechat_teacher_page/bloc/wechat_teacher_repository.dart
  5. +0
    -25
      lib/pages/wechat_teacher_page/bloc/wechat_teacher_state.dart
  6. +0
    -32
      lib/pages/wechat_teacher_page/model/wechat_teacher_data_model.dart
  7. +0
    -293
      lib/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart
  8. +0
    -411
      lib/pages/wechat_teacher_page/wechat_teacher_page.dart
  9. +0
    -137
      lib/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart
  10. +0
    -3
      lib/register.dart

+ 27
- 27
example/android/app/build.gradle View File

@@ -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 { configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details -> resolutionStrategy.eachDependency { DependencyResolveDetails details ->


+ 0
- 62
lib/pages/wechat_teacher_page/bloc/wechat_teacher_bloc.dart View File

@@ -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<WechatTeacherEvent, WechatTeacherState> {
@override
WechatTeacherState get initialState => WechatTeacherInitial();

WechatTeacherRepository repository;

WechatTeacherBloc(this.repository);

@override
Stream<WechatTeacherState> mapEventToState(
WechatTeacherEvent event,
) async* {
/// 初始化
if (event is WechatTeacherInitEvent) {
yield* _mapInitEventToState(event);
}

/// 绑定微信导师
if (event is WechatTeacherBindEvent) {
yield* _mapBindEventToState(event);
}
}

/// 初始化
Stream<WechatTeacherState> _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<WechatTeacherState> _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);
}
}
}

+ 0
- 14
lib/pages/wechat_teacher_page/bloc/wechat_teacher_event.dart View File

@@ -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});
}

+ 0
- 89
lib/pages/wechat_teacher_page/bloc/wechat_teacher_repository.dart View File

@@ -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<String, dynamic> data;

WechatTeacherRepository(this.data);

WechatTeacherStyleModel _styleModel;
WechatTeacherDataModel _dataModel;

WechatTeacherStyleModel get styleModel => _styleModel;

WechatTeacherDataModel get dataModel => _dataModel;

/// 初始化
Future<WechatTeacherStyleModel> 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<WechatTeacherStyleModel> 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<String, dynamic> 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<WechatTeacherDataModel> 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<WechatTeacherDataModel> 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;
}
}

+ 0
- 25
lib/pages/wechat_teacher_page/bloc/wechat_teacher_state.dart View File

@@ -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 {}

+ 0
- 32
lib/pages/wechat_teacher_page/model/wechat_teacher_data_model.dart View File

@@ -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<String, dynamic> 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<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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;
}
}

+ 0
- 293
lib/pages/wechat_teacher_page/model/wechat_teacher_style_model.dart View File

@@ -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<String, dynamic> 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<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;
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<String, dynamic> json) {
wechatAccountColor = json['wechat_account_color'];
btnTextColor = json['btn_text_color'];
btnBgColor = json['btn_bg_color'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<String, dynamic> json) {
inputHintText = json['input_hint_text'];
inputHintTextColor = json['input_hint_text_color'];
inputLineColor = json['input_line_color'];
btnText = json['btn_text'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<String, dynamic> json) {
teacherType = json['teacher_type'];
defalutTeacher = json['defalut_teacher'] != null ? new DefalutTeacher.fromJson(json['defalut_teacher']) : null;
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<String, dynamic> json) {
avatar = json['avatar'];
qrcode = json['qrcode'];
wxAccount = json['wx_account'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['avatar'] = this.avatar;
data['qrcode'] = this.qrcode;
data['wx_account'] = this.wxAccount;
return data;
}
}

class BindTeacherDialog {
List<String> 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<String, dynamic> json) {
dataKeys = json['data_keys'].cast<String>();
btnText = json['btn_text'];
btnTextColor = json['btn_text_color'];
btnBgColor = json['btn_bg_color'];
qrcodeText = json['qrcode_text'];
qrcodeTextColor = json['qrcode_text_color'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<OfficalWxchatList> list;

OfficalWxchat({
this.qrcodeText,
this.qrcodeTextColor,
this.bgColor,
this.title,
this.titleColor,
this.btnText,
this.list,
});

OfficalWxchat.fromJson(Map<String, dynamic> 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<OfficalWxchatList>();
json['list'].forEach((v) {
list.add(new OfficalWxchatList.fromJson(v));
});
}
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<String, dynamic> json) {
index = json['index'];
text = json['text'];
subText = json['sub_text'];
wechatAccount = json['wechat_account'];
qrcode = json['qrcode'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['index'] = this.index;
data['text'] = this.text;
data['sub_text'] = this.subText;
data['wechat_account'] = this.wechatAccount;
data['qrcode'] = this.qrcode;
return data;
}
}

+ 0
- 411
lib/pages/wechat_teacher_page/wechat_teacher_page.dart View File

@@ -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<String, dynamic> data;

WechatTeacherPage(this.data);

@override
Widget build(BuildContext context) {
return BlocProvider<WechatTeacherBloc>(
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<WechatTeacherBloc>(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<WechatTeacherBloc, WechatTeacherState>(
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: <Widget>[
_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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
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: <Widget>[
// 背景图
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: <Widget>[
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: <Widget>[
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<Widget> 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,
);
}
}

+ 0
- 137
lib/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart View File

@@ -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: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// 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: <Widget>[
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')),
),
],
),
)
],
),
);
}
}

+ 0
- 3
lib/register.dart View File

@@ -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_details_page/team_details_page.dart';
import 'package:zhiying_base_widget/pages/team_page/team_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/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/pages/withdraw_page/withdraw_page.dart';
import 'package:zhiying_base_widget/utils/mob_push_util.dart'; import 'package:zhiying_base_widget/utils/mob_push_util.dart';
import 'package:zhiying_base_widget/widgets/custom/banner/custom_banner_widget.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.feedback_list', (model) => FeedbackRecordPage(model));


/// 微信导师
PageFactory.regist('pub.flutter.wechat_teacher', (model) => WechatTeacherPage(model));


/// 提现页 /// 提现页
PageFactory.regist('pub.flutter.cash_out', (model) => WithdrawPage(model)); PageFactory.regist('pub.flutter.cash_out', (model) => WithdrawPage(model));


Loading…
Cancel
Save