Commit 8f45b79c3e04e6f48ec196e6f7be809d31e28ca3

Authored by gaiyaguang
1 parent 311c2135

版本更新

@@ -2,13 +2,14 @@ @@ -2,13 +2,14 @@
2 * 更新版本 2 * 更新版本
3 */ 3 */
4 class Version{ 4 class Version{
5 - String version;//更新版本号 5 + String name;//更新版本号
  6 + String version;//构建版本号
6 String file_url;//安装包下载地址 7 String file_url;//安装包下载地址
7 String content;//更新内容 8 String content;//更新内容
8 9
9 Version(); 10 Version();
10 11
11 - factory Version.fromJson(Map<String,dynamic> json)=>Version()..version=json["version"]..file_url=json["file_url"]..content=json["content"]; 12 + factory Version.fromJson(Map<String,dynamic> json)=>Version()..name=json["name"]..version=json["version"]..file_url=json["file_url"]..content=json["content"];
12 13
13 - Map<String,dynamic> toJson()=><String,dynamic>{"version":version,"file_url":file_url,"content":content}; 14 + Map<String,dynamic> toJson()=><String,dynamic>{name:"name","version":version,"file_url":file_url,"content":content};
14 } 15 }
@@ -37,8 +37,8 @@ class MyPageState extends State<MyPage>{ @@ -37,8 +37,8 @@ class MyPageState extends State<MyPage>{
37 37
38 //检查版本更新 38 //检查版本更新
39 checkUpdate(){ 39 checkUpdate(){
40 -// UpdateModel updateModel=new UpdateModel();  
41 -// updateModel.checkUpdate(context); 40 + UpdateModel updateModel=new UpdateModel();
  41 + updateModel.checkUpdate(context);
42 } 42 }
43 43
44 @override 44 @override
@@ -29,10 +29,14 @@ class UpdateModel { @@ -29,10 +29,14 @@ class UpdateModel {
29 String deviceId = await Utils.getUUID(); 29 String deviceId = await Utils.getUUID();
30 UserModel userModel = Provider.of<UserModel>(context, listen: false); 30 UserModel userModel = Provider.of<UserModel>(context, listen: false);
31 int versionCode = await Utils.getCurrBuildNum(); 31 int versionCode = await Utils.getCurrBuildNum();
  32 + String make="3";
  33 + if(Platform.isIOS)make="4";
32 Map<String, String> params = { 34 Map<String, String> params = {
33 "deviceId": deviceId, 35 "deviceId": deviceId,
34 "sid": userModel.user.sellerid, 36 "sid": userModel.user.sellerid,
35 - "versionCode": versionCode.toString() 37 + "versionCode": versionCode.toString(),
  38 + "flag":"4",
  39 + "make":make,//3 android 4 ios
36 }; 40 };
37 BaseResp<List> baseResp = await DioUtil() 41 BaseResp<List> baseResp = await DioUtil()
38 .request<List>(context, Method.get, HttpUrl.check_update, data: params) 42 .request<List>(context, Method.get, HttpUrl.check_update, data: params)
@@ -41,12 +45,13 @@ class UpdateModel { @@ -41,12 +45,13 @@ class UpdateModel {
41 }); 45 });
42 if (baseResp.code == Constant.status_success) { 46 if (baseResp.code == Constant.status_success) {
43 LogUtil.v(baseResp.data); 47 LogUtil.v(baseResp.data);
44 - Map<String, String> dataMap = baseResp.data[0];  
45 - if (int.parse(dataMap["version"]) > versionCode) { 48 + Map<String, dynamic> dataMap = baseResp.data[0];
  49 + if (int.parse(dataMap["version"].toString()) > versionCode) {
46 Version version = Version.fromJson({ 50 Version version = Version.fromJson({
47 - "version": dataMap["versionName"],  
48 - "file_url":dataMap["file_url"],  
49 - "content": dataMap["content"] 51 + "name":dataMap["name"].toString(),
  52 + "version": dataMap["version"].toString(),
  53 + "file_url":dataMap["file_url"].toString(),
  54 + "content": dataMap["content"].toString()
50 }); 55 });
51 showUpdateDialog(context, version); 56 showUpdateDialog(context, version);
52 } 57 }
@@ -93,7 +98,7 @@ class UpdateModel { @@ -93,7 +98,7 @@ class UpdateModel {
93 children: <Widget>[ 98 children: <Widget>[
94 Center( 99 Center(
95 child: Text( 100 child: Text(
96 - "${version.version}版本更新啦", 101 + "${version.name}版本更新啦",
97 style: TextStyle( 102 style: TextStyle(
98 fontSize: ScreenUtil().setSp(36), 103 fontSize: ScreenUtil().setSp(36),
99 color: MyColours.color_353535), 104 color: MyColours.color_353535),