diff --git a/jiuyi2/App.vue b/jiuyi2/App.vue index c7cfd3bc..2bf94f11 100644 --- a/jiuyi2/App.vue +++ b/jiuyi2/App.vue @@ -1,124 +1,126 @@ \ No newline at end of file diff --git a/jiuyi2/api/mine.js b/jiuyi2/api/mine.js index e0b9c5af..3282bb13 100644 --- a/jiuyi2/api/mine.js +++ b/jiuyi2/api/mine.js @@ -123,6 +123,7 @@ const mine = { url: '/coreplay/app/durian/getUserDataByAccount', query: param.query, method: 'GET', + load: true, }) }, diff --git a/jiuyi2/common/js/config.js b/jiuyi2/common/js/config.js index ea5d4755..2f0ce731 100644 --- a/jiuyi2/common/js/config.js +++ b/jiuyi2/common/js/config.js @@ -6,9 +6,11 @@ const config = { // host: 'h5api', // #endif // #ifndef H5 - // host: 'http://91f.xyz:8080', - host: 'http://3f609e6a.r24.cpolar.top', + host: 'http://91f.xyz:8080', + // host: 'http://3dd3096c.r24.cpolar.top', // #endif + // 是否vivo显示 + showVivo: true, // 支付方式配置 payType: { score: { diff --git a/jiuyi2/common/js/util.js b/jiuyi2/common/js/util.js index 17db9ca8..2a3fd18c 100644 --- a/jiuyi2/common/js/util.js +++ b/jiuyi2/common/js/util.js @@ -213,7 +213,7 @@ const util = { responseType: params.responseType || 'text', // 请求成功返回 success: res => { - // console.log('request success', url, res, params.data ? params.data : '') + console.log('request success', url, res, params.data ? params.data : '') // 关闭加载效果 if (params.load) { uni.hideLoading() @@ -623,7 +623,8 @@ const util = { obj.success && obj.success({ value: result, width: imageInfo.width, - height: imageInfo.height, + height: imageInfo + .height, }); }, }) @@ -1606,6 +1607,28 @@ const util = { }) }) }, + + /** + * 获取app最新版本信息 + * @param {Object} option + */ + getAppVersion(callback) { + // 获取最新版本信息 + api.getAppVersion().then(rs => { + if (rs.code == 200) { + const result = rs.data + console.log('getAppVersion result', result) + // 同步修改云端数据 + uni.$store.commit('setState', { + key: 'versionCloud', + value: result + }) + + if (callback) callback(result) + return + } + }) + }, } export default util \ No newline at end of file diff --git a/jiuyi2/components/index/appVerUpdate.vue b/jiuyi2/components/index/appVerUpdate.vue index 83e43dcb..08507594 100644 --- a/jiuyi2/components/index/appVerUpdate.vue +++ b/jiuyi2/components/index/appVerUpdate.vue @@ -10,6 +10,7 @@ getCurrentInstance, computed, nextTick, + onMounted, } from 'vue' // 工具库 import util from '@/common/js/util'; @@ -19,28 +20,25 @@ const { proxy } = getCurrentInstance() - // 云端版本信息 - const versionCloud = reactive({}) // 程序版本信息 const versionkApp = reactive({}) + // 云端app版本信息 + const versionCloud = computed(() => uni.$store.state.versionCloud) + + onMounted(() => { + let system = uni.getSystemInfoSync() + Object.assign(versionkApp, system) + }) // 初始化 function init() { - // 获取最新版本信息 - api.getAppVersion().then(rs => { - if (rs.code == 200) { - console.log('getAppVersion', rs) - // 结果 - const result = rs.data - let system = uni.getSystemInfoSync() - Object.assign(versionCloud, result) - Object.assign(versionkApp, system) - console.log('if', system.appVersionCode, result.versionCode) - // 如果需要更新 则打开手机浏览器 - if (system.appVersionCode < result.versionCode || true) open() - return - } - }) + console.log('versionCloud', versionCloud.value) + return + Object.assign(versionkApp, system) + // status 1更新 0未开启 + if (result.status != 1) return + // 手机版本号 < 设定版本号 + if (system.appVersionCode < result.versionCode) open() } // 打开弹窗 @@ -56,13 +54,19 @@ // 更新弹窗点击确认 function handleConfirm() { // 下载地址 - // let downloadUrl = 'https://www.doubao.com/chat/' - let downloadUrl = versionCloud.downloadUrl + let downloadUrl = versionCloud.value.downloadUrl plus.runtime.openURL(downloadUrl, function(res) { console.log('打开浏览器结果:', res); }, function(err) { console.log('打开浏览器失败:', err); - }); + }) + } + + // 取消 + function handleCancel() { + // 判断是否强制更新 + if (versionCloud.value.isforce == 1) plus.runtime.quit() + else close() } defineExpose({ @@ -73,10 +77,10 @@