checkModuleUpdate: function (supplier_id, module_type, ver, category_id, callback) {
var me = this;
$http({
'url': me.options.info_cloud_url + 'rest/Sys/S_Sys_Ota/GetNewVersionV2/?key=' + module_type + '&supplier=' + supplier_id + '&categoryid=' + category_id,
'method': 'get',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': localStorage.authorization
}
//transformRequest: transformRequest
}).success(function (moduleVersion) {
console.info('服务器version与本地ver对比', moduleVersion, ver);
if (moduleVersion) {
if (typeof (moduleVersion.key) != 'undefined') {
//转为整形进行判断
var reg=/^\d+$/;
if (reg.test(moduleVersion.key) && reg.test(ver)) {
if (parseInt( moduleVersion.version) > parseInt(ver)) callback(moduleVersion);
}
}
}
}, function () {
toast("无法连接服务器,请检查您的网络。");
});
},
““““““““““““““““““““`调用
_data.checkModuleUpdate(provider_no, module_model, module_version, module_cateogry, function (moduleVersion) {
console.info('moduleVersion,准备升级模块', moduleVersion);
//是否要升级模块?跳转到Login
$ionicActionSheet.show({
buttons: [
{ text: '确定' }
],
titleText: '机器端有新的程序可以升级,是否升级?',
destructiveText: '取消',
destructiveButtonClicked: function () {
return true;
},
buttonClicked: function (index) {
//发一个升级指令
me.sendCommand({
command: { command: '1b 00' },
callbacksuccess: function () {
$ionicLoading.show({
template: '机器端升级中,请勿进行其它操作...'
});
}
});
return true;
}
});
});