改进更新功能
This commit is contained in:
parent
9ac873ff00
commit
9269b33349
@ -64,7 +64,7 @@
|
|||||||
<script src="js/mui.min.js"></script>
|
<script src="js/mui.min.js"></script>
|
||||||
<script src="js/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
|
<script src="js/jquery-3.2.1.min.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<!-- <script src="js/start.js" type="text/javascript" charset="utf-8"></script> -->
|
<!-- <script src="js/start.js" type="text/javascript" charset="utf-8"></script> -->
|
||||||
<script src="js/start.js" type="text/javascript" charset="utf-8"></script>
|
<script src="js/start.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<script src="js/index.js" type="text/javascript" charset="utf-8"></script>
|
<script src="js/index.js" type="text/javascript" charset="utf-8"></script>
|
||||||
<!-- <script type="text/javascript">
|
<!-- <script type="text/javascript">
|
||||||
mui('.mui-bar').on('tap','a',function(){
|
mui('.mui-bar').on('tap','a',function(){
|
||||||
|
@ -9,6 +9,7 @@ var cssUrl = localStorage.getItem("cssUrl");
|
|||||||
var jsUrl = localStorage.getItem("jsUrl");
|
var jsUrl = localStorage.getItem("jsUrl");
|
||||||
var version = localStorage.getItem("version");
|
var version = localStorage.getItem("version");
|
||||||
function qlgUrl(url) {
|
function qlgUrl(url) {
|
||||||
|
console.log(webUrl)
|
||||||
return webUrl + url;
|
return webUrl + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
59
js/index.js
59
js/index.js
@ -9,6 +9,7 @@ function plusReady() { // 获取本地应用资源版本号
|
|||||||
//休眠方法
|
//休眠方法
|
||||||
var ver;
|
var ver;
|
||||||
//获取数据
|
//获取数据
|
||||||
|
|
||||||
function sleep(numberMillis) {
|
function sleep(numberMillis) {
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
var exitTime = now.getTime() + numberMillis;
|
var exitTime = now.getTime() + numberMillis;
|
||||||
@ -32,12 +33,12 @@ mui.back = function() {
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (new Date().getTime() - firstBackbutton < 2000) {
|
if (new Date().getTime() - firstBackbutton < 2000){
|
||||||
if (mui.os.ios) {
|
if (mui.os.ios){
|
||||||
const threadClass = plus.ios.importClass("NSThread");
|
const threadClass = plus.ios.importClass("NSThread");
|
||||||
const mainThread = plus.ios.invoke(threadClass, "mainThread");
|
const mainThread = plus.ios.invoke(threadClass, "mainThread");
|
||||||
plus.ios.invoke(mainThread, "exit");
|
plus.ios.invoke(mainThread, "exit");
|
||||||
} else {
|
} else{
|
||||||
plus.runtime.quit();
|
plus.runtime.quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,20 +57,46 @@ mui.plusReady(function() {
|
|||||||
|
|
||||||
if (!localStorage.getItem('isFirstDownlodad')) {
|
if (!localStorage.getItem('isFirstDownlodad')) {
|
||||||
localStorage.setItem('isFirstDownlodad', true);
|
localStorage.setItem('isFirstDownlodad', true);
|
||||||
|
|
||||||
}
|
}
|
||||||
// clearInterval(timer);
|
mui.ajax('http://qlg.tsgz.moe:233/get_version_new.php?' + Math.random(), {
|
||||||
localStorage.setItem('cssUrl', "../css/");
|
data: {},
|
||||||
localStorage.setItem('jsUrl', "../js/");
|
dataType: 'json', //服务器返回json格式数据
|
||||||
$('nav').css('display', 'block');
|
type: 'post', //HTTP请求类型
|
||||||
$('#bg').css('display', 'none');
|
timeout: 10000, //超时时间设置为10秒;
|
||||||
var ipxSizeTop = 0;
|
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;clearInterval(timer)
|
||||||
var ipxSizeBottom = 0;
|
// clearInterval(timer);
|
||||||
localStorage.setItem('ipxSizeTop', ipxSizeTop);
|
localStorage.setItem('version', data.version);
|
||||||
localStorage.setItem('ipxSizeBottom', ipxSizeBottom);
|
if (0 == is_juzi_online) {
|
||||||
// TODO: 这个就是检测新版本的方法 -> init@start.js 先注释了,避免打不开
|
localStorage.setItem('cssUrl', "../css/");
|
||||||
// init(data);
|
localStorage.setItem('jsUrl', "../js/");
|
||||||
jumpPage(ipxSizeBottom);
|
} else {
|
||||||
nav(0);
|
localStorage.setItem('cssUrl', data.cssUrl ? data.cssUrl : "../css/");
|
||||||
|
localStorage.setItem('jsUrl', data.jsUrl ? data.jsUrl : "../js/");
|
||||||
|
}
|
||||||
|
$('nav').css('display', 'block');
|
||||||
|
$('#bg').css('display', 'none');
|
||||||
|
var ipxSizeTop = 0;
|
||||||
|
var ipxSizeBottom = 0;
|
||||||
|
if (/iphone/gi.test(navigator.userAgent) && ((screen.height == 812 && screen.width == 375) || (screen.height ==
|
||||||
|
896 && screen.width == 414) || (screen.height == 1792 / 3 && screen.width == 828 / 3))) {
|
||||||
|
|
||||||
|
ipxSizeTop = 24;
|
||||||
|
ipxSizeBottom = 34;
|
||||||
|
//$('.mui-bar').attr('style', "bottom: 34px;")
|
||||||
|
};
|
||||||
|
|
||||||
|
localStorage.setItem('ipxSizeTop', ipxSizeTop);
|
||||||
|
localStorage.setItem('ipxSizeBottom', ipxSizeBottom);
|
||||||
|
init(data);
|
||||||
|
jumpPage(ipxSizeBottom);
|
||||||
|
nav(0);
|
||||||
|
},
|
||||||
|
error: function(xhr, type, errorThrown) { //异常处理;
|
||||||
|
// mui.alert(errorThrown);
|
||||||
|
mui.toast("网络异常,请检查网络设置!");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
4
js/my.js
4
js/my.js
@ -175,8 +175,8 @@ var localAuthType = localStorage.getItem("authType");
|
|||||||
$('#expectedProductNum').html(+data.data.expectedProductNum);
|
$('#expectedProductNum').html(+data.data.expectedProductNum);
|
||||||
$('#expectedCouponsNum').html(+data.data.expectedCouponsNum);
|
$('#expectedCouponsNum').html(+data.data.expectedCouponsNum);
|
||||||
$('#expectedWangNum').html(+data.data.expectedWangNum);
|
$('#expectedWangNum').html(+data.data.expectedWangNum);
|
||||||
$('#couponsNum').html(+data.data.user.couponsNum);
|
$('#couponsNum').html(+data.data.alreadyCouponsNum);
|
||||||
$('#productNum').html(+data.data.user.productNum);
|
$('#productNum').html(+data.data.alreadyProductNum);
|
||||||
$('#wangNum').html(+data.data.user.wangNum);
|
$('#wangNum').html(+data.data.user.wangNum);
|
||||||
|
|
||||||
mui.ajax(qlgUrl('app/users/getFavoritesNum'), {
|
mui.ajax(qlgUrl('app/users/getFavoritesNum'), {
|
||||||
|
103
js/start.js
103
js/start.js
@ -1,6 +1,6 @@
|
|||||||
function init(data) {
|
function init(data) {
|
||||||
////console.log(data.apk_version)
|
//console.log(data.apk_version)
|
||||||
// //console.log(localStorage.getItem('jsUrl'))
|
// console.log(localStorage.getItem('jsUrl'))
|
||||||
apk_version = data.apk_version;
|
apk_version = data.apk_version;
|
||||||
apkUrl = data.apk_down_url;
|
apkUrl = data.apk_down_url;
|
||||||
iosUrl = data.ios_down_url;
|
iosUrl = data.ios_down_url;
|
||||||
@ -74,7 +74,7 @@ function init(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// //console.log('当前版本号已是最新');
|
// console.log('当前版本号已是最新');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,8 +87,7 @@ function jumpPage(ipxSizeBottom) {
|
|||||||
//跳转页面
|
//跳转页面
|
||||||
|
|
||||||
var bSize = 50 + (+ipxSizeBottom) + 'px';
|
var bSize = 50 + (+ipxSizeBottom) + 'px';
|
||||||
var subpages = ['templete/home.html', 'templete/shops.html', 'templete/zhuweiba.html',
|
var subpages = ['templete/home.html', 'templete/shops.html', 'templete/zhugouba.html', 'templete/zhuweiba.html',
|
||||||
'templete/zhugouba.html',
|
|
||||||
'templete/my.html'
|
'templete/my.html'
|
||||||
];
|
];
|
||||||
var subpage_style = {
|
var subpage_style = {
|
||||||
@ -111,7 +110,7 @@ function jumpPage(ipxSizeBottom) {
|
|||||||
// launchScreen();
|
// launchScreen();
|
||||||
plus.screen.lockOrientation("portrait-primary");
|
plus.screen.lockOrientation("portrait-primary");
|
||||||
// plus.navigator.setStatusBarStyle('dark');
|
// plus.navigator.setStatusBarStyle('dark');
|
||||||
// //console.log(plus.navigator.getStatusBarStyle())
|
// console.log(plus.navigator.getStatusBarStyle())
|
||||||
var self = plus.webview.currentWebview();
|
var self = plus.webview.currentWebview();
|
||||||
for (var i = 0; i < subpages.length; i++) {
|
for (var i = 0; i < subpages.length; i++) {
|
||||||
var temp = {};
|
var temp = {};
|
||||||
@ -162,11 +161,41 @@ function jumpPage(ipxSizeBottom) {
|
|||||||
|
|
||||||
if (targetTab == 'templete/zhuweiba.html') {
|
if (targetTab == 'templete/zhuweiba.html') {
|
||||||
var targetTab = plus.webview.getWebviewById(targetTab);
|
var targetTab = plus.webview.getWebviewById(targetTab);
|
||||||
mui.fire(targetTab, 'refresh');
|
mui.fire(targetTab, 'refresh');
|
||||||
}
|
var token = localStorage.getItem("token");
|
||||||
if (targetTab == 'templete/zhugouba.html') {
|
if (!token) {
|
||||||
var targetTab = plus.webview.getWebviewById(targetTab);
|
mui.openWindow({
|
||||||
mui.fire(targetTab, 'refresh');
|
url: 'templete/login.html',
|
||||||
|
id: 'templete/login.html',
|
||||||
|
styles: {
|
||||||
|
top: '0px', //新页面顶部位置
|
||||||
|
bottom: '0px', //新页面底部位置
|
||||||
|
width: '100%', //新页面宽度,默认为100%
|
||||||
|
height: '100%' //新页面高度,默认为100%
|
||||||
|
},
|
||||||
|
extras: {
|
||||||
|
// data_href: data_href
|
||||||
|
// ..... //自定义扩展参数,可以用来处理页面间传值
|
||||||
|
},
|
||||||
|
createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示
|
||||||
|
show: {
|
||||||
|
// autoShow: true, //页面loaded事件发生后自动显示,默认为true
|
||||||
|
// aniShow: animationType, //页面显示动画,默认为”slide-in-right“;
|
||||||
|
// duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒;
|
||||||
|
// event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示
|
||||||
|
// extras: {} //窗口动画是否使用图片加速
|
||||||
|
},
|
||||||
|
waiting: {
|
||||||
|
autoShow: true, //自动显示等待框,默认为true
|
||||||
|
title: '正在加载...', //等待对话框上显示的提示内容
|
||||||
|
options: {
|
||||||
|
// width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度
|
||||||
|
// height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||||||
|
// ......
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (targetTab == 'templete/my.html') {
|
if (targetTab == 'templete/my.html') {
|
||||||
var targetTab = plus.webview.getWebviewById(targetTab);
|
var targetTab = plus.webview.getWebviewById(targetTab);
|
||||||
@ -182,13 +211,26 @@ function jumpPage(ipxSizeBottom) {
|
|||||||
width: '100%', //新页面宽度,默认为100%
|
width: '100%', //新页面宽度,默认为100%
|
||||||
height: '100%' //新页面高度,默认为100%
|
height: '100%' //新页面高度,默认为100%
|
||||||
},
|
},
|
||||||
extras: {},
|
extras: {
|
||||||
createNew: false,
|
// data_href: data_href
|
||||||
show: {},
|
// ..... //自定义扩展参数,可以用来处理页面间传值
|
||||||
|
},
|
||||||
|
createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示
|
||||||
|
show: {
|
||||||
|
// autoShow: true, //页面loaded事件发生后自动显示,默认为true
|
||||||
|
// aniShow: animationType, //页面显示动画,默认为”slide-in-right“;
|
||||||
|
// duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒;
|
||||||
|
// event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示
|
||||||
|
// extras: {} //窗口动画是否使用图片加速
|
||||||
|
},
|
||||||
waiting: {
|
waiting: {
|
||||||
autoShow: true, //自动显示等待框,默认为true
|
autoShow: true, //自动显示等待框,默认为true
|
||||||
title: '正在加载...', //等待对话框上显示的提示内容
|
title: '正在加载...', //等待对话框上显示的提示内容
|
||||||
options: {}
|
options: {
|
||||||
|
// width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度
|
||||||
|
// height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||||||
|
// ......
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -197,7 +239,6 @@ function jumpPage(ipxSizeBottom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function nav(num) {
|
function nav(num) {
|
||||||
//console.log(num);
|
|
||||||
$('.mui-tab-item span .img').each(function(a) {
|
$('.mui-tab-item span .img').each(function(a) {
|
||||||
if (num == a) {
|
if (num == a) {
|
||||||
if(a == 2){
|
if(a == 2){
|
||||||
@ -211,16 +252,20 @@ function nav(num) {
|
|||||||
}else{
|
}else{
|
||||||
$(this).attr('src', 'http://img.zgqlg.com.cn/static/app2/img/nav_' + a + '_0.png?version='+localStorage.getItem('version'));
|
$(this).attr('src', 'http://img.zgqlg.com.cn/static/app2/img/nav_' + a + '_0.png?version='+localStorage.getItem('version'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.mui-bar').on('tap', '.mui-tab-item', function(e) {
|
$('.mui-bar').on('tap', '.mui-tab-item', function(e) {
|
||||||
var num = $(this).attr('data-num');
|
var num = $(this).attr('data-num');
|
||||||
$('.nav_in').removeClass('shun');
|
if (num == 2) {
|
||||||
$('.nav_out').removeClass('ni');
|
$('.nav_in').addClass('shun');
|
||||||
|
$('.nav_out').addClass('ni');
|
||||||
|
} else {
|
||||||
|
$('.nav_in').removeClass('shun');
|
||||||
|
$('.nav_out').removeClass('ni');
|
||||||
|
}
|
||||||
nav(num);
|
nav(num);
|
||||||
|
|
||||||
})
|
})
|
||||||
@ -229,6 +274,7 @@ document.addEventListener('plusready', function() {
|
|||||||
}, false);
|
}, false);
|
||||||
// 判断启动方式
|
// 判断启动方式
|
||||||
function checkArguments() {
|
function checkArguments() {
|
||||||
|
// console.log("plus.runtime.launcher: " + plus.runtime.launcher);
|
||||||
var args = plus.runtime.arguments;
|
var args = plus.runtime.arguments;
|
||||||
if (args) {
|
if (args) {
|
||||||
// 处理args参数,如打开新页面等
|
// 处理args参数,如打开新页面等
|
||||||
@ -236,7 +282,7 @@ function checkArguments() {
|
|||||||
var id;
|
var id;
|
||||||
var datago = {};
|
var datago = {};
|
||||||
var arrgo = args.slice(args.indexOf('//') + 2).split(': ');
|
var arrgo = args.slice(args.indexOf('//') + 2).split(': ');
|
||||||
// //console.log(args.slice(args.indexOf('//')+2).split(':'))
|
// console.log(args.slice(args.indexOf('//')+2).split(':'))
|
||||||
if (arrgo[0] == 'goods_id') {
|
if (arrgo[0] == 'goods_id') {
|
||||||
url = 'details.html';
|
url = 'details.html';
|
||||||
id = arrgo[1];
|
id = arrgo[1];
|
||||||
@ -264,11 +310,21 @@ function checkArguments() {
|
|||||||
},
|
},
|
||||||
extras: datago,
|
extras: datago,
|
||||||
createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示
|
createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示
|
||||||
show: {},
|
show: {
|
||||||
|
// autoShow: true, //页面loaded事件发生后自动显示,默认为true
|
||||||
|
// aniShow: animationType, //页面显示动画,默认为”slide-in-right“;
|
||||||
|
// duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒;
|
||||||
|
// event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示
|
||||||
|
// extras: {} //窗口动画是否使用图片加速
|
||||||
|
},
|
||||||
waiting: {
|
waiting: {
|
||||||
autoShow: true, //自动显示等待框,默认为true
|
autoShow: true, //自动显示等待框,默认为true
|
||||||
title: '正在加载...', //等待对话框上显示的提示内容
|
title: '正在加载...', //等待对话框上显示的提示内容
|
||||||
options: {}
|
options: {
|
||||||
|
// width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度
|
||||||
|
// height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||||||
|
// ......
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -277,5 +333,6 @@ function checkArguments() {
|
|||||||
|
|
||||||
// 处理从后台恢复
|
// 处理从后台恢复
|
||||||
document.addEventListener('newintent', function() {
|
document.addEventListener('newintent', function() {
|
||||||
|
// console.log("addEventListener: newintent");
|
||||||
checkArguments();
|
checkArguments();
|
||||||
}, false);
|
}, false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user