Commit 53a63e393e1acae796c1cdef64962a3acf3d7eb4

Authored by wdn127929
1 parent b646ef31

登录页

6.2 KB | W: | H:

1023 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin

932 Bytes | W: | H:

625 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin

2.1 KB | W: | H:

606 Bytes | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -502,7 +502,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 3.3.8;
MARKETING_VERSION = 3.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
PRODUCT_NAME = Runner;
PROVISIONING_PROFILE_SPECIFIER = "";
... ... @@ -635,7 +635,7 @@
CURRENT_PROJECT_VERSION = 325;
DEVELOPMENT_TEAM = 8J59HM8B82;
ENABLE_BITCODE = NO;
FLUTTER_BUILD_MODE = release;
FLUTTER_BUILD_MODE = debug;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
... ... @@ -647,7 +647,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 3.3.8;
MARKETING_VERSION = 3.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
PRODUCT_NAME = Runner;
PROVISIONING_PROFILE_SPECIFIER = "";
... ... @@ -682,7 +682,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 3.3.8;
MARKETING_VERSION = 3.4.0;
PRODUCT_BUNDLE_IDENTIFIER = com.naji.reserveLine;
PRODUCT_NAME = Runner;
PROVISIONING_PROFILE_SPECIFIER = "";
... ...
... ... @@ -14,6 +14,7 @@ import 'package:fluwx/fluwx.dart';
import 'package:one_key/pages/detail/handle_online_page.dart';
import 'package:one_key/pages/home/home_page.dart';
import 'package:one_key/pages/login/first_page.dart';
import 'package:one_key/pages/login/login_page_f.dart';
import 'package:one_key/provider/base_info_provider.dart';
import 'package:one_key/provider/coupon_provider.dart';
import 'package:one_key/provider/create_store_model.dart';
... ...
... ... @@ -109,29 +109,31 @@ class HomePageState extends State<HomePage> with WidgetsBindingObserver {
List<PullMarketingByUidSunModel> data =
Provider.of<UserModel>(context, listen: false)
.pullMarketingByUidSunModel;
if (data != null && data.length > 0) {
Future.delayed(Duration(milliseconds: 300), () {
DialogUtil.cupertinoAlertDialog(context,
title: "全店任务",
content: "管理员发布了新的任务,请立即查看并完成任务",
lTitle: "稍后提醒",
rTitle: "立即查看", lCallback: () {
print("稍后提醒");
// 30分钟后重新弹窗
_startTimerSeller();
}, rCallback: () {
_endTimerSeller();
if (data.length == 1) {
//进入营销详情
NavigatorUtil.goSellerMyMarketingRecordsDetailPage(
context, data[0].mid,
fromNotify: true);
} else {
//进入我的客情首页
NavigatorUtil.goMyCustomerPage(context);
}
if (data != null) {
if (data.length > 0) {
Future.delayed(Duration(milliseconds: 300), () {
DialogUtil.cupertinoAlertDialog(context,
title: "全店任务",
content: "管理员发布了新的任务,请立即查看并完成任务",
lTitle: "稍后提醒",
rTitle: "立即查看", lCallback: () {
print("稍后提醒");
// 30分钟后重新弹窗
_startTimerSeller();
}, rCallback: () {
_endTimerSeller();
if (data.length == 1) {
//进入营销详情
NavigatorUtil.goSellerMyMarketingRecordsDetailPage(
context, data[0].mid,
fromNotify: true);
} else {
//进入我的客情首页
NavigatorUtil.goMyCustomerPage(context);
}
});
});
});
}
}
if (widget.initialIndex == 0) return;
_getIntent();
... ...
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:common_utils/common_utils.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluwx/fluwx.dart' as fluwx;
import 'package:fluwx/fluwx.dart';
import 'package:one_key/app.dart';
import 'package:one_key/models/checkbind_phone_model.dart';
import 'package:one_key/models/store_info.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/provider/create_store_model.dart';
import 'package:one_key/provider/other_login_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigate_service.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/loading.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
class AccountLoginPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new AccountLoginPageState();
}
}
class AccountLoginPageState extends State<AccountLoginPage>
with WidgetsBindingObserver {
TextEditingController _sellerCodeController = TextEditingController();
TextEditingController _accountController = TextEditingController();
final TextEditingController _pwdController = TextEditingController();
final ScrollController _scrollController = new ScrollController();
final FocusNode _sellerCodeFocusNode = new FocusNode();
final FocusNode _accountFocusNode = new FocusNode();
final FocusNode _pwdFocusNode = new FocusNode();
bool isActivate = false; //是否激活登录
StreamSubscription<BaseWeChatResponse> streamSubscription;
OtherLoginProvider otherLoginProvider;
CreateStoreModel createStoreModel;
@override
void initState() {
// TODO: implement initState
super.initState();
WidgetsBinding.instance.addObserver(this);
WidgetsBinding.instance.addPostFrameCallback((_) {
final UserModel userModel =
Provider.of<UserModel>(context, listen: false);
if (userModel != null && userModel.user != null) {
Future.delayed(Duration(milliseconds: 50), () {
_sellerCodeController.text = userModel.user.sellercode;
_accountController.text = userModel.user.account;
// FocusScope.of(context).requestFocus(_pwdFocusNode);
});
}
});
}
//当页面离开时要清除监听器
@override
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
if (streamSubscription != null) {
streamSubscription.cancel();
}
}
//监听输入框,设置登录按钮状态
setActivate() {
if (_sellerCodeController.text.isNotEmpty &&
_accountController.text.isNotEmpty &&
_pwdController.text.isNotEmpty) {
setState(() {
isActivate = true;
});
} else {
setState(() {
isActivate = false;
});
}
}
_showLoading(BuildContext context) {
showGeneralDialog(
context: context,
barrierDismissible: false,
barrierLabel:
MaterialLocalizations.of(context).modalBarrierDismissLabel,
transitionDuration: const Duration(milliseconds: 150),
pageBuilder: (BuildContext context, Animation animation,
Animation secondaryAnimation) {
return Align(
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Container(
width: 80,
height: 80,
child: CupertinoActivityIndicator(),
),
),
);
}).then((v) {});
}
@override
Widget build(BuildContext context) {
otherLoginProvider =
Provider.of<OtherLoginProvider>(context, listen: false);
createStoreModel = Provider.of<CreateStoreModel>(context, listen: false);
final double prefixIconWidth = ScreenUtil().setWidth(24);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
appBar: SystemAppBar(
'',
onTap: () {
Navigator.pop(context);
},
),
body: Container(
width: double.infinity,
height: double.infinity,
padding: EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(40)),
child: SingleChildScrollView(
controller: _scrollController,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
VEmptyView(30),
Row(
children: [
Image.asset(
"assets/logo.png",
width: ScreenUtil().setWidth(20 * 2),
height: ScreenUtil().setWidth(20 * 2),
),
HEmptyView(16),
Text(
'账号密码登录',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(32)),
)
],
),
VEmptyView(60),
Text(
'输入商户编号',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(26)),
),
Container(
height: ScreenUtil().setWidth(84),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: MyColours.color_efefef,
width: ScreenUtil().setWidth(2))),
),
child: TextField(
controller: _sellerCodeController,
focusNode: _sellerCodeFocusNode,
// autofocus: _sellerCodeController.text.isEmpty,
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(28),
),
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
hintText: "例:001698",
hintStyle: TextStyle(
color: MyColours.color_c1c1c1,
fontSize: ScreenUtil().setSp(28),
),
border: InputBorder.none,
contentPadding: EdgeInsets.only(bottom: -5),
),
onChanged: (_) {
setActivate();
},
keyboardType: TextInputType.number,
)),
VEmptyView(40),
Text(
'输入员工号',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(26)),
),
Container(
height: ScreenUtil().setWidth(84),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: MyColours.color_efefef,
width: ScreenUtil().setWidth(2))),
),
child: TextField(
controller: _accountController,
focusNode: _accountFocusNode,
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(28)),
decoration: InputDecoration(
hintText: "例:0001",
hintStyle: TextStyle(
color: MyColours.color_c1c1c1,
fontSize: ScreenUtil().setSp(28)),
border: InputBorder.none,
contentPadding: EdgeInsets.only(bottom: -5),
),
onChanged: (_) {
setActivate();
},
keyboardType: TextInputType.number,
)),
VEmptyView(40),
Text(
'输入员工密码',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(26)),
),
Container(
height: ScreenUtil().setWidth(84),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: MyColours.color_efefef,
width: ScreenUtil().setWidth(2))),
),
child: TextField(
controller: _pwdController,
focusNode: _pwdFocusNode,
// autofocus: _sellerCodeController.text.isNotEmpty &&
// _accountController.text.isNotEmpty &&
// _pwdController.text.isEmpty,
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(28)),
decoration: InputDecoration(
hintText: "请输入六位员工密码",
hintStyle: TextStyle(
color: MyColours.color_c1c1c1,
fontSize: ScreenUtil().setSp(28)),
border: InputBorder.none,
contentPadding: EdgeInsets.only(bottom: -5),
),
onChanged: (_) {
setActivate();
},
obscureText: true,
keyboardType: TextInputType.text,
)),
VEmptyView(40),
Consumer<UserModel>(
builder:
(BuildContext context, UserModel value, Widget child) {
return GestureDetector(
onTap: () {
if (!isActivate) return;
if (App.sp.containsKey('unionid')) {
//微信登陆的时候,退出清空数据
App.sp.remove('openid');
App.sp.remove("unionid");
}
Map<String, String> params = {
"seller_code": "${_sellerCodeController.text}",
"alias": "ssahdahgdafgahjkhakjgh",
"account": "${_accountController.text}",
"password": "${_pwdController.text}"
};
value
.login(context, params, acclogin: true)
.then((value) {});
},
child: Center(
child: Container(
height: ScreenUtil().setWidth(84),
width: ScreenUtil().setWidth(350),
alignment: Alignment.center,
decoration: BoxDecoration(
color: isActivate
? MyColours.color_41444B
: MyColours.color_F7F7F7,
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(8)))),
child: Text(
"登录",
style: TextStyle(
color: isActivate
? MyColours.color_ffffff
: MyColours.color_C9C9C9,
fontSize: ScreenUtil().setSp(34)),
),
)));
},
),
],
),
),
));
}
}
... ...
... ... @@ -98,6 +98,7 @@ class _IfNeedCreateStoreState extends State<IfNeedCreateStore>
///进入某个店铺
_loginStore(context, CheckSellerAccSunModel sunModel) {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
userModel.accountLogin = false;
Map<String, dynamic> seller = sunModel.toJson();
Map<String, dynamic> userMap = {
"openid": seller['uid'],
... ... @@ -308,6 +309,7 @@ class _IfNeedCreateStoreState extends State<IfNeedCreateStore>
}
return InkWell(
onTap: () async {
if (widget.changeStatus) {
UserModel userModel =
Provider.of<UserModel>(context,
listen: false);
... ... @@ -321,6 +323,10 @@ class _IfNeedCreateStoreState extends State<IfNeedCreateStore>
_loginStore(
context, model.sellerList[index]);
}
} else {
_loginStore(
context, model.sellerList[index]);
}
},
child: IfNeedCreateStoreItem(
model: model.sellerList[index]),
... ...
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:common_utils/common_utils.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluwx/fluwx.dart' as fluwx;
import 'package:fluwx/fluwx.dart';
import 'package:one_key/app.dart';
import 'package:one_key/models/checkbind_phone_model.dart';
import 'package:one_key/models/store_info.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/provider/create_store_model.dart';
import 'package:one_key/provider/other_login_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigate_service.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/loading.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
class LoginPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new LoginState();
}
}
class LoginState extends State<LoginPage> with WidgetsBindingObserver {
TextEditingController _sellerCodeController = TextEditingController();
TextEditingController _accountController = TextEditingController();
final TextEditingController _pwdController = TextEditingController();
final ScrollController _scrollController = new ScrollController();
final FocusNode _sellerCodeFocusNode = new FocusNode();
final FocusNode _accountFocusNode = new FocusNode();
final FocusNode _pwdFocusNode = new FocusNode();
bool obscureText = true; //是否隐藏密码
bool isActivate = false; //是否激活登录
String errorText = ""; //错误提示
bool _check = false;
StreamSubscription<BaseWeChatResponse> streamSubscription;
OtherLoginProvider otherLoginProvider;
CreateStoreModel createStoreModel;
@override
void initState() {
// TODO: implement initState
super.initState();
//第一次打开应用
// import 'dart:async';
// import 'dart:convert';
// import 'dart:io';
// import 'package:common_utils/common_utils.dart';
// import 'package:dio/dio.dart';
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart';
// import 'package:flutter_screenutil/flutter_screenutil.dart';
// import 'package:fluwx/fluwx.dart' as fluwx;
// import 'package:fluwx/fluwx.dart';
// import 'package:one_key/app.dart';
// import 'package:one_key/models/checkbind_phone_model.dart';
// import 'package:one_key/models/store_info.dart';
// import 'package:one_key/net/dio_util.dart';
// import 'package:one_key/provider/create_store_model.dart';
// import 'package:one_key/provider/other_login_provider.dart';
// import 'package:one_key/provider/user_model.dart';
// import 'package:one_key/res/colors.dart';
// import 'package:one_key/route/navigate_service.dart';
// import 'package:one_key/route/navigator_util.dart';
// import 'package:one_key/utils/dialog_util.dart';
// import 'package:one_key/utils/utils.dart';
// import 'package:one_key/widgets/MyDivider.dart';
// import 'package:one_key/widgets/h_empty_view.dart';
// import 'package:one_key/widgets/loading.dart';
// import 'package:one_key/widgets/round_button.dart';
// import 'package:one_key/widgets/v_empty_view.dart';
// import 'package:provider/provider.dart';
// import 'package:sign_in_with_apple/sign_in_with_apple.dart';
// class LoginPage extends StatefulWidget {
// @override
// State<StatefulWidget> createState() {
// // TODO: implement createState
// return new LoginState();
// }
// }
// class LoginState extends State<LoginPage> with WidgetsBindingObserver {
// TextEditingController _sellerCodeController = TextEditingController();
// TextEditingController _accountController = TextEditingController();
// final TextEditingController _pwdController = TextEditingController();
// final ScrollController _scrollController = new ScrollController();
// final FocusNode _sellerCodeFocusNode = new FocusNode();
// final FocusNode _accountFocusNode = new FocusNode();
// final FocusNode _pwdFocusNode = new FocusNode();
// bool obscureText = true; //是否隐藏密码
// bool isActivate = false; //是否激活登录
// String errorText = ""; //错误提示
// bool _check = false;
// StreamSubscription<BaseWeChatResponse> streamSubscription;
// OtherLoginProvider otherLoginProvider;
// CreateStoreModel createStoreModel;
// @override
// void initState() {
// // TODO: implement initState
// super.initState();
// //第一次打开应用
_checkWechat();
isLogin();
WidgetsBinding.instance.addObserver(this);
WidgetsBinding.instance.addPostFrameCallback((_) {
final UserModel userModel =
Provider.of<UserModel>(context, listen: false);
if (userModel != null && userModel.user != null) {
Future.delayed(Duration(milliseconds: 50), () {
_sellerCodeController.text = userModel.user.sellercode;
_accountController.text = userModel.user.account;
// FocusScope.of(context).requestFocus(_pwdFocusNode);
});
}
});
}
//当页面离开时要清除监听器
@override
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
if (streamSubscription != null) {
streamSubscription.cancel();
}
}
//微信是否安装
_checkWechat() async {
// await registerWxApi(
// appId: "wx85aa3cdd0f791e65",
// doOnAndroid: true,
// doOnIOS: true,
// universalLink: "https://xt04.colorcun.com/link/OneKey/");
var result = await isWeChatInstalled;
if (result != null && result) {
App.isInstallWx = true;
} else {
App.isInstallWx = false;
}
setState(() {});
LogUtil.v("is installed $result");
}
handlePostFrame(_) {
// _scrollController.jumpTo(_scrollController.position.maxScrollExtent);
}
@override
void didChangeMetrics() {
// TODO: implement didChangeMetrics
WidgetsBinding.instance.addPostFrameCallback(handlePostFrame);
super.didChangeDependencies();
}
//监听输入框,设置登录按钮状态
setActivate() {
if (_sellerCodeController.text.isNotEmpty &&
_accountController.text.isNotEmpty &&
_pwdController.text.isNotEmpty) {
setState(() {
errorText = "";
isActivate = true;
});
} else {
setState(() {
errorText = "";
isActivate = false;
});
}
}
//判断是否登录
void isLogin() async {
await App.initSp();
UserModel userModel = Provider.of<UserModel>(context, listen: false);
userModel.initUser();
if (App.sp.getBool("isLogin") ?? false) {
Future.delayed(Duration(milliseconds: 200), () {
NavigatorUtil.goHomePage(context);
});
} else {
_getWxCode();
}
}
///微信登陆
_wxLogin() {
sendWeChatAuth(scope: "snsapi_userinfo");
}
///获取微信登录code
_getWxCode() {
streamSubscription = fluwx.weChatResponseEventHandler
.distinct((a, b) => a == b)
.listen((res) {
if (res is fluwx.WeChatAuthResponse && res.errCode == 0) {
LogUtil.v("code:" + res.code);
// Loading.showLoading(context);
_getAccessToken(res.code);
} else {
// Utils.showToast(res.errStr??"登录失败,请稍后重试");
}
});
}
///获取微信登录access_token
_getAccessToken(String code) async {
Response response = await DioUtil.getInstance().getDio().get(
"https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx85aa3cdd0f791e65&secret=87c9a23c2e6032b2da75af6b0efc5424&code=$code&grant_type=authorization_code");
LogUtil.v("access_token:${response.toString()}");
Map<String, dynamic> responseData = json.decode(response.data.toString());
if (responseData["errcode"] != null) {
Utils.showToast(responseData["errmsg"] ?? "登录失败,请稍后重试");
// Loading.hideLoading(context);
} else {
App.sp.setString("openid", responseData["openid"]);
App.sp.setString("unionid", responseData["unionid"]);
//跳转至手机号绑定页面
//判断是否已经绑定手机号码 ******调用接口*******
//有,通过手机号吗或者opened查找店铺信息进行登陆
//没有,跳转至绑定手机号码页面
// Map<String, String> params = {
// "unionid": responseData["unionid"],
// };
// BuildContext contextTemp =
// App.getIt<NavigateService>().key.currentState.overlay.context;
// CheckbindPhoneSunModel model =
// await otherLoginProvider.checkbindPhone(contextTemp, params);
// // Loading.hideLoading(context);
// if (model != null) {
// createStoreModel.storeInfo = StoreInfo();
// createStoreModel.storeInfo.phone = model.phone;
createStoreModel.storeInfo = StoreInfo();
NavigatorUtil.goIfNeedCreateStorePage(context);
// } else {
// NavigatorUtil.goBindingPhonePage(context);
// }
// _getUserInfo(responseData["access_token"], responseData["openid"]);
}
}
// //获取用户信息
// _getUserInfo(String access_token, String openid) async {
// _checkWechat();
// isLogin();
// WidgetsBinding.instance.addObserver(this);
// WidgetsBinding.instance.addPostFrameCallback((_) {
// final UserModel userModel =
// Provider.of<UserModel>(context, listen: false);
// if (userModel != null && userModel.user != null) {
// Future.delayed(Duration(milliseconds: 50), () {
// _sellerCodeController.text = userModel.user.sellercode;
// _accountController.text = userModel.user.account;
// // FocusScope.of(context).requestFocus(_pwdFocusNode);
// });
// }
// });
// }
// //当页面离开时要清除监听器
// @override
// void dispose() {
// super.dispose();
// WidgetsBinding.instance.removeObserver(this);
// if (streamSubscription != null) {
// streamSubscription.cancel();
// }
// }
// //微信是否安装
// _checkWechat() async {
// // await registerWxApi(
// // appId: "wx85aa3cdd0f791e65",
// // doOnAndroid: true,
// // doOnIOS: true,
// // universalLink: "https://xt04.colorcun.com/link/OneKey/");
// var result = await isWeChatInstalled;
// if (result != null && result) {
// App.isInstallWx = true;
// } else {
// App.isInstallWx = false;
// }
// setState(() {});
// LogUtil.v("is installed $result");
// }
// handlePostFrame(_) {
// // _scrollController.jumpTo(_scrollController.position.maxScrollExtent);
// }
// @override
// void didChangeMetrics() {
// // TODO: implement didChangeMetrics
// WidgetsBinding.instance.addPostFrameCallback(handlePostFrame);
// super.didChangeDependencies();
// }
// //监听输入框,设置登录按钮状态
// setActivate() {
// if (_sellerCodeController.text.isNotEmpty &&
// _accountController.text.isNotEmpty &&
// _pwdController.text.isNotEmpty) {
// setState(() {
// errorText = "";
// isActivate = true;
// });
// } else {
// setState(() {
// errorText = "";
// isActivate = false;
// });
// }
// }
// //判断是否登录
// void isLogin() async {
// await App.initSp();
// UserModel userModel = Provider.of<UserModel>(context, listen: false);
// userModel.initUser();
// if (App.sp.getBool("isLogin") ?? false) {
// Future.delayed(Duration(milliseconds: 200), () {
// NavigatorUtil.goHomePage(context);
// });
// } else {
// _getWxCode();
// }
// }
// ///微信登陆
// _wxLogin() {
// sendWeChatAuth(scope: "snsapi_userinfo");
// }
// ///获取微信登录code
// _getWxCode() {
// streamSubscription = fluwx.weChatResponseEventHandler
// .distinct((a, b) => a == b)
// .listen((res) {
// if (res is fluwx.WeChatAuthResponse && res.errCode == 0) {
// LogUtil.v("code:" + res.code);
// // Loading.showLoading(context);
// _getAccessToken(res.code);
// } else {
// // Utils.showToast(res.errStr??"登录失败,请稍后重试");
// }
// });
// }
// ///获取微信登录access_token
// _getAccessToken(String code) async {
// Response response = await DioUtil.getInstance().getDio().get(
// "https://api.weixin.qq.com/sns/userinfo?access_token=$access_token&openid=$openid");
// LogUtil.v('userinfo:' + response.data);
// "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx85aa3cdd0f791e65&secret=87c9a23c2e6032b2da75af6b0efc5424&code=$code&grant_type=authorization_code");
// LogUtil.v("access_token:${response.toString()}");
// Map<String, dynamic> responseData = json.decode(response.data.toString());
// if (responseData["errcode"] != null) {
// // Utils.showToast(responseData["errmsg"]??"登录,请稍后重试");
// Utils.showToast(responseData["errmsg"] ?? "登录失败,请稍后重试");
// // Loading.hideLoading(context);
// } else {
// App.sp.setString("nickName", responseData["nickname"]);
// App.sp.setString("headImg", responseData["headimgurl"]);
// App.sp.setString("openid", responseData["openid"]);
// App.sp.setString("unionid", responseData["unionid"]);
// App.sp.setBool("isLogin", true);
// // _fromTypeGo();
// String unionId = App.sp.getString("unionid");
// _getMiniOpenid(unionId);
// //跳转至手机号绑定页面
// //判断是否已经绑定手机号码 ******调用接口*******
// //有,通过手机号吗或者opened查找店铺信息进行登陆
// //没有,跳转至绑定手机号码页面
// // Map<String, String> params = {
// // "unionid": responseData["unionid"],
// // };
// // BuildContext contextTemp =
// // App.getIt<NavigateService>().key.currentState.overlay.context;
// // CheckbindPhoneSunModel model =
// // await otherLoginProvider.checkbindPhone(contextTemp, params);
// // // Loading.hideLoading(context);
// // if (model != null) {
// // createStoreModel.storeInfo = StoreInfo();
// // createStoreModel.storeInfo.phone = model.phone;
// createStoreModel.storeInfo = StoreInfo();
// NavigatorUtil.goIfNeedCreateStorePage(context);
// // } else {
// // NavigatorUtil.goBindingPhonePage(context);
// // }
// // _getUserInfo(responseData["access_token"], responseData["openid"]);
// }
// }
// // //获取用户信息
// // _getUserInfo(String access_token, String openid) async {
// // Response response = await DioUtil.getInstance().getDio().get(
// // "https://api.weixin.qq.com/sns/userinfo?access_token=$access_token&openid=$openid");
// // LogUtil.v('userinfo:' + response.data);
// // Map<String, dynamic> responseData = json.decode(response.data.toString());
// // if (responseData["errcode"] != null) {
// // // Utils.showToast(responseData["errmsg"]??"登录,请稍后重试");
// // } else {
// // App.sp.setString("nickName", responseData["nickname"]);
// // App.sp.setString("headImg", responseData["headimgurl"]);
// // App.sp.setString("unionid", responseData["unionid"]);
// // App.sp.setBool("isLogin", true);
// // // _fromTypeGo();
// // String unionId = App.sp.getString("unionid");
// // _getMiniOpenid(unionId);
// // }
// // }
// // //获取绑定小程序openid
// // _getMiniOpenid(String unionId) async {
// // UserModel userInfoProvider = UserModel();
// // // Provider.of<UserInfoProvider>(context, listen: false);
// // Map<String, String> params = {"unionid": unionId};
// // String miniOpenid =
// // await userInfoProvider.getMiniProgramOpenid(context, params);
// // if (miniOpenid == null) {
// // goMiniProgramMd(unionId);
// // }
// // }
// /*
// 苹果登录获取用户信息
// */
// _getUserInfoIOS() async {
// // Map<String, String> params = {"openid": App.sp.getString("openid")};
// // UserInfoProvider userInfoProvider =
// // Provider.of<UserInfoProvider>(context, listen: false);
// // UseInfoItemModel useInfoItemModel =
// // await userInfoProvider.getUserInfo(context, params);
// // if (ObjectUtil.isNotEmpty(useInfoItemModel.openid)) {
// // _hideLoading(context);
// // App.sp.setString("nickName", useInfoItemModel.nickname);
// // App.sp.setString("headImg", '');
// // App.sp.setString("unionid", '');
// // App.sp.setBool("isLogin", true);
// // UserInfoProvider userInfoProvider = new UserInfoProvider();
// // userInfoProvider.initPlatformState(context);
// // // Loading.hideLoading(context);
// // _fromTypeGo();
// // } else {
// // // 已经授权,但是后台库里没有数据,版本差异,重新插入数据库
// // Map param = {
// // 'openid': App.sp.getString("openid"),
// // 'avatar': 'ios_avatar',
// // 'nickname': '',
// // 'gender': '1'
// // };
// // LoginRespository().appleLogin(context, param, () {
// // _getUserInfoIOS();
// // });
// // }
// }
// _showLoading(BuildContext context) {
// showGeneralDialog(
// context: context,
// barrierDismissible: false,
// barrierLabel:
// MaterialLocalizations.of(context).modalBarrierDismissLabel,
// transitionDuration: const Duration(milliseconds: 150),
// pageBuilder: (BuildContext context, Animation animation,
// Animation secondaryAnimation) {
// return Align(
// child: ClipRRect(
// borderRadius: BorderRadius.circular(10),
// child: Container(
// width: 80,
// height: 80,
// child: CupertinoActivityIndicator(),
// ),
// ),
// );
// }).then((v) {});
// }
// ///苹果登陆
// _iosLogin(UserModel value) async {
// String info = await Utils.getDeviceInfoSystem();
// int systemInfo = info.compareTo('13');
// if (systemInfo < 0) {
// Utils.showToast('该系统版本不支持苹果登录');
// return;
// }
// final credential = await SignInWithApple.getAppleIDCredential(
// scopes: [
// AppleIDAuthorizationScopes.email,
// AppleIDAuthorizationScopes.fullName,
// ],
// webAuthenticationOptions: WebAuthenticationOptions(
// // TODO: Set the `clientId` and `redirectUri` arguments to the values you entered in the Apple Developer portal during the setup
// clientId: 'com.naji.reserveLine',
// redirectUri: Uri.parse(
// 'https://flutter-sign-in-with-apple-example.glitch.me/callbacks/sign_in_with_apple',
// ),
// ),
// );
// // _showLoading(context);
// // print(credential.userIdentifier);
// _loginAppleData(value);
// // NavigatorUtil.goBindingPhonePage(context, wechat: false);
// // String mdString = Utils.generateMd5(credential.userIdentifier);
// // String temp = mdString.substring(8, mdString.length - 2);
// // String openid = 'IOSID_$temp';
// // App.sp.setString("openid", openid);
// // App.sp.setString("unionid", '');
// // print(openid.length);
// // 第一次授权
// // if (ObjectUtil.isNotEmpty(credential.familyName)) {
// // Map param = {
// // 'openid': openid,
// // 'avatar': 'ios_avatar',
// // 'nickname': '${credential.familyName}${credential.givenName}',
// // 'gender': '1'
// // };
// // LoginRespository().appleLogin(context, param, () {
// // _getUserInfoIOS();
// // });
// // } else {
// // if (ObjectUtil.isNotEmpty(App.sp.getString("newUserMsg"))) {
// // Map newUserMsg = jsonDecode(App.sp.getString("newUserMsg"));
// // //上次失败了,这次重新传
// // LoginRespository().appleLogin(context, newUserMsg, () {
// // _getUserInfoIOS();
// // });
// // } else {
// // _getUserInfoIOS();
// // }
// // }
// }
// //获取绑定小程序openid
// _getMiniOpenid(String unionId) async {
// UserModel userInfoProvider = UserModel();
// // Provider.of<UserInfoProvider>(context, listen: false);
// Map<String, String> params = {"unionid": unionId};
// String miniOpenid =
// await userInfoProvider.getMiniProgramOpenid(context, params);
// if (miniOpenid == null) {
// goMiniProgramMd(unionId);
// _loginAppleData(UserModel value) {
// if (App.sp.containsKey('unionid')) {
// //微信登陆的时候,退出清空数据
// App.sp.remove('openid');
// App.sp.remove("unionid");
// }
// Map<String, String> params = {
// "seller_code": "001297",
// "alias": "ssahdahgdafgahjkhakjgh",
// "account": "0001",
// "password": "123456"
// };
// value.login(context, params).then((value) {
// // setState(() {
// // // errorText = value ?? "";
// // });
// });
// }
/*
苹果登录获取用户信息
*/
_getUserInfoIOS() async {
// Map<String, String> params = {"openid": App.sp.getString("openid")};
// UserInfoProvider userInfoProvider =
// Provider.of<UserInfoProvider>(context, listen: false);
// UseInfoItemModel useInfoItemModel =
// await userInfoProvider.getUserInfo(context, params);
// if (ObjectUtil.isNotEmpty(useInfoItemModel.openid)) {
// _hideLoading(context);
// App.sp.setString("nickName", useInfoItemModel.nickname);
// App.sp.setString("headImg", '');
// App.sp.setString("unionid", '');
// App.sp.setBool("isLogin", true);
// UserInfoProvider userInfoProvider = new UserInfoProvider();
// userInfoProvider.initPlatformState(context);
// // Loading.hideLoading(context);
// _fromTypeGo();
// } else {
// // 已经授权,但是后台库里没有数据,版本差异,重新插入数据库
// Map param = {
// 'openid': App.sp.getString("openid"),
// 'avatar': 'ios_avatar',
// 'nickname': '',
// 'gender': '1'
// };
// LoginRespository().appleLogin(context, param, () {
// _getUserInfoIOS();
// });
// }
}
_showLoading(BuildContext context) {
showGeneralDialog(
context: context,
barrierDismissible: false,
barrierLabel:
MaterialLocalizations.of(context).modalBarrierDismissLabel,
transitionDuration: const Duration(milliseconds: 150),
pageBuilder: (BuildContext context, Animation animation,
Animation secondaryAnimation) {
return Align(
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Container(
width: 80,
height: 80,
child: CupertinoActivityIndicator(),
),
),
);
}).then((v) {});
}
///苹果登陆
_iosLogin(UserModel value) async {
String info = await Utils.getDeviceInfoSystem();
int systemInfo = info.compareTo('13');
if (systemInfo < 0) {
Utils.showToast('该系统版本不支持苹果登录');
return;
}
final credential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
webAuthenticationOptions: WebAuthenticationOptions(
// TODO: Set the `clientId` and `redirectUri` arguments to the values you entered in the Apple Developer portal during the setup
clientId: 'com.naji.reserveLine',
redirectUri: Uri.parse(
'https://flutter-sign-in-with-apple-example.glitch.me/callbacks/sign_in_with_apple',
),
),
);
// _showLoading(context);
// print(credential.userIdentifier);
_loginAppleData(value);
// NavigatorUtil.goBindingPhonePage(context, wechat: false);
// String mdString = Utils.generateMd5(credential.userIdentifier);
// String temp = mdString.substring(8, mdString.length - 2);
// String openid = 'IOSID_$temp';
// App.sp.setString("openid", openid);
// App.sp.setString("unionid", '');
// print(openid.length);
// 第一次授权
// if (ObjectUtil.isNotEmpty(credential.familyName)) {
// Map param = {
// 'openid': openid,
// 'avatar': 'ios_avatar',
// 'nickname': '${credential.familyName}${credential.givenName}',
// 'gender': '1'
// };
// LoginRespository().appleLogin(context, param, () {
// _getUserInfoIOS();
// });
// } else {
// if (ObjectUtil.isNotEmpty(App.sp.getString("newUserMsg"))) {
// Map newUserMsg = jsonDecode(App.sp.getString("newUserMsg"));
// //上次失败了,这次重新传
// LoginRespository().appleLogin(context, newUserMsg, () {
// _getUserInfoIOS();
// });
// } else {
// _getUserInfoIOS();
// }
// }
}
_loginAppleData(UserModel value) {
if (App.sp.containsKey('unionid')) {
//微信登陆的时候,退出清空数据
App.sp.remove('openid');
App.sp.remove("unionid");
}
Map<String, String> params = {
"seller_code": "001297",
"alias": "ssahdahgdafgahjkhakjgh",
"account": "0001",
"password": "123456"
};
value.login(context, params).then((value) {
// setState(() {
// // errorText = value ?? "";
// });
});
}
@override
Widget build(BuildContext context) {
ScreenUtil.init(context, width: 750, height: 1334);
otherLoginProvider =
Provider.of<OtherLoginProvider>(context, listen: false);
createStoreModel = Provider.of<CreateStoreModel>(context, listen: false);
final Size size = MediaQuery.of(context).size;
App.screenWidth = size.width;
App.screenHeight = size.height;
App.statusBarHeight = MediaQuery.of(context).padding.top;
App.bottomBarHeight = MediaQuery.of(context).padding.bottom;
final double prefixIconWidth = ScreenUtil().setWidth(24);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
body: Container(
width: double.infinity,
height: double.infinity,
child: SingleChildScrollView(
controller: _scrollController,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
// VEmptyView(218 - App.statusBarHeight),
VEmptyView(80 + App.statusBarHeight),
Image.asset(
"assets/logo.png",
width: ScreenUtil().setWidth(74 * 2),
height: ScreenUtil().setWidth(71 * 2),
),
VEmptyView(80),
Container(
height: ScreenUtil().setHeight(84),
width: ScreenUtil().setWidth(611),
padding: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_bff6f7,
width: ScreenUtil().setWidth(2)),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(8))),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Image.asset(
"assets/icon_sellercode.png",
width: prefixIconWidth,
),
HEmptyView(26),
Center(
child: Text(
"商户编号",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(28)),
)),
Expanded(
child: Container(
height: ScreenUtil().setHeight(84),
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(20),
right: ScreenUtil().setWidth(20),
top: ScreenUtil().setWidth(8)),
child: TextField(
controller: _sellerCodeController,
focusNode: _sellerCodeFocusNode,
// autofocus: _sellerCodeController.text.isEmpty,
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(28),
textBaseline: TextBaseline.alphabetic),
// textAlignVertical: TextAlignVertical.center,
decoration: InputDecoration(
hintText: "请输入6位商户编码",
hintStyle: TextStyle(
color: MyColours.color_c1c1c1,
fontSize: ScreenUtil().setSp(28),
),
border: OutlineInputBorder(
borderSide: BorderSide.none),
contentPadding: EdgeInsets.zero,
),
onChanged: (_) {
setActivate();
},
keyboardType: TextInputType.number,
)),
)
],
)),
Container(
height: ScreenUtil().setHeight(84),
width: ScreenUtil().setWidth(611),
padding: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
margin: EdgeInsets.only(top: ScreenUtil().setHeight(8)),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_bff6f7,
width: ScreenUtil().setWidth(2)),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(8))),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Image.asset(
"assets/icon_account.png",
width: prefixIconWidth,
),
HEmptyView(26),
Text(
"工 号",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(28)),
),
Expanded(
child: Container(
height: ScreenUtil().setHeight(84),
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(20),
right: ScreenUtil().setWidth(20),
top: ScreenUtil().setWidth(8)),
child: TextField(
controller: _accountController,
focusNode: _accountFocusNode,
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(28)),
decoration: InputDecoration(
hintText: "请输入4位工号",
hintStyle: TextStyle(
color: MyColours.color_c1c1c1,
fontSize: ScreenUtil().setSp(28)),
border: OutlineInputBorder(
borderSide: BorderSide.none),
contentPadding: EdgeInsets.zero,
),
onChanged: (_) {
setActivate();
},
keyboardType: TextInputType.number,
),
))
],
)),
Container(
height: ScreenUtil().setHeight(84),
width: ScreenUtil().setWidth(611),
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(20),
right: ScreenUtil().setWidth(27)),
margin: EdgeInsets.only(top: ScreenUtil().setHeight(8)),
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border.all(
color: MyColours.color_bff6f7,
width: ScreenUtil().setWidth(2)),
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(8))),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Image.asset(
"assets/icon_pwd.png",
width: prefixIconWidth,
),
HEmptyView(26),
Text(
"密 码",
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(28)),
),
Expanded(
child: Container(
height: ScreenUtil().setHeight(84),
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(20),
right: ScreenUtil().setWidth(20),
top: ScreenUtil().setWidth(8)),
child: TextField(
controller: _pwdController,
focusNode: _pwdFocusNode,
// autofocus: _sellerCodeController.text.isNotEmpty &&
// _accountController.text.isNotEmpty &&
// _pwdController.text.isEmpty,
style: TextStyle(
color: MyColours.color_353535,
fontSize: ScreenUtil().setSp(28)),
decoration: InputDecoration(
hintText: "请输入密码",
hintStyle: TextStyle(
color: MyColours.color_c1c1c1,
fontSize: ScreenUtil().setSp(28)),
border: OutlineInputBorder(
borderSide: BorderSide.none),
contentPadding: EdgeInsets.zero,
),
onChanged: (_) {
setActivate();
},
obscureText: obscureText,
keyboardType: TextInputType.text,
)),
),
GestureDetector(
child: Padding(
padding: EdgeInsets.all(ScreenUtil().setWidth(10)),
child: Image.asset(
obscureText
? "assets/icon_pwd_show.png"
: "assets/icon_pwd_hide.png",
width: ScreenUtil().setWidth(35),
height: ScreenUtil().setHeight(24),
),
),
onTap: () {
setState(() {
obscureText = !obscureText;
});
},
)
],
)),
Container(
width: ScreenUtil().setWidth(611),
margin: EdgeInsets.only(top: ScreenUtil().setHeight(16)),
alignment: Alignment.centerLeft,
child: Text(
errorText,
// 'hfhfhf',
style: TextStyle(
color: MyColours.color_d93535,
fontSize: ScreenUtil().setSp(16)),
),
),
VEmptyView(40),
Consumer<UserModel>(
builder:
(BuildContext context, UserModel value, Widget child) {
return GestureDetector(
onTap: () {
if (!isActivate) return;
if (!_check) {
Utils.showToast('请先仔细阅读并同意协议');
return;
}
if (App.sp.containsKey('unionid')) {
//微信登陆的时候,退出清空数据
App.sp.remove('openid');
App.sp.remove("unionid");
}
Map<String, String> params = {
"seller_code": "${_sellerCodeController.text}",
"alias": "ssahdahgdafgahjkhakjgh",
"account": "${_accountController.text}",
"password": "${_pwdController.text}"
};
value.login(context, params).then((value) {
setState(() {
errorText = value ?? "";
});
});
},
child: Container(
height: ScreenUtil().setWidth(84),
width: ScreenUtil().setWidth(611),
alignment: Alignment.center,
decoration: BoxDecoration(
color: isActivate
? MyColours.color_2bb5b7
: MyColours.color_2bb5b7,
boxShadow: [
BoxShadow(
color: MyColours.color_26000000,
offset: Offset(0, ScreenUtil().setWidth(4)),
)
],
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(8)))),
child: Text(
"登录",
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(34)),
),
),
);
},
),
VEmptyView(20),
Row(
// mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
InkWell(
onTap: () {
setState(() {
_check = !_check;
});
},
child: Container(
alignment: Alignment.topCenter,
// color: Colors.red,
height: ScreenUtil().setWidth(134),
padding: EdgeInsets.only(
left: ScreenUtil().setWidth(102),
bottom: ScreenUtil().setWidth(10)),
child: Image.asset(
_check
? "assets/mine_radio_sel.png"
: "assets/mine_radio_nor.png",
width: ScreenUtil().setWidth(42),
height: ScreenUtil().setWidth(42)),
)),
HEmptyView(6),
Padding(
padding: EdgeInsets.only(top: ScreenUtil().setWidth(10)),
child: Text(
'已阅读并同意',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_353535),
),
),
InkWell(
onTap: () {
NavigatorUtil.goWebPage(context, '软件服务协议', "xy");
},
child: Padding(
padding:
EdgeInsets.only(top: ScreenUtil().setWidth(10)),
child: Text(
'《软件服务协议》',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_2bb5b7),
)),
),
Padding(
padding:
EdgeInsets.only(top: ScreenUtil().setWidth(10)),
child: Text('及',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_353535))),
InkWell(
onTap: () {
NavigatorUtil.goWebPage(context, '隐私政策', "zc");
},
child: Padding(
padding:
EdgeInsets.only(top: ScreenUtil().setWidth(10)),
child: Text('《隐私政策》',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_2bb5b7))),
)
],
),
VEmptyView(120),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
MyDivider(
ScreenUtil().setWidth(68 * 2), ScreenUtil().setWidth(2),
color: MyColours.color_e5e5e5),
HEmptyView(20),
Text(
'其他登录方式',
style: TextStyle(
fontSize: ScreenUtil().setWidth(24),
color: MyColours.color_999999),
),
HEmptyView(20),
MyDivider(
ScreenUtil().setWidth(68 * 2), ScreenUtil().setWidth(2),
color: MyColours.color_e5e5e5),
],
),
VEmptyView(80),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Platform.isAndroid
? Text('')
: Consumer<UserModel>(builder: (BuildContext context,
UserModel value, Widget child) {
return InkWell(
child: Image.asset(Utils.getImgPath('apple'),
width: ScreenUtil().setWidth(100)),
onTap: () {
if (!_check) {
Utils.showToast('请先仔细阅读并同意协议');
return;
}
_iosLogin(value);
});
}),
Offstage(
offstage: !App.isInstallWx,
child: InkWell(
child: Container(
margin: EdgeInsets.only(
left: Platform.isAndroid
? ScreenUtil().setWidth(0)
: ScreenUtil().setWidth(140)),
child: Image.asset(
Utils.getImgPath('icon_wechat_login'),
width: ScreenUtil().setWidth(100))),
onTap: () {
if (!_check) {
Utils.showToast('请先仔细阅读并同意协议');
return;
}
_wxLogin();
},
)),
],
),
],
),
),
));
}
}
// @override
// Widget build(BuildContext context) {
// ScreenUtil.init(context, width: 750, height: 1334);
// otherLoginProvider =
// Provider.of<OtherLoginProvider>(context, listen: false);
// createStoreModel = Provider.of<CreateStoreModel>(context, listen: false);
// final Size size = MediaQuery.of(context).size;
// App.screenWidth = size.width;
// App.screenHeight = size.height;
// App.statusBarHeight = MediaQuery.of(context).padding.top;
// App.bottomBarHeight = MediaQuery.of(context).padding.bottom;
// final double prefixIconWidth = ScreenUtil().setWidth(24);
// return Scaffold(
// backgroundColor: MyColours.color_ffffff,
// body: Container(
// width: double.infinity,
// height: double.infinity,
// child: SingleChildScrollView(
// controller: _scrollController,
// child: Column(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// // VEmptyView(218 - App.statusBarHeight),
// VEmptyView(80 + App.statusBarHeight),
// Image.asset(
// "assets/logo.png",
// width: ScreenUtil().setWidth(74 * 2),
// height: ScreenUtil().setWidth(71 * 2),
// ),
// VEmptyView(80),
// Container(
// height: ScreenUtil().setHeight(84),
// width: ScreenUtil().setWidth(611),
// padding: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// border: Border.all(
// color: MyColours.color_bff6f7,
// width: ScreenUtil().setWidth(2)),
// borderRadius:
// BorderRadius.circular(ScreenUtil().setWidth(8))),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// Image.asset(
// "assets/icon_sellercode.png",
// width: prefixIconWidth,
// ),
// HEmptyView(26),
// Center(
// child: Text(
// "商户编号",
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28)),
// )),
// Expanded(
// child: Container(
// height: ScreenUtil().setHeight(84),
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20),
// right: ScreenUtil().setWidth(20),
// top: ScreenUtil().setWidth(8)),
// child: TextField(
// controller: _sellerCodeController,
// focusNode: _sellerCodeFocusNode,
// // autofocus: _sellerCodeController.text.isEmpty,
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28),
// textBaseline: TextBaseline.alphabetic),
// // textAlignVertical: TextAlignVertical.center,
// decoration: InputDecoration(
// hintText: "请输入6位商户编码",
// hintStyle: TextStyle(
// color: MyColours.color_c1c1c1,
// fontSize: ScreenUtil().setSp(28),
// ),
// border: OutlineInputBorder(
// borderSide: BorderSide.none),
// contentPadding: EdgeInsets.zero,
// ),
// onChanged: (_) {
// setActivate();
// },
// keyboardType: TextInputType.number,
// )),
// )
// ],
// )),
// Container(
// height: ScreenUtil().setHeight(84),
// width: ScreenUtil().setWidth(611),
// padding: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
// margin: EdgeInsets.only(top: ScreenUtil().setHeight(8)),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// border: Border.all(
// color: MyColours.color_bff6f7,
// width: ScreenUtil().setWidth(2)),
// borderRadius:
// BorderRadius.circular(ScreenUtil().setWidth(8))),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// Image.asset(
// "assets/icon_account.png",
// width: prefixIconWidth,
// ),
// HEmptyView(26),
// Text(
// "工 号",
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28)),
// ),
// Expanded(
// child: Container(
// height: ScreenUtil().setHeight(84),
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20),
// right: ScreenUtil().setWidth(20),
// top: ScreenUtil().setWidth(8)),
// child: TextField(
// controller: _accountController,
// focusNode: _accountFocusNode,
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28)),
// decoration: InputDecoration(
// hintText: "请输入4位工号",
// hintStyle: TextStyle(
// color: MyColours.color_c1c1c1,
// fontSize: ScreenUtil().setSp(28)),
// border: OutlineInputBorder(
// borderSide: BorderSide.none),
// contentPadding: EdgeInsets.zero,
// ),
// onChanged: (_) {
// setActivate();
// },
// keyboardType: TextInputType.number,
// ),
// ))
// ],
// )),
// Container(
// height: ScreenUtil().setHeight(84),
// width: ScreenUtil().setWidth(611),
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20),
// right: ScreenUtil().setWidth(27)),
// margin: EdgeInsets.only(top: ScreenUtil().setHeight(8)),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// border: Border.all(
// color: MyColours.color_bff6f7,
// width: ScreenUtil().setWidth(2)),
// borderRadius:
// BorderRadius.circular(ScreenUtil().setWidth(8))),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// Image.asset(
// "assets/icon_pwd.png",
// width: prefixIconWidth,
// ),
// HEmptyView(26),
// Text(
// "密 码",
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28)),
// ),
// Expanded(
// child: Container(
// height: ScreenUtil().setHeight(84),
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20),
// right: ScreenUtil().setWidth(20),
// top: ScreenUtil().setWidth(8)),
// child: TextField(
// controller: _pwdController,
// focusNode: _pwdFocusNode,
// // autofocus: _sellerCodeController.text.isNotEmpty &&
// // _accountController.text.isNotEmpty &&
// // _pwdController.text.isEmpty,
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28)),
// decoration: InputDecoration(
// hintText: "请输入密码",
// hintStyle: TextStyle(
// color: MyColours.color_c1c1c1,
// fontSize: ScreenUtil().setSp(28)),
// border: OutlineInputBorder(
// borderSide: BorderSide.none),
// contentPadding: EdgeInsets.zero,
// ),
// onChanged: (_) {
// setActivate();
// },
// obscureText: obscureText,
// keyboardType: TextInputType.text,
// )),
// ),
// GestureDetector(
// child: Padding(
// padding: EdgeInsets.all(ScreenUtil().setWidth(10)),
// child: Image.asset(
// obscureText
// ? "assets/icon_pwd_show.png"
// : "assets/icon_pwd_hide.png",
// width: ScreenUtil().setWidth(35),
// height: ScreenUtil().setHeight(24),
// ),
// ),
// onTap: () {
// setState(() {
// obscureText = !obscureText;
// });
// },
// )
// ],
// )),
// Container(
// width: ScreenUtil().setWidth(611),
// margin: EdgeInsets.only(top: ScreenUtil().setHeight(16)),
// alignment: Alignment.centerLeft,
// child: Text(
// errorText,
// // 'hfhfhf',
// style: TextStyle(
// color: MyColours.color_d93535,
// fontSize: ScreenUtil().setSp(16)),
// ),
// ),
// VEmptyView(40),
// Consumer<UserModel>(
// builder:
// (BuildContext context, UserModel value, Widget child) {
// return GestureDetector(
// onTap: () {
// if (!isActivate) return;
// if (!_check) {
// Utils.showToast('请先仔细阅读并同意协议');
// return;
// }
// if (App.sp.containsKey('unionid')) {
// //微信登陆的时候,退出清空数据
// App.sp.remove('openid');
// App.sp.remove("unionid");
// }
// Map<String, String> params = {
// "seller_code": "${_sellerCodeController.text}",
// "alias": "ssahdahgdafgahjkhakjgh",
// "account": "${_accountController.text}",
// "password": "${_pwdController.text}"
// };
// value.login(context, params).then((value) {
// setState(() {
// errorText = value ?? "";
// });
// });
// },
// child: Container(
// height: ScreenUtil().setWidth(84),
// width: ScreenUtil().setWidth(611),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// color: isActivate
// ? MyColours.color_2bb5b7
// : MyColours.color_2bb5b7,
// boxShadow: [
// BoxShadow(
// color: MyColours.color_26000000,
// offset: Offset(0, ScreenUtil().setWidth(4)),
// )
// ],
// borderRadius: BorderRadius.all(
// Radius.circular(ScreenUtil().setWidth(8)))),
// child: Text(
// "登录",
// style: TextStyle(
// color: MyColours.color_ffffff,
// fontSize: ScreenUtil().setSp(34)),
// ),
// ),
// );
// },
// ),
// VEmptyView(20),
// Row(
// // mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: <Widget>[
// InkWell(
// onTap: () {
// setState(() {
// _check = !_check;
// });
// },
// child: Container(
// alignment: Alignment.topCenter,
// // color: Colors.red,
// height: ScreenUtil().setWidth(134),
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(102),
// bottom: ScreenUtil().setWidth(10)),
// child: Image.asset(
// _check
// ? "assets/mine_radio_sel.png"
// : "assets/mine_radio_nor.png",
// width: ScreenUtil().setWidth(42),
// height: ScreenUtil().setWidth(42)),
// )),
// HEmptyView(6),
// Padding(
// padding: EdgeInsets.only(top: ScreenUtil().setWidth(10)),
// child: Text(
// '已阅读并同意',
// style: TextStyle(
// fontSize: ScreenUtil().setSp(24),
// color: MyColours.color_353535),
// ),
// ),
// InkWell(
// onTap: () {
// NavigatorUtil.goWebPage(context, '软件服务协议', "xy");
// },
// child: Padding(
// padding:
// EdgeInsets.only(top: ScreenUtil().setWidth(10)),
// child: Text(
// '《软件服务协议》',
// style: TextStyle(
// fontSize: ScreenUtil().setSp(24),
// color: MyColours.color_2bb5b7),
// )),
// ),
// Padding(
// padding:
// EdgeInsets.only(top: ScreenUtil().setWidth(10)),
// child: Text('及',
// style: TextStyle(
// fontSize: ScreenUtil().setSp(24),
// color: MyColours.color_353535))),
// InkWell(
// onTap: () {
// NavigatorUtil.goWebPage(context, '隐私政策', "zc");
// },
// child: Padding(
// padding:
// EdgeInsets.only(top: ScreenUtil().setWidth(10)),
// child: Text('《隐私政策》',
// style: TextStyle(
// fontSize: ScreenUtil().setSp(24),
// color: MyColours.color_2bb5b7))),
// )
// ],
// ),
// VEmptyView(120),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: [
// MyDivider(
// ScreenUtil().setWidth(68 * 2), ScreenUtil().setWidth(2),
// color: MyColours.color_e5e5e5),
// HEmptyView(20),
// Text(
// '其他登录方式',
// style: TextStyle(
// fontSize: ScreenUtil().setWidth(24),
// color: MyColours.color_999999),
// ),
// HEmptyView(20),
// MyDivider(
// ScreenUtil().setWidth(68 * 2), ScreenUtil().setWidth(2),
// color: MyColours.color_e5e5e5),
// ],
// ),
// VEmptyView(80),
// Row(
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Platform.isAndroid
// ? Text('')
// : Consumer<UserModel>(builder: (BuildContext context,
// UserModel value, Widget child) {
// return InkWell(
// child: Image.asset(Utils.getImgPath('apple'),
// width: ScreenUtil().setWidth(100)),
// onTap: () {
// if (!_check) {
// Utils.showToast('请先仔细阅读并同意协议');
// return;
// }
// _iosLogin(value);
// });
// }),
// Offstage(
// offstage: !App.isInstallWx,
// child: InkWell(
// child: Container(
// margin: EdgeInsets.only(
// left: Platform.isAndroid
// ? ScreenUtil().setWidth(0)
// : ScreenUtil().setWidth(140)),
// child: Image.asset(
// Utils.getImgPath('icon_wechat_login'),
// width: ScreenUtil().setWidth(100))),
// onTap: () {
// if (!_check) {
// Utils.showToast('请先仔细阅读并同意协议');
// return;
// }
// _wxLogin();
// },
// )),
// ],
// ),
// ],
// ),
// ),
// ));
// }
// }
... ...
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:common_utils/common_utils.dart';
import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluwx/fluwx.dart' as fluwx;
import 'package:fluwx/fluwx.dart';
import 'package:one_key/app.dart';
import 'package:one_key/models/checkbind_phone_model.dart';
import 'package:one_key/models/store_info.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/provider/create_store_model.dart';
import 'package:one_key/provider/other_login_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/route/navigate_service.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/h_empty_view.dart';
import 'package:one_key/widgets/loading.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:provider/provider.dart';
import 'package:sign_in_with_apple/sign_in_with_apple.dart';
class LoginPage extends StatefulWidget {
@override
State<StatefulWidget> createState() {
// TODO: implement createState
return new LoginState();
}
}
class LoginState extends State<LoginPage> with WidgetsBindingObserver {
TextEditingController _sellerCodeController = TextEditingController();
TextEditingController _accountController = TextEditingController();
final TextEditingController _pwdController = TextEditingController();
final ScrollController _scrollController = new ScrollController();
final FocusNode _sellerCodeFocusNode = new FocusNode();
final FocusNode _accountFocusNode = new FocusNode();
final FocusNode _pwdFocusNode = new FocusNode();
bool obscureText = true; //是否隐藏密码
bool isActivate = false; //是否激活登录
String errorText = ""; //错误提示
bool _check = false;
StreamSubscription<BaseWeChatResponse> streamSubscription;
OtherLoginProvider otherLoginProvider;
CreateStoreModel createStoreModel;
@override
void initState() {
// TODO: implement initState
super.initState();
//第一次打开应用
_checkWechat();
isLogin();
WidgetsBinding.instance.addObserver(this);
WidgetsBinding.instance.addPostFrameCallback((_) {
final UserModel userModel =
Provider.of<UserModel>(context, listen: false);
if (userModel != null && userModel.user != null) {
Future.delayed(Duration(milliseconds: 50), () {
_sellerCodeController.text = userModel.user.sellercode;
_accountController.text = userModel.user.account;
// FocusScope.of(context).requestFocus(_pwdFocusNode);
});
}
});
}
//当页面离开时要清除监听器
@override
void dispose() {
super.dispose();
WidgetsBinding.instance.removeObserver(this);
if (streamSubscription != null) {
streamSubscription.cancel();
}
}
//微信是否安装
_checkWechat() async {
// await registerWxApi(
// appId: "wx85aa3cdd0f791e65",
// doOnAndroid: true,
// doOnIOS: true,
// universalLink: "https://xt04.colorcun.com/link/OneKey/");
var result = await isWeChatInstalled;
if (result != null && result) {
App.isInstallWx = true;
} else {
App.isInstallWx = false;
}
setState(() {});
LogUtil.v("is installed $result");
}
handlePostFrame(_) {
// _scrollController.jumpTo(_scrollController.position.maxScrollExtent);
}
@override
void didChangeMetrics() {
// TODO: implement didChangeMetrics
WidgetsBinding.instance.addPostFrameCallback(handlePostFrame);
super.didChangeDependencies();
}
//监听输入框,设置登录按钮状态
setActivate() {
if (_sellerCodeController.text.isNotEmpty &&
_accountController.text.isNotEmpty &&
_pwdController.text.isNotEmpty) {
setState(() {
errorText = "";
isActivate = true;
});
} else {
setState(() {
errorText = "";
isActivate = false;
});
}
}
//判断是否登录
void isLogin() async {
await App.initSp();
UserModel userModel = Provider.of<UserModel>(context, listen: false);
userModel.initUser();
if (App.sp.getBool("isLogin") ?? false) {
Future.delayed(Duration(milliseconds: 200), () {
NavigatorUtil.goHomePage(context);
});
} else {
_getWxCode();
}
}
///微信登陆
_wxLogin() {
sendWeChatAuth(scope: "snsapi_userinfo");
}
///获取微信登录code
_getWxCode() {
streamSubscription = fluwx.weChatResponseEventHandler
.distinct((a, b) => a == b)
.listen((res) {
if (res is fluwx.WeChatAuthResponse && res.errCode == 0) {
LogUtil.v("code:" + res.code);
// Loading.showLoading(context);
_getAccessToken(res.code);
} else {
// Utils.showToast(res.errStr??"登录失败,请稍后重试");
}
});
}
///获取微信登录access_token
_getAccessToken(String code) async {
Response response = await DioUtil.getInstance().getDio().get(
"https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx85aa3cdd0f791e65&secret=87c9a23c2e6032b2da75af6b0efc5424&code=$code&grant_type=authorization_code");
LogUtil.v("access_token:${response.toString()}");
Map<String, dynamic> responseData = json.decode(response.data.toString());
if (responseData["errcode"] != null) {
Utils.showToast(responseData["errmsg"] ?? "登录失败,请稍后重试");
// Loading.hideLoading(context);
} else {
App.sp.setString("openid", responseData["openid"]);
App.sp.setString("unionid", responseData["unionid"]);
//跳转至手机号绑定页面
//判断是否已经绑定手机号码 ******调用接口*******
//有,通过手机号吗或者opened查找店铺信息进行登陆
//没有,跳转至绑定手机号码页面
// Map<String, String> params = {
// "unionid": responseData["unionid"],
// };
// BuildContext contextTemp =
// App.getIt<NavigateService>().key.currentState.overlay.context;
// CheckbindPhoneSunModel model =
// await otherLoginProvider.checkbindPhone(contextTemp, params);
// // Loading.hideLoading(context);
// if (model != null) {
// createStoreModel.storeInfo = StoreInfo();
// createStoreModel.storeInfo.phone = model.phone;
createStoreModel.storeInfo = StoreInfo();
NavigatorUtil.goIfNeedCreateStorePage(context);
// } else {
// NavigatorUtil.goBindingPhonePage(context);
// }
// _getUserInfo(responseData["access_token"], responseData["openid"]);
}
}
// //获取用户信息
// _getUserInfo(String access_token, String openid) async {
// Response response = await DioUtil.getInstance().getDio().get(
// "https://api.weixin.qq.com/sns/userinfo?access_token=$access_token&openid=$openid");
// LogUtil.v('userinfo:' + response.data);
// Map<String, dynamic> responseData = json.decode(response.data.toString());
// if (responseData["errcode"] != null) {
// // Utils.showToast(responseData["errmsg"]??"登录,请稍后重试");
// } else {
// App.sp.setString("nickName", responseData["nickname"]);
// App.sp.setString("headImg", responseData["headimgurl"]);
// App.sp.setString("unionid", responseData["unionid"]);
// App.sp.setBool("isLogin", true);
// // _fromTypeGo();
// String unionId = App.sp.getString("unionid");
// _getMiniOpenid(unionId);
// }
// }
// //获取绑定小程序openid
// _getMiniOpenid(String unionId) async {
// UserModel userInfoProvider = UserModel();
// // Provider.of<UserInfoProvider>(context, listen: false);
// Map<String, String> params = {"unionid": unionId};
// String miniOpenid =
// await userInfoProvider.getMiniProgramOpenid(context, params);
// if (miniOpenid == null) {
// goMiniProgramMd(unionId);
// }
// }
/*
苹果登录获取用户信息
*/
_getUserInfoIOS() async {
// Map<String, String> params = {"openid": App.sp.getString("openid")};
// UserInfoProvider userInfoProvider =
// Provider.of<UserInfoProvider>(context, listen: false);
// UseInfoItemModel useInfoItemModel =
// await userInfoProvider.getUserInfo(context, params);
// if (ObjectUtil.isNotEmpty(useInfoItemModel.openid)) {
// _hideLoading(context);
// App.sp.setString("nickName", useInfoItemModel.nickname);
// App.sp.setString("headImg", '');
// App.sp.setString("unionid", '');
// App.sp.setBool("isLogin", true);
// UserInfoProvider userInfoProvider = new UserInfoProvider();
// userInfoProvider.initPlatformState(context);
// // Loading.hideLoading(context);
// _fromTypeGo();
// } else {
// // 已经授权,但是后台库里没有数据,版本差异,重新插入数据库
// Map param = {
// 'openid': App.sp.getString("openid"),
// 'avatar': 'ios_avatar',
// 'nickname': '',
// 'gender': '1'
// };
// LoginRespository().appleLogin(context, param, () {
// _getUserInfoIOS();
// });
// }
}
_showLoading(BuildContext context) {
showGeneralDialog(
context: context,
barrierDismissible: false,
barrierLabel:
MaterialLocalizations.of(context).modalBarrierDismissLabel,
transitionDuration: const Duration(milliseconds: 150),
pageBuilder: (BuildContext context, Animation animation,
Animation secondaryAnimation) {
return Align(
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Container(
width: 80,
height: 80,
child: CupertinoActivityIndicator(),
),
),
);
}).then((v) {});
}
///苹果登陆
_iosLogin(UserModel value) async {
String info = await Utils.getDeviceInfoSystem();
int systemInfo = info.compareTo('13');
if (systemInfo < 0) {
Utils.showToast('该系统版本不支持苹果登录');
return;
}
final credential = await SignInWithApple.getAppleIDCredential(
scopes: [
AppleIDAuthorizationScopes.email,
AppleIDAuthorizationScopes.fullName,
],
webAuthenticationOptions: WebAuthenticationOptions(
// TODO: Set the `clientId` and `redirectUri` arguments to the values you entered in the Apple Developer portal during the setup
clientId: 'com.naji.reserveLine',
redirectUri: Uri.parse(
'https://flutter-sign-in-with-apple-example.glitch.me/callbacks/sign_in_with_apple',
),
),
);
// _showLoading(context);
// print(credential.userIdentifier);
_loginAppleData(value);
// NavigatorUtil.goBindingPhonePage(context, wechat: false);
// String mdString = Utils.generateMd5(credential.userIdentifier);
// String temp = mdString.substring(8, mdString.length - 2);
// String openid = 'IOSID_$temp';
// App.sp.setString("openid", openid);
// App.sp.setString("unionid", '');
// print(openid.length);
// 第一次授权
// if (ObjectUtil.isNotEmpty(credential.familyName)) {
// Map param = {
// 'openid': openid,
// 'avatar': 'ios_avatar',
// 'nickname': '${credential.familyName}${credential.givenName}',
// 'gender': '1'
// };
// LoginRespository().appleLogin(context, param, () {
// _getUserInfoIOS();
// });
// } else {
// if (ObjectUtil.isNotEmpty(App.sp.getString("newUserMsg"))) {
// Map newUserMsg = jsonDecode(App.sp.getString("newUserMsg"));
// //上次失败了,这次重新传
// LoginRespository().appleLogin(context, newUserMsg, () {
// _getUserInfoIOS();
// });
// } else {
// _getUserInfoIOS();
// }
// }
}
_loginAppleData(UserModel value) {
if (App.sp.containsKey('unionid')) {
//微信登陆的时候,退出清空数据
App.sp.remove('openid');
App.sp.remove("unionid");
}
Map<String, String> params = {
"seller_code": "001297",
"alias": "ssahdahgdafgahjkhakjgh",
"account": "0001",
"password": "123456"
};
value.login(context, params).then((value) {
// setState(() {
// // errorText = value ?? "";
// });
});
}
@override
Widget build(BuildContext context) {
ScreenUtil.init(context, width: 750, height: 1334);
otherLoginProvider =
Provider.of<OtherLoginProvider>(context, listen: false);
createStoreModel = Provider.of<CreateStoreModel>(context, listen: false);
final Size size = MediaQuery.of(context).size;
App.screenWidth = size.width;
App.screenHeight = size.height;
App.statusBarHeight = MediaQuery.of(context).padding.top;
App.bottomBarHeight = MediaQuery.of(context).padding.bottom;
final double prefixIconWidth = ScreenUtil().setWidth(24);
return Scaffold(
backgroundColor: MyColours.color_ffffff,
body: Container(
width: double.infinity,
height: double.infinity,
child: SingleChildScrollView(
controller: _scrollController,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
// VEmptyView(218 - App.statusBarHeight),
VEmptyView(80 + App.statusBarHeight),
Padding(
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(40)),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Image.asset(
"assets/logo.png",
width: ScreenUtil().setWidth(40 * 2),
height: ScreenUtil().setWidth(40 * 2),
)
],
)),
VEmptyView(120),
Image.asset(
Utils.getImgPath('login_bg'),
),
// Container(
// height: ScreenUtil().setHeight(84),
// width: ScreenUtil().setWidth(611),
// padding: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// border: Border.all(
// color: MyColours.color_bff6f7,
// width: ScreenUtil().setWidth(2)),
// borderRadius:
// BorderRadius.circular(ScreenUtil().setWidth(8))),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// Image.asset(
// "assets/icon_sellercode.png",
// width: prefixIconWidth,
// ),
// HEmptyView(26),
// Center(
// child: Text(
// "商户编号",
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28)),
// )),
// Expanded(
// child: Container(
// height: ScreenUtil().setHeight(84),
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20),
// right: ScreenUtil().setWidth(20),
// top: ScreenUtil().setWidth(8)),
// child: TextField(
// controller: _sellerCodeController,
// focusNode: _sellerCodeFocusNode,
// // autofocus: _sellerCodeController.text.isEmpty,
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28),
// textBaseline: TextBaseline.alphabetic),
// // textAlignVertical: TextAlignVertical.center,
// decoration: InputDecoration(
// hintText: "请输入6位商户编码",
// hintStyle: TextStyle(
// color: MyColours.color_c1c1c1,
// fontSize: ScreenUtil().setSp(28),
// ),
// border: OutlineInputBorder(
// borderSide: BorderSide.none),
// contentPadding: EdgeInsets.zero,
// ),
// onChanged: (_) {
// setActivate();
// },
// keyboardType: TextInputType.number,
// )),
// )
// ],
// )),
// Container(
// height: ScreenUtil().setHeight(84),
// width: ScreenUtil().setWidth(611),
// padding: EdgeInsets.only(left: ScreenUtil().setWidth(20)),
// margin: EdgeInsets.only(top: ScreenUtil().setHeight(8)),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// border: Border.all(
// color: MyColours.color_bff6f7,
// width: ScreenUtil().setWidth(2)),
// borderRadius:
// BorderRadius.circular(ScreenUtil().setWidth(8))),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// Image.asset(
// "assets/icon_account.png",
// width: prefixIconWidth,
// ),
// HEmptyView(26),
// Text(
// "工 号",
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28)),
// ),
// Expanded(
// child: Container(
// height: ScreenUtil().setHeight(84),
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20),
// right: ScreenUtil().setWidth(20),
// top: ScreenUtil().setWidth(8)),
// child: TextField(
// controller: _accountController,
// focusNode: _accountFocusNode,
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28)),
// decoration: InputDecoration(
// hintText: "请输入4位工号",
// hintStyle: TextStyle(
// color: MyColours.color_c1c1c1,
// fontSize: ScreenUtil().setSp(28)),
// border: OutlineInputBorder(
// borderSide: BorderSide.none),
// contentPadding: EdgeInsets.zero,
// ),
// onChanged: (_) {
// setActivate();
// },
// keyboardType: TextInputType.number,
// ),
// ))
// ],
// )),
// Container(
// height: ScreenUtil().setHeight(84),
// width: ScreenUtil().setWidth(611),
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20),
// right: ScreenUtil().setWidth(27)),
// margin: EdgeInsets.only(top: ScreenUtil().setHeight(8)),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// border: Border.all(
// color: MyColours.color_bff6f7,
// width: ScreenUtil().setWidth(2)),
// borderRadius:
// BorderRadius.circular(ScreenUtil().setWidth(8))),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// Image.asset(
// "assets/icon_pwd.png",
// width: prefixIconWidth,
// ),
// HEmptyView(26),
// Text(
// "密 码",
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28)),
// ),
// Expanded(
// child: Container(
// height: ScreenUtil().setHeight(84),
// padding: EdgeInsets.only(
// left: ScreenUtil().setWidth(20),
// right: ScreenUtil().setWidth(20),
// top: ScreenUtil().setWidth(8)),
// child: TextField(
// controller: _pwdController,
// focusNode: _pwdFocusNode,
// // autofocus: _sellerCodeController.text.isNotEmpty &&
// // _accountController.text.isNotEmpty &&
// // _pwdController.text.isEmpty,
// style: TextStyle(
// color: MyColours.color_353535,
// fontSize: ScreenUtil().setSp(28)),
// decoration: InputDecoration(
// hintText: "请输入密码",
// hintStyle: TextStyle(
// color: MyColours.color_c1c1c1,
// fontSize: ScreenUtil().setSp(28)),
// border: OutlineInputBorder(
// borderSide: BorderSide.none),
// contentPadding: EdgeInsets.zero,
// ),
// onChanged: (_) {
// setActivate();
// },
// obscureText: obscureText,
// keyboardType: TextInputType.text,
// )),
// ),
// GestureDetector(
// child: Padding(
// padding: EdgeInsets.all(ScreenUtil().setWidth(10)),
// child: Image.asset(
// obscureText
// ? "assets/icon_pwd_show.png"
// : "assets/icon_pwd_hide.png",
// width: ScreenUtil().setWidth(35),
// height: ScreenUtil().setHeight(24),
// ),
// ),
// onTap: () {
// setState(() {
// obscureText = !obscureText;
// });
// },
// )
// ],
// )),
// Container(
// width: ScreenUtil().setWidth(611),
// margin: EdgeInsets.only(top: ScreenUtil().setHeight(16)),
// alignment: Alignment.centerLeft,
// child: Text(
// errorText,
// // 'hfhfhf',
// style: TextStyle(
// color: MyColours.color_d93535,
// fontSize: ScreenUtil().setSp(16)),
// ),
// ),
VEmptyView(60),
// Consumer<UserModel>(
// builder:
// (BuildContext context, UserModel value, Widget child) {
// return GestureDetector(
// onTap: () {
// if (!isActivate) return;
// if (!_check) {
// Utils.showToast('请先仔细阅读并同意协议');
// return;
// }
// if (App.sp.containsKey('unionid')) {
// //微信登陆的时候,退出清空数据
// App.sp.remove('openid');
// App.sp.remove("unionid");
// }
// Map<String, String> params = {
// "seller_code": "${_sellerCodeController.text}",
// "alias": "ssahdahgdafgahjkhakjgh",
// "account": "${_accountController.text}",
// "password": "${_pwdController.text}"
// };
// value.login(context, params).then((value) {
// setState(() {
// errorText = value ?? "";
// });
// });
// },
// child: Container(
// height: ScreenUtil().setWidth(84),
// width: ScreenUtil().setWidth(611),
// alignment: Alignment.center,
// decoration: BoxDecoration(
// color: isActivate
// ? MyColours.color_2bb5b7
// : MyColours.color_2bb5b7,
// boxShadow: [
// BoxShadow(
// color: MyColours.color_26000000,
// offset: Offset(0, ScreenUtil().setWidth(4)),
// )
// ],
// borderRadius: BorderRadius.all(
// Radius.circular(ScreenUtil().setWidth(8)))),
// child: Text(
// "登录",
// style: TextStyle(
// color: MyColours.color_ffffff,
// fontSize: ScreenUtil().setSp(34)),
// ),
// ),
// );
// },
// ),
Row(
// mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
InkWell(
onTap: () {
setState(() {
_check = !_check;
});
},
child: Container(
alignment: Alignment.topCenter,
// color: Colors.red,
height: ScreenUtil().setWidth(110),
padding: EdgeInsets.only(
right: ScreenUtil().setWidth(30),
left: ScreenUtil().setWidth(102),
bottom: ScreenUtil().setWidth(10)),
child: Image.asset(
_check
? "assets/mine_radio_sel.png"
: "assets/mine_radio_nor.png",
width: ScreenUtil().setWidth(26),
height: ScreenUtil().setWidth(26)),
)),
// HEmptyView(30),
Padding(
padding: EdgeInsets.only(top: ScreenUtil().setWidth(2)),
child: Text(
'已阅读并同意',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_999999),
),
),
InkWell(
onTap: () {
NavigatorUtil.goWebPage(context, '软件服务协议', "xy");
},
child: Padding(
padding:
EdgeInsets.only(top: ScreenUtil().setWidth(2)),
child: Text(
'《软件服务协议》',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_333333),
)),
),
Padding(
padding: EdgeInsets.only(top: ScreenUtil().setWidth(2)),
child: Text('及',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_999999))),
InkWell(
onTap: () {
NavigatorUtil.goWebPage(context, '隐私政策', "zc");
},
child: Padding(
padding:
EdgeInsets.only(top: ScreenUtil().setWidth(2)),
child: Text('《隐私政策》',
style: TextStyle(
fontSize: ScreenUtil().setSp(24),
color: MyColours.color_333333))),
)
],
),
//微信登录
Offstage(
offstage: !App.isInstallWx,
child: InkWell(
child: Container(
width: double.infinity,
height: ScreenUtil().setWidth(90),
margin: EdgeInsets.only(
bottom: ScreenUtil().setWidth(30),
right: ScreenUtil().setWidth(80),
left: ScreenUtil().setWidth(80)),
decoration: BoxDecoration(
color: MyColours.color_55AA67,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(8))),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(Utils.getImgPath('icon_wechat_login'),
width: ScreenUtil().setWidth(46)),
HEmptyView(20),
Text('微信登录',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(28),
fontWeight: FontWeight.bold)),
],
)),
onTap: () {
if (!_check) {
DialogUtil.openAlertDialogLogin(context, 500,
onTap: () {
Navigator.pop(context);
_wxLogin();
});
return;
}
_wxLogin();
},
)),
//账号登录
Consumer<UserModel>(builder:
(BuildContext context, UserModel value, Widget child) {
return InkWell(
child: Container(
width: double.infinity,
height: ScreenUtil().setWidth(90),
margin: EdgeInsets.only(
bottom: ScreenUtil().setWidth(30),
right: ScreenUtil().setWidth(80),
left: ScreenUtil().setWidth(80)),
decoration: BoxDecoration(
color: MyColours.color_41444B,
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(8))),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('一键订账号登录',
style: TextStyle(
color: MyColours.color_ffffff,
fontSize: ScreenUtil().setSp(28),
fontWeight: FontWeight.bold)),
],
)),
onTap: () {
if (!_check) {
DialogUtil.openAlertDialogLogin(context, 500,
onTap: () {
Navigator.pop(context);
NavigatorUtil.goAccountLoginPage(context);
});
return;
}
NavigatorUtil.goAccountLoginPage(context);
});
}),
// ios登录
Platform.isAndroid
? Text('')
: Consumer<UserModel>(builder:
(BuildContext context, UserModel value, Widget child) {
return InkWell(
child: Container(
width: double.infinity,
height: ScreenUtil().setWidth(90),
margin: EdgeInsets.only(
bottom: ScreenUtil().setWidth(30),
right: ScreenUtil().setWidth(80),
left: ScreenUtil().setWidth(80)),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
border: Border.all(
color: MyColours.color_E4E4E4,
width: ScreenUtil().setWidth(2)),
borderRadius: BorderRadius.circular(
ScreenUtil().setWidth(8))),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
Utils.getImgPath('icon_apple_login'),
width: ScreenUtil().setWidth(46)),
HEmptyView(20),
Text('通过 Apple 登录',
style: TextStyle(
color: MyColours.color_41444B,
fontSize: ScreenUtil().setSp(28),
fontWeight: FontWeight.bold)),
],
)),
onTap: () {
if (!_check) {
DialogUtil.openAlertDialogLogin(context, 500,
onTap: () {
Navigator.pop(context);
_iosLogin(value);
});
return;
}
_iosLogin(value);
});
}),
InkWell(
onTap: () {
Utils.goPhone("400-000-9690");
},
child: Text('联系客服',
style: TextStyle(
color: MyColours.color_333333,
fontWeight: FontWeight.bold,
fontSize: ScreenUtil().setSp(26),
decoration: TextDecoration.underline))),
],
),
),
));
}
}
... ...
... ... @@ -232,9 +232,17 @@ class MyPageState extends State<MyPage> with WidgetsBindingObserver {
height: ScreenUtil().setWidth(56),
fontSize: 28,
isBold: false,
textColor: MyColours.color_199095,
textColor:
Provider.of<UserModel>(context, listen: false)
.accountLogin
? MyColours.color_999999
: MyColours.color_199095,
radius: ScreenUtil().setWidth(20),
onPressed: () {
if (Provider.of<UserModel>(context, listen: false)
.accountLogin) {
return;
}
NavigatorUtil.goIfNeedCreateStorePage(context,
changeStatus: true);
},
... ...
... ... @@ -25,6 +25,7 @@ class UserModel with ChangeNotifier {
String _registrationId; //极光推送registrationId
String _token; //信鸽推送token
List<PullMarketingByUidSunModel> pullMarketingByUidSunModel;
bool accountLogin = false;
User get user => _user;
... ... @@ -47,7 +48,8 @@ class UserModel with ChangeNotifier {
}
/// 登录
Future<String> login(BuildContext context, Map<String, String> params) async {
Future<String> login(BuildContext context, Map<String, String> params,
{bool acclogin = false}) async {
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.app_user_login,
data: params)
... ... @@ -55,8 +57,16 @@ class UserModel with ChangeNotifier {
print(error.toString());
});
if (baseResp.code != Constant.status_success) {
return baseResp.msg ?? '登录失败,请检查账号密码';
Utils.showToast('用户名密码错误,请重新输入');
return '';
// return baseResp.msg ?? '用户名密码错误,请重新输入';
} else {
if (acclogin) {
accountLogin = true;
} else {
accountLogin = false;
}
Map<String, dynamic> seller = baseResp.data[0]["seller"];
Map<String, dynamic> user = baseResp.data[0]["user"];
Map<String, dynamic> userMap = {
... ...
import 'package:flutter/material.dart';
class MyColours {
static const Color color_C9C9C9 = Color(0xffC9C9C9);
static const Color color_F7F7F7 = Color(0xffF7F7F7);
static const Color color_A3A3A3 = Color(0xffA3A3A3);
static const Color color_5688F3 = Color(0xff5688F3);
static const Color color_6097F4 = Color(0xff6097F4);
static const Color color_2C2C2C = Color(0xff2C2C2C);
static const Color color_404040 = Color(0xff404040);
static const Color color_2264FF = Color(0xff2264FF);
static const Color color_E4E4E4 = Color(0xffE4E4E4);
static const Color color_41444B = Color(0xff41444B);
static const Color color_55AA67 = Color(0xff55AA67);
static const Color color_d7d7d7 = Color(0xffD7D7D7);
static const Color color_F4FAFF = Color(0xffF4FAFF);
static const Color app_main = Color(0xFF24A4A8);
... ...
... ... @@ -46,6 +46,11 @@ class NavigatorUtil {
_navigateTo(context, Routes.login, clearStack: true);
}
/// 账号登录页
static void goAccountLoginPage(BuildContext context) {
_navigateTo(context, Routes.account_login_page);
}
/// 首页
static void goHomePage(BuildContext context, {int initialIndex = 1}) {
_navigateTo(context, "${Routes.home}?initialIndex=$initialIndex",
... ...
... ... @@ -39,11 +39,13 @@ import 'package:one_key/pages/detail/notebook_detail_change_page_f.dart';
import 'package:one_key/pages/detail/select_tables_f_page.dart';
import 'package:one_key/pages/home/home_page.dart';
import 'package:one_key/pages/invicate/invitation_page.dart';
import 'package:one_key/pages/login/account_login_page.dart';
import 'package:one_key/pages/login/binding_phone.dart';
import 'package:one_key/pages/login/if_need_create_store.dart';
import 'package:one_key/pages/login/login_page.dart';
import 'package:one_key/pages/detail/handle_online_page.dart';
import 'package:one_key/pages/detail/notebook_detail_page.dart';
import 'package:one_key/pages/login/login_page_f.dart';
import 'package:one_key/pages/login/web_page.dart';
import 'package:one_key/pages/message/message_order_menu.dart';
... ... @@ -1186,3 +1188,10 @@ var tableManagerPageHandle = new Handler(
child: TableManagerPage(guest: guest),
);
});
///账号登录页面
var accountLoginPageHandle = new Handler(
handlerFunc: (BuildContext context, Map<dynamic, List<Object>> params) {
return ChangeNotifierProvider<OtherLoginProvider>(
create: (_) => OtherLoginProvider(), child: AccountLoginPage());
});
... ...
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart' hide Router;
import 'package:one_key/pages/login/login_page.dart';
import 'package:one_key/pages/login/login_page_f.dart';
import 'route_handles.dart';
... ... @@ -104,6 +105,8 @@ class Routes {
static String my_show_customer_list_page =
"/my_show_customer_list_page"; //仅展示的客户列表----我的
static String table_manager_page = "/table_manager_page"; //客情再次预订跳转的桌位预订页面
static String account_login_page = "/account_login_page"; //账号登录页面
static void configureRoutes(FluroRouter router) {
router.notFoundHandler = new Handler(
... ... @@ -212,5 +215,7 @@ class Routes {
router.define(my_show_customer_list_page,
handler: myShowCustomerListPageHandle);
router.define(table_manager_page, handler: tableManagerPageHandle);
router.define(account_login_page, handler: accountLoginPageHandle);
}
}
... ...
... ... @@ -857,46 +857,49 @@ class DialogUtil {
width: double.infinity,
height: ScreenUtil().setWidth(114) * 2 +
ScreenUtil().setWidth(114) +
ScreenUtil().setWidth(70),
decoration: BoxDecoration(
color: MyColours.color_ffffff,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(ScreenUtil().setWidth(40)),
topRight: Radius.circular(ScreenUtil().setWidth(40)))),
ScreenUtil().setWidth(70) -
ScreenUtil().setWidth(104),
color: Colors.transparent,
// decoration: BoxDecoration(
// color: MyColours.color_ffffff,
// borderRadius: BorderRadius.only(
// topLeft: Radius.circular(ScreenUtil().setWidth(40)),
// topRight: Radius.circular(ScreenUtil().setWidth(40)))),
child: Column(
children: <Widget>[
VEmptyView(60),
Container(
height: ScreenUtil().setWidth(44),
alignment: Alignment.center,
child: Text(phone,
style: TextStyle(
color: MyColours.color_666666,
fontSize: ScreenUtil().setSp(36)))),
VEmptyView(60),
// Container(
// height: ScreenUtil().setWidth(44),
// alignment: Alignment.center,
// child: Text(phone,
// style: TextStyle(
// color: MyColours.color_666666,
// fontSize: ScreenUtil().setSp(36)))),
// VEmptyView(60),
InkWell(
child: Container(
width: double.infinity,
height: ScreenUtil().setWidth(114),
alignment: Alignment.topCenter,
color: MyColours.color_ffffff,
// color: MyColours.color_404040,
child: Container(
width: ScreenUtil().setWidth(670),
height: ScreenUtil().setWidth(84),
alignment: Alignment.center,
decoration: BoxDecoration(
color: MyColours.color_f5f5f5,
color: MyColours.color_404040,
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(42))),
BorderRadius.circular(ScreenUtil().setWidth(8))),
child: Text(
"呼叫",
"呼叫 $phone",
style: TextStyle(
color: MyColours.color_666666,
fontSize: ScreenUtil().setSp(28)),
color: MyColours.color_6097F4,
fontSize: ScreenUtil().setSp(32)),
),
)),
onTap: () {
Navigator.of(context).pop();
Utils.goPhone(phone);
},
),
InkWell(
... ... @@ -904,20 +907,21 @@ class DialogUtil {
width: double.infinity,
height: ScreenUtil().setWidth(114),
alignment: Alignment.topCenter,
color: MyColours.color_ffffff,
// color: MyColours.color_2C2C2C,
child: Container(
width: ScreenUtil().setWidth(670),
height: ScreenUtil().setWidth(84),
alignment: Alignment.center,
decoration: BoxDecoration(
color: MyColours.color_f5f5f5,
color: MyColours.color_2C2C2C,
borderRadius:
BorderRadius.circular(ScreenUtil().setWidth(42))),
BorderRadius.circular(ScreenUtil().setWidth(8))),
child: Text(
"取消",
style: TextStyle(
color: MyColours.color_666666,
fontSize: ScreenUtil().setSp(28)),
fontWeight: FontWeight.bold,
color: MyColours.color_5688F3,
fontSize: ScreenUtil().setSp(32)),
),
)),
onTap: () {
... ... @@ -2063,6 +2067,141 @@ class DialogUtil {
);
}
static Future openAlertDialogLogin(BuildContext context, double height,
{GestureTapCallback onTap, double fontSize = 36}) async {
final action = await showDialog(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return Center(
child: Container(
padding:
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(72)),
height: ScreenUtil().setWidth(height),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(ScreenUtil().setWidth(30))),
child: Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(ScreenUtil().setWidth(30)))), //设置圆角
child: Column(
children: [
VEmptyView(40),
Container(
height: ScreenUtil().setWidth(48),
alignment: Alignment.center,
child: Text('欢迎使用一键订',
style: TextStyle(
fontSize: ScreenUtil().setSp(fontSize),
fontWeight: FontWeight.bold,
color: MyColours.color_333333)),
),
VEmptyView(40),
Container(
// height: ScreenUtil().setWidth(80),
// color: Colors.red,
padding: EdgeInsets.symmetric(
horizontal: ScreenUtil().setWidth(68)),
alignment: Alignment.center,
child: Transform.translate(
offset: Offset(
0,
ScreenUtil().setWidth(2) /
ScreenUtil()
.setWidth(2)), //1为 StrutStyle 的 leading的值
child: Text(
'登录一键订前,请先阅读并同意',
style: TextStyle(
color: MyColours.color_333333,
fontSize: ScreenUtil().setSp(30),
),
strutStyle: StrutStyle(
forceStrutHeight: true,
height: ScreenUtil().setWidth(0.8),
leading: ScreenUtil().setWidth(2)),
),
)),
VEmptyView(10),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () {
NavigatorUtil.goWebPage(context, '软件服务协议', "xy");
},
child: Padding(
padding:
EdgeInsets.only(top: ScreenUtil().setWidth(2)),
child: Text(
'《软件服务协议》',
style: TextStyle(
fontSize: ScreenUtil().setSp(27),
color: MyColours.color_2264FF),
)),
),
Padding(
padding:
EdgeInsets.only(top: ScreenUtil().setWidth(2)),
child: Text('及',
style: TextStyle(
fontSize: ScreenUtil().setSp(27),
color: MyColours.color_353535))),
InkWell(
onTap: () {
NavigatorUtil.goWebPage(context, '隐私政策', "zc");
},
child: Padding(
padding:
EdgeInsets.only(top: ScreenUtil().setWidth(2)),
child: Text('《隐私政策》',
style: TextStyle(
fontSize: ScreenUtil().setSp(27),
color: MyColours.color_2264FF))),
)
],
),
VEmptyView(60),
MyDivider(double.infinity, ScreenUtil().setWidth(2),
color: MyColours.color_efefef),
InkWell(
child: Container(
height: ScreenUtil().setWidth(50 * 2),
alignment: Alignment.center,
child: Text(
'我已阅读并同意',
style: TextStyle(
color: MyColours.color_2264FF,
fontSize: ScreenUtil().setWidth(38)),
),
),
onTap: onTap,
),
MyDivider(double.infinity, ScreenUtil().setWidth(2),
color: MyColours.color_efefef),
InkWell(
child: Container(
height: ScreenUtil().setWidth(50 * 2),
alignment: Alignment.center,
child: Text(
'暂不同意',
style: TextStyle(
color: MyColours.color_999999,
fontSize: ScreenUtil().setWidth(38)),
),
),
onTap: () {
Navigator.pop(context);
},
)
],
),
),
),
);
},
);
}
static Future openAlertDialog(BuildContext context, String title,
String content, String btnTitle, double height,
{GestureTapCallback onTap, double fontSize = 36}) async {
... ...