diff --git a/pages/gather/gather.vue b/pages/gather/gather.vue index d5bd71f..f189638 100644 --- a/pages/gather/gather.vue +++ b/pages/gather/gather.vue @@ -1,656 +1,755 @@ \ No newline at end of file diff --git a/utils/uniMP.js b/utils/uniMP.js index 173f75e..ed86f2a 100644 --- a/utils/uniMP.js +++ b/utils/uniMP.js @@ -152,17 +152,68 @@ const loadMPx = async (id) => { // 按URL加载小程序 const loadMPurl = async (e) => { appid = e.id; - mp.getUniMPVersion(appid, (ret) => { - console.log('当前版本', ret); - wgtFile = e.url; - doInstallMP(); - // if (0 != ret.code) { - // wgtFile = e.url; - // installMP(); - // } else { - // open() - // } - }); + let FURL = e.url; + uni.showLoading({ + title: '初始化中...', + mask: true + }) + uni.request({ + url: FURL, + method: 'GET', + success: (fileInfo) => { + mp.getUniMPVersion(appid, (ret) => { + console.log('当前版本', ret); + let flag; + if (HTTP_REQUEST_URL == 'https://shop.lihaink.cn') { + flag = false + } else { + flag = true + } + if (0 != ret.code || compareVersions(fileInfo.data?.data?.version, ret.versionInfo.name) == 1 || flag == + true) { + let count = 0; + timer = setInterval(() => { + if (count < 100) uni.showLoading({ + title: `初始化中... ${count}%`, + mask: true + }) + else uni.showLoading({ + title: '初始化中...100%', + mask: true + }) + }, 600) + let downloadTask = uni.downloadFile({ + url: fileInfo.data?.data?.down_url, + success(res) { + wgtFile = res.tempFilePath; + console.log('初始化完成', wgtFile); + installMP(); + }, + fail(res) { + clearInterval(timer); + timer = null; + uni.hideLoading(); + } + }); + downloadTask.onProgressUpdate((res) => { + // console.log('初始化进度' + res.progress); + if (res.progress > count) count += 10; + if (count >= 90) { + clearInterval(timer); + timer = null; + } + }); + } else { + open() + } + }); + + }, + fail:(err)=> { + console.log('错误:', err); + } + }) + }; // 小程序版本信息