更新
This commit is contained in:
@@ -2,7 +2,10 @@ import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:fluwx/fluwx.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/CheckNetwork.dart';
|
||||
import 'package:vbvs_app/common/util/CommonVariables.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
@@ -26,6 +29,58 @@ class _EPageState extends State<LoginPage> {
|
||||
LoginController loginController = Get.find();
|
||||
ThemeController themeController = Get.find();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
LoginController loginController = Get.find();
|
||||
Fluwx fluwx = loginController.fluwx;
|
||||
if (isiOS) {
|
||||
loginController.model.isIos = true;
|
||||
fluwx.isWeChatInstalled.then((isWeChatInstalled) {
|
||||
debugPrint('is wechat installed: $isWeChatInstalled');
|
||||
if (!isWeChatInstalled) {
|
||||
// TODO ios未安装微信 隐藏微信一键登录按钮
|
||||
loginController.model.isWeChatNotInstalled = false;
|
||||
} else {
|
||||
loginController.model.isWeChatNotInstalled = true;
|
||||
}
|
||||
loginController.updateAll();
|
||||
});
|
||||
}
|
||||
// 微信监听回调
|
||||
loginController.fluwxCancelable = fluwx.addSubscriber((response) async {
|
||||
if (response is WeChatAuthResponse) {
|
||||
debugPrint('state :${response.state} \n code:${response.code}');
|
||||
int errCode = response.errCode ?? -9999;
|
||||
if (errCode == 0) {
|
||||
// TODO 微信登录成功 传递code给后台 再操作逻辑
|
||||
String code = response.code ?? "";
|
||||
//把微信登录返回的code传给后台,剩下的事就交给后台处理
|
||||
//首次未注册的用户引导去手机号填写页面
|
||||
//已注册的用户直接跳转首页
|
||||
if (CommonVariables.isNetWorkOn == false) {
|
||||
showToast("网络未连接,请开启设备网络后重试");
|
||||
return;
|
||||
}
|
||||
String msg = await loginController.loginByWechatCode(code);
|
||||
if (msg.isEmpty) {
|
||||
// TODO 操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听
|
||||
loginController.fluwxCancelable?.cancel();
|
||||
// 登录成功移出网络检查监听
|
||||
Checknetwork.subscription?.cancel();
|
||||
Get.offAndToNamed("/mianPageBottomChange");
|
||||
}
|
||||
// TODO 操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听
|
||||
// fluwxCancelable?.cancel();
|
||||
} else if (errCode == -4) {
|
||||
showToast("用户拒绝授权");
|
||||
} else if (errCode == -2) {
|
||||
showToast("用户取消授权");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
@@ -186,9 +241,7 @@ class _EPageState extends State<LoginPage> {
|
||||
], // 渐变色是同一个色,也可以根据需要调整
|
||||
|
||||
child: Container(
|
||||
width:
|
||||
// MediaQuery.sizeOf(context).width * 0.66,
|
||||
bodysize.maxWidth,
|
||||
width: bodysize.maxWidth,
|
||||
height: MediaQuery.sizeOf(context).height *
|
||||
0.055,
|
||||
constraints: BoxConstraints(
|
||||
@@ -200,19 +253,24 @@ class _EPageState extends State<LoginPage> {
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'登录页.本机号码一键登录/注册'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
//todo 颜色
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
textAlign: TextAlign.center,
|
||||
'登录页.本机号码一键登录/注册'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
//todo 颜色
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(
|
||||
width: 17.rpx,
|
||||
@@ -241,6 +299,8 @@ class _EPageState extends State<LoginPage> {
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
@@ -433,43 +493,97 @@ class _EPageState extends State<LoginPage> {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: 91.rpx,
|
||||
height: 91.rpx,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/wechat.png",
|
||||
width: 30.rpx,
|
||||
height: 30.rpx,
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.white, // 背景色
|
||||
highlightColor: Colors.grey, // 点击水波纹颜色
|
||||
borderRadius: 999.rpx,
|
||||
padding: EdgeInsets.zero,
|
||||
// onTap: () {
|
||||
// TopSlideNotification.show(context,
|
||||
// text: "待开发功能".tr);
|
||||
// },
|
||||
onTap: () async {
|
||||
if (loginController.model.isIos == true &&
|
||||
loginController
|
||||
.model.isWeChatNotInstalled !=
|
||||
true) {
|
||||
} else {
|
||||
if (loginController
|
||||
.model.register_agree ==
|
||||
null ||
|
||||
loginController
|
||||
.model.register_agree !=
|
||||
true) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "登录页.未同意协议".tr,
|
||||
textColor:
|
||||
themeController.currentColor.sc9,
|
||||
);
|
||||
return;
|
||||
}
|
||||
await loginController
|
||||
.wxLoginSendAuth(context);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
width: 91.rpx,
|
||||
height: 91.rpx,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/wechat.png",
|
||||
width: 30.rpx,
|
||||
height: 30.rpx,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 91.rpx,
|
||||
height: 91.rpx,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/tel.png",
|
||||
width: 30.rpx,
|
||||
height: 30.rpx,
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
borderRadius: 999.rpx,
|
||||
padding: EdgeInsets.zero,
|
||||
onTap: () {
|
||||
TopSlideNotification.show(context,
|
||||
text: "待开发功能".tr);
|
||||
},
|
||||
child: Container(
|
||||
width: 91.rpx,
|
||||
height: 91.rpx,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/tel.png",
|
||||
width: 30.rpx,
|
||||
height: 30.rpx,
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: 91.rpx,
|
||||
height: 91.rpx,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/google.png",
|
||||
width: 30.rpx,
|
||||
height: 30.rpx,
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.white,
|
||||
highlightColor: Colors.grey,
|
||||
borderRadius: 999.rpx,
|
||||
padding: EdgeInsets.zero,
|
||||
onTap: () {
|
||||
TopSlideNotification.show(context,
|
||||
text: "待开发功能".tr);
|
||||
},
|
||||
child: Container(
|
||||
width: 91.rpx,
|
||||
height: 91.rpx,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Image.asset(
|
||||
"assets/img/google.png",
|
||||
width: 30.rpx,
|
||||
height: 30.rpx,
|
||||
),
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 35.rpx)),
|
||||
|
||||
Reference in New Issue
Block a user