app每次更新版本时调用js代码提示用户下载更新
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代码提示用户下载更新的更多相关文章
- 在Java中直接调用js代码(转载)
http://blog.csdn.net/xzyxuanyuan/article/details/8062887 JDK1.6版添加了新的ScriptEngine类,允许用户直接执行js代码. 在Ja ...
- 在Java中直接调用js代码
JDK1.6版添加了新的ScriptEngine类,允许用户直接执行js代码. 在Java中直接调用js代码 不能调用浏览器中定义的js函数,会抛出异常提示ReferenceError: “alert ...
- 解决VSCode中使用vetur插件格式化vue文件时,js代码会自动加上冒号和分号
解决VSCode中使用vetur插件格式化vue文件时,js代码会自动加上冒号和分号 在设置中把"vetur.format.defaultFormatter.js": " ...
- Zend Studio 上 安装使用Aptana插件(html,css,js代码提示功能) .
最近装了zend studio 9.0 用了段时间发现写html,css,js代码没提示,要开dreamwaver(对js代码提示也不好).就网上搜索了下,发现了Aptana插件,装上用了下,感觉不错 ...
- 【前端】js代码模拟用户键盘鼠标输入
js代码模拟用户键盘鼠标输入 原生js var event = new Event('mousewheel'); event.wheelDelta = 360 document.dispatchEve ...
- <a>标签中的href如何调用js代码
在HTML中,<a>标签的href属性用于指定超链接的目标的URL.在所有浏览器中,链接的默认外观是: 未被访问的链接带有下划线而且是蓝色的 已被访问的链接带有下划线而且是紫色的 活动链接 ...
- python 调用js代码
Python2 安装pyv8 pip install-egit://github.com/brokenseal/PyV8-OS-X#egg=pyv8 from pyv8 import PyV8 c ...
- dropdownlist值改变时调用js
DropDownList的OnSelectedIndexChanged方法是服务器端方法如要用需要设置AutoPostBack选项为true,并且在服务器后台写方法 要调用js方法需要onchange ...
- 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; ...
随机推荐
- SpringBoot搭建
使用eclipse搭建项目 File>New> 点击下一步 填写相关信息,点击下一步 勾选需要的组件,点击下一步. 会生成一个项目,如下图 打开pom.xml文件 <?xml ver ...
- centos7的内核区别
最近重新搭建环境准备测试一些东西,在网上随意下载了一个镜像,名字叫做:CentOS-7-i386-Everything-1810 下载完之后开始做实验安装软件的时候发现一直报错:[Errno 14] ...
- elasticsearch6.x集群环境部署
elasticsearch集群部署安装jdk chmod 755 jdk-8u161-linux-x64.tar.gztar -zxvf jdk-8u161-linux-x64.tar.gzcp jd ...
- QPushButton class
Help on class QPushButton in module PyQt5.QtWidgets: class QPushButton(QAbstractButton) | QPushButt ...
- 了解基本的bash shell命令
本节内容主要介绍如何使用bash shell提供的基本命令处理Linux文件和目录: 1.启动shell shell是一个可以交互访问的Linux系统程序,它的运行与普通程序相同,系统启动的shell ...
- hibernate 查询字段是重复名字的处理方法
目前遇到了三种情况: 一:当表的字段是数字类型(int,long .....) select name,ifnull(conpih.uh_id,0) from user; 将重复的字段如上修改用ifn ...
- Django在根据models生成数据库表时报 __init__() missing 1 required positional argument: 'on_delete'
from django.db import models # Create your models here. class Category(models.Model): caption = mode ...
- 鼠标拖动DOM
自己收藏,使用angualrjs的directive些的鼠标拖动DOM.... <!DOCTYPE html> <html lang="en"> <h ...
- CF 543C Remembering Strings
https://cn.vjudge.net/problem/CodeForces-543C 题目 You have multiset of n strings of the same length, ...
- Xilinx FPGA引脚txt文件导入excel中
需求 为了把xilinx FPGA的官方引脚文件txt转成excel文件(实际官网中有对应的csv文件就是excel文件了...) xilinx FPGA引脚地址:https://china.xili ...