diff --git a/lib/common/request/apis.dart b/lib/common/request/apis.dart index 9d73ee8..45dfbb2 100644 --- a/lib/common/request/apis.dart +++ b/lib/common/request/apis.dart @@ -71,6 +71,9 @@ class Apis { /// get static const String homePopup = 'home/popup'; + /// 兑换 + static const String exchange = '/exchange'; + /// 获取阿里云oss鉴权信息 static const String aliyunOssSts = 'oss/sts/upload'; } diff --git a/lib/common/request/dao/request_dao.dart b/lib/common/request/dao/request_dao.dart new file mode 100644 index 0000000..ee814e8 --- /dev/null +++ b/lib/common/request/dao/request_dao.dart @@ -0,0 +1,9 @@ +import '../request_client.dart'; + +class RequestDao { + ///视频跟读提交结果 + static Future exchange(code) async { + var data = await requestClient.post(Apis.exchange,data: {'code':code}); + return data; + } +} \ No newline at end of file diff --git a/lib/pages/login/forgetpwd/forget_password_home_page.dart b/lib/pages/login/forgetpwd/forget_password_home_page.dart index a92c11b..4f2f3f7 100644 --- a/lib/pages/login/forgetpwd/forget_password_home_page.dart +++ b/lib/pages/login/forgetpwd/forget_password_home_page.dart @@ -48,36 +48,36 @@ class _ForgetPasswordHomePageView extends StatelessWidget { } Widget _buildForgetPwdView() => BlocBuilder(builder: (context, state) { - final bloc = BlocProvider.of(context); - return Scaffold( - body: Container( - color: Colors.white, - child: SafeArea( - child: SingleChildScrollView( - child: Padding( - padding: EdgeInsets.only(left: 49.w, right: 10.w), - child: Column( + final bloc = BlocProvider.of(context); + return Scaffold( + body: Container( + color: Colors.white, + child: SafeArea( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.only(left: 49.w, right: 10.w), + child: Column( + children: [ + 34.verticalSpace, + Row( children: [ - 34.verticalSpace, - Row( - children: [ - Image.asset( - 'wow_logo'.assetPng, - height: 49.w, - width: 83.5.h, - ), - 12.5.horizontalSpace, - Text( - '修改密码\n请输入您的手机号和验证码吧', - style: TextStyle(fontSize: 16.sp, color: const Color(0xFF666666)), - ) - ], + Image.asset( + 'wow_logo'.assetPng, + height: 49.w, + width: 83.5.h, ), - Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - child: Column( + 12.5.horizontalSpace, + Text( + '修改密码\n请输入您的手机号和验证码吧', + style: TextStyle(fontSize: 16.sp, color: const Color(0xFF666666)), + ) + ], + ), + Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Column( children: [ 44.5.verticalSpace, Row( @@ -90,15 +90,15 @@ class _ForgetPasswordHomePageView extends StatelessWidget { 15.horizontalSpace, Expanded( child: TextFieldCustomerWidget( - height: 50.h, - hitText: '请输入当前手机号', - textInputType: TextInputType.phone, - bgImageName: 'Input_layer_up', - onChangeValue: (String value) { - bloc.add(PhoneNumChangeEvent()); - }, - controller: bloc.phoneNumController, - )) + height: 50.h, + hitText: '请输入当前手机号', + textInputType: TextInputType.phone, + bgImageName: 'Input_layer_up', + onChangeValue: (String value) { + bloc.add(PhoneNumChangeEvent()); + }, + controller: bloc.phoneNumController, + )) ], ), 11.5.verticalSpace, @@ -113,14 +113,14 @@ class _ForgetPasswordHomePageView extends StatelessWidget { 18.5.horizontalSpace, Expanded( child: TextFieldCustomerWidget( - hitText: '请输入验证码', - bgImageName: 'Input_layer_down', - onChangeValue: (String value) { - bloc.add(CheckCodeChangeEvent()); - }, - textInputType: TextInputType.emailAddress, - controller: bloc.checkNumController, - )), + hitText: '请输入验证码', + bgImageName: 'Input_layer_down', + onChangeValue: (String value) { + bloc.add(CheckCodeChangeEvent()); + }, + textInputType: TextInputType.emailAddress, + controller: bloc.checkNumController, + )), 16.5.horizontalSpace, TimerWidget( pageType: 1, @@ -131,39 +131,39 @@ class _ForgetPasswordHomePageView extends StatelessWidget { ) ], )), - 2.verticalSpace, - Image.asset( - 'steven_bride'.assetPng, - height: 173.h, - width: 157.w, - ) - ], - ), - GestureDetector( - onTap: () { - if (bloc.canSetPwd) { - bloc.add(SetPassWordEvent()); - } - }, - child: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage(bloc.canSetPwd ? 'login_enter'.assetPng : 'login_enter_dis'.assetPng), - fit: BoxFit.fill), - ), - padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 14.h), - child: Text( - '确定', - style: TextStyle(fontSize: 16.sp, color: Colors.white), - ), - ), + 2.verticalSpace, + Image.asset( + 'steven_bride'.assetPng, + height: 173.h, + width: 157.w, ) ], ), - ), + GestureDetector( + onTap: () { + if (bloc.canSetPwd) { + bloc.add(SetPassWordEvent()); + } + }, + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage(bloc.canSetPwd ? 'login_enter'.assetPng : 'login_enter_dis'.assetPng), + fit: BoxFit.fill), + ), + padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 14.h), + child: Text( + '确定', + style: TextStyle(fontSize: 16.sp, color: Colors.white), + ), + ), + ) + ], ), ), ), - ); - }); + ), + ), + ); + }); } diff --git a/lib/pages/login/loginpage/bloc/login_bloc.dart b/lib/pages/login/loginpage/bloc/login_bloc.dart index 075839b..7739b79 100644 --- a/lib/pages/login/loginpage/bloc/login_bloc.dart +++ b/lib/pages/login/loginpage/bloc/login_bloc.dart @@ -70,6 +70,9 @@ class LoginBloc extends Bloc { } var checkKey = _isSmsLoginType ? 'smsCode' : 'password'; var type = _isSmsLoginType ? 'sms_code' : 'pwd'; + if (type == 'pwd') {//md5加密 + checkNumber = EncryptUtil.encodeMd5(checkNumber); + } try { await loading(() async { diff --git a/lib/pages/login/loginpage/login_page.dart b/lib/pages/login/loginpage/login_page.dart index fa29f95..662c911 100644 --- a/lib/pages/login/loginpage/login_page.dart +++ b/lib/pages/login/loginpage/login_page.dart @@ -38,152 +38,152 @@ class _LoginPageView extends StatelessWidget { } Widget _buildLoginViewWidget() => BlocBuilder( - builder: (context, state) { - final bloc = BlocProvider.of(context); - return Scaffold( - body: SafeArea( - child: SingleChildScrollView( - child: Container( - padding: EdgeInsets.only(top: 25.h), - child: Stack( - children: [ - Positioned( - right: 29.w, - child: GestureDetector( - onTap: () => bloc.add(ChangeLoginTypeEvent()), - child: Container( - decoration: BoxDecoration( - image: DecorationImage(image: AssetImage('login_logo'.assetPng), fit: BoxFit.fill), - ), - padding: EdgeInsets.symmetric(horizontal: 18.w, vertical: 5.h), - child: Text( - bloc.isSmsLoginType ? '密码登录' : '验证码登录', - style: TextStyle(fontSize: 16.sp), - ), - ), - )), - Center( - child: Column( + builder: (context, state) { + final bloc = BlocProvider.of(context); + return Scaffold( + body: SafeArea( + child: SingleChildScrollView( + child: Container( + padding: EdgeInsets.only(top: 25.h), + child: Stack( + children: [ + Positioned( + right: 29.w, + child: GestureDetector( + onTap: () => bloc.add(ChangeLoginTypeEvent()), + child: Container( + decoration: BoxDecoration( + image: DecorationImage(image: AssetImage('login_logo'.assetPng), fit: BoxFit.fill), + ), + padding: EdgeInsets.symmetric(horizontal: 18.w, vertical: 5.h), + child: Text( + bloc.isSmsLoginType ? '密码登录' : '验证码登录', + style: TextStyle(fontSize: 16.sp), + ), + ), + )), + Center( + child: Column( + children: [ + Image.asset( + 'wow_logo'.assetPng, + height: 81.h, + width: 131.w, + ), + Offstage( + offstage: !bloc.isSmsLoginType, + child: _buildSmsViewWidget(), + ), + Offstage( + offstage: bloc.isSmsLoginType, + child: _buildPwdViewWidget(), + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, children: [ - Image.asset( - 'wow_logo'.assetPng, - height: 81.h, - width: 131.w, - ), - Offstage( - offstage: !bloc.isSmsLoginType, - child: _buildSmsViewWidget(), - ), - Offstage( - offstage: bloc.isSmsLoginType, - child: _buildPwdViewWidget(), - ), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - GestureDetector( - onTap: () => bloc.add(AgreementChangeEvent()), - child: Icon(bloc.agreement ? Icons.check_circle_outlined : Icons.circle_outlined, - color: bloc.agreement ? Colors.green : Colors.black), - ), - 6.horizontalSpace, - RichText( - text: TextSpan(children: [ - TextSpan( - text: '我已阅读并同意', - style: TextStyle( - fontSize: 12.sp, - color: const Color(0xFF333333), - )), - TextSpan( - text: '《用户隐私协议》', - style: TextStyle( - fontSize: 12.sp, - color: const Color(0xFF333333), - ), - recognizer: TapGestureRecognizer() - ..onTap = () { - Navigator.of(context).pushNamed(AppRouteName.webView, arguments: { - 'urlStr': AppConsts.userPrivacyPolicyUrl, - 'webViewTitle': '用户隐私协议' - }); - }), - TextSpan( - text: ',', style: TextStyle(fontSize: 12.sp, color: const Color(0xFF333333))), - TextSpan( - text: '《儿童隐私政策》', - style: TextStyle(fontSize: 12.sp, color: const Color(0xFF333333)), - recognizer: TapGestureRecognizer() - ..onTap = () { - Navigator.of(context).pushNamed(AppRouteName.webView, arguments: { - 'urlStr': AppConsts.childrenPrivacyPolicyUrl, - 'webViewTitle': '儿童隐私协议' - }); - }) - ]), - ) - ], - ), GestureDetector( - onTap: () { - if (bloc.canLogin) { - bloc.add(RequestLoginEvent()); - } - }, - child: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage( - bloc.canLogin ? 'login_enter'.assetPng : 'login_enter_dis'.assetPng), - fit: BoxFit.fill), - ), - padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 14.h), - child: Text( - '登录', - style: TextStyle(fontSize: 16.sp), - ), - ), + onTap: () => bloc.add(AgreementChangeEvent()), + child: Icon(bloc.agreement ? Icons.check_circle_outlined : Icons.circle_outlined, + color: bloc.agreement ? Colors.green : Colors.black), + ), + 6.horizontalSpace, + RichText( + text: TextSpan(children: [ + TextSpan( + text: '我已阅读并同意', + style: TextStyle( + fontSize: 12.sp, + color: const Color(0xFF333333), + )), + TextSpan( + text: '《用户隐私协议》', + style: TextStyle( + fontSize: 12.sp, + color: const Color(0xFF333333), + ), + recognizer: TapGestureRecognizer() + ..onTap = () { + Navigator.of(context).pushNamed(AppRouteName.webView, arguments: { + 'urlStr': AppConsts.userPrivacyPolicyUrl, + 'webViewTitle': '用户隐私协议' + }); + }), + TextSpan( + text: ',', style: TextStyle(fontSize: 12.sp, color: const Color(0xFF333333))), + TextSpan( + text: '《儿童隐私政策》', + style: TextStyle(fontSize: 12.sp, color: const Color(0xFF333333)), + recognizer: TapGestureRecognizer() + ..onTap = () { + Navigator.of(context).pushNamed(AppRouteName.webView, arguments: { + 'urlStr': AppConsts.childrenPrivacyPolicyUrl, + 'webViewTitle': '儿童隐私协议' + }); + }) + ]), ) ], ), - ) - ], - ), - ), + GestureDetector( + onTap: () { + if (bloc.canLogin) { + bloc.add(RequestLoginEvent()); + } + }, + child: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage( + bloc.canLogin ? 'login_enter'.assetPng : 'login_enter_dis'.assetPng), + fit: BoxFit.fill), + ), + padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 14.h), + child: Text( + '登录', + style: TextStyle(fontSize: 16.sp), + ), + ), + ) + ], + ), + ) + ], ), ), - ); - }, + ), + ), ); + }, + ); Widget _buildSmsViewWidget() => BlocBuilder(builder: (context, state) { - final bloc = BlocProvider.of(context); - return Padding( - padding: EdgeInsets.symmetric(horizontal: 135.w), - child: Column( + final bloc = BlocProvider.of(context); + return Padding( + padding: EdgeInsets.symmetric(horizontal: 135.w), + child: Column( + children: [ + 15.verticalSpace, + TextFieldCustomerWidget( + height: 55.h, + hitText: '请输入手机号', + textInputType: TextInputType.phone, + bgImageName: 'Input_layer_up', + onChangeValue: (String value) { + bloc.add(PhoneNumChangeEvent()); + }, + controller: bloc.phoneNumController, + ), + 6.5.verticalSpace, + Text( + '未注册用户登录默认注册', + style: TextStyle(fontSize: 12.sp, color: const Color(0xFF999999)), + ), + 4.5.verticalSpace, + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - 15.verticalSpace, - TextFieldCustomerWidget( - height: 55.h, - hitText: '请输入手机号', - textInputType: TextInputType.phone, - bgImageName: 'Input_layer_up', - onChangeValue: (String value) { - bloc.add(PhoneNumChangeEvent()); - }, - controller: bloc.phoneNumController, - ), - 6.5.verticalSpace, - Text( - '未注册用户登录默认注册', - style: TextStyle(fontSize: 12.sp, color: const Color(0xFF999999)), - ), - 4.5.verticalSpace, - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Expanded( - child: TextFieldCustomerWidget( + Expanded( + child: TextFieldCustomerWidget( height: 50.h, hitText: '请输入验证码', textInputType: TextInputType.number, @@ -193,35 +193,35 @@ class _LoginPageView extends StatelessWidget { }, controller: bloc.checkNumController, )), - TimerWidget( - canSendSms: bloc.canSendSms, - sendSmsEvent: () => bloc.add(RequestSmsCodeEvent()), - ) - ], + TimerWidget( + canSendSms: bloc.canSendSms, + sendSmsEvent: () => bloc.add(RequestSmsCodeEvent()), ) ], - ), - ); - }); + ) + ], + ), + ); + }); Widget _buildPwdViewWidget() => BlocBuilder(builder: (context, state) { - final bloc = BlocProvider.of(context); - return Padding( - padding: EdgeInsets.symmetric(horizontal: 90.w), - child: Column( + final bloc = BlocProvider.of(context); + return Padding( + padding: EdgeInsets.symmetric(horizontal: 90.w), + child: Column( + children: [ + 15.verticalSpace, + Row( + mainAxisAlignment: MainAxisAlignment.center, children: [ - 15.verticalSpace, - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - 'phone'.assetPng, - height: 45.h, - width: 35.w, - ), - 10.5.horizontalSpace, - Expanded( - child: TextFieldCustomerWidget( + Image.asset( + 'phone'.assetPng, + height: 45.h, + width: 35.w, + ), + 10.5.horizontalSpace, + Expanded( + child: TextFieldCustomerWidget( height: 50.h, hitText: '请输入手机号', textInputType: TextInputType.phone, @@ -231,51 +231,52 @@ class _LoginPageView extends StatelessWidget { }, controller: bloc.phoneNumController, )), - 5.horizontalSpace, - SizedBox( - width: 100.w, - height: 55.h, - ) - ], + 5.horizontalSpace, + SizedBox( + width: 100.w, + height: 55.h, + ) + ], + ), + 12.verticalSpace, + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + 'lock'.assetPng, + height: 34.h, + width: 31.w, ), - 12.verticalSpace, - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Image.asset( - 'lock'.assetPng, - height: 34.h, - width: 31.w, - ), - 10.5.horizontalSpace, - Expanded( - child: TextFieldCustomerWidget( + 10.5.horizontalSpace, + Expanded( + child: TextFieldCustomerWidget( hitText: '请输入密码', + obscureText: true, bgImageName: 'Input_layer_down', onChangeValue: (String value) { bloc.add(CheckFieldChangeEvent()); }, controller: bloc.checkNumController, )), - 5.horizontalSpace, - GestureDetector( - onTap: () { - Navigator.of(context).pushNamed(AppRouteName.fogPwd); - }, - child: Container( - width: 100.w, - height: 55.h, - alignment: Alignment.centerLeft, - child: Text( - '忘记密码 ?', - style: TextStyle(fontSize: 12.sp), - ), - ), - ) - ], + 5.horizontalSpace, + GestureDetector( + onTap: () { + Navigator.of(context).pushNamed(AppRouteName.fogPwd); + }, + child: Container( + width: 100.w, + height: 55.h, + alignment: Alignment.centerLeft, + child: Text( + '忘记密码 ?', + style: TextStyle(fontSize: 12.sp), + ), + ), ) ], - ), - ); - }); + ) + ], + ), + ); + }); } diff --git a/lib/pages/login/setpwd/bloc/set_pwd_bloc.dart b/lib/pages/login/setpwd/bloc/set_pwd_bloc.dart index ede2b78..662e4d7 100644 --- a/lib/pages/login/setpwd/bloc/set_pwd_bloc.dart +++ b/lib/pages/login/setpwd/bloc/set_pwd_bloc.dart @@ -1,3 +1,4 @@ +import 'package:common_utils/common_utils.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:wow_english/common/request/dao/user_dao.dart'; @@ -128,11 +129,12 @@ class SetPwdBloc extends Bloc { /// 设置密码,调接口 void _setPassword(SetPasswordEvent event, Emitter emitter) async { + var password = EncryptUtil.encodeMd5(passwordText); try { await loading(() async { switch (pageType) { case SetPwdPageType.initPwd: - await UserDao.initPassword(passwordText); + await UserDao.initPassword(password); break; case SetPwdPageType.changePwd: // 现在走同一个流程和接口 @@ -145,7 +147,7 @@ class SetPwdBloc extends Bloc { if (smsCode == null || smsCode!.isEmpty) { throw ApiException(ApiException.customErrorCode, '验证码为空'); } - await UserDao.resetPassword(phoneNumber!, passwordText, smsCode!); + await UserDao.resetPassword(phoneNumber!, password, smsCode!); break; } }); diff --git a/lib/pages/shop/exchane/bloc/exchange_lesson_bloc.dart b/lib/pages/shop/exchane/bloc/exchange_lesson_bloc.dart index 27dc483..0b7432e 100644 --- a/lib/pages/shop/exchane/bloc/exchange_lesson_bloc.dart +++ b/lib/pages/shop/exchane/bloc/exchange_lesson_bloc.dart @@ -1,5 +1,10 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:wow_english/common/request/exception.dart'; +import 'package:wow_english/utils/loading.dart'; +import 'package:wow_english/utils/toast_util.dart'; + +import '../../../../common/request/dao/request_dao.dart'; part 'exchange_lesson_event.dart'; part 'exchange_lesson_state.dart'; @@ -32,6 +37,13 @@ class ExchangeLessonBloc extends Bloc } _requestCheckCode(CheckCodeEvent event, Emitter emitter) async { - emitter(CheckCodeResultState(false)); + try { + await loading(() async { + await RequestDao.exchange(codeNumberController.text); + emitter(CheckCodeResultState(true)); + }); + } catch (e) { + emitter(CheckCodeResultState(false)); + } } } diff --git a/lib/pages/shop/exchane/exchange_lesson_page.dart b/lib/pages/shop/exchane/exchange_lesson_page.dart index f7ab1b0..e640eec 100644 --- a/lib/pages/shop/exchane/exchange_lesson_page.dart +++ b/lib/pages/shop/exchane/exchange_lesson_page.dart @@ -5,7 +5,6 @@ import 'package:wow_english/common/extension/string_extension.dart'; import 'package:wow_english/common/widgets/textfield_customer_widget.dart'; import 'package:wow_english/pages/shop/exchane/widegts/exchange_result_dialog.dart'; import 'package:wow_english/route/route.dart'; -import 'package:wow_english/utils/toast_util.dart'; import 'bloc/exchange_lesson_bloc.dart'; @@ -34,7 +33,7 @@ class _ExchangeLessonPage extends StatelessWidget { return ExChangeResultDialog( resultType:state.result, onTap:(){ - + popPage(); } ); }); diff --git a/lib/pages/shop/exchangelist/bloc/exchange_list_bloc.dart b/lib/pages/shop/exchangelist/bloc/exchange_list_bloc.dart index bccf206..72438cf 100644 --- a/lib/pages/shop/exchangelist/bloc/exchange_list_bloc.dart +++ b/lib/pages/shop/exchangelist/bloc/exchange_list_bloc.dart @@ -1,7 +1,5 @@ -import 'dart:async'; - -import 'package:bloc/bloc.dart'; -import 'package:meta/meta.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; part 'exchange_list_event.dart'; part 'exchange_list_state.dart';