| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import 'dart:convert';
- import 'package:bbyyy/beans/login_information_bean_entity.dart';
- import 'package:bbyyy/beans/user_bean_entity.dart';
- import 'package:bbyyy/my_tools/event_bus.dart';
- import 'package:disable_screenshots/disable_screenshots.dart';
- import 'package:package_info/package_info.dart';
- import 'package:shared_preferences/shared_preferences.dart';
- import 'my_apis.dart';
- String appName = '梆梆鱼';
- class MyCookie {
- MyCookie._internal() {
- // initP();
- }
- //保存单例
- static MyCookie _singleton = new MyCookie._internal();
- //工厂构造函数
- factory MyCookie() => _singleton;
- // String server = '172.16.104.34';
- String server = 'bby.banghuo.net';
- // String server = '39.108.225.84';
- SharedPreferences prefs;
- PackageInfo packageInfo;
- UserBeanDataData userBean;
- DisableScreenshots plugin;
- double balance;
- MyLocation location;
- bool haveNoPay = false;
- bool underReview = true;
- bool switching = false;
- int reNum = 0;
- getUT() {
- return '${MyApis.getApi('user')}=${loginInformation.data.user}&${MyApis.getApi('token')}=${loginInformation.data.token}';
- }
- getServer() {
- return 'https://$server:4001';
- }
- initP() async {
- prefs = await SharedPreferences.getInstance();
- if(prefs.getString('serverID')==null||prefs.getString('serverID').isEmpty){
- prefs.setString('serverID', '0');
- }
- packageInfo = await PackageInfo.fromPlatform();
- EventBus().emit('packageInfo');
- plugin = DisableScreenshots();
- if (prefs.getBool('收入进账提示音') == null) {
- prefs.setBool('收入进账提示音', true);
- }
- if (prefs.getBool('聊天新消息提示音') == null) {
- prefs.setBool('聊天新消息提示音', true);
- }
- }
- LoginInformationBeanEntity loginInformation;
- saveLoginInformationBeanEntity(
- LoginInformationBeanEntity loginInformationBeanEntity) {
- prefs.setString(
- 'LoginInformationBeanEntity', json.encode(loginInformationBeanEntity));
- loginInformation = loginInformationBeanEntity;
- }
- LoginInformationBeanEntity getLoginInformation() {
- if (loginInformation == null) {
- try {
- loginInformation = LoginInformationBeanEntity.fromJson(
- json.decode(prefs.getString('LoginInformationBeanEntity')));
- } catch (e) {
- return null;
- }
- return loginInformation;
- } else {
- return loginInformation;
- }
- }
- getUser() {
- return loginInformation.data.user;
- }
- String getToken() {
- return loginInformation.data.token;
- }
- getUID() {
- return loginInformation.data.extra.uid;
- }
- clean() {
- loginInformation = null;
- prefs.remove('LoginInformationBeanEntity');
- // prefs.clear();
- }
- String getName() {
- return loginInformation.data.extra.name;
- }
- String getPic() {
- return loginInformation.data.extra.picture;
- }
- }
- class MyLocation{
- String province;
- String city;
- String formattedAddress;
- String district;
- double latitude;
- double longitude;
- MyLocation(
- {this.province,
- this.city,
- this.district,
- this.formattedAddress,
- this.latitude,
- this.longitude});
- }
|