Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 79d054ab
authored
2026-01-27 16:07:46 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
iOS中未安装微信App时,设置界面不显示"在线客服"
1 parent
5a44fc5c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
23 deletions
lib/bloc/setting/setting_cubit.dart
lib/ui/pages/setting/setting_page.dart
lib/bloc/setting/setting_cubit.dart
View file @
79d054a
...
@@ -11,21 +11,25 @@ import 'package:shared_preferences/shared_preferences.dart';
...
@@ -11,21 +11,25 @@ import 'package:shared_preferences/shared_preferences.dart';
class
SettingState
extends
Equatable
{
class
SettingState
extends
Equatable
{
final
String
h5Version
;
final
String
h5Version
;
final
bool
wechatInstalled
;
const
SettingState
({
const
SettingState
({
this
.
h5Version
=
''
,
this
.
h5Version
=
''
,
this
.
wechatInstalled
=
false
,
});
});
SettingState
copyWith
({
SettingState
copyWith
({
String
?
h5Version
,
String
?
h5Version
,
bool
?
wechatInstalled
,
})
{
})
{
return
SettingState
(
return
SettingState
(
h5Version:
h5Version
??
this
.
h5Version
,
h5Version:
h5Version
??
this
.
h5Version
,
wechatInstalled:
wechatInstalled
??
this
.
wechatInstalled
,
);
);
}
}
@override
@override
List
<
Object
?>
get
props
=>
[
h5Version
];
List
<
Object
?>
get
props
=>
[
h5Version
,
wechatInstalled
];
}
}
class
SettingCubit
extends
Cubit
<
SettingState
>
{
class
SettingCubit
extends
Cubit
<
SettingState
>
{
...
@@ -38,6 +42,7 @@ class SettingCubit extends Cubit<SettingState> {
...
@@ -38,6 +42,7 @@ class SettingCubit extends Cubit<SettingState> {
void
_init
()
{
void
_init
()
{
_readH5ShowVersion
();
_readH5ShowVersion
();
_checkWechat
();
}
}
void
_readH5ShowVersion
()
{
void
_readH5ShowVersion
()
{
...
@@ -45,6 +50,13 @@ class SettingCubit extends Cubit<SettingState> {
...
@@ -45,6 +50,13 @@ class SettingCubit extends Cubit<SettingState> {
emit
(
state
.
copyWith
(
h5Version:
h5Version
));
emit
(
state
.
copyWith
(
h5Version:
h5Version
));
}
}
// 微信安装检测
void
_checkWechat
()
{
_fluwx
.
isWeChatInstalled
.
then
((
value
)
{
emit
(
state
.
copyWith
(
wechatInstalled:
value
));
});
}
/// 跳转客服(微信小程序)
/// 跳转客服(微信小程序)
void
goCs
()
{
void
goCs
()
{
_fluwx
.
open
(
_fluwx
.
open
(
...
...
lib/ui/pages/setting/setting_page.dart
View file @
79d054a
import
'dart:io'
;
import
'package:appframe/bloc/setting/setting_cubit.dart'
;
import
'package:appframe/bloc/setting/setting_cubit.dart'
;
import
'package:appframe/config/constant.dart'
;
import
'package:appframe/config/constant.dart'
;
import
'package:appframe/config/env_config.dart'
;
import
'package:appframe/config/env_config.dart'
;
...
@@ -16,6 +18,33 @@ class SettingPage extends StatelessWidget {
...
@@ -16,6 +18,33 @@ class SettingPage extends StatelessWidget {
builder:
(
context
,
state
)
{
builder:
(
context
,
state
)
{
final
settingCubit
=
context
.
read
<
SettingCubit
>();
final
settingCubit
=
context
.
read
<
SettingCubit
>();
var
customerService
=
Platform
.
isAndroid
||
state
.
wechatInstalled
?
[
Card
(
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
16
,
vertical:
2
),
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
6
),
),
child:
Column
(
children:
[
ListTile
(
leading:
const
Icon
(
Icons
.
headset_mic
,
size:
20
),
title:
const
Text
(
'在线客服'
,
style:
TextStyle
(
fontSize:
14
)),
onTap:
()
{
settingCubit
.
goCs
();
},
contentPadding:
const
EdgeInsets
.
symmetric
(
horizontal:
16
,
vertical:
4
),
trailing:
const
Icon
(
Icons
.
arrow_forward_ios
,
size:
14
),
dense:
true
,
visualDensity:
VisualDensity
.
compact
,
),
],
),
),
const
SizedBox
(
height:
8
),
]
:
[];
return
Scaffold
(
return
Scaffold
(
appBar:
AppBar
(
appBar:
AppBar
(
title:
const
Text
(
'设置'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
)),
title:
const
Text
(
'设置'
,
style:
TextStyle
(
color:
Colors
.
white
,
fontSize:
18
)),
...
@@ -129,28 +158,7 @@ class SettingPage extends StatelessWidget {
...
@@ -129,28 +158,7 @@ class SettingPage extends StatelessWidget {
),
),
),
),
const
SizedBox
(
height:
8
),
const
SizedBox
(
height:
8
),
Card
(
...
customerService
,
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
16
,
vertical:
2
),
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
circular
(
6
),
),
child:
Column
(
children:
[
ListTile
(
leading:
const
Icon
(
Icons
.
headset_mic
,
size:
20
),
title:
const
Text
(
'在线客服'
,
style:
TextStyle
(
fontSize:
14
)),
onTap:
()
{
settingCubit
.
goCs
();
},
contentPadding:
const
EdgeInsets
.
symmetric
(
horizontal:
16
,
vertical:
4
),
trailing:
const
Icon
(
Icons
.
arrow_forward_ios
,
size:
14
),
dense:
true
,
visualDensity:
VisualDensity
.
compact
,
),
],
),
),
const
SizedBox
(
height:
8
),
Card
(
Card
(
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
16
,
vertical:
2
),
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
16
,
vertical:
2
),
shape:
RoundedRectangleBorder
(
shape:
RoundedRectangleBorder
(
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment