import 'dart:async' show Future; import './net_utils.dart'; import '../model/user_info.dart'; import 'package:flutter_go/api/api.dart'; class DataUtils { // 登陆获取用户信息 static Future doLogin(Map params) async { var response = await NetUtils.post(Api.DO_LOGIN, params); try { UserInformation userInfo = UserInformation.fromJson(response['data']); return userInfo; } catch (err) { return response['message']; } } // 获取用户信息 static Future getUserInfo(Map params) async { var response = await NetUtils.get(Api.GET_USER_INFO, params); try { UserInformation userInfo = UserInformation.fromJson(response['data']); return userInfo; } catch (err) { return response['message']; } } // 验证登陆 static Future checkLogin() async { var response = await NetUtils.get(Api.CHECK_LOGIN); try { if (response['success']) { UserInformation userInfo = UserInformation.fromJson(response['data']); return userInfo; } else { return response['success']; } } catch (err) { return response['message']; } } // 退出登陆 static Future logout() async { var response = await NetUtils.get(Api.LOGOUT); print('退出登陆 $response'); return response['success']; } }