admin
2022-01-20 d8ef9a783b9e0b2a495f02fdf3daaf27ef49e99d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import 'dart:convert';
 
import 'package:flutter/cupertino.dart';
import '../api/http.dart';
import 'package:shared_preferences/shared_preferences.dart';
 
class ConfigUtil {
  ///保存配置信息
  static void saveConfig(Map<String, dynamic> map) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    await prefs.setString("config_value", jsonEncode(map));
  }
 
  static Future<String?> getConfig(String key) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    String? result = prefs.getString("config_value");
    if (result != null) {
      Map<String, dynamic> map = jsonDecode(result);
      return map[key];
    } else {
      //重新请求
      ConfigApiUtil.getConfig().then((value) {
        if (value == null) {
          return;
        }
        if (value["code"] == 0) {
          saveConfig(value["data"]);
        }
      });
    }
    return null;
  }
}
 
class ConfigKey {
  //客服
  static const String kefu = "kefu";
 
  //教程
  static const String course = "course";
 
  //注销
  static const String unRegister = "unRegister";
 
  //隐私投诉
  static const String privacyComplain = "privacyComplain";
 
  //会员链接
  static const String vipLink = "vipLink";
 
  //三方SDK链接
  static const String sdkList = "sdkList";
}
 
enum SharePlatform { wx, wxcircle, qq, qqzone, sina }