|
|
@@ -9,19 +9,19 @@
|
|
|
</RouterTransition>
|
|
|
</router-view>
|
|
|
<app-tabbar class="home-tabbar" :data-list="tabList" :data-index="currentTab" @click="onTabClick" />
|
|
|
+ <app-updater />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
import { shallowRef, nextTick, watch, onMounted ,computed} from 'vue'
|
|
|
-import { fullloading, dialog } from '@/utils/vant'
|
|
|
+import { fullloading } from '@/utils/vant'
|
|
|
import { Tabbar } from '@mobile/components/base/tabbar/types'
|
|
|
-import { getAppUpdateInfo } from '@/services/api/common'
|
|
|
import { useNavigation } from '@mobile/router/navigation'
|
|
|
import { useLogin } from '@/business/login'
|
|
|
import { useLoginStore } from '@/stores'
|
|
|
-import plus from '@/utils/h5plus'
|
|
|
import AppTabbar from '@mobile/components/base/tabbar/index.vue'
|
|
|
+import AppUpdater from '@mobile/components/base/updater/index.vue'
|
|
|
import RouterTransition from '@mobile/components/base/router-transition/index.vue'
|
|
|
|
|
|
const { route, routerTo, getGlobalUrlParams, setGlobalUrlParams } = useNavigation()
|
|
|
@@ -80,82 +80,8 @@ const onTabClick = (index: number) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 版本号转数值
|
|
|
-const versionToNumber = (value: number | string) => {
|
|
|
- if (value) {
|
|
|
- const num = value.toString().split(/\D/)
|
|
|
- // 版本号位数
|
|
|
- const place = ['', '0', '00', '000', '0000', '00000', '000000'].reverse()
|
|
|
- for (let i = 0; i < num.length; i++) {
|
|
|
- const len = num[i].length
|
|
|
- num[i] = place[len] + num[i]
|
|
|
- }
|
|
|
- return +num.join('')
|
|
|
- }
|
|
|
- return 0
|
|
|
-}
|
|
|
-
|
|
|
onMounted(() => {
|
|
|
currentTab.value = tabIndex.value
|
|
|
- const os = plus.getSystemInfo('os')
|
|
|
- const currentVersion = plus.getSystemInfo('version')
|
|
|
- const currentVersionCode = plus.getSystemInfo('versionCode')
|
|
|
-
|
|
|
- if (os === 'Android') {
|
|
|
- // 监听下载进度
|
|
|
- const ondownload = plus.onDownload((filename, progress) => {
|
|
|
- if (progress === 100) {
|
|
|
- dialog({
|
|
|
- message: '新版本下载完成,是否安装?',
|
|
|
- showCancelButton: true,
|
|
|
- confirmButtonText: '安装'
|
|
|
- }).then(() => {
|
|
|
- plus.installApp(filename)
|
|
|
- }).catch(() => {
|
|
|
- plus.deleteFile(filename)
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- // 获取应用更新信息
|
|
|
- getAppUpdateInfo().then((res) => {
|
|
|
- const data = JSON.parse(res)
|
|
|
- if (data) {
|
|
|
- const { LastVersionCode, ApkUrl } = data[0] as Model.AppUpdateInfo
|
|
|
- if (Number(LastVersionCode) > Number(currentVersionCode)) {
|
|
|
- dialog({
|
|
|
- message: '发现新版本,是否下载?',
|
|
|
- showCancelButton: true,
|
|
|
- confirmButtonText: '下载'
|
|
|
- }).then(() => {
|
|
|
- plus.createDownload(ApkUrl)
|
|
|
- }).catch(() => {
|
|
|
- ondownload.cancel()
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- if (os === 'iOS') {
|
|
|
- // plus.httpRequest({
|
|
|
- // url: ''
|
|
|
- // }).then((res) => {
|
|
|
- // const results = res.data.results
|
|
|
- // if (results?.length) {
|
|
|
- // const { version, trackViewUrl } = results[0]
|
|
|
- // if (versionToNumber(version) > versionToNumber(currentVersion)) {
|
|
|
- // dialog({
|
|
|
- // message: '发现新版本,是否更新?',
|
|
|
- // showCancelButton: true,
|
|
|
- // confirmButtonText: '更新'
|
|
|
- // }).then(() => {
|
|
|
- // plus.openURL(trackViewUrl)
|
|
|
- // })
|
|
|
- // }
|
|
|
- // }
|
|
|
- // })
|
|
|
- }
|
|
|
})
|
|
|
|
|
|
watch(() => route.name, () => {
|