Commit 8f45b79c3e04e6f48ec196e6f7be809d31e28ca3

Authored by gaiyaguang
1 parent 311c2135

版本更新

... ... @@ -2,13 +2,14 @@
* 更新版本
*/
class Version{
String version;//更新版本号
String name;//更新版本号
String version;//构建版本号
String file_url;//安装包下载地址
String content;//更新内容
Version();
factory Version.fromJson(Map<String,dynamic> json)=>Version()..version=json["version"]..file_url=json["file_url"]..content=json["content"];
factory Version.fromJson(Map<String,dynamic> json)=>Version()..name=json["name"]..version=json["version"]..file_url=json["file_url"]..content=json["content"];
Map<String,dynamic> toJson()=><String,dynamic>{"version":version,"file_url":file_url,"content":content};
Map<String,dynamic> toJson()=><String,dynamic>{name:"name","version":version,"file_url":file_url,"content":content};
}
\ No newline at end of file
... ...
... ... @@ -37,8 +37,8 @@ class MyPageState extends State<MyPage>{
//检查版本更新
checkUpdate(){
// UpdateModel updateModel=new UpdateModel();
// updateModel.checkUpdate(context);
UpdateModel updateModel=new UpdateModel();
updateModel.checkUpdate(context);
}
@override
... ...
... ... @@ -29,10 +29,14 @@ class UpdateModel {
String deviceId = await Utils.getUUID();
UserModel userModel = Provider.of<UserModel>(context, listen: false);
int versionCode = await Utils.getCurrBuildNum();
String make="3";
if(Platform.isIOS)make="4";
Map<String, String> params = {
"deviceId": deviceId,
"sid": userModel.user.sellerid,
"versionCode": versionCode.toString()
"versionCode": versionCode.toString(),
"flag":"4",
"make":make,//3 android 4 ios
};
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.get, HttpUrl.check_update, data: params)
... ... @@ -41,12 +45,13 @@ class UpdateModel {
});
if (baseResp.code == Constant.status_success) {
LogUtil.v(baseResp.data);
Map<String, String> dataMap = baseResp.data[0];
if (int.parse(dataMap["version"]) > versionCode) {
Map<String, dynamic> dataMap = baseResp.data[0];
if (int.parse(dataMap["version"].toString()) > versionCode) {
Version version = Version.fromJson({
"version": dataMap["versionName"],
"file_url":dataMap["file_url"],
"content": dataMap["content"]
"name":dataMap["name"].toString(),
"version": dataMap["version"].toString(),
"file_url":dataMap["file_url"].toString(),
"content": dataMap["content"].toString()
});
showUpdateDialog(context, version);
}
... ... @@ -93,7 +98,7 @@ class UpdateModel {
children: <Widget>[
Center(
child: Text(
"${version.version}版本更新啦",
"${version.name}版本更新啦",
style: TextStyle(
fontSize: ScreenUtil().setSp(36),
color: MyColours.color_353535),
... ...