|
|
@ -92,15 +92,15 @@ |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
this.globalData.privacyInitialized = true |
|
|
this.globalData.privacyInitialized = true |
|
|
// #ifdef APP-PLUS |
|
|
|
|
|
jpushModule = uni.requireNativePlugin("JG-JPush"); |
|
|
|
|
|
audioObj = uni.getBackgroundAudioManager(); |
|
|
|
|
|
// #endif |
|
|
|
|
|
const baseUrl = getApp().globalData.mainurl |
|
|
const baseUrl = getApp().globalData.mainurl |
|
|
//这里是热更新的代码 |
|
|
//这里是热更新的代码 |
|
|
// #ifdef APP-PLUS |
|
|
// #ifdef APP-PLUS |
|
|
this.checkAppUpdate(baseUrl) |
|
|
this.checkAppUpdate(baseUrl) |
|
|
// #endif |
|
|
// #endif |
|
|
|
|
|
// #ifdef APP-PLUS |
|
|
|
|
|
jpushModule = uni.requireNativePlugin("JG-JPush"); |
|
|
|
|
|
audioObj = uni.getBackgroundAudioManager(); |
|
|
|
|
|
// #endif |
|
|
// this.getRegistrationID() |
|
|
// this.getRegistrationID() |
|
|
// #ifdef APP-PLUS |
|
|
// #ifdef APP-PLUS |
|
|
if (jpushModule.setLoggerEnable) { |
|
|
if (jpushModule.setLoggerEnable) { |
|
|
@ -238,31 +238,42 @@ |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
checkAppUpdate(baseUrl) { |
|
|
checkAppUpdate(baseUrl) { |
|
|
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => { |
|
|
console.log('app update check start:', baseUrl) |
|
|
const currentVersion = widgetInfo && widgetInfo.version ? widgetInfo.version : plus.runtime.version |
|
|
try { |
|
|
uni.request({ |
|
|
if (!plus || !plus.runtime) { |
|
|
url: baseUrl + '/setting/app-update/latest', |
|
|
console.error('app update skipped: plus.runtime is unavailable') |
|
|
data: {}, |
|
|
return |
|
|
success: (res) => { |
|
|
} |
|
|
const body = res.data || {} |
|
|
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => { |
|
|
const data = body.result || {} |
|
|
const currentVersion = widgetInfo && widgetInfo.version ? widgetInfo.version : plus.runtime.version |
|
|
console.log('app update response:', JSON.stringify(data), 'current:', currentVersion) |
|
|
console.log('app update current widget:', JSON.stringify(widgetInfo), 'runtime:', plus.runtime.version) |
|
|
if (!data.url) { |
|
|
uni.request({ |
|
|
console.log('app update skipped: url is empty') |
|
|
url: baseUrl + '/setting/app-update/latest', |
|
|
return |
|
|
data: {}, |
|
|
} |
|
|
success: (res) => { |
|
|
if (data.version && this.compareVersion(data.version, currentVersion) <= 0) { |
|
|
const body = res.data || {} |
|
|
console.log('app update skipped: current version is latest', currentVersion, data.version) |
|
|
const data = body.result || {} |
|
|
return |
|
|
console.log('app update response:', JSON.stringify(data), 'current:', currentVersion) |
|
|
|
|
|
if (!data.url) { |
|
|
|
|
|
console.log('app update skipped: url is empty') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (data.version && this.compareVersion(data.version, currentVersion) <= 0) { |
|
|
|
|
|
console.log('app update skipped: current version is latest', currentVersion, data.version) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
const downloadUrl = this.appendUpdateQuery(data.url, data.version) |
|
|
|
|
|
console.log('app update downloading:', downloadUrl) |
|
|
|
|
|
this.downloadAndInstallWgt(downloadUrl) |
|
|
|
|
|
}, |
|
|
|
|
|
fail: (err) => { |
|
|
|
|
|
console.error('app update request fail:', JSON.stringify(err)) |
|
|
} |
|
|
} |
|
|
const downloadUrl = this.appendUpdateQuery(data.url, data.version) |
|
|
}) |
|
|
this.downloadAndInstallWgt(downloadUrl) |
|
|
|
|
|
}, |
|
|
|
|
|
fail: (err) => { |
|
|
|
|
|
console.error('app update request fail:', JSON.stringify(err)) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
}) |
|
|
}) |
|
|
} catch (e) { |
|
|
|
|
|
console.error('app update check error:', JSON.stringify(e)) |
|
|
|
|
|
} |
|
|
}, |
|
|
}, |
|
|
downloadAndInstallWgt(url) { |
|
|
downloadAndInstallWgt(url) { |
|
|
uni.downloadFile({ |
|
|
uni.downloadFile({ |
|
|
|