| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import 'package:flutter/rendering.dart';
- import 'package:get/get.dart';
- import 'package:get/get_core/src/get_main.dart';
- import 'package:injectable/injectable.dart';
- import 'package:keyboard/base/base_controller.dart';
- import 'package:keyboard/module/about/about_page.dart';
- import 'package:keyboard/module/feedback/feedback_page.dart';
- import '../../data/consts/error_code.dart';
- import '../../data/repository/account_repository.dart';
- import '../../resource/string.gen.dart';
- import '../../utils/http_handler.dart';
- import '../../utils/toast_util.dart';
- @injectable
- class MineController extends BaseController {
- final AccountRepository accountRepository;
- MineController(this.accountRepository);
- bool get isLogin => accountRepository.isLogin.value;
- String? get phone => accountRepository.loginPhoneNum.value;
- String getUserName() {
- if (isLogin || phone != null && phone!.length > 4) {
- return '${StringName.mineAccountLoggedDesc}${phone!.substring(phone!.length - 4)}';
- } else {
- return StringName.mineAccountNoLogin;
- }
- }
- clickVip() {
- debugPrint('clickVip');
- }
- clickOnlineCustomerService() {
- debugPrint('clickOnlineCustomerService');
- accountRepository
- .loginUserLogin("11223344551", "1122")
- .then((data) {
- Get.back();
- ToastUtil.show(StringName.loginSuccess);
- })
- .catchError((error) {
- if (error is LoginTooOftenException) {
- ToastUtil.show(StringName.loginTooOftenToast);
- return;
- }
- if (error is ServerErrorException) {
- if (error.code == ErrorCode.verificationCodeError) {
- ToastUtil.show(StringName.loginVerificationCodeErrorToast);
- } else {
- ToastUtil.show(error.message);
- }
- } else {
- ToastUtil.show(StringName.loginFailedToast);
- }
- });
- }
- clickTutorials() {
- debugPrint('clickTutorials');
- }
- clickPersonalProfile() {
- debugPrint('clickPersonalProfile');
- accountRepository.setUserInfo(name: "老铁",birthday: "2021-03-17",gender: 1,hobbies: ["a","b","c"],characters: ["测试"]);
- }
- clickFeedback() {
- debugPrint('clickFeedback');
- FeedbackPage.start();
- }
- clickAboutUs() {
- debugPrint('clickAboutUs');
- AboutPage.start();
- }
- }
|