Browse Source

1223 微信导师打开微信问题修复

tags/0.0.3+1
23028876916@qq.com 3 years ago
parent
commit
5acef154e9
2 changed files with 72 additions and 72 deletions
  1. +39
    -61
      lib/pages/wechat_teacher_page/wechat_teacher_page.dart
  2. +33
    -11
      lib/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart

+ 39
- 61
lib/pages/wechat_teacher_page/wechat_teacher_page.dart View File

@@ -12,6 +12,7 @@ import 'package:zhiying_comm/zhiying_comm.dart';


import 'bloc/wechat_teacher_event.dart'; import 'bloc/wechat_teacher_event.dart';
import 'bloc/wechat_teacher_state.dart'; import 'bloc/wechat_teacher_state.dart';
import 'package:url_launcher/url_launcher.dart';


/// ///
/// 微信导师 /// 微信导师
@@ -24,8 +25,7 @@ class WechatTeacherPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BlocProvider<WechatTeacherBloc>( return BlocProvider<WechatTeacherBloc>(
create: (_) => WechatTeacherBloc(WechatTeacherRepository(data))
..add(WechatTeacherInitEvent()),
create: (_) => WechatTeacherBloc(WechatTeacherRepository(data))..add(WechatTeacherInitEvent()),
child: _WechatTeacherPageContainer(), child: _WechatTeacherPageContainer(),
); );
} }
@@ -33,12 +33,10 @@ class WechatTeacherPage extends StatelessWidget {


class _WechatTeacherPageContainer extends StatefulWidget { class _WechatTeacherPageContainer extends StatefulWidget {
@override @override
_WechatTeacherPageContainerState createState() =>
_WechatTeacherPageContainerState();
_WechatTeacherPageContainerState createState() => _WechatTeacherPageContainerState();
} }


class _WechatTeacherPageContainerState
extends State<_WechatTeacherPageContainer> {
class _WechatTeacherPageContainerState extends State<_WechatTeacherPageContainer> {
TextEditingController _editingController; TextEditingController _editingController;


/// 是否绑定中 /// 是否绑定中
@@ -55,24 +53,33 @@ class _WechatTeacherPageContainerState
setState(() { setState(() {
_isBinding = true; _isBinding = true;
}); });
BlocProvider.of<WechatTeacherBloc>(context)
.add(WechatTeacherBindEvent(teacherWxChat: wxAccount));
BlocProvider.of<WechatTeacherBloc>(context).add(WechatTeacherBindEvent(teacherWxChat: wxAccount));
} }
} }


/// 拷贝 /// 拷贝
void _copyText(String text) {
void _copyText(String text) async {
if (!EmptyUtil.isEmpty(text)) { if (!EmptyUtil.isEmpty(text)) {
Clipboard.setData(ClipboardData(text: text));
await Clipboard.setData(ClipboardData(text: text));
Fluttertoast.showToast(msg: '复制成功~'); Fluttertoast.showToast(msg: '复制成功~');
String url = "weixin://";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
} else { } else {
Fluttertoast.showToast(msg: '内容不能为空~'); Fluttertoast.showToast(msg: '内容不能为空~');
} }
} }


/// 长按保存图片 /// 长按保存图片
void _longClickSaveImage() {
void _longClickSaveImage(String url) async {
Logger.log('长按保存图片'); Logger.log('长按保存图片');
if (!EmptyUtil.isEmpty(url)) {
var msg = await Download().fileToGallery(url);
Fluttertoast.showToast(msg: msg);
}
} }


@override @override
@@ -115,8 +122,7 @@ class _WechatTeacherPageContainerState
); );
} }


Widget _createMainWidget(
WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) {
Widget _createMainWidget(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) {
return Scaffold( return Scaffold(
appBar: _createNav(styleModel), appBar: _createNav(styleModel),
backgroundColor: HexColor.fromHex(styleModel?.bgColor ?? '#FFF5F5F5'), backgroundColor: HexColor.fromHex(styleModel?.bgColor ?? '#FFF5F5F5'),
@@ -184,8 +190,7 @@ class _WechatTeacherPageContainerState
child: CupertinoTextField( child: CupertinoTextField(
onSubmitted: (val) => _bindTeacher(), onSubmitted: (val) => _bindTeacher(),
controller: _editingController, controller: _editingController,
placeholder: styleModel?.nobindTeacherDialog?.inputHintText ??
'请填写邀请人邀请码/手机号码',
placeholder: styleModel?.nobindTeacherDialog?.inputHintText ?? '请填写邀请人邀请码/手机号码',
placeholderStyle: TextStyle(fontSize: 14), placeholderStyle: TextStyle(fontSize: 14),
decoration: BoxDecoration(), decoration: BoxDecoration(),
), ),
@@ -202,19 +207,14 @@ class _WechatTeacherPageContainerState
width: 130, width: 130,
height: 30, height: 30,
decoration: BoxDecoration( decoration: BoxDecoration(
color: HexColor.fromHex(
styleModel?.commStyle?.btnBgColor ?? '#FF5A5A'),
color: HexColor.fromHex(styleModel?.commStyle?.btnBgColor ?? '#FF5A5A'),
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
), ),
child: Center( child: Center(
child: Text( child: Text(
_isBinding
? '绑定中...'
: styleModel?.nobindTeacherDialog?.btnText ?? '绑定邀请人',
_isBinding ? '绑定中...' : styleModel?.nobindTeacherDialog?.btnText ?? '绑定邀请人',
style: TextStyle( style: TextStyle(
color: HexColor.fromHex(
styleModel?.commStyle?.btnTextColor ?? '#FFFFFFF'),
fontSize: 14),
color: HexColor.fromHex(styleModel?.commStyle?.btnTextColor ?? '#FFFFFFF'), fontSize: 14),
), ),
), ),
), ),
@@ -225,8 +225,7 @@ class _WechatTeacherPageContainerState
} }


/// 绑定的UI /// 绑定的UI
Widget _createBindWidget(
WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) {
Widget _createBindWidget(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) {
return Container( return Container(
width: double.infinity, width: double.infinity,
height: double.infinity, height: double.infinity,
@@ -249,35 +248,25 @@ class _WechatTeacherPageContainerState
children: <Widget>[ children: <Widget>[
Text(dataModel?.teacherUsername ?? '', Text(dataModel?.teacherUsername ?? '',
style: TextStyle( style: TextStyle(
fontSize: 15,
color: HexColor.fromHex(
styleModel?.teacherDialogTitleColor ?? '#3C3C3C'))),
fontSize: 15, color: HexColor.fromHex(styleModel?.teacherDialogTitleColor ?? '#3C3C3C'))),
Text('微信号: ${dataModel?.teacherWechatAccount ?? ''}', Text('微信号: ${dataModel?.teacherWechatAccount ?? ''}',
style: TextStyle( style: TextStyle(
fontSize: 15,
color: HexColor.fromHex(
styleModel?.commStyle?.wechatAccountColor ??
'#FF5050'))),
fontSize: 15, color: HexColor.fromHex(styleModel?.commStyle?.wechatAccountColor ?? '#FF5050'))),
GestureDetector( GestureDetector(
onTap: () => _copyText(dataModel?.teacherWechatAccount), onTap: () => _copyText(dataModel?.teacherWechatAccount),
child: UnconstrainedBox( child: UnconstrainedBox(
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
// color: Color(0xffffdada), // color: Color(0xffffdada),
color: HexColor.fromHex(
styleModel?.bindTeacherDialog?.btnBgColor ??
'#FFDADA'),
color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnBgColor ?? '#FFDADA'),
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
), ),
padding:
EdgeInsets.only(left: 9, right: 9, top: 4, bottom: 4),
padding: EdgeInsets.only(left: 9, right: 9, top: 4, bottom: 4),
child: Text( child: Text(
styleModel?.bindTeacherDialog?.btnText ?? '复制去微信添加', styleModel?.bindTeacherDialog?.btnText ?? '复制去微信添加',
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
color: HexColor.fromHex(
styleModel?.bindTeacherDialog?.btnTextColor ??
'#FF0000')),
color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnTextColor ?? '#FF0000')),
), ),
), ),
), ),
@@ -288,7 +277,8 @@ class _WechatTeacherPageContainerState
child: Align( child: Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: GestureDetector( child: GestureDetector(
onLongPress: () => _longClickSaveImage(),
onLongPress: () => _longClickSaveImage(
dataModel?.teacherWxQrCode ?? styleModel?.myTeacher?.defalutTeacher?.qrcode ?? ''),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Container( Container(
@@ -296,9 +286,7 @@ class _WechatTeacherPageContainerState
height: 56, height: 56,
// color: Colors.red, // color: Colors.red,
child: CachedNetworkImage( child: CachedNetworkImage(
imageUrl: dataModel?.teacherWxQrCode ??
styleModel?.myTeacher?.defalutTeacher?.qrcode ??
'',
imageUrl: dataModel?.teacherWxQrCode ?? styleModel?.myTeacher?.defalutTeacher?.qrcode ?? '',
), ),
), ),
const SizedBox(height: 9), const SizedBox(height: 9),
@@ -306,9 +294,7 @@ class _WechatTeacherPageContainerState
styleModel?.officalWxchat?.qrcodeText ?? '长按保存二维码', styleModel?.officalWxchat?.qrcodeText ?? '长按保存二维码',
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
color: HexColor.fromHex(
styleModel?.officalWxchat?.qrcodeTextColor ??
'#999999')),
color: HexColor.fromHex(styleModel?.officalWxchat?.qrcodeTextColor ?? '#999999')),
), ),
], ],
), ),
@@ -320,8 +306,7 @@ class _WechatTeacherPageContainerState
); );
} }


Widget _createHeader(
WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) {
Widget _createHeader(WechatTeacherStyleModel styleModel, WechatTeacherDataModel dataModel) {
return Container( return Container(
width: double.infinity, width: double.infinity,
height: 283, height: 283,
@@ -347,8 +332,7 @@ class _WechatTeacherPageContainerState
margin: EdgeInsets.only(left: 10, right: 10), margin: EdgeInsets.only(left: 10, right: 10),
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
decoration: BoxDecoration( decoration: BoxDecoration(
color: HexColor.fromHex(
styleModel?.teacherDialogBgColor ?? '#FFFFFF'),
color: HexColor.fromHex(styleModel?.teacherDialogBgColor ?? '#FFFFFF'),
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
child: Column( child: Column(
@@ -360,8 +344,7 @@ class _WechatTeacherPageContainerState
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 15, fontSize: 15,
color: HexColor.fromHex(
styleModel?.teacherDialogTitleColor ?? '#3C3C3C'),
color: HexColor.fromHex(styleModel?.teacherDialogTitleColor ?? '#3C3C3C'),
), ),
), ),
Expanded( Expanded(
@@ -386,8 +369,7 @@ class _WechatTeacherPageContainerState
margin: EdgeInsets.only(left: 10, right: 10, top: 0, bottom: 22), margin: EdgeInsets.only(left: 10, right: 10, top: 0, bottom: 22),
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
decoration: BoxDecoration( decoration: BoxDecoration(
color:
HexColor.fromHex(styleModel?.officalWxchat?.bgColor ?? '#FFFFFF'),
color: HexColor.fromHex(styleModel?.officalWxchat?.bgColor ?? '#FFFFFF'),
borderRadius: BorderRadius.circular(10), borderRadius: BorderRadius.circular(10),
), ),
child: Column( child: Column(
@@ -397,8 +379,7 @@ class _WechatTeacherPageContainerState
Text( Text(
styleModel?.officalWxchat?.title ?? '官方微信', styleModel?.officalWxchat?.title ?? '官方微信',
style: TextStyle( style: TextStyle(
color: HexColor.fromHex(
styleModel?.officalWxchat?.titleColor ?? '#3C3C3C'),
color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#3C3C3C'),
fontSize: 15, fontSize: 15,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
@@ -416,10 +397,7 @@ class _WechatTeacherPageContainerState
styleModel.officalWxchat.list.forEach((element) { styleModel.officalWxchat.list.forEach((element) {
widgets.add(WechatTeachetItem(element, styleModel)); widgets.add(WechatTeachetItem(element, styleModel));
widgets.add(Container( widgets.add(Container(
margin: EdgeInsets.only(top: 4, bottom: 4),
width: double.infinity,
height: 0.5,
color: Color(0xffebebeb)));
margin: EdgeInsets.only(top: 4, bottom: 4), width: double.infinity, height: 0.5, color: Color(0xffebebeb)));
}); });
widgets.removeLast(); widgets.removeLast();
} else { } else {


+ 33
- 11
lib/pages/wechat_teacher_page/widgets/wechat_teacher_item.dart View File

@@ -3,6 +3,7 @@ import 'package:flutter/services.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/model/wechat_teacher_style_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart'; import 'package:zhiying_comm/zhiying_comm.dart';
import 'package:fluttertoast/fluttertoast.dart'; import 'package:fluttertoast/fluttertoast.dart';
import 'package:url_launcher/url_launcher.dart';


class WechatTeachetItem extends StatelessWidget { class WechatTeachetItem extends StatelessWidget {
OfficalWxchatList itemStyleModel; OfficalWxchatList itemStyleModel;
@@ -11,23 +12,35 @@ class WechatTeachetItem extends StatelessWidget {
WechatTeachetItem(this.itemStyleModel, this.styleModel); WechatTeachetItem(this.itemStyleModel, this.styleModel);


/// 拷贝 /// 拷贝
void _copyText(String text) {
if(!EmptyUtil.isEmpty(text)) {
Clipboard.setData(ClipboardData(text: text));
void _copyText(String text) async {
if (!EmptyUtil.isEmpty(text)) {
await Clipboard.setData(ClipboardData(text: text));
Fluttertoast.showToast(msg: '复制成功~'); Fluttertoast.showToast(msg: '复制成功~');
}else{
String url = "weixin://";
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
} else {
Fluttertoast.showToast(msg: '内容不能为空~'); Fluttertoast.showToast(msg: '内容不能为空~');
} }
} }


/// 长按保存图片 /// 长按保存图片
void _longClickSaveImage(){
void _longClickSaveImage(String url) async {
Logger.log('长按保存图片'); Logger.log('长按保存图片');
if (!EmptyUtil.isEmpty(url)) {



var msg = await Download().fileToGallery(url);
Fluttertoast.showToast(msg: msg);
}
} }


@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

return Container( return Container(
margin: EdgeInsets.only(top: 8, bottom: 8), margin: EdgeInsets.only(top: 8, bottom: 8),
child: Row( child: Row(
@@ -49,10 +62,16 @@ class WechatTeachetItem extends StatelessWidget {
text: TextSpan(children: [ text: TextSpan(children: [
TextSpan( TextSpan(
text: itemStyleModel?.text ?? '', text: itemStyleModel?.text ?? '',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#FF3C3C3C'))),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#FF3C3C3C'))),
TextSpan( TextSpan(
text: ' ${itemStyleModel?.subText ?? ''}', text: ' ${itemStyleModel?.subText ?? ''}',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 11, color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#FF3C3C3C'))),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 11,
color: HexColor.fromHex(styleModel?.officalWxchat?.titleColor ?? '#FF3C3C3C'))),
]), ]),
), ),


@@ -69,7 +88,7 @@ class WechatTeachetItem extends StatelessWidget {
), ),
), ),
GestureDetector( GestureDetector(
onTap: ()=> _copyText(itemStyleModel?.wechatAccount),
onTap: () => _copyText(itemStyleModel?.wechatAccount),
child: UnconstrainedBox( child: UnconstrainedBox(
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -80,7 +99,9 @@ class WechatTeachetItem extends StatelessWidget {
padding: EdgeInsets.only(left: 9, right: 9, top: 4, bottom: 4), padding: EdgeInsets.only(left: 9, right: 9, top: 4, bottom: 4),
child: Text( child: Text(
styleModel?.bindTeacherDialog?.btnText ?? '复制去微信添加', styleModel?.bindTeacherDialog?.btnText ?? '复制去微信添加',
style: TextStyle(fontSize: 13, color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnTextColor ?? '#FF0000')),
style: TextStyle(
fontSize: 13,
color: HexColor.fromHex(styleModel?.bindTeacherDialog?.btnTextColor ?? '#FF0000')),
), ),
), ),
), ),
@@ -89,7 +110,7 @@ class WechatTeachetItem extends StatelessWidget {
), ),
), ),
GestureDetector( GestureDetector(
onLongPress: ()=> _longClickSaveImage(),
onLongPress: () => _longClickSaveImage(itemStyleModel?.qrcode),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Container( Container(
@@ -103,7 +124,8 @@ class WechatTeachetItem extends StatelessWidget {
), ),
Text( Text(
styleModel?.officalWxchat?.qrcodeText ?? '长按保存二维码', styleModel?.officalWxchat?.qrcodeText ?? '长按保存二维码',
style: TextStyle(fontSize: 13, color: HexColor.fromHex(styleModel?.officalWxchat?.qrcodeTextColor ?? '#999999')),
style: TextStyle(
fontSize: 13, color: HexColor.fromHex(styleModel?.officalWxchat?.qrcodeTextColor ?? '#999999')),
), ),
], ],
), ),


Loading…
Cancel
Save