diff --git a/App.vue b/App.vue index 70dfda3..46a5fad 100644 --- a/App.vue +++ b/App.vue @@ -1,136 +1,159 @@ \ No newline at end of file + /* common css for page */ + // uni-page-body, + // html, + // body, + // page { + // width: 100% !important; + // height: 100% !important; + // overflow: hidden; + // } + diff --git a/api/index.js b/api/index.js index 8e45579..76fa037 100644 --- a/api/index.js +++ b/api/index.js @@ -194,4 +194,12 @@ export const getGroupBanList = id => { url: `/api/service/imGroup/muted/account/${id}`, method: 'get' }) +} + +/** 获取应用版本信息 */ +export const getAppVersion = () => { + return uni.request({ + url: 'https://s3.yxdim.com/app-version.json', + method: 'get' + }) } \ No newline at end of file diff --git a/app-version.json b/app-version.json new file mode 100644 index 0000000..9706543 --- /dev/null +++ b/app-version.json @@ -0,0 +1,7 @@ +{ + "version": "1.1.8", + "forceUpdate": true, + "updateMessage": "修复了一些问题并优化了性能", + "updateUrl": "https://store.yxdim.com/app/yxdIM", + "minSupportVersion": "0.0.1" +} diff --git a/pages/adduser/details.vue b/pages/adduser/details.vue index 0f787a5..52f3e20 100644 --- a/pages/adduser/details.vue +++ b/pages/adduser/details.vue @@ -350,7 +350,7 @@ {{ friendInfo.nick || '未知名称' }} - 手机号: {{ friendInfo.userID }} + ID: {{ friendInfo.userID }} 个性签名: {{ friendInfo.selfSignature || '暂无个性签名' }} @@ -513,7 +513,9 @@ display: flex; flex-direction: column; .title { - font-family: PingFang SC, PingFang SC; + font-family: + PingFang SC, + PingFang SC; font-weight: 500; font-size: 28rpx; color: #333333; diff --git a/pages/my-index/my-index.vue b/pages/my-index/my-index.vue index ae0f509..2279086 100644 --- a/pages/my-index/my-index.vue +++ b/pages/my-index/my-index.vue @@ -97,7 +97,9 @@ {{ userInfo?.userName || '' }} - ID:{{ userInfo?.invitationCode || '' }} + + ID: {{ userInfo?.invitationCode || '' }} + {{ userInfo.userName }} - ID: {{ userInfo.userId }} + ID: {{ userInfo.invitationCode }} diff --git a/pages/my-index/set-up/index.vue b/pages/my-index/set-up/index.vue index eab9070..14adb79 100644 --- a/pages/my-index/set-up/index.vue +++ b/pages/my-index/set-up/index.vue @@ -2,6 +2,8 @@ import { useUserStore } from '@/stores/user' import { navigateTo } from '../../../utils/router' import { useUI } from '../../../utils/use-ui' + import { getAppVersion } from '@/api' + import { compareVersion } from '@/utils/util.js' const { showDialog, showToast } = useUI() @@ -14,7 +16,11 @@ }, // { name: '聊天背景', value: '', url: '' }, // { name: '朋友圈设置', value: '', url: '' }, - { name: '消息通知', value: '', url: '/pages/my-index/set-up/message/index' } + { + name: '消息通知', + value: '', + url: '/pages/my-index/set-up/message/index' + } // { name: '安全设置', value: '', url: '' }, // { name: '群发消息', value: '', url: '' }, // { name: '登录设备', value: '', url: '' } @@ -29,6 +35,9 @@ value: '', url: '/pages/my-index/set-up/feedback' }, + // #ifdef APP-PLUS + { name: '检查更新', value: '3', url: '' }, + // #endif { name: '关于我们', value: '', url: '/pages/discover/company' } ] @@ -45,6 +54,35 @@ } }) return + } else if (item.value === '3') { + plus.runtime.getProperty(plus.runtime.appid, function (widgetInfo) { + getAppVersion().then(res => { + console.log('应用版本信息', res.data) + const lastVersion = res.data.version + const currentVersion = widgetInfo.version + if (compareVersion(currentVersion, lastVersion) < 0) { + // 当前版本低于最新版本,提示用户更新 + console.log('当前版本低于最新版本,请更新应用') + const url = res.data.updateUrl + const isForceUpdate = res.data.forceUpdate + uni.showModal({ + title: '更新提示', + content: res.data.updateMessage, + confirmText: '立即更新', + cancelText: '稍后再说', + showCancel: !isForceUpdate, + success: res => { + if (res.confirm) { + plus.runtime.openURL(url) + } + } + }) + } else { + showToast('当前已是最新版本', 'info') + } + }) + }) + return } item.url && navigateTo(item.url) } @@ -104,7 +142,9 @@ padding: 0 32rpx; .item { padding: 20rpx 0; - font-family: PingFang SC, PingFang SC; + font-family: + PingFang SC, + PingFang SC; text-align: left; font-style: normal; text-transform: none; @@ -135,7 +175,9 @@ height: 80rpx; line-height: 80rpx; background: #fff; - font-family: PingFang SC, PingFang SC; + font-family: + PingFang SC, + PingFang SC; font-weight: 500; font-size: 28rpx; color: #eb1c26; diff --git a/utils/util.js b/utils/util.js index 918a3ce..019a5f2 100644 --- a/utils/util.js +++ b/utils/util.js @@ -1,3 +1,21 @@ -export const formate = function(arr){ - return JSON.parse('['+ arr.join(',') + ']'); +export const formate = function (arr) { + return JSON.parse('[' + arr.join(',') + ']'); +} + +export function compareVersion(version1, version2) { + const v1Parts = version1.split(".").map(Number); + const v2Parts = version2.split(".").map(Number); + const maxLength = Math.max(v1Parts.length, v2Parts.length); + + for (let i = 0; i < maxLength; i++) { + const v1Part = v1Parts[i] || 0; + const v2Part = v2Parts[i] || 0; + + if (v1Part < v2Part) + return -1; + if (v1Part > v2Part) + return 1; + } + + return 0; } \ No newline at end of file