版本更新

This commit is contained in:
haomingming 2025-09-26 08:41:01 +08:00
parent 36cda41b14
commit df4d95993a
4 changed files with 67 additions and 7 deletions

View File

@ -36,6 +36,8 @@ export default {
/** 关闭启动画面,锁定竖屏 */ /** 关闭启动画面,锁定竖屏 */
plus.navigator.closeSplashscreen(); plus.navigator.closeSplashscreen();
plus.screen.lockOrientation("portrait-primary"); plus.screen.lockOrientation("portrait-primary");
// #endif // #endif
/** 设置语言 此处为了方便demo切换语言将其存到本地实际需根据业务情况设置*/ /** 设置语言 此处为了方便demo切换语言将其存到本地实际需根据业务情况设置*/

View File

@ -14,6 +14,10 @@ const my_api = {
expertWxLogin(data,header) { expertWxLogin(data,header) {
return request('/expertAPI/wechatLogin', data, 'post', true,'application/json',header); return request('/expertAPI/wechatLogin', data, 'post', true,'application/json',header);
},
checkVersion(data) {
return request('/expertAPI/checkVersion', data, 'post', true);
} }
} }

View File

@ -144,8 +144,7 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { onShow } from "@dcloudio/uni-app"; import my_api from '@/api/my_api.js'
import navTo from "@/utils/navTo"
// //
const goBack = () => { const goBack = () => {
uni.navigateBack(); uni.navigateBack();
@ -181,12 +180,65 @@
// //
const checkUpdate = () => { const checkUpdate = () => {
uni.showToast({ // #ifdef APP-PLUS
title: '检查版本更新', plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
icon: 'none' 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 = () => { const goToAbout = () => {
uni.showToast({ uni.showToast({

View File

@ -8,6 +8,7 @@
* @createTime: 2024-7-22 15:05:06 * @createTime: 2024-7-22 15:05:06
*/ */
import BASE_URL from "./config.js"; import BASE_URL from "./config.js";
import version from '@/utils/version.js'
export const request = (url, data = {}, method = 'post', loading = false, contentType = export const request = (url, data = {}, method = 'post', loading = false, contentType =
'application/json',extraHeader={}) => { 'application/json',extraHeader={}) => {
if (loading) { if (loading) {
@ -17,6 +18,7 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
}) })
}; };
let token = ''; let token = '';
if (process.env.UNI_PLATFORM == "h5") { if (process.env.UNI_PLATFORM == "h5") {
if (window.location.href.indexOf('//.igandan.com') > -1) { 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; header['Authorization']='Bearer ' + token;
let userInfo= uni.getStorageSync('userInfo') let userInfo= uni.getStorageSync('userInfo')
defaultData = { defaultData = {
version: '4.0.0', version: version,
user_uuid:userInfo.uuid, user_uuid:userInfo.uuid,
client_type: 'A', //client_type, client_type: 'A', //client_type,
timestamp:new Date().getTime() timestamp:new Date().getTime()
@ -75,7 +77,7 @@ export const request = (url, data = {}, method = 'post', loading = false, conten
let userInfo= uni.getStorageSync('userInfo') let userInfo= uni.getStorageSync('userInfo')
console.log(userInfo) console.log(userInfo)
defaultData = { defaultData = {
version: '4.0.0', version: version,
user_uuid:userInfo.uuid, user_uuid:userInfo.uuid,
client_type: 'A', //client_type, client_type: 'A', //client_type,
timestamp:new Date().getTime() timestamp:new Date().getTime()