var url = '网络地址';
//APP升级
var wait;
function update(){
//判断操作系统
var system = 'android';
if(mui.os.ios){
system = 'ios';
}
mui.getJSON(url+'/apicommon/update/index',{
app:'cooperatives',
system:system,
version:plus.runtime.version
},function(data){
//data = JSON.stringify(data);
if(data.code==){
var APPInfo = data.data;
if(APPInfo.colum=='full'){
mui.confirm(APPInfo.brief, APPInfo.name, ['稍后','立即升级'], function(e) {
if(e.index==){
if(system=='android'){
//当苹果调整进市场下载
plus.runtime.openURL(APPInfo.url);
plus.nativeUI.closeWaiting();
}else{
wait = plus.nativeUI.showWaiting("下载升级文件",{width:'100%',height:'100%',round:,background:'rgba(0,0,0,0.3)'});
//当安卓及其他下载
var dtask = plus.downloader.createDownload(url+APPInfo.url, {}, function(d, status){
if(status == ){
console.log(d.filename);
wait.setTitle("安装APP更新");
plus.runtime.install(d.filename,{},function(){
plus.nativeUI.closeWaiting();
mui.alert('应用安装完成', '升级成功', '确认重启', function(e) {
plus.runtime.restart();
});
delFile(d.filename);
},function(e){
plus.nativeUI.closeWaiting();
mui.toast('安装失败');
delFile(d.filename);
});
} else {
plus.nativeUI.closeWaiting();
mui.toast('下载失败');
}
});
dtask.addEventListener("statechanged", onStateChanged, false);
dtask.start();
}
}
});
}else{
var dtask = plus.downloader.createDownload(url+APPInfo.url, {}, function(d, status){
if(status == ){
plus.runtime.install(d.filename,{},function(){
delFile(d.filename);
},function(e){
delFile(d.filename);
});
}
});
dtask.start();
}
//plus.navigator.closeSplashscreen();
}
});
}
function onStateChanged(download, status) {
wait.setTitle((download.downloadedSize/( * )).toFixed()+'MB/'+(download.totalSize/( * )).toFixed()+'MB');
}
function delFile(filename) {
plus.io.resolveLocalFileSystemURL(filename, function(entry) {
entry.remove();
});
} //打开新窗口
function opens(url,data){
mui.openWindow({
url:url,
id:url,
waiting:{
autoShow:false,
},
show:{
aniShow:"pop-in"
},
extras:data
});
}
//登录窗口
function login_open(url,data){
mui.openWindow({
url:url,
id:url,
waiting:{
autoShow:false,
},
show:{
aniShow:"slide-in-bottom"
},
extras:data
});
}
//登录窗口
function search_open(url,data){
mui.openWindow({
url:url,
id:url,
waiting:{
autoShow:false,
},
show:{
aniShow:"none"
},
extras:data
});
}
//监听状态栏
mui.ready(function() {});
mui.plusReady(function() {}); /* mui.ajax(url+'apicommon/update/index',{
data:{
app:'cooperatives',
system:'ios',
version:plus.runtime.version
},
dataType:'json',//服务器返回json格式数据
type:'post',//HTTP请求类型
success:function(data){
console.log('加载:3');
response = JSON.stringify(data);
console.log('加载:'+response);
plus.navigator.closeSplashscreen();
},
error:function(xhr,type,errorThrown){
//异常处理;
console.log('异常:'+type);
}
}); */

app每次更新版本时调用js代码提示用户下载更新的更多相关文章

  1. 在Java中直接调用js代码(转载)

    http://blog.csdn.net/xzyxuanyuan/article/details/8062887 JDK1.6版添加了新的ScriptEngine类,允许用户直接执行js代码. 在Ja ...

  2. 在Java中直接调用js代码

    JDK1.6版添加了新的ScriptEngine类,允许用户直接执行js代码. 在Java中直接调用js代码 不能调用浏览器中定义的js函数,会抛出异常提示ReferenceError: “alert ...

  3. 解决VSCode中使用vetur插件格式化vue文件时,js代码会自动加上冒号和分号

    解决VSCode中使用vetur插件格式化vue文件时,js代码会自动加上冒号和分号 在设置中把"vetur.format.defaultFormatter.js": " ...

  4. Zend Studio 上 安装使用Aptana插件(html,css,js代码提示功能) .

    最近装了zend studio 9.0 用了段时间发现写html,css,js代码没提示,要开dreamwaver(对js代码提示也不好).就网上搜索了下,发现了Aptana插件,装上用了下,感觉不错 ...

  5. 【前端】js代码模拟用户键盘鼠标输入

    js代码模拟用户键盘鼠标输入 原生js var event = new Event('mousewheel'); event.wheelDelta = 360 document.dispatchEve ...

  6. <a>标签中的href如何调用js代码

    在HTML中,<a>标签的href属性用于指定超链接的目标的URL.在所有浏览器中,链接的默认外观是: 未被访问的链接带有下划线而且是蓝色的 已被访问的链接带有下划线而且是紫色的 活动链接 ...

  7. python 调用js代码

    Python2   安装pyv8 pip install-egit://github.com/brokenseal/PyV8-OS-X#egg=pyv8 from pyv8 import PyV8 c ...

  8. dropdownlist值改变时调用js

    DropDownList的OnSelectedIndexChanged方法是服务器端方法如要用需要设置AutoPostBack选项为true,并且在服务器后台写方法 要调用js方法需要onchange ...

  9. OC 调用JS 代码 处理HTML5 实战

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; ...

随机推荐

  1. c++11の顺序容器

      容器是一种容纳特定类型对象的集合.C++的容器可以分为两类:顺序容器和关联容器.顺序容器的元素排列和元素值大小无关,而是由元素添加到容器中的次序决定的.标准库定义了三种顺序容器的类型:vector ...

  2. centos6.8 安装jenkins

    1.使用yum安装java环境 #查看CentOS自带JDK是否已安装yum list installed |grep java #查看yum库中的Java安装包yum -y list java*#以 ...

  3. antd form 自定义验证表单使用方法

    import React from 'react'; import classNames from 'classnames'; export default class FormClass exten ...

  4. consumer zookeeper is not a recognized option

    kafka 创建消费者报错 consumer zookeeper is not a recognized option 在做kafka测试的时候,使用命令bin/kafka-console-consu ...

  5. ajax属性详解

    https://blog.csdn.net/mooncom/article/details/52402836 资料库: $.ajaxSetup()方法为将来的ajax请求设置默认值. http://w ...

  6. TCP/IP协议、UDP协议、 Http协议

    开放式系统互联通信参考模型(Open System Interconnection Reference Model,缩写为 OSI),简称为OSI模型(OSI model),一种概念模型,由国际标准化 ...

  7. 基于Vue cli生成的Vue项目的webpack4升级

    前面的话 本文将详细介绍从webpack3到webpack4的升级过程 概述 相比于webpack3,webpack4可以零配置运行,打包速度比之前提高了90%,可以直接到ES6的代码进行无用代码剔除 ...

  8. 1.promethues监控融入k8s

    文档链接地址 https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_confi ...

  9. JS获取浏览器地址栏的多个参数值的任意值

    getParamValue("id"); //http://localhost:2426/TransactionNotes.aspx?id=100 //返回值是100: // 根据 ...

  10. hdu-4612(无向图缩点+树的直径)

    题意:给你n个点和m条边的无向图,问你如果多加一条边的话,那么这个图最少的桥是什么 解题思路:无向图缩点和树的直径,用并查集缩点: #include<iostream> #include& ...