Files
zgty-mas-m/nx/utils/call-check-version.js
2025-12-24 15:46:30 +08:00

69 lines
1.9 KiB
JavaScript

import { getUpgradeBaseUrl, getTenantId, clientId } from '@/defaultBaseUrl'
export default function () {
// #ifdef APP-PLUS
return new Promise((resolve, reject) => {
plus.runtime.getProperty(plus.runtime.appid, function (widgetInfo) {
const osName = plus.os.name
let appId = plus.runtime.appid
appId = clientId
uni.request({
url:
getUpgradeBaseUrl() +
'/qms/version-management/checkUpdate?' +
'applicationCode=ytgg_lims' +
'&updatePlatform=android',
method: 'GET',
success: res => {
console.log(res)
const data = res.data.data
if (data) {
data.localVersion = plus.runtime.version
data.localWgtVersion = widgetInfo.version
data.version = data.currentVersion
data.url = data.downloadUrl
data.type = data.updateType
data.platform = data.updatePlatform
data.is_silently = data.silenceFlag == '1'
data.is_mandatory = data.mustFlag == '1'
data.contents = data.updateContent
}
console.log('更新信息:', data)
resolve(data)
},
fail: err => {
reject(error)
}
})
// uni.request(options).then(res => {
// resolve(res)
// }).catch(err => {
// reject(error)
// });
// uniCloud.callFunction({
// name: 'check-version',
// data: {
// appid: plus.runtime.appid,
// appVersion: plus.runtime.version,
// wgtVersion: widgetInfo.version
// },
// success: (e) => {
// resolve(e)
// },
// fail: (error) => {
// reject(error)
// }
// })
})
})
// #endif
// #ifndef APP-PLUS
return new Promise((resolve, reject) => {
reject({
message: '请在App中使用'
})
})
// #endif
}