Files
zgty-mas-m/nx/utils/call-check-version.js
houjunxiang 386f1e7466 1
2025-10-09 18:19:55 +08:00

63 lines
1.7 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() +
'/api/sys/app-client-version/latestVersionUniapp?clientId=' +
appId +
'&platform=' +
osName +
'&tenantId=' +
getTenantId(),
method: 'GET',
success: res => {
if (res.data && res.data.result) {
res.data.result.localVersion = plus.runtime.version
res.data.result.localWgtVersion = widgetInfo.version
res.data.result.url = getUpgradeBaseUrl() + res.data.result.url
}
console.log('更新信息:', res.data)
resolve(res.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
}