Commit 1f47f948 by LJM

app更新

parent a53f4c2c
Showing with 88 additions and 17 deletions
<script>
import { API } from '@/util/api.js';
export default {
onLaunch: function() {
console.log('App Launch');
},
onShow: function() {
console.log('App Show');
let wms_version = uni.getStorageSync('wms_version') || '';
this.request(API.getLatestAppInfo, 'POST', {}, false, false).then(res => {
if (res.code === 0) {
if (wms_version == '') {
uni.setStorageSync('wms_version', res.data.latest_app_info.wms_version);
} else {
//判断是否跟线上版本一样
if (wms_version != res.data.latest_app_info.wms_version) {
uni.showModal({
title: '更新提示',
content: res.data.latest_app_info.remark,
confirmText: '确定更新',
cancelText: '取消更新',
success: data => {
if (data.confirm) {
uni.setStorageSync('wms_version', res.data.latest_app_info.wms_version);
this.downloadApk(res.data.latest_app_info.download_url);
console.log('用户点击确定');
} else if (data.cancel) {
console.log('用户点击取消');
}
}
});
}
}
}
});
},
onHide: function() {
console.log('App Hide');
},
methods: {
//下载apk文件
downloadApk(url) {
uni.showLoading({
title: '下载apk文件'
});
let dtask = plus.downloader.createDownload(url, {}, (d, status) => {
if (status == 200) {
//下载成功后调用安装方法
this.installApk(d.filename);
uni.hideLoading();
} else {
uni.showToast({
title: '下载失败',
icon: 'error'
});
console.log('下载失败');
}
});
dtask.start();
},
//安装apk文件
installApk(filePath) {
plus.runtime.install(
filePath,
{},
() => {
console.log('安装成功');
},
e => {
uni.showToast({
title: '安装失败',
icon: 'error'
});
console.log('安装失败:' + JSON.stringify(e));
}
);
}
}
};
</script>
......
// const API_BASE_USER = 'http://user.liexindev.net'; //用户系统
// const API_BASE_ORDER = 'http://order.liexindev.net'; //订单系统
// const API_BASE_PUR = 'http://pur.liexindev.net'; //采购系统
// const API_BASE_SUPPLIER = 'http://supplier.liexin.net'; //供应商系统
// const API_BASE_CRM = 'http://crmnew.liexindev.net'; //CRM系统
// const API_BASE = 'http://wms.liexindev.net'; //WMS系统
// const API_BASE_LIEXIN = 'http://api.liexin.com'; //api系统
// const API_BASE_OSS = 'http://file.liexindev.net'; //oss系统
const API_BASE_USER = 'http://user.liexindev.net'; //用户系统
const API_BASE_ORDER = 'http://order.liexindev.net'; //订单系统
const API_BASE_PUR = 'http://pur.liexindev.net'; //采购系统
const API_BASE_SUPPLIER = 'http://supplier.liexin.net'; //供应商系统
const API_BASE_CRM = 'http://crmnew.liexindev.net'; //CRM系统
const API_BASE = 'http://wms.liexindev.net'; //WMS系统
const API_BASE_LIEXIN = 'http://api.liexin.com'; //api系统
const API_BASE_OSS = 'http://file.liexindev.net'; //oss系统
const API_BASE_USER = 'https://user.ichunt.net'; //用户系统
const API_BASE_ORDER = 'https://order.ichunt.net'; //订单系统
const API_BASE_PUR = 'https://purchase.ichunt.net'; //采购系统
const API_BASE_SUPPLIER = 'https://supplier.ichunt.net'; //供应商系统
const API_BASE_CRM = 'https://crm.ichunt.net'; //CRM系统
const API_BASE = 'https://wms.ichunt.net'; //WMS系统
const API_BASE_LIEXIN = 'https://api.ichunt.com'; //api系统
const API_BASE_OSS = 'https://files.ichunt.net'; //oss系统
// const API_BASE_USER = 'https://user.ichunt.net'; //用户系统
// const API_BASE_ORDER = 'https://order.ichunt.net'; //订单系统
// const API_BASE_PUR = 'https://purchase.ichunt.net'; //采购系统
// const API_BASE_SUPPLIER = 'https://supplier.ichunt.net'; //供应商系统
// const API_BASE_CRM = 'https://crm.ichunt.net'; //CRM系统
// const API_BASE = 'https://wms.ichunt.net'; //WMS系统
// const API_BASE_LIEXIN = 'https://api.ichunt.com'; //api系统
// const API_BASE_OSS = 'https://files.ichunt.net'; //oss系统
const API = {
......@@ -257,7 +257,11 @@ const API = {
/**
* 获取产地
* */
getUseOption: API_BASE + '/api/stockIn/getUseOption'
getUseOption: API_BASE + '/api/stockIn/getUseOption',
/**
* 获取最新版本信息
* */
getLatestAppInfo: API_BASE + '/api/app/getLatestAppInfo'
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment