版本更新
This commit is contained in:
parent
36cda41b14
commit
df4d95993a
2
App.vue
2
App.vue
@ -36,6 +36,8 @@ export default {
|
||||
/** 关闭启动画面,锁定竖屏 */
|
||||
plus.navigator.closeSplashscreen();
|
||||
plus.screen.lockOrientation("portrait-primary");
|
||||
|
||||
|
||||
// #endif
|
||||
|
||||
/** 设置语言 (此处为了方便demo切换语言,将其存到本地,实际需根据业务情况设置)*/
|
||||
|
||||
@ -14,6 +14,10 @@ const my_api = {
|
||||
|
||||
expertWxLogin(data,header) {
|
||||
return request('/expertAPI/wechatLogin', data, 'post', true,'application/json',header);
|
||||
},
|
||||
|
||||
checkVersion(data) {
|
||||
return request('/expertAPI/checkVersion', data, 'post', true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -144,8 +144,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import navTo from "@/utils/navTo"
|
||||
import my_api from '@/api/my_api.js'
|
||||
// 返回上一页
|
||||
const goBack = () => {
|
||||
uni.navigateBack();
|
||||
@ -181,12 +180,65 @@
|
||||
|
||||
// 检查版本更新
|
||||
const checkUpdate = () => {
|
||||
uni.showToast({
|
||||
title: '检查版本更新',
|
||||
icon: 'none'
|
||||
// #ifdef APP-PLUS
|
||||
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
|
||||
console.log('App 名称:', widgetInfo.name);
|
||||
console.log('App 版本号 (version):', widgetInfo.version); // 如:1.0.0
|
||||
console.log('App 版本代码 (versionCode):', widgetInfo.versionCode); // 数字,如:100
|
||||
});
|
||||
|
||||
my_api.checkVersion().then(res=>{
|
||||
console.log(res)
|
||||
}).catch(err=>{
|
||||
console.log(err)
|
||||
if(err.data.code === 80002){
|
||||
if(err.data.data.apk_path){
|
||||
appdownLoad(err.data.data.apk_path)
|
||||
}else{
|
||||
uni.showToast({
|
||||
title: err.data.msg || '当前版本已是最新版本',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
};
|
||||
|
||||
//执行下载app
|
||||
const appdownLoad = (url) => {
|
||||
uni.showLoading({
|
||||
title: '安装包下载中……'
|
||||
})
|
||||
const downloadTask = uni.downloadFile({
|
||||
url: url, //服务器 app 的下载地址
|
||||
success: (downloadResult) => {
|
||||
uni.hideLoading();
|
||||
console.log(downloadResult)
|
||||
if (downloadResult.statusCode === 200) {
|
||||
uni.showModal({
|
||||
title: '',
|
||||
content: '下载成功,是否允许安装新版本?',
|
||||
confirmText: '确定',
|
||||
success: function(res) {
|
||||
if (res.confirm == true) {
|
||||
plus.runtime.install( //安装
|
||||
downloadResult.tempFilePath, {
|
||||
force: true
|
||||
},
|
||||
function(res) {
|
||||
utils.showToast('更新成功,重启中');
|
||||
plus.runtime.restart();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 跳转到关于页面
|
||||
const goToAbout = () => {
|
||||
uni.showToast({
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* @createTime: 2024-7-22 15:05:06
|
||||
*/
|
||||
import BASE_URL from "./config.js";
|
||||
import version from '@/utils/version.js'
|
||||
export const request = (url, data = {}, method = 'post', loading = false, contentType =
|
||||
'application/json',extraHeader={}) => {
|
||||
if (loading) {
|
||||
@ -17,6 +18,7 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
let token = '';
|
||||
if (process.env.UNI_PLATFORM == "h5") {
|
||||
if (window.location.href.indexOf('//.igandan.com') > -1) {
|
||||
@ -58,7 +60,7 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
|
||||
header['Authorization']='Bearer ' + token;
|
||||
let userInfo= uni.getStorageSync('userInfo')
|
||||
defaultData = {
|
||||
version: '4.0.0',
|
||||
version: version,
|
||||
user_uuid:userInfo.uuid,
|
||||
client_type: 'A', //client_type,
|
||||
timestamp:new Date().getTime()
|
||||
@ -75,7 +77,7 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
|
||||
let userInfo= uni.getStorageSync('userInfo')
|
||||
console.log(userInfo)
|
||||
defaultData = {
|
||||
version: '4.0.0',
|
||||
version: version,
|
||||
user_uuid:userInfo.uuid,
|
||||
client_type: 'A', //client_type,
|
||||
timestamp:new Date().getTime()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user