| | |
| | | |
| | | typedef OnHttpRequestStart = void Function(); |
| | | |
| | | _showLoading(BuildContext context) { |
| | | showLoading(BuildContext context) { |
| | | //先丢失焦点 |
| | | FocusScope.of(context).unfocus(); |
| | | //开启加载框 |
| | |
| | | return EncryptUtil.MD5(signStr); |
| | | } |
| | | |
| | | static Future<HttpRequestResult> baseRequest( |
| | | String api, Map<String, dynamic> params, OnHttpRequestStart? onStart, |
| | | {bool notifyError = false}) async { |
| | | // params ??= {}; |
| | | static Future<Map<String, dynamic>> getBaseParams( |
| | | Map<String, dynamic>? params) async { |
| | | params ??= {}; |
| | | |
| | | if (Platform.isAndroid) { |
| | | if (_androidInfo == null) { |
| | |
| | | } |
| | | |
| | | params["sign"] = _getSign(params); |
| | | |
| | | return params; |
| | | } |
| | | |
| | | static Future<HttpRequestResult> baseRequest( |
| | | String api, Map<String, dynamic> params, OnHttpRequestStart? onStart, |
| | | {bool notifyError = false}) async { |
| | | // params ??= {}; |
| | | params = await getBaseParams(params); |
| | | |
| | | var httpClient = HttpClient(); |
| | | httpClient.connectionTimeout = const Duration(seconds: 20); |
| | |
| | | BuildContext context, String phone) async { |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/sms/sendSMS", {"phone": phone}, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | params["uid"] = uid.toString(); |
| | | } |
| | | |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/user/uploadPushRegId", params, () { |
| | | }); |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/user/uploadPushRegId", params, () {}); |
| | | if (result.success) { |
| | | return result.data; |
| | | } |
| | |
| | | |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/user/loginPhone", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }, notifyError: true); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | type.toString().substring(type.toString().indexOf(".") + 1); |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/location/addLocationUser", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | |
| | | _dismissDialog(context); |
| | |
| | | |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/location/updateLocationUser", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | var params = {"uid": uid.toString(), "id": id}; |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/location/deleteLocationUser", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/sos/addEmergencyContacts", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/sos/deleteEmergencyContacts", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | |
| | | var result = await HttpUtil.baseRequest( |
| | | "/api/v1/sos/updateEmergencyContacts", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/sos/addSOSRecord", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/sos/clearSOSRecord", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }); |
| | | _dismissDialog(context); |
| | | if (result.success) { |
| | |
| | | params["content"] = content; |
| | | var result = |
| | | await HttpUtil.baseRequest("/api/v1/feedback/advice", params, () { |
| | | _showLoading(context); |
| | | showLoading(context); |
| | | }, notifyError: true); |
| | | |
| | | _dismissDialog(context); |
| | |
| | | double width = MediaQuery.of(context).size.width; |
| | | double height = MediaQuery.of(context).size.height; |
| | | |
| | | Widget? splash = CSJAdUtil.loadSplash("887634894",width,height-94, (success, msg) { |
| | | |
| | | Widget? splash = AdUtil.loadSplash(await AdUtil.getAdInfo(AdPosition.splash),width,height-94, (success, msg) { |
| | | NavigatorUtil.navigateToNextPageWithFinish(context, |
| | | MaterialPageRoute(builder: (context) { |
| | | return MainPage(title: ""); |
| | |
| | | |
| | | Future requestPermission() async { |
| | | await PermissionUtil.openPermission(Permission.phone); |
| | | await PermissionUtil.openPermission(Permission.locationAlways); |
| | | await PermissionUtil.openPermission(PermissionUtil.getLocationPermission()); |
| | | return; |
| | | } |
| | | |
| | |
| | | Expanded( |
| | | child: WebView( |
| | | //http://192.168.3.122:8848/test/JsTest.html |
| | | initialUrl: "http://192.168.3.122:8848/base/JsTest.html", |
| | | initialUrl: "http://192.168.3.122:8848/location/abountOur/tousu.html", |
| | | onWebViewCreated: (WebViewController webViewController) { |
| | | _webViewController = webViewController; |
| | | |
| | |
| | | }); |
| | | }); |
| | | |
| | | Permission.locationAlways.status.then((value) { |
| | | PermissionUtil.getLocationPermission().status.then((value) { |
| | | setState(() { |
| | | locationPermissionStatus = value; |
| | | }); |
| | |
| | | child: InkWell( |
| | | onTap: () { |
| | | PermissionUtil.openPermission( |
| | | Permission.locationAlways, |
| | | PermissionUtil.getLocationPermission(), |
| | | force: true) |
| | | .then((value) { |
| | | setState(() { |
| | |
| | | _tabController = |
| | | TabController(length: _pages.length, initialIndex: 1, vsync: this); |
| | | super.initState(); |
| | | CSJAdUtil.loadInterstitial("947240112"); |
| | | |
| | | // CSJAdUtil.loadReward("947239184", (success, msg) { |
| | | // |
| | | // print("success:$success msg:$msg"); |
| | | // |
| | | // }); |
| | | |
| | | AdUtil.getAdInfo(AdPosition.homeInterstitial).then((value) { |
| | | AdUtil.loadInterstitial(value, (success, msg) {}); |
| | | }); |
| | | } |
| | | |
| | | //设置选中的导航栏 |
| | |
| | | return; |
| | | } |
| | | |
| | | Widget ad = CSJAdUtil.loadExpress( |
| | | "947239180", MediaQuery.of(context).size.width - 20, 200, |
| | | |
| | | Widget? ad = AdUtil.loadExpress( |
| | | await AdUtil.getAdInfo(AdPosition.mineExpress), MediaQuery.of(context).size.width - 20, 200, |
| | | (success, msg) { |
| | | adDeleted = true; |
| | | setState(() { |
| | |
| | | if (deleteAd && expressAd == null) { |
| | | return; |
| | | } |
| | | Widget ad = CSJAdUtil.loadExpress( |
| | | "947239180", MediaQuery.of(context).size.width - 20, 190, |
| | | (success, msg) { |
| | | Widget? ad = AdUtil.loadExpress( |
| | | await AdUtil.getAdInfo(AdPosition.searchExpress), |
| | | MediaQuery.of(context).size.width - 20, |
| | | 190, (success, msg) { |
| | | setState(() { |
| | | expressAd = null; |
| | | deleteAd = true; |
| | |
| | | //banner广告 |
| | | Widget? _banner; |
| | | |
| | | loadBanner() { |
| | | loadBanner() async { |
| | | if (_banner != null) { |
| | | return; |
| | | } |
| | | Widget ad = CSJAdUtil.loadBanner( |
| | | "947242084", |
| | | Widget? ad = AdUtil.loadBanner( |
| | | await AdUtil.getAdInfo(AdPosition.searchResultBanner), |
| | | MediaQuery.of(context).size.width, |
| | | MediaQuery.of(context).size.width / 4, (success, msg) { |
| | | setState(() { |
| | |
| | | double? distance; |
| | | if (Global.currentPosition != null) { |
| | | distance = await MapUtil.getDistance( |
| | | Global.currentPosition!, BMFCoordinate.fromMap(info!.pt!.toMap())); |
| | | Global.currentPosition!, BMFCoordinate.fromMap(info.pt!.toMap())); |
| | | } |
| | | distance ??= 0; |
| | | info.distance = distance.toInt(); |
| | |
| | | endDate ??= DateTime.now(); |
| | | startDate ??= DateTime(2000, 1, 1); |
| | | _requestTravel(); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | //获取轨迹 |
| | |
| | | } else { |
| | | ToastUtil.toast(result["msg"]); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | void _onRefresh() async { |
| | |
| | | : _locationList!.length), |
| | | itemBuilder: (BuildContext context, int index) { |
| | | if (_locationList!.isEmpty) { |
| | | return |
| | | Container( |
| | | padding: EdgeInsets.only(top: 50), |
| | | alignment: Alignment.center, |
| | | child: const Text("暂无数据")); |
| | | return Container( |
| | | padding: EdgeInsets.only(top: 50), |
| | | alignment: Alignment.center, |
| | | child: const Text("暂无数据")); |
| | | } else { |
| | | return getListViewItem(index); |
| | | } |
| | |
| | | setState(() {}); |
| | | }); |
| | | |
| | | Timer(Duration(seconds: 2), (){ |
| | | AdUtil.getAdInfo(AdPosition.travelShareInterstitial).then((value) { |
| | | //插屏广告 |
| | | CSJAdUtil.loadInterstitial("947240112"); |
| | | AdUtil.loadInterstitial(value, (success, msg) {}); |
| | | }); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | _getPermissionState() async { |
| | | PermissionStatus status = await Permission.locationAlways.status; |
| | | PermissionStatus status = await PermissionUtil.getLocationPermission().status; |
| | | setState(() { |
| | | if (status == PermissionStatus.granted) { |
| | | _location = true; |
| | |
| | | checked: _location, |
| | | changed: (bool value) { |
| | | if (value) { |
| | | PermissionUtil.openPermission(Permission.locationAlways, |
| | | PermissionUtil.openPermission(PermissionUtil.getLocationPermission(), |
| | | force: true) |
| | | .then((value) { |
| | | if (value == PermissionStatus.granted) { |
| | |
| | | } |
| | | }); |
| | | } else { |
| | | PermissionUtil.closePermission(Permission.locationAlways).then((value) { |
| | | PermissionUtil.closePermission(PermissionUtil.getLocationPermission()).then((value) { |
| | | if (value == PermissionStatus.granted) { |
| | | setState(() { |
| | | _location = true; |
| | |
| | | |
| | | static void showSplashAd( |
| | | double width, double height, OnAdCallback adCallback) async { |
| | | var csjAppId = await ConfigUtil.getConfig(ConfigKey.csjAppId); |
| | | var gdtAppId = await ConfigUtil.getConfig(ConfigKey.gdtAppId); |
| | | if (StringUtil.isNullOrEmpty(csjAppId) && |
| | | StringUtil.isNullOrEmpty(gdtAppId)) { |
| | | adCallback(false, "appId为空"); |
| | | return; |
| | | //加载广告 |
| | | } |
| | | |
| | | static Widget? loadSplash(AdinfoModel? adInfo, double width, double height, |
| | | OnAdCallback adCallback) { |
| | | if (adInfo == null) { |
| | | adCallback(false, "广告信息为空"); |
| | | return null; |
| | | } |
| | | |
| | | var adInfo = await getAdInfo(AdPosition.splash); |
| | | if (adInfo == null) { |
| | | adCallback(false, "appId为空"); |
| | | return; |
| | | if (StringUtil.isNullOrEmpty(adInfo.type)) { |
| | | adCallback(false, "广告类型为空"); |
| | | return null; |
| | | } |
| | | |
| | | if (adInfo.type == "csj") { |
| | | CSJAdUtil.loadSplash(adInfo.pid!, width, height, (success, msg) {}); |
| | | return CSJAdUtil.loadSplash(adInfo.pid!, width, height, adCallback); |
| | | } else { |
| | | GDTAdUtil.loadSplash(adInfo.pid!, (success, msg) {}); |
| | | return GDTAdUtil.loadSplash(adInfo.pid!, width, height, adCallback); |
| | | } |
| | | } |
| | | |
| | | static Widget? loadBanner( |
| | | AdinfoModel? adInfo, double width, double height, OnAdCallback callback) { |
| | | if (adInfo == null) { |
| | | callback(false, "广告信息为空"); |
| | | return null; |
| | | } |
| | | |
| | | //加载广告 |
| | | if (StringUtil.isNullOrEmpty(adInfo.type)) { |
| | | callback(false, "广告类型为空"); |
| | | return null; |
| | | } |
| | | |
| | | if (adInfo.type == "csj") { |
| | | return CSJAdUtil.loadBanner(adInfo.pid!, width, height, callback); |
| | | } else { |
| | | return GDTAdUtil.loadBanner(adInfo.pid!, width, height, callback); |
| | | } |
| | | } |
| | | |
| | | static Widget? loadExpress( |
| | | AdinfoModel? adInfo, double width, double height, OnAdCallback callback) { |
| | | if (adInfo == null) { |
| | | callback(false, "广告信息为空"); |
| | | return null; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(adInfo.type)) { |
| | | callback(false, "广告类型为空"); |
| | | return null; |
| | | } |
| | | |
| | | if (adInfo.type == "csj") { |
| | | return CSJAdUtil.loadExpress(adInfo.pid!, width, height, callback); |
| | | } else { |
| | | return GDTAdUtil.loadExpress(adInfo.pid!, width, height, callback); |
| | | } |
| | | } |
| | | |
| | | static loadReward(AdinfoModel? adInfo, OnAdCallback callback) async { |
| | | if (adInfo == null) { |
| | | callback(false, "广告信息为空"); |
| | | return null; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(adInfo.type)) { |
| | | callback(false, "广告类型为空"); |
| | | return null; |
| | | } |
| | | |
| | | if (adInfo.type == "csj") { |
| | | return CSJAdUtil.loadReward(adInfo.pid!, callback); |
| | | } else { |
| | | return GDTAdUtil.loadReward(adInfo.pid!, callback); |
| | | } |
| | | } |
| | | |
| | | static loadInterstitial(AdinfoModel? adInfo, OnAdCallback callback) async { |
| | | if (adInfo == null) { |
| | | return null; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(adInfo.type)) { |
| | | return null; |
| | | } |
| | | |
| | | if (adInfo.type == "csj") { |
| | | CSJAdUtil.loadInterstitial(adInfo.pid!, callback); |
| | | } else { |
| | | GDTAdUtil.loadInterstitial(adInfo.pid!, callback); |
| | | } |
| | | } |
| | | |
| | | static Future<AdinfoModel?> getAdInfo(String position) async { |
| | |
| | | if (StringUtil.isNullOrEmpty(model.type)) { |
| | | return null; |
| | | } |
| | | return model; |
| | | } |
| | | } |
| | | |
| | | class CSJAdUtil { |
| | | static Future init() async { |
| | | var csjAppId = await ConfigUtil.getConfig(ConfigKey.csjAppId); |
| | | var csjAppId = "5240078"; |
| | | //初始化穿山甲 |
| | | if (!StringUtil.isNullOrEmpty(csjAppId)) { |
| | | // if (Platform.isAndroid) { |
| | |
| | | // } |
| | | |
| | | await FlutterUnionad.register( |
| | | androidAppId: csjAppId!, |
| | | androidAppId: csjAppId, |
| | | //穿山甲广告 Android appid 必填 |
| | | iosAppId: "", |
| | | //穿山甲广告 ios appid 必填 |
| | |
| | | ); |
| | | } |
| | | |
| | | static loadInterstitial(String pid) async { |
| | | static loadInterstitial(String pid, OnAdCallback adCallback) async { |
| | | FlutterUnionad.loadFullScreenVideoAdInteraction( |
| | | androidCodeId: pid, //android 全屏广告id 必填 |
| | | iosCodeId: "", //ios 全屏广告id 必填 |
| | |
| | | }, |
| | | onFail: (error) { |
| | | print("新模板渲染插屏广告错误 $error"); |
| | | adCallback(false, "新模板渲染插屏广告错误 $error"); |
| | | }, |
| | | onClose: () { |
| | | print("新模板渲染插屏广告关闭"); |
| | | adCallback(true, "新模板渲染插屏广告关闭"); |
| | | }, |
| | | onReady: () async { |
| | | print("新模板渲染插屏广告预加载准备就绪"); |
| | |
| | | |
| | | class GDTAdUtil { |
| | | static Future init() async { |
| | | var gdtAppId = await ConfigUtil.getConfig(ConfigKey.gdtAppId); |
| | | var gdtAppId = "1200343363"; |
| | | //初始化广点通 |
| | | if (!StringUtil.isNullOrEmpty(gdtAppId)) { |
| | | await FlutterTencentad.register( |
| | | androidId: gdtAppId!, //androidId |
| | | androidId: gdtAppId, //androidId |
| | | iosId: "", //iosId |
| | | debug: true, //是否显示日志log |
| | | ); |
| | | } |
| | | } |
| | | |
| | | static loadSplash(String? pid, OnAdCallback adCallback) { |
| | | if (pid == null) { |
| | | adCallback(false, "pid为空"); |
| | | return; |
| | | } |
| | | FlutterTencentad.splashAdView( |
| | | static Widget? loadSplash( |
| | | String? pid, double width, double height, OnAdCallback adCallback) { |
| | | return FlutterTencentad.splashAdView( |
| | | //android广告id |
| | | androidId: pid, |
| | | androidId: pid!, |
| | | //ios广告id |
| | | iosId: "", |
| | | ////设置开屏广告从请求到展示所花的最大时长(并不是指广告曝光时长),取值范围为[1500, 5000]ms |
| | |
| | | }, |
| | | onClose: () { |
| | | print("开屏广告关闭"); |
| | | adCallback(true, ""); |
| | | adCallback(true, "开屏广告关闭"); |
| | | }, |
| | | onExpose: () { |
| | | print("开屏广告曝光"); |
| | | }, |
| | | onFail: (code, message) { |
| | | adCallback(true, message); |
| | | adCallback(false, message); |
| | | }, |
| | | ), |
| | | ); |
| | | } |
| | | |
| | | static Widget loadBanner( |
| | | String pid, double width, double height, OnAdCallback callback) { |
| | | return FlutterTencentad.bannerAdView( |
| | | //android广告id |
| | | androidId: pid, |
| | | //ios广告id |
| | | iosId: "", |
| | | //广告宽 单位dp |
| | | viewWidth: width, |
| | | //广告高 单位dp 宽高比应该为6.4:1 |
| | | viewHeight: height, |
| | | // 广告回调 |
| | | callBack: FlutterTencentadBannerCallBack( |
| | | onShow: () { |
| | | print("Banner广告显示"); |
| | | }, |
| | | onFail: (code, message) { |
| | | print("Banner广告错误 $code $message"); |
| | | callback(false, "Banner广告错误 $code $message"); |
| | | }, |
| | | onClose: () { |
| | | print("Banner广告关闭"); |
| | | callback(true, "Banner广告关闭"); |
| | | }, |
| | | onExpose: () { |
| | | print("Banner广告曝光"); |
| | | }, |
| | | onClick: () { |
| | | print("Banner广告点击"); |
| | | }, |
| | | ), |
| | | ); |
| | | } |
| | | |
| | | static Widget loadExpress( |
| | | String pid, double width, double height, OnAdCallback callback) { |
| | | return FlutterTencentad.expressAdView( |
| | | //android广告id |
| | | androidId: pid, |
| | | //ios广告id |
| | | iosId: "", |
| | | //广告宽 单位dp |
| | | viewWidth: width.toInt(), |
| | | //广告高 单位dp |
| | | viewHeight: height.toInt(), |
| | | //回调事件 |
| | | callBack: FlutterTencentadExpressCallBack( |
| | | onShow: () { |
| | | print("动态信息流广告显示"); |
| | | }, |
| | | onFail: (code, message) { |
| | | print("动态信息流广告错误 $code $message"); |
| | | }, |
| | | onClose: () { |
| | | print("动态信息流广告关闭"); |
| | | }, |
| | | onExpose: () { |
| | | print("动态信息流广告曝光"); |
| | | }, |
| | | onClick: () { |
| | | print("动态信息流广告点击"); |
| | | }, |
| | | )); |
| | | } |
| | | |
| | | static loadReward(String pid, OnAdCallback adCallback) async { |
| | | await FlutterTencentad.loadRewardVideoAd( |
| | | //android广告id |
| | | androidId: pid, |
| | | //ios广告id |
| | | iosId: "", |
| | | //用户id |
| | | userID: "", |
| | | //奖励 |
| | | rewardName: "VIP", |
| | | //奖励数 |
| | | rewardAmount: 1, |
| | | //扩展参数 服务器回调使用 |
| | | customData: ""); |
| | | |
| | | FlutterTencentAdStream.initAdStream( |
| | | //激励广告 |
| | | flutterTencentadRewardCallBack: |
| | | FlutterTencentadRewardCallBack(onShow: () { |
| | | print("激励广告显示"); |
| | | }, onClick: () { |
| | | print("激励广告点击"); |
| | | }, onFail: (code, message) { |
| | | print("激励广告失败 $code $message"); |
| | | adCallback(false, "激励广告失败"); |
| | | }, onClose: () { |
| | | print("激励广告关闭"); |
| | | }, onReady: () async { |
| | | print("激励广告预加载准备就绪"); |
| | | await FlutterTencentad.showRewardVideoAd(); |
| | | }, onUnReady: () { |
| | | print("激励广告预加载未准备就绪"); |
| | | }, onVerify: (transId, rewardName, rewardAmount) { |
| | | print("激励广告奖励 $transId $rewardName $rewardAmount"); |
| | | adCallback(true, "激励广告奖励"); |
| | | }, onFinish: () { |
| | | print("激励广告完成"); |
| | | }), |
| | | ); |
| | | } |
| | | |
| | | static loadInterstitial(String pid, OnAdCallback adCallback) async { |
| | | await FlutterTencentad.loadUnifiedInterstitialAD( |
| | | //android广告id |
| | | androidId: pid, |
| | | //ios广告id |
| | | iosId: "", |
| | | //是否全屏 |
| | | isFullScreen: false, |
| | | ); |
| | | |
| | | FlutterTencentAdStream.initAdStream( |
| | | flutterTencentadInteractionCallBack: FlutterTencentadInteractionCallBack( |
| | | onShow: () { |
| | | print("插屏广告显示"); |
| | | }, |
| | | onClick: () { |
| | | print("插屏广告点击"); |
| | | }, |
| | | onFail: (code, message) { |
| | | print("插屏广告失败 $code $message"); |
| | | adCallback(false, "插屏广告失败 $code $message"); |
| | | }, |
| | | onClose: () { |
| | | print("插屏广告关闭"); |
| | | adCallback(true, "插屏广告关闭"); |
| | | }, |
| | | onReady: () async { |
| | | print("插屏广告预加载准备就绪"); |
| | | await FlutterTencentad.showUnifiedInterstitialAD(); |
| | | }, |
| | | onUnReady: () { |
| | | print("插屏广告预加载未准备就绪"); |
| | | }, |
| | | ), |
| | | ); |
| | |
| | | import 'package:locations/utils/global.dart'; |
| | | import 'package:locations/utils/push_util.dart'; |
| | | import 'package:package_info/package_info.dart'; |
| | | import 'package:device_info/device_info.dart'; |
| | | |
| | | class AppUtil { |
| | | static JPush _jpush = JPush(); |
| | |
| | | } |
| | | |
| | | //初始化广告 |
| | | await AdUtil.init(); |
| | | await AdUtil.init(); |
| | | |
| | | //初始化本地应用 |
| | | await _initNativeApp(); |
| | |
| | | try { |
| | | PushUtil.init(context); |
| | | } catch (e) {} |
| | | //初始化应用 |
| | | //初始化版本 |
| | | if (Platform.isAndroid) { |
| | | |
| | | DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); |
| | | AndroidDeviceInfo _androidInfo = await deviceInfo.androidInfo; |
| | | Global.androidSDK = _androidInfo.version.sdkInt; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //初始化广告 |
| | | static _initAd() async { |
| | | |
| | | } |
| | | |
| | | //本地应用初始化 |
| | |
| | | |
| | | //三方SDK链接 |
| | | static const String sdkList = "sdkList"; |
| | | |
| | | //穿山甲APPID |
| | | static const String csjAppId = "csjAppId"; |
| | | |
| | | //广点通APPID |
| | | static const String gdtAppId = "gdtAppId"; |
| | | } |
| | |
| | | |
| | | static String? utdId; |
| | | |
| | | //android的版本 |
| | | static int? androidSDK; |
| | | |
| | | static Future loadUtdId() async { |
| | | String? value = |
| | | await messageChannel.send({"method": "getUtdid"}) as String?; |
| | |
| | | |
| | | import 'package:flutter/widgets.dart'; |
| | | import 'package:fluttertoast/fluttertoast.dart'; |
| | | import 'package:locations/api/http.dart' as http; |
| | | import 'package:locations/utils/ad_util.dart'; |
| | | import 'package:locations/utils/user_util.dart'; |
| | | import 'package:webview_flutter/platform_interface.dart'; |
| | |
| | | case "getUid": |
| | | getUid(params, _callback); |
| | | break; |
| | | case "getBaseRequestParams": |
| | | case "getRequestBaseParams": |
| | | getBaseRequestParams(params, _callback); |
| | | break; |
| | | |
| | | case "showRewardVideoAd": |
| | | showRewardVideoAd(_callback); |
| | | break; |
| | | |
| | | case "showLoading": |
| | | showLoading(); |
| | | break; |
| | | case "hideLoading": |
| | | hideLoading(); |
| | | break; |
| | | case "finishPage": |
| | | finishPage(); |
| | | break; |
| | | } |
| | | })); |
| | |
| | | if (params != null) { |
| | | ps.addAll(params); |
| | | } |
| | | String result = jsonEncode(ps); |
| | | |
| | | if (callbackName != null) { |
| | | callback(callbackName, result); |
| | | } |
| | | http.HttpUtil.getBaseParams(params).then((value) { |
| | | String result = jsonEncode(value); |
| | | if (callbackName != null) { |
| | | callback(callbackName, result); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //展示激励视频 |
| | | showRewardVideoAd( String? callbackName) { |
| | | CSJAdUtil.loadReward("947239184", (success, msg) { |
| | | if (success) { |
| | | //成功 |
| | | if (callbackName != null) { |
| | | callback(callbackName, true); |
| | | showRewardVideoAd(String? callbackName) { |
| | | AdUtil.getAdInfo(AdPosition.vipReward).then((value) { |
| | | AdUtil.loadReward(value, (success, msg) { |
| | | if (success) { |
| | | //成功 |
| | | if (callbackName != null) { |
| | | callback(callbackName, true); |
| | | } |
| | | } else { |
| | | if (callbackName != null) { |
| | | callback(callbackName, false); |
| | | } |
| | | } |
| | | } else { |
| | | if (callbackName != null) { |
| | | callback(callbackName, false); |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | showLoading() { |
| | | http.showLoading(context); |
| | | } |
| | | |
| | | hideLoading() { |
| | | Navigator.of(context).pop(); |
| | | } |
| | | |
| | | //结束页面 |
| | | finishPage() { |
| | | Navigator.of(context).pop(); |
| | | } |
| | | |
| | | //保存图片 |
| | | saveImg(String url) { |
| | | //TODO |
| | | } |
| | | |
| | | //分享图片 |
| | | shareImg(String url, int type) { |
| | | //TODO |
| | | } |
| | | } |
| | |
| | | |
| | | ///请求定位权限 |
| | | static Future<PermissionStatus> requestLocationPermission() async { |
| | | final status = await PermissionUtil.openPermission(Permission.locationAlways); |
| | | final status = await PermissionUtil.openPermission(PermissionUtil.getLocationPermission()); |
| | | return status; |
| | | } |
| | | |
| | |
| | | import 'dart:convert'; |
| | | import 'dart:io'; |
| | | |
| | | import 'package:locations/utils/global.dart'; |
| | | import 'package:permission_handler/permission_handler.dart'; |
| | | import 'package:shared_preferences/shared_preferences.dart'; |
| | | |
| | |
| | | |
| | | class PermissionUtil { |
| | | static var deniedSets = Set(); |
| | | |
| | | static Permission getLocationPermission() { |
| | | if (Platform.isAndroid) { |
| | | //获取系统版本 |
| | | if (Global.androidSDK != null && Global.androidSDK! < 29) { |
| | | return Permission.locationAlways; |
| | | } else { |
| | | return Permission.location; |
| | | } |
| | | } else { |
| | | return Permission.locationAlways; |
| | | } |
| | | } |
| | | |
| | | static Future _loadDeniedPermissions() async { |
| | | //加载 |
| | |
| | | if (list != null) { |
| | | deniedSets.addAll(list); |
| | | } |
| | | |
| | | |
| | | print(jsonEncode(list)); |
| | | } |
| | | |
| | |
| | | PermissionStatus status = await permission.status; |
| | | PermissionStatus? resultStatus; |
| | | switch (status) { |
| | | //Android授权 |
| | | //Android授权 |
| | | case PermissionStatus.granted: |
| | | resultStatus = status; |
| | | break; |
| | | //Android拒绝 |
| | | //Android拒绝 |
| | | case PermissionStatus.denied: |
| | | if (deniedSets.contains(permission.value.toString()) && !force) { |
| | | resultStatus = PermissionStatus.denied; |
| | |
| | | resultStatus = await permission.request(); |
| | | } |
| | | break; |
| | | //Android禁止后不再提示 |
| | | //Android禁止后不再提示 |
| | | case PermissionStatus.permanentlyDenied: |
| | | if (deniedSets.contains(permission.value.toString()) && !force) { |
| | | resultStatus = PermissionStatus.permanentlyDenied; |
| | |
| | | resultStatus = await permission.status; |
| | | } |
| | | break; |
| | | //IOS |
| | | //IOS |
| | | case PermissionStatus.limited: |
| | | if (deniedSets.contains(permission.value.toString()) && !force) { |
| | | resultStatus = PermissionStatus.limited; |
| | |
| | | resultStatus = await permission.request(); |
| | | } |
| | | break; |
| | | //IOS |
| | | //IOS |
| | | case PermissionStatus.restricted: |
| | | if (deniedSets.contains(permission.value.toString()) && !force) { |
| | | resultStatus = PermissionStatus.restricted; |
| | |
| | | break; |
| | | } |
| | | |
| | | if(permission==Permission.locationAlways){ |
| | | if (permission == PermissionUtil.getLocationPermission()) { |
| | | eventBus.fire(UserLocationPermissionEventBus(resultStatus)); |
| | | } |
| | | |