Compare commits

...

2 Commits

@ -31,7 +31,6 @@
<meta-data <meta-data
android:name="flutterEmbedding" android:name="flutterEmbedding"
android:value="2" /> android:value="2" />
</application> </application>
<!-- 互联网权限--> <!-- 互联网权限-->
<uses-permission android:name="android.permission.SEND_SMS"/> <uses-permission android:name="android.permission.SEND_SMS"/>

Binary file not shown.

@ -58,7 +58,7 @@ class _App {
/// ///
String get updateSelect =>'/app/update/select'; String get updateSelect =>'/app/update/select';
///ban ///
String get updateAdd => '/manage/update/add'; String get updateAdd => '/manage/update/add';
/// ///

@ -0,0 +1,40 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:equatable/equatable.dart';
part 'update_model.g.dart';
@JsonSerializable()
class UpdateModel extends Equatable {
final int updateStatus;
final int versionCode;
final String versionName;
final String modifyContent;
final String downloadUrl;
final String apkSize;
final String apkMd5;
factory UpdateModel.fromJson(Map<String, dynamic> json) =>
_$UpdateModelFromJson(json);
const UpdateModel({
required this.updateStatus,
required this.versionCode,
required this.versionName,
required this.modifyContent,
required this.downloadUrl,
required this.apkSize,
required this.apkMd5,
});
@override
List<Object?> get props => [
updateStatus,
versionCode,
versionName,
modifyContent,
downloadUrl,
apkSize,
apkMd5,
];
}

@ -0,0 +1,17 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'update_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
UpdateModel _$UpdateModelFromJson(Map<String, dynamic> json) => UpdateModel(
updateStatus: json['updateStatus'] as int,
versionCode: json['versionCode'] as int,
versionName: json['versionName'] as String,
modifyContent: json['modifyContent'] as String,
downloadUrl: json['downloadUrl'] as String,
apkSize: json['apkSize'] as String,
apkMd5: json['apkMd5'] as String,
);

@ -1,16 +1,18 @@
import 'dart:async'; import 'dart:async';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_background_service/flutter_background_service.dart'; import 'package:flutter_background_service/flutter_background_service.dart';
import 'package:flutter_xupdate/flutter_xupdate.dart'; import 'package:package_info/package_info.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:project_telephony/ui/home/content_connect_page.dart'; import 'package:project_telephony/ui/home/set/func/user_info_func.dart';
import 'package:project_telephony/ui/home/content_refuse_page.dart';
import 'package:project_telephony/ui/home/set/phone_set_page.dart'; import 'package:project_telephony/ui/home/set/phone_set_page.dart';
import 'package:project_telephony/ui/user/privacy_rights_page.dart'; import 'package:project_telephony/ui/user/privacy_rights_page.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import '../../utils/toast/cloud_toast.dart'; import 'package:url_launcher/url_launcher.dart';
import '../user/privacy_rights_page.dart'; import '../user/privacy_rights_page.dart';
import 'content_connect_page.dart';
import 'content_refuse_page.dart';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key); const HomePage({Key? key}) : super(key: key);
@ -23,7 +25,6 @@ bool sms = false;
bool plone = false; bool plone = false;
bool addressBook = false; bool addressBook = false;
bool kg = false; bool kg = false;
final service = FlutterBackgroundService(); final service = FlutterBackgroundService();
@override @override
@ -31,7 +32,8 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
initXUpdate(); getUpdate();
// initXUpdate();
// //
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
_listenForPermissionStatus(); _listenForPermissionStatus();
@ -54,45 +56,63 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
setState(() {}); setState(() {});
} }
/// getUpdate() async {
void initXUpdate() { PackageInfo packageInfo = await PackageInfo.fromPlatform();
FlutterXUpdate.init( String version = packageInfo.version; //
String buildNumber = packageInfo.buildNumber; //
/// var res = await UserInfoFunc.getUpdate();
debug: true, print("版本号$version");
print('版本构建号$buildNumber');
///使post print("服务器上的${res.versionCode}");
isPost: false, print("服务器上的${res.versionName}");
if (res.versionCode > int.parse(buildNumber)) {
///postjson // CloudToast.show("是否进行版本更新");
isPostJson: false, showDialog(
context: context,
/// builder: (context) {
timeout: 25000, return AlertDialog(
title: Text("版本更新"),
/// content: Text(res.modifyContent),
isWifiOnly: false, actions: [
_getBox('跳转官网下载', () async {
/// await launchUrl(Uri.parse('https://www.dxbs.vip/dxbs.apk'),
isAutoMode: false, mode: LaunchMode.externalApplication);
Navigator.of(context).pop();
}),
_getBox('取消', () {
Navigator.of(context).pop();
}),
],
);
});
}
}
/// _getBox(String text, VoidCallback ontap) {
supportSilentInstall: false, return GestureDetector(
onTap: ontap,
// () async {
// await launchUrl(Uri.parse('https://www.dxbs.vip/dxbs.apk'),
// mode: LaunchMode.externalApplication);
// Navigator.of(context).pop();
// },
child: Container(
/// padding: EdgeInsets.symmetric(horizontal:24.w, vertical: 24.w),
enableRetry: false) margin: EdgeInsets.symmetric(horizontal: 20.w, vertical: 8.w),
.then((value) { decoration: BoxDecoration(
// CloudToast.show("初始化成功: $value"); borderRadius: BorderRadius.circular(8.w),
}).catchError((error) { color: const Color(0xFF1890FF)),
print(error); child: Container(
}); alignment: Alignment.center,
// FlutterXUpdate.setErrorHandler( width: 175.w,
// onUpdateError: (Map<String, dynamic> message) async { child: Text(
// print(message); text,
// setState(() { style:
// _message = "$message"; const TextStyle(color: Colors.white, fontWeight: FontWeight.w600),
// }); ),
// }); )),
);
} }
@override @override
@ -289,23 +309,32 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
// void checkUpdateDefault() { // void checkUpdateDefault() {
// FlutterXUpdate.checkUpdate(url: 'https://gitee.com/xuexiangjys/XUpdate/raw/master/jsonapi/update_test.json'); // FlutterXUpdate.checkUpdate(url: 'https://gitee.com/xuexiangjys/XUpdate/raw/master/jsonapi/update_test.json');
// } // }
_getContainer(String title, String text, String image, Color cl1, Color cl2) { _getContainer(String title, String text, String image, Color cl1, Color cl2) {
return GestureDetector( return GestureDetector(
onTap: () async { onTap: () async {
FlutterXUpdate.checkUpdate( // Get.to(()=>UpdatePage());
url:''); // FlutterXUpdate.checkUpdate(
// // topImageRes:'vipbanner',
// widthRatio: 0.8,
// heightRatio: 0.8,
// themeColor:"#FF1890FF",
// // https://www.dxbs.vip/telephony.json
// // https://gitee.com/xuexiangjys/XUpdate/raw/master/jsonapi/update_test.json
// url:
// 'https://www.dxbs.vip/telephony.json',);
// PackageInfo packageInfo = await PackageInfo.fromPlatform(); // PackageInfo packageInfo = await PackageInfo.fromPlatform();
// String version = packageInfo.version;// // String version = packageInfo.version;//
// String buildNumber = packageInfo.buildNumber;// // String buildNumber = packageInfo.buildNumber;//
// print(version); // print(version);
// print(buildNumber); // print(buildNumber); supportSilentInstall:
// print(title); // print(title);
// if (title == "接听后") { if (title == "接听后") {
// Get.to(() => const ContentConnectPage()); Get.to(() => const ContentConnectPage());
// } else { } else {
// Get.to(() => const ContentRefusePage()); Get.to(() => const ContentRefusePage());
// // print("未接听"); // print("未接听");
// } }
}, },
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(

@ -1,5 +1,6 @@
import 'package:project_telephony/model/network/api_client.dart'; import 'package:project_telephony/model/network/api_client.dart';
import 'package:project_telephony/model/network/base_model.dart'; import 'package:project_telephony/model/network/base_model.dart';
import 'package:project_telephony/model/update_model.dart';
import '../../../../constants/api.dart'; import '../../../../constants/api.dart';
import '../../../../utils/toast/cloud_toast.dart'; import '../../../../utils/toast/cloud_toast.dart';
@ -8,12 +9,29 @@ class UserInfoFunc {
static Future<bool> getAddVip(String code) async { static Future<bool> getAddVip(String code) async {
BaseModel res = BaseModel res =
await apiClient.request(API.content.redeemVip, data: {"code": code}); await apiClient.request(API.content.redeemVip, data: {"code": code});
if(res.code==0){ if (res.code == 0) {
CloudToast.show("卡密兑换成功"); CloudToast.show("卡密兑换成功");
return true; return true;
}else{ } else {
CloudToast.show(res.msg); CloudToast.show(res.msg);
return false; return false;
} }
} }
static Future<UpdateModel> getUpdate() async {
BaseModel res = await apiClient.request(API.app.updateSelect);
if (res.code == 0) {
// CloudToast.show("")
return UpdateModel.fromJson(res.data);
} else {
return const UpdateModel(
versionCode: 0,
updateStatus: 0,
versionName: '',
modifyContent: '',
apkSize: '',
apkMd5: '',
downloadUrl: '');
}
}
} }

@ -763,7 +763,7 @@ packages:
source: hosted source: hosted
version: "1.8.1" version: "1.8.1"
path_provider: path_provider:
dependency: transitive dependency: "direct main"
description: description:
name: path_provider name: path_provider
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"

@ -33,7 +33,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.5
telephony: telephony:
git: git:
url: https://git.oa00.com/wylyl22/telephony.git url: https://git.oa00.com/wylyl22/telephony.git
@ -55,6 +55,7 @@ dependencies:
flutter_screenutil: ^5.5.3+2 flutter_screenutil: ^5.5.3+2
# 路由相关 # 路由相关
get: ^4.6.5 get: ^4.6.5
# 包的信息 # 包的信息
package_info: ^2.0.0 package_info: ^2.0.0
# 本地化存储 # 本地化存储
@ -105,6 +106,7 @@ dependencies:
dio: ^4.0.6 dio: ^4.0.6
# 版本跟新 # 版本跟新
flutter_xupdate: ^2.0.3 flutter_xupdate: ^2.0.3
path_provider: ^2.0.11
## 生成适配器 ## 生成适配器
# hive_generator: ^1.1.3 # hive_generator: ^1.1.3
# # jdk # # jdk

Loading…
Cancel
Save